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