UNPKG

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