Debian Codegraph @

examples/linechart.html

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 <html>
2 <head>
3 <title>JSXGraph example</title>
4 <link rel="stylesheet" type="text/css" href="../distrib/jsxgraph.css" />
5 <script type="text/javascript" src="prototype.js"></script>
6 <script type="text/javascript" src="../distrib/jsxgraphcore.js"></script>
7 </head>
8 <body>
9 <h2>Spline chart with special highlighted points</h2>
10 <div style="width:800px">
11 <div id="jxgbox" class="jxgbox" style="width:800px; height:600px; float:left"></div>
12 </div>
13 <div id="debug" style="display:block;"></div>
14 <script type="text/javascript">
15 /* <![CDATA[ */
16 board = JXG.JSXGraph.initBoard('jxgbox', {originX: 50, originY: 550, unitX: 50, unitY: 1});
17 board.suspendUpdate();
18 //var s = board.createElement('slider', [[1,9],[4,9],[1,1,1.5]], {name:'S',strokeColor:'black',fillColor:'white'});
19 var dataArr = [[1,2,3,4,5,6,7,8,9,10,11,12], [232,94,312,278,432,341,159,201,496,143,48,281]];
20 var axisx = board.createElement('axis', [[0,0], [1,0]], {strokeColor:'black'});
21 var axisy = board.createElement('axis', [[0,0], [0,1]], {strokeColor:'black'});
22 var chart = board.createElement('chart', dataArr, {chartStyle:'spline,point',labels:dataArr});
23 chart[0].setProperty({strokeColor:'#008B45',highlightStrokeColor:'#008B45',strokeWidth:'4px',shadow:true});
24 board.unsuspendUpdate();
25 board.updateInfobox(chart[1][1]);
26 var i;
27 for(i=0; i<chart[1].length; i++) {
28 chart[1][i].setProperty({face:'square',size:6,fillColor:'#008B45',strokeColor:'#3F1771',strokeWidth:'4px',shadow:true,showInfobox:true});
29 chart[1][i].highlight = function() {
30 var ms = 350, toR = 12, fromR = 6, toC = 1, fromC = 0.55, differenceR, differenceC, el = this, start = new Date, animate;
31 differenceR = (toR-fromR)/ms;
32 differenceC = (toC-fromC)/ms;
33
34 function step() {
35 var time = new Date - start, currentR, currentC;
36 if(time < ms) {
37 currentR = fromR + time * differenceR;
38 currentC = fromC + time * differenceC;
39 el.visProp['size'] = currentR;
40 el.visProp['fillColor'] = JXG.hsv2rgb(150,1,currentC);
41 el.board.renderer.updatePoint(el);
42 animate = setTimeout(step,35);
43 }
44 else {
45 el.visProp['size'] = toR;
46 el.visProp['fillColor'] = JXG.hsv2rgb(150,1,toC);
47 el.board.renderer.updatePoint(el);
48 clearTimeout(animate);
49 }
50 }
51 animate = setTimeout(step,1);
52 }
53 chart[1][i].noHighlight = function() {
54 var ms = 350, toR = 6, fromR = 12, toC = 0.55, fromC = 1, differenceR, differenceC, el = this, start = new Date, animate;
55 differenceR = (toR-fromR)/ms;
56 differenceC = (toC-fromC)/ms;
57
58 function step() {
59 var time = new Date - start, currentR, currentC;
60 if(time < ms) {
61 currentR = fromR + time * differenceR;
62 currentC = fromC + time * differenceC;
63 el.visProp['size'] = currentR;
64 el.visProp['fillColor'] = JXG.hsv2rgb(150,1,currentC);
65 el.board.renderer.updatePoint(el);
66 animate = setTimeout(step,35);
67 }
68 else {
69 el.visProp['size'] = toR;
70 el.visProp['fillColor'] = JXG.hsv2rgb(150,1,toC);
71 el.board.renderer.updatePoint(el);
72 clearTimeout(animate);
73 }
74 }
75 animate = setTimeout(step,1);
76 }
77 }
78
79 board.infobox.distanceX = 25;
80 board.highlightInfobox = function(x,y,el) {
81 var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
82 this.infobox.setText('<span style="color:black;font-weight:bold">' + months[x-1] + ': ' + Math.abs(y) + ' Clicks</span>');
83 this.infobox.rendNode.style.border = "groove #3F1771 8px";
84 this.infobox.rendNode.style.padding = "10px";
85 this.infobox.rendNode.style.backgroundColor = JXG.hsv2rgb(150,0.5,1);
86 }
87
88 /* ]]> */
89 </script>
90 </body>
91 </html>