kcp_pyramid.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Pyramid Charts</title>
  5. <link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
  6. <link rel="stylesheet" type="text/css" href="examples.min.css" />
  7. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
  8. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
  9. <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
  10. <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  11. </head>
  12. <body>
  13. <div id="header">
  14. <div class="nav">
  15. <a class="nav" href="../../../index.php"><span>&gt;</span>Home</a>
  16. <a class="nav" href="../../../docs/"><span>&gt;</span>Docs</a>
  17. <a class="nav" href="../../download/"><span>&gt;</span>Download</a>
  18. <a class="nav" href="../../../info.php"><span>&gt;</span>Info</a>
  19. <a class="nav" href="../../../donate.php"><span>&gt;</span>Donate</a>
  20. </div>
  21. </div>
  22. <div class="colmask leftmenu">
  23. <div class="colleft">
  24. <div class="col1" id="example-content">
  25. <!-- Example scripts go here -->
  26. <link class="include" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/smoothness/jquery-ui.css" rel="Stylesheet" />
  27. <style type="text/css">
  28. .chart-container {
  29. border: 1px solid darkblue;
  30. padding: 30px;
  31. width: 600px;
  32. height: 700px;
  33. }
  34. #chart1 {
  35. width: 96%;
  36. height: 96%;
  37. }
  38. .jqplot-datestamp {
  39. font-size: 0.8em;
  40. color: #777;
  41. /* margin-top: 1em;
  42. text-align: right;*/
  43. font-style: italic;
  44. position: absolute;
  45. bottom: 15px;
  46. right: 15px;
  47. }
  48. td.controls li {
  49. list-style-type: none;
  50. }
  51. td.controls ul {
  52. margin-top: 0.5em;
  53. padding-left: 0.2em;
  54. }
  55. pre.code {
  56. margin-top: 45px;
  57. clear: both;
  58. }
  59. div.tooltip {
  60. border: 1px solid #aaa;
  61. margin-right: 10px;
  62. }
  63. </style>
  64. <table class="app">
  65. <td class="controls">
  66. <div style="margin-bottom: 15px;">
  67. Axes:
  68. <select name="axisPosition">
  69. <option value="both">Left &amp; Right</option>
  70. <option value = "left">Left</option>
  71. <option value = "right">Right</option>
  72. <option value = "mid">Mid</option>
  73. </select>
  74. </div>
  75. <div>
  76. Background Color:
  77. <ul>
  78. <li><input name="backgroundColor" value="white" type="radio" checked />Default</li>
  79. <li><input name="backgroundColor" value="#efefef" type="radio" />Gray</li>
  80. </ul>
  81. </div>
  82. <div>
  83. Pyramid Color:
  84. <ul>
  85. <li><input name="seriesColor" value="green" type="radio" checked />Green</li>
  86. <li><input name="seriesColor" value="blue" type="radio" />Blue</li>
  87. </ul>
  88. </div>
  89. <div>
  90. Grids:
  91. <ul>
  92. <li><input name="gridsVertical" value="vertical" type="checkbox" checked />Vertical</li>
  93. <li><input name="gridsHorizontal" value="horizontal" type="checkbox" checked />Horizontal</li>
  94. <li><input name="showMinorTicks" value="true" type="checkbox" />Only major</li>
  95. <li><input name="plotBands" value="true" type="checkbox" />Plot Bands</li>
  96. </ul>
  97. </div>
  98. <div>
  99. <ul>
  100. <li><input name="barPadding" value="2" type="checkbox" checked />Gap between bars</li>
  101. <!-- value for showContour is speed at which to fade lines in/out -->
  102. <li><input name="showContour" value="500" type="checkbox" checked />Comparison Line</li>
  103. </ul>
  104. </div>
  105. <div class="tooltip">
  106. <table>
  107. <tr>
  108. <td>Age: </td><td><div class="tooltip-item" id="tooltipAge">&nbsp;</div></td>
  109. </tr>
  110. <tr>
  111. <td>Male: </td><td><div class="tooltip-item" id="tooltipMale">&nbsp;</div></td>
  112. </tr>
  113. <tr>
  114. <td>Female: </td><td><div class="tooltip-item" id="tooltipFemale">&nbsp;</div></td>
  115. </tr>
  116. <tr>
  117. <td>Ratio: </td><td><div class="tooltip-item" id="tooltipRatio">&nbsp;</div></td>
  118. </tr>
  119. </table>
  120. </div>
  121. </td>
  122. <td class="chart">
  123. <div class="chart-container">
  124. <div id="chart1"></div>
  125. <div class="jqplot-datestamp"></div>
  126. </div>
  127. </td>
  128. </table>
  129. <pre class="code brush:js"></pre>
  130. <script class="code" type="text/javascript" language="javascript">
  131. $(document).ready(function(){
  132. // the "x" values from the data will go into the ticks array.
  133. // ticks should be strings for this case where we have values like "75+"
  134. var ticks = ["0", "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+", ""];
  135. // The "y" values of the data are put into seperate series arrays.
  136. var male = [0.635441, 1.066868, 0.889602, 0.816883, 1.016458, 0.916705, 0.79569, 0.970443, 1.046451, 1.335686, 0.926962, 0.936646, 0.919405, 0.722027, 0.896342, 0.993397, 0.613794, 0.916921, 0.828748, 0.43487, 0.391652, 0.517303, 0.507104, 0.336168, 0.554176, 0.691826, 0.66553, 0.686232, 0.7097, 0.356915, 0.756028, 0.430155, 0.420597, 0.608589, 0.609348, 0.83607, 0.79871, 0.63388, 0.866719, 0.711042, 1.160429, 0.439268, 0.659694, 0.468406, 0.340002, 0.996662, 0.371047, 0.638918, 0.462334, 0.467053, 0.545638, 0.463275, 0.480992, 0.515747, 0.499415, 0.287639, 0.520332, 0.443779, 0.334986, 0.43161, 0.474405, 0.179186, 0.620127, 0.219074, 0.411669, 0.495684, 0.315231, 0.275056, 0.157341, 0.113926, 0.24991, 0.128113, 0.175297, 0.103093, 0.253292, 0.988836];
  137. var female = [0.767078, 0.679554, 1.064493, 0.915063, 0.860792, 0.785728, 0.892471, 0.687886, 1.055313, 0.921839, 0.659624, 1.14516, 0.910735, 1.279864, 0.714669, 0.873929, 0.928453, 0.595752, 1.093534, 0.501142, 0.52829, 0.411606, 0.633309, 0.616121, 0.621781, 0.621598, 0.638378, 0.703724, 0.742589, 0.48523, 0.735727, 0.898816, 0.740614, 0.991105, 1.48909, 1.226996, 1.020624, 0.737742, 0.946817, 0.69129, 0.933744, 0.957472, 0.793112, 0.581121, 0.767528, 1.031739, 1.202133, 0.626926, 0.959522, 0.594303, 1.202145, 0.611707, 0.480779, 0.383338, 0.532876, 0.849878, 0.52453, 0.660183, 0.25419, 0.137567, 0.762322, 0.490294, 0.463194, 0.566921, 0.353006, 0.730591, 0.34669, 0.271638, 0.309785, 0.152756, 0.478111, 0.177234, 0.269302, 0.396318, 0.194934, 1.683044];
  138. var male2 = [0.230476, 0.175917, 0.225027, 0.40564, 0.408617, 0.495873, 0.441314, 0.282774, 0.47483, 0.393433, 0.580612, 0.220204, 0.514281, 0.32985, 0.514933, 0.507871, 0.398236, 0.362535, 0.603625, 0.528885, 0.550904, 0.87645, 0.857331, 0.713371, 0.703566, 0.703473, 0.858118, 0.751679, 0.832039, 0.752134, 1.202689, 1.069239, 1.051431, 0.732728, 0.992696, 0.828825, 0.723044, 0.857868, 1.088298, 0.86951, 0.914989, 0.549574, 0.672405, 0.637425, 0.530195, 0.706179, 0.941525, 0.576152, 0.913033, 0.647477, 0.734785, 0.441276, 0.583452, 0.537074, 0.7625, 0.662768, 0.307013, 0.384606, 0.470416, 0.22771, 0.470173, 0.152773, 0.338433, 0.348797, 0.10273, 0.285215, 0.139796, 0.186955, 0.143478, 0.178882, 0.141022, 0.1435, 0.146959, 0.056583, 0.05317, 0.784258];
  139. var female2 = [0.203297, 0.298698, 0.452947, 0.783013, 0.50033, 0.53629, 0.451817, 0.69927, 0.741356, 0.545433, 0.559643, 0.334842, 0.443899, 0.437309, 0.584658, 0.451757, 0.509258, 0.73483, 0.640501, 0.698825, 0.803701, 1.018148, 1.504918, 0.701318, 0.781324, 1.792142, 0.968484, 1.3288, 1.059729, 1.079985, 2.245553, 1.080526, 1.122927, 1.512428, 1.296163, 1.047212, 0.988065, 1.239462, 1.521174, 1.05187, 1.253013, 0.983437, 1.181799, 1.090029, 0.718064, 1.578813, 1.121987, 1.010202, 1.438581, 1.051654, 1.656156, 0.732428, 0.719311, 0.742441, 0.623806, 0.643911, 0.579092, 0.472909, 0.683453, 0.39008, 0.437458, 0.464595, 0.385552, 0.520029, 0.240536, 0.457316, 0.339587, 0.203276, 0.282141, 0.19517, 0.283663, 0.12404, 0.147211, 0.141153, 0.177653, 1.193951];
  140. // Custom color arrays are set up for each series to get the look that is desired.
  141. // Two color arrays are created for the default and optional color which the user can pick.
  142. var greenColors = ["#526D2C", "#77933C", "#C57225", "#C57225"];
  143. var blueColors = ["#3F7492", "#4F9AB8", "#C57225", "#C57225"];
  144. // To accomodate changing y axis, need to keep track of plot options, so they are defined separately
  145. // changing axes will require recreating the plot, so need to keep
  146. // track of state changes.
  147. var plotOptions = {
  148. // We set up a customized title which acts as labels for the left and right sides of the pyramid.
  149. title: '<div style="float:left;width:50%;text-align:center">Male</div><div style="float:right;width:50%;text-align:center">Female</div>',
  150. // by default, the series will use the green color scheme.
  151. seriesColors: greenColors,
  152. grid: {
  153. drawBorder: false,
  154. shadow: false,
  155. background: 'white',
  156. rendererOptions: {
  157. // plotBands is an option of the pyramidGridRenderer.
  158. // it will put banding at starting at a specified value
  159. // along the y axis with an adjustable interval.
  160. plotBands: {
  161. show: false
  162. }
  163. }
  164. },
  165. // This makes the effective starting value of the axes 0 instead of 1.
  166. // For display, the y axis will use the ticks we supplied.
  167. defaultAxisStart: 0,
  168. seriesDefaults: {
  169. renderer: $.jqplot.PyramidRenderer,
  170. rendererOptions: {
  171. barPadding: 2,
  172. offsetBars: true
  173. },
  174. yaxis: 'yaxis',
  175. shadow: false
  176. },
  177. // We have 4 series, the left and right pyramid bars and
  178. // the left and rigt overlay lines.
  179. series: [
  180. // For pyramid plots, the default side is right.
  181. // We want to override here to put first set of bars
  182. // on left.
  183. {
  184. rendererOptions:{
  185. side: 'left',
  186. synchronizeHighlight: 1
  187. }
  188. },
  189. {
  190. yaxis: 'y2axis',
  191. rendererOptions:{
  192. synchronizeHighlight: 0
  193. }
  194. },
  195. // Pyramid series are filled bars by default.
  196. // The overlay series will be unfilled lines.
  197. {
  198. rendererOptions: {
  199. fill: false,
  200. side: 'left'
  201. }
  202. },
  203. {
  204. yaxis: 'y2axis',
  205. rendererOptions: {
  206. fill: false
  207. }
  208. }
  209. ],
  210. // Set up all the y axes, since users are allowed to switch between them.
  211. // The only axis that will show is the one that the series are "attached" to.
  212. // We need the appropriate options for the others for when the user switches.
  213. axes: {
  214. xaxis: {
  215. tickOptions: {},
  216. rendererOptions: {
  217. baselineWidth: 2
  218. }
  219. },
  220. yaxis: {
  221. label: 'Age',
  222. // Use canvas label renderer to get rotated labels.
  223. labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
  224. // include empty tick options, they will be used
  225. // as users set options with plot controls.
  226. tickOptions: {},
  227. tickInterval: 5,
  228. showMinorTicks: true,
  229. ticks: ticks,
  230. rendererOptions: {
  231. category: false,
  232. baselineWidth: 2
  233. }
  234. },
  235. yMidAxis: {
  236. label: 'Age',
  237. // include empty tick options, they will be used
  238. // as users set options with plot controls.
  239. tickOptions: {},
  240. tickInterval: 5,
  241. showMinorTicks: true,
  242. ticks: ticks,
  243. rendererOptions: {
  244. category: false,
  245. baselineWidth: 2
  246. }
  247. },
  248. y2axis: {
  249. label: 'Age',
  250. // Use canvas label renderer to get rotated labels.
  251. labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
  252. // include empty tick options, they will be used
  253. // as users set options with plot controls.
  254. tickOptions: {},
  255. tickInterval: 5,
  256. showMinorTicks: true,
  257. ticks: ticks,
  258. rendererOptions: {
  259. category: false,
  260. baselineWidth: 2
  261. }
  262. }
  263. }
  264. };
  265. // initialize form elements
  266. // set these before attaching event handlers.
  267. $('input[type=checkbox][name=gridsVertical]').attr('checked', true);
  268. $('input[type=checkbox][name=gridsHorizontal]').attr('checked', true);
  269. $('input[type=checkbox][name=showMinorTicks]').attr('checked', false);
  270. $('input[type=checkbox][name=plotBands]').attr('checked', false);
  271. $('input[type=checkbox][name=showContour]').attr('checked', true);
  272. $('input[type=checkbox][name=barPadding]').attr('checked', true);
  273. $('select[name=axisPosition]').val('both');
  274. $('input[type=radio][name=backgroundColor]').attr('checked', false);
  275. $('input[type=radio][name=backgroundColor][value=white]').attr('checked', true);
  276. $('input[type=radio][name=backgroundColor]').attr('checked', false);
  277. $('input[type=radio][name=backgroundColor][value=white]').attr('checked', true);
  278. $('input[type=radio][name=seriesColor]').attr('checked', false);
  279. $('input[type=radio][name=seriesColor][value=green]').attr('checked', true);
  280. plot1 = $.jqplot('chart1', [male, female, male2, female2], plotOptions);
  281. // After plot creation, check to see if contours should be displayed
  282. checkContour();
  283. //////
  284. // The followng functions use verbose css selectors to make
  285. // it clear exactly which elements they are binging to/operating on
  286. //////
  287. //////
  288. // Function which checkes if the countour lines checkbox is checked.
  289. // If not, hide the contour lines by hiding the canvases they are
  290. // drawn on.
  291. //////
  292. function checkContour() {
  293. if (!$('input[type=checkbox][name=showContour]').get(0).checked) {
  294. plot1.series[2].canvas._elem.addClass('jqplot-series-hidden');
  295. plot1.series[2].canvas._elem.hide();
  296. plot1.series[3].canvas._elem.addClass('jqplot-series-hidden');
  297. plot1.series[3].canvas._elem.hide();
  298. }
  299. }
  300. $('select[name=axisPosition]').change(function(){
  301. // this refers to the html element we are binding to.
  302. // $(this) is jQuery object on that element.
  303. switch ($(this).val()) {
  304. case 'both':
  305. plotOptions.series[0].yaxis = 'yaxis';
  306. plotOptions.series[1].yaxis = 'y2axis';
  307. plotOptions.series[2].yaxis = 'yaxis';
  308. plotOptions.series[3].yaxis = 'y2axis';
  309. break;
  310. case 'left':
  311. plotOptions.series[0].yaxis = 'yaxis';
  312. plotOptions.series[1].yaxis = 'yaxis';
  313. plotOptions.series[2].yaxis = 'yaxis';
  314. plotOptions.series[3].yaxis = 'yaxis';
  315. break;
  316. case 'right':
  317. plotOptions.series[0].yaxis = 'y2axis';
  318. plotOptions.series[1].yaxis = 'y2axis';
  319. plotOptions.series[2].yaxis = 'y2axis';
  320. plotOptions.series[3].yaxis = 'y2axis';
  321. break;
  322. case 'mid':
  323. plotOptions.series[0].yaxis = 'yMidAxis';
  324. plotOptions.series[1].yaxis = 'yMidAxis';
  325. plotOptions.series[2].yaxis = 'yMidAxis';
  326. plotOptions.series[3].yaxis = 'yMidAxis';
  327. break;
  328. default:
  329. break;
  330. }
  331. plot1.destroy();
  332. plot1 = $.jqplot('chart1', [male, female, male2, female2], plotOptions);
  333. // Finally, check to see if we need to hide contour lines.
  334. checkContour();
  335. });
  336. $('input[type=radio][name=backgroundColor]').change(function(){
  337. // this refers to the html element we are binding to.
  338. // $(this) is jQuery object on that element.
  339. plot1.grid.background = $(this).val();
  340. plotOptions.grid.background = $(this).val();
  341. plot1.replot();
  342. // Finally, check to see if we need to hide contour lines.
  343. checkContour();
  344. });
  345. $('input[type=radio][name=seriesColor]').change(function(){
  346. // this refers to the html element we are binding to.
  347. // $(this) is jQuery object on that element.
  348. if ($(this).val() === 'blue') {
  349. // reset highlight colors so they will be recalculated.
  350. plot1.series[0].highlightColors = [];
  351. plot1.series[1].highlightColors = [];
  352. // reset series color to properly calculate highlight color.
  353. plot1.series[0].color = blueColors[0];
  354. plot1.series[1].color = blueColors[1];
  355. // to actually draw a new color, have to set the color on the shaperenderer.
  356. plot1.series[0].renderer.shapeRenderer.fillStyle = blueColors[0];
  357. plot1.series[1].renderer.shapeRenderer.fillStyle = blueColors[1];
  358. // update plot options state.
  359. plotOptions.seriesColors = blueColors;
  360. }
  361. else if ($(this).val() === 'green') {
  362. // reset highlight colors so they will be recalculated.
  363. plot1.series[0].highlightColors = [];
  364. plot1.series[1].highlightColors = [];
  365. // reset series color to properly calculate highlight color.
  366. plot1.series[0].color = greenColors[0];
  367. plot1.series[1].color = greenColors[1];
  368. // to actually draw a new color, have to set the color on the shaperenderer.
  369. plot1.series[0].renderer.shapeRenderer.fillStyle = greenColors[0];
  370. plot1.series[1].renderer.shapeRenderer.fillStyle = greenColors[1];
  371. // update plot options state.
  372. plotOptions.seriesColors = blueColors;
  373. }
  374. plot1.replot();
  375. // Finally, check to see if we need to hide contour lines.
  376. checkContour();
  377. });
  378. $('input[type=checkbox][name=gridsVertical]').change(function(){
  379. // this refers to the html element we are binding to.
  380. // $(this) is jQuery object on that element.
  381. plot1.axes.xaxis.tickOptions.showGridline = this.checked;
  382. plotOptions.axes.xaxis.tickOptions.showGridline = this.checked;
  383. plot1.replot();
  384. // Finally, check to see if we need to hide contour lines.
  385. checkContour();
  386. });
  387. $('input[type=checkbox][name=gridsHorizontal]').change(function(){
  388. // this refers to the html element we are binding to.
  389. // $(this) is jQuery object on that element.
  390. plot1.axes.yaxis.tickOptions.showGridline = this.checked;
  391. plot1.axes.y2axis.tickOptions.showGridline = this.checked;
  392. plot1.axes.yMidAxis.tickOptions.showGridline = this.checked;
  393. plotOptions.axes.yaxis.tickOptions.showGridline = this.checked;
  394. plotOptions.axes.y2axis.tickOptions.showGridline = this.checked;
  395. plotOptions.axes.yMidAxis.tickOptions.showGridline = this.checked;
  396. plot1.replot();
  397. // Finally, check to see if we need to hide contour lines.
  398. checkContour();
  399. });
  400. $('input[type=checkbox][name=showMinorTicks]').change(function(){
  401. // this refers to the html element we are binding to.
  402. // $(this) is jQuery object on that element.
  403. plot1.axes.yaxis.showMinorTicks = !this.checked;
  404. plot1.axes.y2axis.showMinorTicks = !this.checked;
  405. plot1.axes.yMidAxis.showMinorTicks = !this.checked;
  406. plotOptions.axes.yaxis.showMinorTicks = !this.checked;
  407. plotOptions.axes.y2axis.showMinorTicks = !this.checked;
  408. plotOptions.axes.yMidAxis.showMinorTicks = !this.checked;
  409. plot1.replot();
  410. // Finally, check to see if we need to hide contour lines.
  411. checkContour();
  412. });
  413. $('input[type=checkbox][name=plotBands]').change(function(){
  414. // this refers to the html element we are binding to.
  415. // $(this) is jQuery object on that element.
  416. plot1.grid.plotBands.show = this.checked;
  417. plotOptions.grid.rendererOptions.plotBands.show = this.checked;
  418. plot1.replot();
  419. // Finally, check to see if we need to hide contour lines.
  420. checkContour();
  421. });
  422. $('input[type=checkbox][name=showContour]').change(function(){
  423. // this refers to the html element we are binding to.
  424. // $(this) is jQuery object on that element.
  425. var speed = $(this).val();
  426. if (this.checked) {
  427. plot1.series[2].canvas._elem.removeClass('jqplot-series-hidden');
  428. plot1.series[2].canvas._elem.fadeIn(speed);
  429. plot1.series[3].canvas._elem.removeClass('jqplot-series-hidden');
  430. plot1.series[3].canvas._elem.fadeIn(speed);
  431. }
  432. else {
  433. plot1.series[2].canvas._elem.addClass('jqplot-series-hidden');
  434. plot1.series[2].canvas._elem.fadeOut(speed);
  435. plot1.series[3].canvas._elem.addClass('jqplot-series-hidden');
  436. plot1.series[3].canvas._elem.fadeOut(speed);
  437. }
  438. });
  439. $('input[type=checkbox][name=barPadding]').change(function(){
  440. // this refers to the html element we are binding to.
  441. // $(this) is jQuery object on that element.
  442. if (this.checked) {
  443. var val = parseFloat($(this).val());
  444. plot1.series[0].barPadding = val;
  445. plot1.series[1].barPadding = val;
  446. plotOptions.seriesDefaults.rendererOptions.barPadding = val;
  447. }
  448. else {
  449. plot1.series[0].barPadding = 0;
  450. plot1.series[1].barPadding = 0;
  451. plotOptions.seriesDefaults.rendererOptions.barPadding = 0;
  452. }
  453. plot1.replot();
  454. // Finally, check to see if we need to hide contour lines.
  455. checkContour();
  456. });
  457. // bind to the data highlighting event to make custom tooltip:
  458. $('.jqplot-target').bind('jqplotDataHighlight', function(evt, seriesIndex, pointIndex, data) {
  459. // Here, assume first series is male poulation and second series is female population.
  460. // Adjust series indices as appropriate.
  461. var malePopulation = Math.abs(plot1.series[0].data[pointIndex][1]);
  462. var femalePopulation = Math.abs(plot1.series[1].data[pointIndex][1]);
  463. var ratio = femalePopulation / malePopulation * 100;
  464. $('#tooltipMale').stop(true, true).fadeIn(250).html(malePopulation.toPrecision(4));
  465. $('#tooltipFemale').stop(true, true).fadeIn(250).html(femalePopulation.toPrecision(4));
  466. $('#tooltipRatio').stop(true, true).fadeIn(250).html(ratio.toPrecision(4));
  467. // Since we don't know which axis is rendererd and acive with out a little extra work,
  468. // just use the supplied ticks array to get the age label.
  469. $('#tooltipAge').stop(true, true).fadeIn(250).html(ticks[pointIndex]);
  470. });
  471. // bind to the data highlighting event to make custom tooltip:
  472. $('.jqplot-target').bind('jqplotDataUnhighlight', function(evt, seriesIndex, pointIndex, data) {
  473. // clear out all the tooltips.
  474. $('.tooltip-item').stop(true, true).fadeOut(200).html('');
  475. });
  476. // add a date at the bottom.
  477. var d = new $.jsDate();
  478. $('div.jqplot-datestamp').html('Generated on '+d.strftime('%v'));
  479. $("div.chart-container").resizable({delay:20});
  480. $("div.chart-container").bind("resize", function(event, ui) {
  481. plot1.replot();
  482. });
  483. });
  484. </script>
  485. <!-- End example scripts -->
  486. <!-- Don't touch this! -->
  487. <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
  488. <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
  489. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
  490. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
  491. <!-- End Don't touch this! -->
  492. <!-- Additional plugins go here -->
  493. <script class="include" type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.min.js"></script>
  494. <!-- 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. -->
  495. <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidAxisRenderer.min.js"></script>
  496. <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidGridRenderer.min.js"></script>
  497. <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidRenderer.min.js"></script>
  498. <script class="include" type="text/javascript" src="../plugins/jqplot.canvasTextRenderer.min.js"></script>
  499. <script class="include" type="text/javascript" src="../plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
  500. <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
  501. <!-- End additional plugins -->
  502. </div>
  503. <div class="col2">
  504. <div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
  505. <div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
  506. <div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
  507. <div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
  508. <div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
  509. <div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
  510. <div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
  511. <div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
  512. <div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
  513. <div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
  514. <div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
  515. <div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
  516. <div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
  517. <div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
  518. <div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
  519. <div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
  520. <div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
  521. <div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
  522. <div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
  523. <div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
  524. <div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
  525. <div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
  526. <div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
  527. <div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
  528. <div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
  529. <div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
  530. <div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
  531. <div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
  532. <div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
  533. <div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
  534. <div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
  535. <div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
  536. <div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
  537. <div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
  538. <div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
  539. <div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
  540. <div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
  541. <div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
  542. <div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
  543. <div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
  544. <div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
  545. <div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
  546. <div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
  547. <div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
  548. <div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
  549. <div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
  550. <div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
  551. <div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
  552. <div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
  553. <div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
  554. <div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
  555. <div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
  556. <div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
  557. <div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
  558. <div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
  559. <div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
  560. </div>
  561. </div>
  562. </div>
  563. <script type="text/javascript" src="example.min.js"></script>
  564. </body>
  565. </html>