summaryrefslogtreecommitdiff
path: root/includes/js/dojox/charting/tests/test_chart2d_updating.html
blob: 6a7641b7898874ff9153637b2b82e5694c81ccbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<html>
<head>
<title>Chart 2D</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
	@import "../../../dojo/resources/dojo.css";
	@import "../../../dijit/tests/css/dijitTests.css";
</style>
<!--
The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend
<script type="text/javascript" src="Silverlight.js"></script>
-->
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
<script type="text/javascript" src="../../lang/functional.js"></script>
<script type="text/javascript" src="../Theme.js"></script>
<script type="text/javascript" src="../scaler.js"></script>
<script type="text/javascript" src="../Chart2D.js"></script>
<script type="text/javascript">

dojo.require("dojox.charting.Chart2D");
dojo.require("dojox.charting.themes.PlotKit.orange");

var chart, limit = 10, magnitude = 30;

var randomValue = function(){
	return Math.random() * magnitude;
};

var makeSeries = function(len){
    var s = [];
    do{
        s.push(randomValue());
	}while(s.length < len);
    return s;
};

var seriesA = makeSeries(limit),
	seriesB = makeSeries(limit),
	seriesC = makeSeries(limit);

var makeObjects = function(){
	chart = new dojox.charting.Chart2D("test");
	chart.setTheme(dojox.charting.themes.PlotKit.orange);
   	chart.addAxis("x", {fixLower: "minor", natural: true, min: 1, max: limit});
	chart.addAxis("y", {vertical: true, min: 0, max: 30, majorTickStep: 5, minorTickStep: 1});
	chart.addPlot("default", {type: "Areas"});
	chart.addSeries("Series A", seriesA);
	chart.addSeries("Series B", seriesB);
	chart.addSeries("Series C", seriesC);
	chart.addPlot("grid", {type: "Grid", hMinorLines: true});
	chart.render();
    setInterval(function(){updateTest();}, 200);
};

var updateTest = function(){
	seriesA.shift();
	seriesA.push(randomValue());
	chart.updateSeries("Series A", seriesA);

	seriesB.shift();
	seriesB.push(randomValue());
	chart.updateSeries("Series B", seriesB);

	seriesC.shift();
	seriesC.push(randomValue());
	chart.updateSeries("Series C", seriesC);

	chart.render();
};

dojo.addOnLoad(makeObjects);

</script>
</head>
<body>
<h1>Chart 2D Updating Data</h1>
<p>Areas, orange theme, axes, grid. Very crude example to show a chart with updating values.</p>
<div id="test" style="width: 400px; height: 400px;"></div>
</body>
</html>