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>
|
19 | var R=rlab, fx = R.fx, dt=R.dt;
|
20 |
|
21 | function curve() {
|
22 | dt = R.dt;
|
23 | G.curve((x)=>dt(x,3) ,{name:"dt(3)", step:0.1});
|
24 | G.curve((x)=>dt(x,10),{name:"dt(10)", step:0.1});
|
25 | G.curve((x)=>dt(x,25),{name:"dt(25)", step:0.1});
|
26 | }
|
27 |
|
28 | function hist() {
|
29 | var x = R.rnorm(10000, 5, 2);
|
30 | G.hist(x, {name:"x", mode:"normalized", step:0.2});
|
31 | G.curve((x)=>R.dnorm(x, 5,2), {name:"N(5,2)", step:0.2});
|
32 | }
|
33 |
|
34 | function f(x, y) {
|
35 | return (Math.sin(x/50) * Math.cos(y/50) * 50 + 50);
|
36 | }
|
37 |
|
38 | function curve3D() { G.curve3d(f); }
|
39 |
|
40 | function plot() {
|
41 | Ax = R.rnorm(100, 10, 1);
|
42 | Ay = R.rnorm(100, 0, 0.5);
|
43 | Bx = R.rnorm(100, 0, 1);
|
44 | By = R.rnorm(100, 0, 0.5);
|
45 | G.plot(Ax, Ay, {name:"A"});
|
46 | G.plot(Bx, By, {name:"B"});
|
47 | }
|
48 |
|
49 | var chartbox = document.getElementById("chart");
|
50 | G.newGraph(chartbox);
|
51 |
|
52 |
|
53 | curve3D();
|
54 |
|
55 | </script>
|
56 | </body>
|
57 | </html>
|