1 | print('The chart demo of Rlab.\nPlease scroll down to see charts below ...')
|
2 |
|
3 | G.chart2D('#chart1', function(g) {
|
4 | dt = R.dt;
|
5 | G.curve(g, "dt(3)" , (x)=>dt(x,3) );
|
6 | G.curve(g, "dt(10)", (x)=>dt(x,10));
|
7 | G.curve(g, "dt(25)", (x)=>dt(x,25));
|
8 | });
|
9 |
|
10 | G.chart2D('#chart2', function(g) {
|
11 | var x = R.rnorm(10000, 3, 2);
|
12 | G.hist(g, "x", x, 'bar', -10, 10, 0.3);
|
13 |
|
14 | });
|
15 |
|
16 | G.chart2D('#chart3', function(g) {
|
17 | Ax = R.rnorm(100, 10, 1);
|
18 | Ay = R.rnorm(100, 0, 0.5);
|
19 | Bx = R.rnorm(100, 0, 1);
|
20 | By = R.rnorm(100, 0, 0.5);
|
21 | G.plot(g, "A", Ax, Ay);
|
22 | G.plot(g, "B", Bx, By);
|
23 | });
|
24 |
|
25 | function hist(g,name,x,k) {
|
26 | var mk = x.fillVM(k,x.length/k);
|
27 | var xbar = mk.colSum();
|
28 | G.ihist(g, name, xbar, 'bar');
|
29 | }
|
30 |
|
31 | var x = R.samples([0,1], 100000, {replace:true});
|
32 | G.chart2D('#chart4', (g)=>hist(g,'x1bar', x,1));
|
33 | G.chart2D('#chart5', (g)=>hist(g,'x2bar', x,2));
|
34 | G.chart2D('#chart6', (g)=>hist(g,'x10bar', x,10));
|
35 | G.chart2D('#chart7', (g)=>G.pie(g, {A:30, B:40, C:20, D:10}));
|
36 | G.chart2D('#chart8', (g)=>G.timeSeries(g, [
|
37 | ['x','2013-01-01','2013-01-02','2013-01-03','2013-01-04','2013-01-05'],
|
38 | ['data1', 30, 200, 100, 400, 150],
|
39 | ['data2', 130, 340, 200, 500, 250]
|
40 | ]));
|
41 |
|
42 | G.chart3D('#chart9', 'surface', function(x, y) {
|
43 | return (Math.sin(x/50) * Math.cos(y/50) * 50 + 50);
|
44 | });
|
45 |
|
46 | |
\ | No newline at end of file |