Debian Codegraph @

examples/plot-legend/index.html

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>Flot Examples: Graph Legend</title>
6 <link href="../examples.css" rel="stylesheet" type="text/css">
7 <script language="javascript" type="text/javascript" src="../../source/jquery.js"></script>
8 <script language="javascript" type="text/javascript" src="../../lib/jquery.mousewheel.js"></script>
9 <script language="javascript" type="text/javascript" src="../../source/jquery.canvaswrapper.js"></script>
10 <script language="javascript" type="text/javascript" src="../../source/jquery.colorhelpers.js"></script>
11 <script language="javascript" type="text/javascript" src="../../source/jquery.flot.js"></script>
12 <script language="javascript" type="text/javascript" src="../../source/jquery.flot.saturated.js"></script>
13 <script language="javascript" type="text/javascript" src="../../source/jquery.flot.browser.js"></script>
14 <script language="javascript" type="text/javascript" src="../../source/jquery.flot.drawSeries.js"></script>
15 <script language="javascript" type="text/javascript" src="../../source/jquery.flot.uiConstants.js"></script>
16 <script language="javascript" type="text/javascript" src="../../source/jquery.flot.symbol.js"></script>
17 <script language="javascript" type="text/javascript" src="../../source/jquery.flot.legend.js"></script>
18
19 <script type="text/javascript">
20
21 $(function() {
22 var plot;
23 function drawArrow(ctx, x, y, radius){
24 ctx.beginPath();
25 ctx.moveTo(x + radius, y + radius);
26 ctx.lineTo(x, y);
27 ctx.lineTo(x - radius, y + radius);
28 ctx.stroke();
29 }
30
31 function drawSemiCircle(ctx, x, y, radius){
32 ctx.beginPath();
33 ctx.arc(x, y, radius, 0, Math.PI, false);
34 ctx.moveTo(x - radius, y);
35 ctx.lineTo(x + radius, y);
36 ctx.stroke();
37 }
38
39 var data1 = [];
40 for (var i = 0; i < 3; i += 0.005) {
41 data1.push([i, 1.2 + Math.sin(i*10)]);
42 }
43
44 var data2 = [
45 [0,0],
46 [1,1],
47 [2,2],
48 [3,3]
49 ];
50
51 var data2_points = {
52 show: true,
53 radius: 5,
54 fillColor: "dodgerblue",
55 symbol: "diamond",
56 };
57
58 var data3 = [
59 [.7,3,.2,.4],
60 [1.5,2.2,.3,.4],
61 [2.3,1,.5,.2]
62 ];
63
64 var data3_points = {
65 show: true,
66 radius: 5,
67 };
68
69 var data4 = [
70 [1,2],
71 [2,0.5],
72 [2.7,2]
73 ];
74
75 var data4_points = {
76 //do not show points
77 show: false,
78 radius: 5,
79 fillColor: "white",
80 };
81
82 var data5 = [
83 [1.3, 1],
84 [1.75, 2.5],
85 [2.5, 0.5]
86 ];
87
88 var data = [
89 // area
90 {color: "cyan", lines: {show: true, fill: true}, data: data1, label: "Area"},
91 // bars
92 {color: "orange", bars: {show: true, align: "center", barWidth: 0.25}, data: data5, label: "Bars"},
93 //lines
94 {color: "forestgreen", lines: {show: true, lineWidth: 4}, points: data4_points, data: data4, label: "Lines"},
95 // points
96 {color: "indigo", points: data2_points, data: data2, label: "Points"},
97 // lines + points
98 {color: "red", lines: {show: true, lineWidth:2}, points: data3_points, data: data3, label: "Lines & Points"},
99 ];
100
101 var legendContainer = document.getElementById("legendContainer");
102 var legendSettings = {
103 position: "nw",
104 show: true,
105 noColumns: 2,
106 container: legendContainer
107 };
108 $('#myForm input').on('change', function() {
109 var val = $('input[name="myRadio"]:checked', '#myForm').val();
110
111 $(legendContainer).html('');
112 switch (val) {
113 case 'se':
114 legendSettings.position = "se"
115 legendSettings.container = null;
116 break;
117 case 'sw':
118 legendSettings.position = "sw"
119 legendSettings.container = null;
120 break;
121 case 'ne':
122 legendSettings.position = "ne"
123 legendSettings.container = null;
124 break;
125 case 'nw':
126 legendSettings.position = "nw"
127 legendSettings.container = null;
128 break;
129 case 'container':
130 legendSettings.container = legendContainer;
131 break;
132 }
133 setupGraph();
134 });
135
136 setupGraph();
137 drawGraph();
138
139 function setupGraph() {
140 plot = $.plot($("#placeholder"), data , {
141 legend: legendSettings,
142 series: {
143 lines: {
144 show: false
145 }
146 },
147 xaxis: {
148 autoScale: "none",
149 min: 0,
150 max: 3
151 },
152 yaxis: {
153 autoScale: "none",
154 min: 0,
155 max: 3.5
156 },
157 zoom: {
158 interactive: true
159 },
160 pan: {
161 interactive: true
162 }
163 });
164 }
165
166 function drawGraph() {
167 plot.setData(data);
168 plot.setupGrid();
169 plot.draw();
170 requestAnimationFrame(drawGraph);
171 }
172
173 // Add the Flot version string to the footer
174
175 $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
176 });
177
178 </script>
179 </head>
180 <body>
181
182 <div id="header">
183 <h2>Graph Legend</h2>
184 </div>
185
186 <div id="content">
187
188 <div class="demo-container">
189 <div id="placeholder" class="demo-placeholder"></div>
190 </div>
191 <p>Legend Container:</p>
192 <div id="legendContainer" class="legend" style="width:9em;height:8em;border-style:solid;border-color:threedface"></div>
193
194 <div>
195 <fieldset id="myForm">
196 <legend>Legend Position</legend>
197 <input type="radio" name="myRadio" value="se"> SE - Over Graph <br>
198 <input type="radio" name="myRadio" value="sw"> SW - Over Graph <br>
199 <input type="radio" name="myRadio" value="ne"> NE - Over Graph <br>
200 <input type="radio" name="myRadio" value="nw"> NW - Over Graph <br>
201 <input type="radio" name="myRadio" value="container" checked="checked"> Container <br>
202 </fieldset>
203 </div>
204 </div>
205
206 <div id="footer">
207 Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
208 </div>
209
210 </body>
211 </html>