UNPKG

1.35 kBHTMLView Raw
1<html>
2<head>
3 <meta charset="UTF-8">
4 <link rel="stylesheet" type="text/css" href="web/c3.css">
5
6</head>
7<body>
8 <title>A Javascript IDE like R</title>
9 <fieldset>
10 <legend>Graph</legend>
11 <div id="chart" style="height:80%; width:100%"></div>
12 </fieldset>
13 <script src="web/d3.js"></script>
14 <script src="web/c3.js"></script>
15 <script src="web/vis.js"></script>
16 <script src="web/rlab.js"></script>
17 <script src="web/G.js"></script>
18 <script src="web/coffeequate.min.js"></script>
19<script>
20var R=rlab, fx = R.fx, dt=R.dt;
21
22function curve() {
23 dt = R.dt;
24 G.curve((x)=>dt(x,3) ,{name:"dt(3)", step:0.1});
25 G.curve((x)=>dt(x,10),{name:"dt(10)", step:0.1});
26 G.curve((x)=>dt(x,25),{name:"dt(25)", step:0.1});
27}
28
29function hist() {
30 var x = R.rnorm(10000, 5, 2);
31 G.hist(x, {name:"x", mode:"normalized", step:0.2});
32 G.curve((x)=>R.dnorm(x, 5,2), {name:"N(5,2)", step:0.2});
33}
34
35function f(x, y) {
36 return (Math.sin(x/50) * Math.cos(y/50) * 50 + 50);
37}
38
39function curve3D() { G.curve3d(f); }
40
41function plot() {
42 Ax = R.rnorm(100, 10, 1);
43 Ay = R.rnorm(100, 0, 0.5);
44 Bx = R.rnorm(100, 0, 1);
45 By = R.rnorm(100, 0, 0.5);
46 G.plot(Ax, Ay, {name:"A"});
47 G.plot(Bx, By, {name:"B"});
48}
49
50var chartbox = document.getElementById("chart");
51G.newGraph(chartbox);
52// hist();
53// curve();
54curve3D();
55// plot();
56</script>
57</body>
58</html>