| 875 |
lars |
1 |
<!DOCTYPE html>
|
|
|
2 |
|
|
|
3 |
<html>
|
|
|
4 |
<head>
|
|
|
5 |
|
|
|
6 |
<title>Pyramid Charts 2</title>
|
|
|
7 |
|
|
|
8 |
<link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
|
|
|
9 |
<link rel="stylesheet" type="text/css" href="examples.min.css" />
|
|
|
10 |
<link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
|
|
|
11 |
<link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
|
|
|
12 |
|
|
|
13 |
<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
|
|
|
14 |
<script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
</head>
|
|
|
18 |
<body>
|
|
|
19 |
<div id="header">
|
|
|
20 |
<div class="nav">
|
|
|
21 |
<a class="nav" href="../../../index.php"><span>></span>Home</a>
|
|
|
22 |
<a class="nav" href="../../../docs/"><span>></span>Docs</a>
|
|
|
23 |
<a class="nav" href="../../download/"><span>></span>Download</a>
|
|
|
24 |
<a class="nav" href="../../../info.php"><span>></span>Info</a>
|
|
|
25 |
<a class="nav" href="../../../donate.php"><span>></span>Donate</a>
|
|
|
26 |
</div>
|
|
|
27 |
</div>
|
|
|
28 |
<div class="colmask leftmenu">
|
|
|
29 |
<div class="colleft">
|
|
|
30 |
<div class="col1" id="example-content">
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
<!-- Example scripts go here -->
|
|
|
34 |
|
|
|
35 |
<link class="include" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/smoothness/jquery-ui.css" rel="Stylesheet" />
|
|
|
36 |
|
|
|
37 |
<style type="text/css">
|
|
|
38 |
.chart-container {
|
|
|
39 |
border: 1px solid darkblue;
|
|
|
40 |
padding: 30px;
|
|
|
41 |
width: 600px;
|
|
|
42 |
height: 700px;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
#chart1 {
|
|
|
46 |
width: 96%;
|
|
|
47 |
height: 96%;
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
.jqplot-datestamp {
|
|
|
51 |
font-size: 0.8em;
|
|
|
52 |
color: #777;
|
|
|
53 |
/* margin-top: 1em;
|
|
|
54 |
text-align: right;*/
|
|
|
55 |
font-style: italic;
|
|
|
56 |
position: absolute;
|
|
|
57 |
bottom: 15px;
|
|
|
58 |
right: 15px;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
td.controls li {
|
|
|
62 |
list-style-type: none;
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
td.controls ul {
|
|
|
66 |
margin-top: 0.5em;
|
|
|
67 |
padding-left: 0.2em;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
pre.code {
|
|
|
71 |
margin-top: 45px;
|
|
|
72 |
clear: both;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
</style>
|
|
|
76 |
|
|
|
77 |
<table class="app">
|
|
|
78 |
<td class="controls">
|
|
|
79 |
|
|
|
80 |
<div style="margin-bottom: 15px;">
|
|
|
81 |
Axes:
|
|
|
82 |
<select name="axisPosition">
|
|
|
83 |
<option value="both">Left & Right</option>
|
|
|
84 |
<option value = "left">Left</option>
|
|
|
85 |
<option value = "right">Right</option>
|
|
|
86 |
<option value = "mid">Mid</option>
|
|
|
87 |
</select>
|
|
|
88 |
</div>
|
|
|
89 |
|
|
|
90 |
<div>
|
|
|
91 |
Background Color:
|
|
|
92 |
<ul>
|
|
|
93 |
<li><input name="backgroundColor" value="white" type="radio" checked />Default</li>
|
|
|
94 |
<li><input name="backgroundColor" value="#efefef" type="radio" />Gray</li>
|
|
|
95 |
</ul>
|
|
|
96 |
</div>
|
|
|
97 |
|
|
|
98 |
<div>
|
|
|
99 |
Pyramid Color:
|
|
|
100 |
<ul>
|
|
|
101 |
<li><input name="seriesColor" value="green" type="radio" checked />Green</li>
|
|
|
102 |
<li><input name="seriesColor" value="blue" type="radio" />Blue</li>
|
|
|
103 |
</ul>
|
|
|
104 |
</div>
|
|
|
105 |
|
|
|
106 |
<div>
|
|
|
107 |
Grids:
|
|
|
108 |
<ul>
|
|
|
109 |
<li><input name="gridsVertical" value="vertical" type="checkbox" checked />Vertical</li>
|
|
|
110 |
<li><input name="gridsHorizontal" value="horizontal" type="checkbox" checked />Horizontal</li>
|
|
|
111 |
<li><input name="showMinorTicks" value="true" type="checkbox" />Only major</li>
|
|
|
112 |
<li><input name="plotBands" value="true" type="checkbox" />Plot Bands</li>
|
|
|
113 |
</ul>
|
|
|
114 |
</div>
|
|
|
115 |
|
|
|
116 |
<div>
|
|
|
117 |
<ul>
|
|
|
118 |
<li><input name="barPadding" value="4" type="checkbox" checked />Gap between bars</li>
|
|
|
119 |
<!-- value for showContour is speed at which to fade lines in/out -->
|
|
|
120 |
<li><input name="showContour" value="500" type="checkbox" />Comparison Line</li>
|
|
|
121 |
</ul>
|
|
|
122 |
</div>
|
|
|
123 |
|
|
|
124 |
<div class="tooltip">
|
|
|
125 |
<table>
|
|
|
126 |
<tr>
|
|
|
127 |
<td>Age: </td><td><div class="tooltip-item" id="tooltipAge"> </div></td>
|
|
|
128 |
</tr>
|
|
|
129 |
<tr>
|
|
|
130 |
<td>Male: </td><td><div class="tooltip-item" id="tooltipMale"> </div></td>
|
|
|
131 |
</tr>
|
|
|
132 |
<tr>
|
|
|
133 |
<td>Female: </td><td><div class="tooltip-item" id="tooltipFemale"> </div></td>
|
|
|
134 |
</tr>
|
|
|
135 |
<tr>
|
|
|
136 |
<td>Ratio: </td><td><div class="tooltip-item" id="tooltipRatio"> </div></td>
|
|
|
137 |
</tr>
|
|
|
138 |
</table>
|
|
|
139 |
</div>
|
|
|
140 |
</td>
|
|
|
141 |
|
|
|
142 |
<td class="chart">
|
|
|
143 |
<div class="chart-container">
|
|
|
144 |
<div id="chart1"></div>
|
|
|
145 |
<div class="jqplot-datestamp"></div>
|
|
|
146 |
</div>
|
|
|
147 |
</td>
|
|
|
148 |
|
|
|
149 |
</table>
|
|
|
150 |
|
|
|
151 |
<pre class="code brush:js"></pre>
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
<script class="code" type="text/javascript" language="javascript">
|
|
|
156 |
$(document).ready(function(){
|
|
|
157 |
|
|
|
158 |
// the "x" values from the data will go into the ticks array.
|
|
|
159 |
// ticks should be strings for this case where we have values like "75+"
|
|
|
160 |
var ticks = ["0-4", "5-9", "10-14", "15-19", "20-24", "25-29", "30-34", "35-39", "40-44", "45-49", "50-54", "55-59", "60-64", "65-69", "70-74", "75+"];
|
|
|
161 |
|
|
|
162 |
// The "y" values of the data are put into seperate series arrays.
|
|
|
163 |
var male = [4.425251, 5.064975, 4.401382, 3.787731, 2.306403, 3.110203, 2.824716, 3.846422, 3.067799, 2.936013, 2.505067, 2.018346, 1.90446, 1.357237, 0.909704, 0.988836];
|
|
|
164 |
var female = [4.28698, 4.343237, 4.710053, 3.99281, 2.811107, 3.191518, 4.855351, 4.62347, 4.032976, 4.414623, 3.210845, 2.426347, 2.635736, 1.811459, 1.515899, 1.683044];
|
|
|
165 |
var male2 = [1.445677, 2.088224, 2.159879, 2.401152, 3.701622, 3.897444, 5.048783, 4.367545, 3.304588, 3.784367, 3.059088, 2.052513, 1.412907, 0.934326, 0.541234, 0.784258];
|
|
|
166 |
var female2 =[2.238284, 2.974165, 2.360351, 3.03517, 4.80941, 6.229139, 7.257596, 5.847782, 5.226342, 6.201237, 4.474141, 2.769444, 2.048169, 1.47749, 0.87372, 1.193951];
|
|
|
167 |
|
|
|
168 |
// Custom color arrays are set up for each series to get the look that is desired.
|
|
|
169 |
// Two color arrays are created for the default and optional color which the user can pick.
|
|
|
170 |
var greenColors = ["#526D2C", "#77933C", "#C57225", "#C57225"];
|
|
|
171 |
var blueColors = ["#3F7492", "#4F9AB8", "#C57225", "#C57225"];
|
|
|
172 |
|
|
|
173 |
// To accomodate changing y axis, need to keep track of plot options.
|
|
|
174 |
// changing axes will require recreating the plot, so need to keep
|
|
|
175 |
// track of state changes.
|
|
|
176 |
var plotOptions = {
|
|
|
177 |
// We set up a customized title which acts as labels for the left and right sides of the pyramid.
|
|
|
178 |
title: '<div style="float:left;width:50%;text-align:center">Male</div><div style="float:right;width:50%;text-align:center">Female</div>',
|
|
|
179 |
|
|
|
180 |
// by default, the series will use the green color scheme.
|
|
|
181 |
seriesColors: greenColors,
|
|
|
182 |
|
|
|
183 |
grid: {
|
|
|
184 |
drawBorder: false,
|
|
|
185 |
shadow: false,
|
|
|
186 |
background: "white",
|
|
|
187 |
rendererOptions: {
|
|
|
188 |
// plotBands is an option of the pyramidGridRenderer.
|
|
|
189 |
// it will put banding at starting at a specified value
|
|
|
190 |
// along the y axis with an adjustable interval.
|
|
|
191 |
plotBands: {
|
|
|
192 |
show: false,
|
|
|
193 |
interval: 2
|
|
|
194 |
}
|
|
|
195 |
},
|
|
|
196 |
},
|
|
|
197 |
|
|
|
198 |
// This makes the effective starting value of the axes 0 instead of 1.
|
|
|
199 |
// For display, the y axis will use the ticks we supplied.
|
|
|
200 |
defaultAxisStart: 0,
|
|
|
201 |
seriesDefaults: {
|
|
|
202 |
renderer: $.jqplot.PyramidRenderer,
|
|
|
203 |
rendererOptions: {
|
|
|
204 |
barPadding: 4
|
|
|
205 |
},
|
|
|
206 |
yaxis: "yaxis",
|
|
|
207 |
shadow: false
|
|
|
208 |
},
|
|
|
209 |
|
|
|
210 |
// We have 4 series, the left and right pyramid bars and
|
|
|
211 |
// the left and rigt overlay lines.
|
|
|
212 |
series: [
|
|
|
213 |
// For pyramid plots, the default side is right.
|
|
|
214 |
// We want to override here to put first set of bars
|
|
|
215 |
// on left.
|
|
|
216 |
{
|
|
|
217 |
rendererOptions:{
|
|
|
218 |
side: 'left',
|
|
|
219 |
synchronizeHighlight: 1
|
|
|
220 |
}
|
|
|
221 |
},
|
|
|
222 |
{
|
|
|
223 |
yaxis: "y2axis",
|
|
|
224 |
rendererOptions:{
|
|
|
225 |
synchronizeHighlight: 0
|
|
|
226 |
}
|
|
|
227 |
},
|
|
|
228 |
// Pyramid series are filled bars by default.
|
|
|
229 |
// The overlay series will be unfilled lines.
|
|
|
230 |
{
|
|
|
231 |
rendererOptions: {
|
|
|
232 |
fill: false,
|
|
|
233 |
side: "left"
|
|
|
234 |
}
|
|
|
235 |
},
|
|
|
236 |
{
|
|
|
237 |
yaxis: "y2axis",
|
|
|
238 |
rendererOptions: {
|
|
|
239 |
fill: false
|
|
|
240 |
}
|
|
|
241 |
}
|
|
|
242 |
],
|
|
|
243 |
|
|
|
244 |
// Set up all the y axes, since users are allowed to switch between them.
|
|
|
245 |
// The only axis that will show is the one that the series are "attached" to.
|
|
|
246 |
// We need the appropriate options for the others for when the user switches.
|
|
|
247 |
axes: {
|
|
|
248 |
xaxis: {
|
|
|
249 |
tickOptions: {},
|
|
|
250 |
rendererOptions: {
|
|
|
251 |
baselineWidth: 2
|
|
|
252 |
}
|
|
|
253 |
},
|
|
|
254 |
yaxis: {
|
|
|
255 |
label: "Age",
|
|
|
256 |
// Use canvas label renderer to get rotated labels.
|
|
|
257 |
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
|
|
|
258 |
// include empty tick options, they will be used
|
|
|
259 |
// as users set options with plot controls.
|
|
|
260 |
tickOptions: {},
|
|
|
261 |
showMinorTicks: true,
|
|
|
262 |
ticks: ticks,
|
|
|
263 |
rendererOptions: {
|
|
|
264 |
category: true,
|
|
|
265 |
baselineWidth: 2
|
|
|
266 |
}
|
|
|
267 |
},
|
|
|
268 |
yMidAxis: {
|
|
|
269 |
label: "Age",
|
|
|
270 |
// include empty tick options, they will be used
|
|
|
271 |
// as users set options with plot controls.
|
|
|
272 |
tickOptions: {},
|
|
|
273 |
showMinorTicks: true,
|
|
|
274 |
ticks: ticks,
|
|
|
275 |
rendererOptions: {
|
|
|
276 |
category: true,
|
|
|
277 |
baselineWidth: 2
|
|
|
278 |
}
|
|
|
279 |
},
|
|
|
280 |
y2axis: {
|
|
|
281 |
label: "Age",
|
|
|
282 |
// Use canvas label renderer to get rotated labels.
|
|
|
283 |
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
|
|
|
284 |
// include empty tick options, they will be used
|
|
|
285 |
// as users set options with plot controls.
|
|
|
286 |
tickOptions: {},
|
|
|
287 |
showMinorTicks: true,
|
|
|
288 |
ticks: ticks,
|
|
|
289 |
rendererOptions: {
|
|
|
290 |
category: true,
|
|
|
291 |
baselineWidth: 2
|
|
|
292 |
}
|
|
|
293 |
}
|
|
|
294 |
}
|
|
|
295 |
};
|
|
|
296 |
|
|
|
297 |
// initialize form elements
|
|
|
298 |
// set these before attaching event handlers.
|
|
|
299 |
|
|
|
300 |
$("input[type=checkbox][name=gridsVertical]").attr("checked", true);
|
|
|
301 |
$("input[type=checkbox][name=gridsHorizontal]").attr("checked", true);
|
|
|
302 |
$("input[type=checkbox][name=showMinorTicks]").attr("checked", false);
|
|
|
303 |
$("input[type=checkbox][name=plotBands]").attr("checked", false);
|
|
|
304 |
$("input[type=checkbox][name=showContour]").attr("checked", true);
|
|
|
305 |
$("input[type=checkbox][name=barPadding]").attr("checked", true);
|
|
|
306 |
$("select[name=axisPosition]").val("both");
|
|
|
307 |
$("input[type=radio][name=backgroundColor]").attr("checked", false);
|
|
|
308 |
$("input[type=radio][name=backgroundColor][value=white]").attr("checked", true);
|
|
|
309 |
$("input[type=radio][name=backgroundColor]").attr("checked", false);
|
|
|
310 |
$("input[type=radio][name=backgroundColor][value=white]").attr("checked", true);
|
|
|
311 |
$("input[type=radio][name=seriesColor]").attr("checked", false);
|
|
|
312 |
$("input[type=radio][name=seriesColor][value=green]").attr("checked", true);
|
|
|
313 |
|
|
|
314 |
plot1 = $.jqplot("chart1", [male, female, male2, female2], plotOptions);
|
|
|
315 |
|
|
|
316 |
// After plot creation, check to see if contours should be displayed
|
|
|
317 |
checkContour();
|
|
|
318 |
|
|
|
319 |
//////
|
|
|
320 |
// The followng functions use verbose css selectors to make
|
|
|
321 |
// it clear exactly which elements they are binging to/operating on
|
|
|
322 |
//////
|
|
|
323 |
|
|
|
324 |
//////
|
|
|
325 |
// Function which checkes if the countour lines checkbox is checked.
|
|
|
326 |
// If not, hide the contour lines.
|
|
|
327 |
//////
|
|
|
328 |
function checkContour() {
|
|
|
329 |
if (!$("input[type=checkbox][name=showContour]").get(0).checked) {
|
|
|
330 |
plot1.series[2].canvas._elem.addClass("jqplot-series-hidden");
|
|
|
331 |
plot1.series[2].canvas._elem.hide();
|
|
|
332 |
plot1.series[3].canvas._elem.addClass("jqplot-series-hidden");
|
|
|
333 |
plot1.series[3].canvas._elem.hide();
|
|
|
334 |
}
|
|
|
335 |
}
|
|
|
336 |
|
|
|
337 |
$("select[name=axisPosition]").change(function(){
|
|
|
338 |
// this refers to the html element we are binding to.
|
|
|
339 |
// $(this) is jQuery object on that element.
|
|
|
340 |
|
|
|
341 |
switch ($(this).val()) {
|
|
|
342 |
case "both":
|
|
|
343 |
plotOptions.series[0].yaxis = "yaxis";
|
|
|
344 |
plotOptions.series[1].yaxis = "y2axis";
|
|
|
345 |
plotOptions.series[2].yaxis = "yaxis";
|
|
|
346 |
plotOptions.series[3].yaxis = "y2axis";
|
|
|
347 |
break;
|
|
|
348 |
case "left":
|
|
|
349 |
plotOptions.series[0].yaxis = "yaxis";
|
|
|
350 |
plotOptions.series[1].yaxis = "yaxis";
|
|
|
351 |
plotOptions.series[2].yaxis = "yaxis";
|
|
|
352 |
plotOptions.series[3].yaxis = "yaxis";
|
|
|
353 |
break;
|
|
|
354 |
case "right":
|
|
|
355 |
plotOptions.series[0].yaxis = "y2axis";
|
|
|
356 |
plotOptions.series[1].yaxis = "y2axis";
|
|
|
357 |
plotOptions.series[2].yaxis = "y2axis";
|
|
|
358 |
plotOptions.series[3].yaxis = "y2axis";
|
|
|
359 |
break;
|
|
|
360 |
case "mid":
|
|
|
361 |
plotOptions.series[0].yaxis = "yMidAxis";
|
|
|
362 |
plotOptions.series[1].yaxis = "yMidAxis";
|
|
|
363 |
plotOptions.series[2].yaxis = "yMidAxis";
|
|
|
364 |
plotOptions.series[3].yaxis = "yMidAxis";
|
|
|
365 |
break;
|
|
|
366 |
default:
|
|
|
367 |
break;
|
|
|
368 |
|
|
|
369 |
}
|
|
|
370 |
|
|
|
371 |
plot1.destroy();
|
|
|
372 |
plot1 = $.jqplot("chart1", [male, female, male2, female2], plotOptions);
|
|
|
373 |
// Finally, check to see if we need to hide contour lines.
|
|
|
374 |
checkContour();
|
|
|
375 |
});
|
|
|
376 |
|
|
|
377 |
$("input[type=radio][name=backgroundColor]").change(function(){
|
|
|
378 |
// this refers to the html element we are binding to.
|
|
|
379 |
// $(this) is jQuery object on that element.
|
|
|
380 |
plot1.grid.background = $(this).val();
|
|
|
381 |
plotOptions.grid.background = $(this).val();
|
|
|
382 |
plot1.replot();
|
|
|
383 |
// Finally, check to see if we need to hide contour lines.
|
|
|
384 |
checkContour();
|
|
|
385 |
});
|
|
|
386 |
|
|
|
387 |
$("input[type=radio][name=seriesColor]").change(function(){
|
|
|
388 |
// this refers to the html element we are binding to.
|
|
|
389 |
// $(this) is jQuery object on that element.
|
|
|
390 |
if ($(this).val() === "blue") {
|
|
|
391 |
// reset highlight colors so they will be recalculated.
|
|
|
392 |
plot1.series[0].highlightColors = [];
|
|
|
393 |
plot1.series[1].highlightColors = [];
|
|
|
394 |
// reset series color to properly calculate highlight color.
|
|
|
395 |
plot1.series[0].color = blueColors[0];
|
|
|
396 |
plot1.series[1].color = blueColors[1];
|
|
|
397 |
// to actually draw a new color, have to set the color on the shaperenderer.
|
|
|
398 |
plot1.series[0].renderer.shapeRenderer.fillStyle = blueColors[0];
|
|
|
399 |
plot1.series[1].renderer.shapeRenderer.fillStyle = blueColors[1];
|
|
|
400 |
// update plot options state.
|
|
|
401 |
plotOptions.seriesColors = blueColors;
|
|
|
402 |
}
|
|
|
403 |
else if ($(this).val() === "green") {
|
|
|
404 |
// reset highlight colors so they will be recalculated.
|
|
|
405 |
plot1.series[0].highlightColors = [];
|
|
|
406 |
plot1.series[1].highlightColors = [];
|
|
|
407 |
// reset series color to properly calculate highlight color.
|
|
|
408 |
plot1.series[0].color = greenColors[0];
|
|
|
409 |
plot1.series[1].color = greenColors[1];
|
|
|
410 |
// to actually draw a new color, have to set the color on the shaperenderer.
|
|
|
411 |
plot1.series[0].renderer.shapeRenderer.fillStyle = greenColors[0];
|
|
|
412 |
plot1.series[1].renderer.shapeRenderer.fillStyle = greenColors[1];
|
|
|
413 |
// update plot options state.
|
|
|
414 |
plotOptions.seriesColors = blueColors;
|
|
|
415 |
}
|
|
|
416 |
plot1.replot();
|
|
|
417 |
// Finally, check to see if we need to hide contour lines.
|
|
|
418 |
checkContour();
|
|
|
419 |
});
|
|
|
420 |
|
|
|
421 |
|
|
|
422 |
$("input[type=checkbox][name=gridsVertical]").change(function(){
|
|
|
423 |
// this refers to the html element we are binding to.
|
|
|
424 |
// $(this) is jQuery object on that element.
|
|
|
425 |
plot1.axes.xaxis.tickOptions.showGridline = this.checked;
|
|
|
426 |
plotOptions.axes.xaxis.tickOptions.showGridline = this.checked;
|
|
|
427 |
plot1.replot();
|
|
|
428 |
// Finally, check to see if we need to hide contour lines.
|
|
|
429 |
checkContour();
|
|
|
430 |
});
|
|
|
431 |
|
|
|
432 |
$("input[type=checkbox][name=gridsHorizontal]").change(function(){
|
|
|
433 |
// this refers to the html element we are binding to.
|
|
|
434 |
// $(this) is jQuery object on that element.
|
|
|
435 |
plot1.axes.yaxis.tickOptions.showGridline = this.checked;
|
|
|
436 |
plot1.axes.y2axis.tickOptions.showGridline = this.checked;
|
|
|
437 |
plot1.axes.yMidAxis.tickOptions.showGridline = this.checked;
|
|
|
438 |
plotOptions.axes.yaxis.tickOptions.showGridline = this.checked;
|
|
|
439 |
plotOptions.axes.y2axis.tickOptions.showGridline = this.checked;
|
|
|
440 |
plotOptions.axes.yMidAxis.tickOptions.showGridline = this.checked;
|
|
|
441 |
plot1.replot();
|
|
|
442 |
// Finally, check to see if we need to hide contour lines.
|
|
|
443 |
checkContour();
|
|
|
444 |
});
|
|
|
445 |
|
|
|
446 |
$("input[type=checkbox][name=showMinorTicks]").change(function(){
|
|
|
447 |
// this refers to the html element we are binding to.
|
|
|
448 |
// $(this) is jQuery object on that element.
|
|
|
449 |
plot1.axes.yaxis.showMinorTicks = !this.checked;
|
|
|
450 |
plot1.axes.y2axis.showMinorTicks = !this.checked;
|
|
|
451 |
plot1.axes.yMidAxis.showMinorTicks = !this.checked;
|
|
|
452 |
plotOptions.axes.yaxis.showMinorTicks = !this.checked;
|
|
|
453 |
plotOptions.axes.y2axis.showMinorTicks = !this.checked;
|
|
|
454 |
plotOptions.axes.yMidAxis.showMinorTicks = !this.checked;
|
|
|
455 |
plot1.replot();
|
|
|
456 |
// Finally, check to see if we need to hide contour lines.
|
|
|
457 |
checkContour();
|
|
|
458 |
});
|
|
|
459 |
|
|
|
460 |
$("input[type=checkbox][name=plotBands]").change(function(){
|
|
|
461 |
// this refers to the html element we are binding to.
|
|
|
462 |
// $(this) is jQuery object on that element.
|
|
|
463 |
plot1.grid.plotBands.show = this.checked;
|
|
|
464 |
plotOptions.grid.rendererOptions.plotBands.show = this.checked;
|
|
|
465 |
plot1.replot();
|
|
|
466 |
// Finally, check to see if we need to hide contour lines.
|
|
|
467 |
checkContour();
|
|
|
468 |
});
|
|
|
469 |
|
|
|
470 |
$("input[type=checkbox][name=showContour]").change(function(){
|
|
|
471 |
// this refers to the html element we are binding to.
|
|
|
472 |
// $(this) is jQuery object on that element.
|
|
|
473 |
var speed = $(this).val();
|
|
|
474 |
if (this.checked) {
|
|
|
475 |
plot1.series[2].canvas._elem.removeClass("jqplot-series-hidden");
|
|
|
476 |
plot1.series[2].canvas._elem.fadeIn(speed);
|
|
|
477 |
plot1.series[3].canvas._elem.removeClass("jqplot-series-hidden");
|
|
|
478 |
plot1.series[3].canvas._elem.fadeIn(speed);
|
|
|
479 |
}
|
|
|
480 |
else {
|
|
|
481 |
plot1.series[2].canvas._elem.addClass("jqplot-series-hidden");
|
|
|
482 |
plot1.series[2].canvas._elem.fadeOut(speed);
|
|
|
483 |
plot1.series[3].canvas._elem.addClass("jqplot-series-hidden");
|
|
|
484 |
plot1.series[3].canvas._elem.fadeOut(speed);
|
|
|
485 |
}
|
|
|
486 |
});
|
|
|
487 |
|
|
|
488 |
$("input[type=checkbox][name=barPadding]").change(function(){
|
|
|
489 |
// this refers to the html element we are binding to.
|
|
|
490 |
// $(this) is jQuery object on that element.
|
|
|
491 |
if (this.checked) {
|
|
|
492 |
var val = parseFloat($(this).val());
|
|
|
493 |
plot1.series[0].barPadding = val;
|
|
|
494 |
plot1.series[1].barPadding = val;
|
|
|
495 |
plotOptions.seriesDefaults.rendererOptions.barPadding = val;
|
|
|
496 |
}
|
|
|
497 |
else {
|
|
|
498 |
plot1.series[0].barPadding = 0;
|
|
|
499 |
plot1.series[1].barPadding = 0;
|
|
|
500 |
plotOptions.seriesDefaults.rendererOptions.barPadding = 0;
|
|
|
501 |
}
|
|
|
502 |
plot1.replot();
|
|
|
503 |
// Finally, check to see if we need to hide contour lines.
|
|
|
504 |
checkContour();
|
|
|
505 |
});
|
|
|
506 |
|
|
|
507 |
// bind to the data highlighting event to make custom tooltip:
|
|
|
508 |
$(".jqplot-target").bind("jqplotDataHighlight", function(evt, seriesIndex, pointIndex, data) {
|
|
|
509 |
// Here, assume first series is male poulation and second series is female population.
|
|
|
510 |
// Adjust series indices as appropriate.
|
|
|
511 |
var malePopulation = Math.abs(plot1.series[0].data[pointIndex][1]);
|
|
|
512 |
var femalePopulation = Math.abs(plot1.series[1].data[pointIndex][1]);
|
|
|
513 |
var ratio = femalePopulation / malePopulation * 100;
|
|
|
514 |
|
|
|
515 |
$("#tooltipMale").stop(true, true).fadeIn(250).html(malePopulation.toPrecision(4));
|
|
|
516 |
$("#tooltipFemale").stop(true, true).fadeIn(250).html(femalePopulation.toPrecision(4));
|
|
|
517 |
$("#tooltipRatio").stop(true, true).fadeIn(250).html(ratio.toPrecision(4));
|
|
|
518 |
|
|
|
519 |
// Since we don't know which axis is rendererd and acive with out a little extra work,
|
|
|
520 |
// just use the supplied ticks array to get the age label.
|
|
|
521 |
$("#tooltipAge").stop(true, true).fadeIn(250).html(ticks[pointIndex]);
|
|
|
522 |
});
|
|
|
523 |
|
|
|
524 |
// bind to the data highlighting event to make custom tooltip:
|
|
|
525 |
$(".jqplot-target").bind("jqplotDataUnhighlight", function(evt, seriesIndex, pointIndex, data) {
|
|
|
526 |
// clear out all the tooltips.
|
|
|
527 |
$(".tooltip-item").stop(true, true).fadeOut(200).html('');
|
|
|
528 |
});
|
|
|
529 |
|
|
|
530 |
// add a date at the bottom.
|
|
|
531 |
|
|
|
532 |
var d = new $.jsDate();
|
|
|
533 |
$("div.jqplot-datestamp").html("Generated on "+d.strftime("%v"));
|
|
|
534 |
|
|
|
535 |
$("div.chart-container").resizable({delay:20});
|
|
|
536 |
|
|
|
537 |
$("div.chart-container").bind("resize", function(event, ui) {
|
|
|
538 |
plot1.replot();
|
|
|
539 |
});
|
|
|
540 |
|
|
|
541 |
});
|
|
|
542 |
</script>
|
|
|
543 |
|
|
|
544 |
<!-- End example scripts -->
|
|
|
545 |
|
|
|
546 |
<!-- Don't touch this! -->
|
|
|
547 |
|
|
|
548 |
|
|
|
549 |
<script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
|
|
|
550 |
<script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
|
|
|
551 |
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
|
|
|
552 |
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
|
|
|
553 |
<!-- End Don't touch this! -->
|
|
|
554 |
|
|
|
555 |
<!-- Additional plugins go here -->
|
|
|
556 |
|
|
|
557 |
<script class="include" type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.min.js"></script>
|
|
|
558 |
|
|
|
559 |
<!-- load the pyramidAxis and Grid renderers in production. pyramidRenderer will try to load via ajax if not present, but that is not optimal and depends on paths being set. -->
|
|
|
560 |
<script class="include" type="text/javascript" src="../plugins/jqplot.pyramidAxisRenderer.min.js"></script>
|
|
|
561 |
<script class="include" type="text/javascript" src="../plugins/jqplot.pyramidGridRenderer.min.js"></script>
|
|
|
562 |
|
|
|
563 |
<script class="include" type="text/javascript" src="../plugins/jqplot.pyramidRenderer.min.js"></script>
|
|
|
564 |
<script class="include" type="text/javascript" src="../plugins/jqplot.canvasTextRenderer.min.js"></script>
|
|
|
565 |
<script class="include" type="text/javascript" src="../plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
|
|
|
566 |
<script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
|
|
|
567 |
|
|
|
568 |
<!-- End additional plugins -->
|
|
|
569 |
|
|
|
570 |
</div>
|
|
|
571 |
<div class="col2">
|
|
|
572 |
|
|
|
573 |
<div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
|
|
|
574 |
<div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
|
|
|
575 |
<div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
|
|
|
576 |
<div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
|
|
|
577 |
<div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
|
|
|
578 |
<div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
|
|
|
579 |
<div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
|
|
|
580 |
<div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
|
|
|
581 |
<div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
|
|
|
582 |
<div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
|
|
|
583 |
<div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
|
|
|
584 |
<div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
|
|
|
585 |
<div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
|
|
|
586 |
<div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
|
|
|
587 |
<div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
|
|
|
588 |
<div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
|
|
|
589 |
<div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
|
|
|
590 |
<div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
|
|
|
591 |
<div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
|
|
|
592 |
<div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
|
|
|
593 |
<div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
|
|
|
594 |
<div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
|
|
|
595 |
<div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
|
|
|
596 |
<div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
|
|
|
597 |
<div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
|
|
|
598 |
<div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
|
|
|
599 |
<div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
|
|
|
600 |
<div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
|
|
|
601 |
<div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
|
|
|
602 |
<div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
|
|
|
603 |
<div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
|
|
|
604 |
<div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
|
|
|
605 |
<div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
|
|
|
606 |
<div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
|
|
|
607 |
<div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
|
|
|
608 |
<div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
|
|
|
609 |
<div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
|
|
|
610 |
<div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
|
|
|
611 |
<div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
|
|
|
612 |
<div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
|
|
|
613 |
<div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
|
|
|
614 |
<div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
|
|
|
615 |
<div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
|
|
|
616 |
<div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
|
|
|
617 |
<div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
|
|
|
618 |
<div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
|
|
|
619 |
<div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
|
|
|
620 |
<div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
|
|
|
621 |
<div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
|
|
|
622 |
<div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
|
|
|
623 |
<div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
|
|
|
624 |
<div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
|
|
|
625 |
<div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
|
|
|
626 |
<div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
|
|
|
627 |
<div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
|
|
|
628 |
<div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
|
|
|
629 |
|
|
|
630 |
</div>
|
|
|
631 |
</div>
|
|
|
632 |
</div>
|
|
|
633 |
<script type="text/javascript" src="example.min.js"></script>
|
|
|
634 |
|
|
|
635 |
</body>
|
|
|
636 |
|
|
|
637 |
|
|
|
638 |
</html>
|