PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/magehelp/js/jqplot/examples/kcp_pyramid_by_age.php

https://bitbucket.org/jit_bec/shopifine
PHP | 862 lines | 692 code | 117 blank | 53 comment | 6 complexity | fc2bdf5056019cbd9cd18a237c8c1dc2 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <?php
  5. $title = "Pyramid Chart By Age";
  6. ?>
  7. <title><?php print $title ?></title>
  8. <link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.css" />
  9. <link rel="stylesheet" type="text/css" href="examples.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. <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
  13. <script class="include" type="text/javascript" src="../jquery.min.js"></script>
  14. <link class="include" type="text/css" href="jquery-ui/css/smoothness/jquery-ui.min.css" rel="Stylesheet" />
  15. <link href="colorpicker/jquery.colorpicker.css" rel="stylesheet" type="text/css"/>
  16. <style type="text/css">
  17. html {
  18. width: 100%;
  19. height: 100%;
  20. }
  21. body {
  22. width: 98%;
  23. height: 97%;
  24. margin: 6px;
  25. }
  26. .quintile-outer-container {
  27. width: 97%;
  28. height: 97%;
  29. margin: auto;
  30. }
  31. .jqplot-chart {
  32. /* width: 400px;
  33. height: 400px;*/
  34. }
  35. .quintile-toolbar .ui-icon {
  36. float: right;
  37. margin: 3px 5px;
  38. }
  39. table.stats-table td, table.highlighted-stats-table td {
  40. background-color: rgb(230, 230, 230);
  41. padding: 0.5em;
  42. }
  43. col.label {
  44. width: 14em;
  45. }
  46. col.value {
  47. width: 7em;
  48. }
  49. td.quintile-value {
  50. width: 7em;
  51. text-align: right;
  52. }
  53. table.stats-table td.tooltip-header, table.highlighted-stats-table td.tooltip-header {
  54. background-color: rgb(200, 200, 200);
  55. }
  56. table.stats-table, table.highlighted-stats-table, td.contour-cell {
  57. font-size: 0.7em;
  58. }
  59. td.contour-cell {
  60. height: 1.5em;
  61. padding-left: 20px;
  62. padding-bottom: 1.5em;
  63. }
  64. table.highlighted-stats-table {
  65. margin-top: 15px;
  66. }
  67. div.stats-cell div.input {
  68. font-size: 0.7em;
  69. margin-top: 1.5em;
  70. }
  71. div.content-container {
  72. padding-left: 230px; /* LC width */
  73. padding-right: 300px; /* RC width */
  74. height: 100%;
  75. }
  76. div.content-container .column {
  77. position: relative;
  78. float: left;
  79. }
  80. div.controls {
  81. width: 170px; /* LC width */
  82. right: 230px; /* LC width */
  83. padding-left: 30px;
  84. padding-right: 30px;
  85. margin-left: -100%;
  86. margin-top: 30px;
  87. }
  88. div.chart-cell {
  89. width: 100%;
  90. height: 100%;
  91. }
  92. div.stats-cell {
  93. width: 270px; /* RC width */
  94. margin-right: -300px; /* RC width */
  95. padding-right: 30px;
  96. margin-top: 30px;
  97. }
  98. div.controls, div.controls select {
  99. font-size: 0.8em;
  100. }
  101. div.controls li {
  102. list-style-type: none;
  103. }
  104. div.controls ul {
  105. margin-top: 0.5em;
  106. padding-left: 0.2em;
  107. }
  108. div.overlay-chart-container {
  109. display: none;
  110. z-index: 11;
  111. position: fixed;
  112. width: 800px;
  113. left: 50%;
  114. margin-left: -400px;
  115. background-color: white;
  116. }
  117. div.overlay-chart-container div.ui-icon {
  118. float: right;
  119. margin: 3px 5px;
  120. }
  121. div.overlay-shadow {
  122. display: none;
  123. z-index: 10;
  124. background-color: rgba(0, 0, 0, 0.8);
  125. position: fixed;
  126. top: 0px;
  127. left: 0px;
  128. width: 100%;
  129. height: 100%;
  130. }
  131. div.ui-colorpicker div.ui-dialog-titlebar {
  132. padding: 0.1em 0.3em;
  133. }
  134. input.color {
  135. display: none;
  136. }
  137. div.colorpicker-container span {
  138. padding: 3px;
  139. }
  140. div.quintile-content {
  141. width: 100%;
  142. height: 100%;
  143. }
  144. @media print {
  145. div.stats-cell {
  146. vertical-align: top;
  147. padding-top: 35px;
  148. }
  149. table.stats-table, table.stats-table td {
  150. color: #aaaaaa;
  151. border: 1px solid #bbbbbb;
  152. border-collapse: collapse;
  153. }
  154. table.stats-table tr {
  155. font-family: Verdana,Arial,sans-serif;
  156. /*font-size: 0.7em;*/
  157. }
  158. }
  159. </style>
  160. </head>
  161. <body>
  162. <!-- Example scripts go here -->
  163. <div class="overlay-shadow"></div>
  164. <div class="overlay-chart-container ui-corner-all">
  165. <div class="overlay-chart-container-header ui-widget-header ui-corner-top">Right click the image to Copy or Save As...<div class="ui-icon ui-icon-closethick"></div></div>
  166. <div class="overlay-chart-container-content ui-corner-bottom"></div>
  167. </div>
  168. <div class="quintile-outer-container ui-widget ui-corner-all">
  169. <div class="quintile-toolbar ui-widget-header ui-corner-top">
  170. <span class="quintile-title">Income Level:</span>
  171. </div>
  172. <div class="quintile-content ui-widget-content ui-corner-bottom">
  173. <div class="content-container">
  174. <div class="chart-cell column">
  175. <div id="agesChart" class="jqplot-chart"></div>
  176. </div>
  177. <div class="controls column">
  178. <table>
  179. <tr>
  180. <td>
  181. Axes:
  182. </td>
  183. <td>
  184. <select name="axisPosition">
  185. <option value="both">Left &amp; Right</option>
  186. <option value = "left">Left</option>
  187. <option value = "right">Right</option>
  188. <option value = "mid">Mid</option>
  189. </select>
  190. </td>
  191. </tr>
  192. <tr>
  193. <td>
  194. Colors:
  195. </td>
  196. <td>
  197. <ul>
  198. <li><input class="color" type="color" id="colorMale" /> Male</li>
  199. <li><input class="color" type="color" id="colorFemale" /> Female</li>
  200. <li><input class="color" type="color" id="colorBackground" /> Background</li>
  201. <li><input class="color" type="color" id="colorPlotBands" /> Plot Bands</li>
  202. </ul>
  203. </td>
  204. </tr>
  205. <tr>
  206. <td>
  207. Grids:
  208. </td>
  209. <td>
  210. <ul>
  211. <li><input name="gridsVertical" value="vertical" type="checkbox" />Vertical</li>
  212. <li><input name="gridsHorizontal" value="horizontal" type="checkbox" />Horizontal</li>
  213. <li><input name="showMinorTicks" value="true" type="checkbox" checked />Only major</li>
  214. <li><input name="plotBands" value="true" type="checkbox" checked />Plot Bands</li>
  215. </ul>
  216. </td>
  217. </tr>
  218. <tr>
  219. <td colspan="2">
  220. <ul>
  221. <li><input name="barPadding" value="2" type="checkbox" checked />Gap between bars</li>
  222. <!-- value for showContour is speed at which to fade lines in/out -->
  223. <li><input name="showContour" value="500" type="checkbox" />Comparison Line</li>
  224. </ul>
  225. </td>
  226. </tr>
  227. </table>
  228. </div>
  229. <div class="stats-cell column">
  230. <table class="stats-table">
  231. <colgroup>
  232. <col class="label">
  233. <col class="value">
  234. </colgroup>
  235. <tbody>
  236. <tr>
  237. <td class="ui-corner-tl">Mean Age:</td>
  238. <td class="quintile-value summary-meanAge ui-corner-tr"></td>
  239. </tr>
  240. <tr>
  241. <td>Sex Ratio:</td>
  242. <td class="quintile-value summary-sexRatio"></td>
  243. </tr>
  244. <tr>
  245. <td>Age Dependency Ratio:</td>
  246. <td class="quintile-value summary-ageDependencyRatio"></td>
  247. </tr>
  248. <tr>
  249. <td>Population, Total:</td>
  250. <td class="quintile-value summary-populationTotal"></td>
  251. </tr>
  252. <tr>
  253. <td>Population, Male:</td>
  254. <td class="quintile-value summary-populationMale"></td>
  255. </tr>
  256. <tr>
  257. <td class="ui-corner-bl">Population, Female:</td>
  258. <td class="quintile-value summary-populationFemale ui-corner-br"></td>
  259. </tr>
  260. </tbody>
  261. </table>
  262. <table class="highlighted-stats-table">
  263. <colgroup>
  264. <col class="label">
  265. <col class="value">
  266. </colgroup>
  267. <tbody>
  268. <tr class="tooltip-header">
  269. <td class="tooltip-header ui-corner-top" colspan="2">Highlighted Age: <span class="tooltip-item tooltipAge">&nbsp;</span></td>
  270. </tr>
  271. <tr>
  272. <td>Population, Male: </td>
  273. <td class="quintile-value"><span class="tooltip-item tooltipMale">&nbsp;</span></td>
  274. </tr>
  275. <tr>
  276. <td>Population, Female: </td>
  277. <td class="quintile-value"><span class="tooltip-item tooltipFemale">&nbsp;</span></td>
  278. </tr>
  279. <tr>
  280. <td class="ui-corner-bl">Sex Ratio: </td>
  281. <td class="quintile-value ui-corner-br"><span class="tooltip-item tooltipRatio">&nbsp;</span></td>
  282. </tr>
  283. <tbody>
  284. </table>
  285. </div>
  286. </div>
  287. </div>
  288. </div>
  289. <script class="code" type="text/javascript">
  290. $(document).ready(function(){
  291. // if browser supports canvas, show additional toolbar icons
  292. if (!$.jqplot.use_excanvas) {
  293. $('div.quintile-toolbar').append('<div class="ui-icon ui-icon-image"></div><div class="ui-icon ui-icon-print"></div>');
  294. }
  295. // for this demo, all data is same for each quintile.
  296. // could do something like this to get the index of the quintile.
  297. // <!-- var quintileIndex = parseInt(< ? php echo $_GET["qidx"]; ? >); -->
  298. var male;
  299. var female;
  300. var summaryTable;
  301. var sexRatios;
  302. jsondata = [];
  303. $.ajax({
  304. type: "GET",
  305. dataType: 'json',
  306. async: false,
  307. url: "ages.json",
  308. contentType: "application/json",
  309. success: function (retdata) {
  310. // array of arrays of data for each quintile
  311. // each quintile array has data for following:
  312. // 0: summary table
  313. // 1: male data
  314. // 2: female data
  315. // 3: ratios
  316. jsondata = retdata;
  317. },
  318. error: function (xhr) { console.log("ERROR: ", xhr.statusText) }
  319. });
  320. // the "x" values from the data will go into the ticks array.
  321. // ticks should be strings for this case where we have values like "75+"
  322. var ticks = jsondata[4];
  323. $('td.summary-meanAge').each(function(index) {
  324. $(this).html($.jqplot.sprintf('%5.2f', jsondata[0][3]));
  325. });
  326. $('td.summary-sexRatio').each(function(index) {
  327. $(this).html($.jqplot.sprintf('%5.2f', jsondata[3][0]));
  328. });
  329. $('td.summary-ageDependencyRatio').each(function(index) {
  330. $(this).html($.jqplot.sprintf('%5.2f', jsondata[0][6]));
  331. });
  332. $('td.summary-populationTotal').each(function(index) {
  333. $(this).html($.jqplot.sprintf("%'d", jsondata[0][0]));
  334. });
  335. $('td.summary-populationMale').each(function(index) {
  336. $(this).html($.jqplot.sprintf("%'d", jsondata[0][1]));
  337. });
  338. $('td.summary-populationFemale').each(function(index) {
  339. $(this).html($.jqplot.sprintf("%'d", jsondata[0][2]));
  340. });
  341. // These two variables should be removed outside of the jqplot.com example environment.
  342. $.jqplot._noToImageButton = true;
  343. $.jqplot._noCodeBlock = true;
  344. // Custom color arrays are set up for each series to get the look that is desired.
  345. // Two color arrays are created for the default and optional color which the user can pick.
  346. var greenColors = ["#526D2C", "#77933C", "#C57225", "#C57225"];
  347. var blueColors = ["#3F7492", "#4F9AB8", "#C57225", "#C57225"];
  348. // To accomodate changing y axis, need to keep track of plot options.
  349. // changing axes will require recreating the plot, so need to keep
  350. // track of state changes.
  351. var plotOptions = {
  352. // We set up a customized title which acts as labels for the left and right sides of the pyramid.
  353. title: {
  354. text: '<span style="margin-left:25%;">Male</span><span style="margin-left:33%;">Female</span>',
  355. textAlign: 'left'
  356. },
  357. // by default, the series will use the green color scheme.
  358. seriesColors: greenColors,
  359. grid: {
  360. drawBorder: false,
  361. shadow: false,
  362. background: "#ffffff",
  363. rendererOptions: {
  364. // plotBands is an option of the pyramidGridRenderer.
  365. // it will put banding at starting at a specified value
  366. // along the y axis with an adjustable interval.
  367. plotBands: {
  368. show: true,
  369. interval: 10,
  370. color: 'rgb(245, 235, 215)'
  371. }
  372. }
  373. },
  374. // This makes the effective starting value of the axes 0 instead of 1.
  375. // For display, the y axis will use the ticks we supplied.
  376. defaultAxisStart: 0,
  377. seriesDefaults: {
  378. renderer: $.jqplot.PyramidRenderer,
  379. rendererOptions: {
  380. barPadding: 1.5,
  381. offsetBars: true
  382. },
  383. yaxis: "yaxis",
  384. shadow: false
  385. },
  386. // We have 4 series, the left and right pyramid bars and
  387. // the left and rigt overlay lines.
  388. series: [
  389. // For pyramid plots, the default side is right.
  390. // We want to override here to put first set of bars
  391. // on left.
  392. {
  393. rendererOptions:{
  394. side: "left",
  395. synchronizeHighlight: 1
  396. }
  397. },
  398. {
  399. yaxis: "y2axis",
  400. rendererOptions: {
  401. synchronizeHighlight: 0
  402. }
  403. },
  404. {
  405. rendererOptions: {
  406. fill: false,
  407. side: 'left'
  408. }
  409. },
  410. {
  411. yaxis: 'y2axis',
  412. rendererOptions: {
  413. fill: false
  414. }
  415. }
  416. ],
  417. axesDefaults: {
  418. tickOptions: {
  419. showGridline: false
  420. },
  421. pad: 0,
  422. rendererOptions: {
  423. baselineWidth: 2
  424. }
  425. },
  426. // Set up all the y axes, since users are allowed to switch between them.
  427. // The only axis that will show is the one that the series are "attached" to.
  428. // We need the appropriate options for the others for when the user switches.
  429. axes: {
  430. xaxis: {
  431. tickOptions: {
  432. formatter: $.jqplot.PercentTickFormatter,
  433. formatString: '%.1f%%'
  434. }
  435. },
  436. yaxis: {
  437. label: "Age",
  438. // Use canvas label renderer to get rotated labels.
  439. labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
  440. // include empty tick options, they will be used
  441. // as users set options with plot controls.
  442. tickOptions: {},
  443. showMinorTicks: false,
  444. tickInterval: 5,
  445. ticks: ticks,
  446. rendererOptions: {
  447. tickSpacingFactor: 15,
  448. category: false
  449. }
  450. },
  451. yMidAxis: {
  452. label: "Age",
  453. // include empty tick options, they will be used
  454. // as users set options with plot controls.
  455. tickOptions: {},
  456. showMinorTicks: false,
  457. tickInterval: 5,
  458. ticks: ticks,
  459. rendererOptions: {
  460. tickSpacingFactor: 15,
  461. category: false
  462. }
  463. },
  464. y2axis: {
  465. label: "Age",
  466. // Use canvas label renderer to get rotated labels.
  467. labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
  468. // include empty tick options, they will be used
  469. // as users set options with plot controls.
  470. tickOptions: {},
  471. showMinorTicks: false,
  472. tickInterval: 5,
  473. ticks: ticks,
  474. rendererOptions: {
  475. tickSpacingFactor: 15,
  476. category: false
  477. }
  478. }
  479. }
  480. };
  481. // resize the chart container to fill the space
  482. $('#agesChart').height($('div.chart-cell').height()*0.96);
  483. $('#agesChart').width($('div.chart-cell').width()*0.97);
  484. // $('#agesChart').jqplot([jsondata[1], jsondata[2]], plotOptions);
  485. $.jqplot.config.addDomReference = true;
  486. var plot1 = $.jqplot('agesChart', [jsondata[1], jsondata[2]], plotOptions);
  487. $(window).resize (function(event, ui) {
  488. // pass in resetAxes: true option to get rid of old ticks and axis properties
  489. // which should be recomputed based on new plot size.
  490. $('#agesChart').height($('div.chart-cell').height()*0.96);
  491. $('#agesChart').width($('div.chart-cell').width()*0.97);
  492. plot1.replot( { resetAxes: true } );
  493. });
  494. // initialize form elements
  495. // set these before attaching event handlers.
  496. $("input[type=checkbox][name=gridsVertical]").attr("checked", false);
  497. $("input[type=checkbox][name=gridsHorizontal]").attr("checked", false);
  498. $("input[type=checkbox][name=showMinorTicks]").attr("checked", true);
  499. $("input[type=checkbox][name=plotBands]").attr("checked", true);
  500. $("input[type=checkbox][name=showContour]").attr("checked", true);
  501. $("input[type=checkbox][name=barPadding]").attr("checked", true);
  502. $("select[name=axisPosition]").val("both");
  503. //////
  504. // The followng functions use verbose css selectors to make
  505. // it clear exactly which elements they are binging to/operating on
  506. //////
  507. $("select[name=axisPosition]").change(function(){
  508. // this refers to the html element we are binding to.
  509. // $(this) is jQuery object on that element.
  510. var opts = {series:[{}, {}, {}, {}]};
  511. switch ($(this).val()) {
  512. case "both":
  513. opts.series[0].yaxis = "yaxis";
  514. opts.series[1].yaxis = "y2axis";
  515. opts.series[2].yaxis = "yaxis";
  516. opts.series[3].yaxis = "y2axis";
  517. break;
  518. case "left":
  519. opts.series[0].yaxis = "yaxis";
  520. opts.series[1].yaxis = "yaxis";
  521. opts.series[2].yaxis = "yaxis";
  522. opts.series[3].yaxis = "yaxis";
  523. break;
  524. case "right":
  525. opts.series[0].yaxis = "y2axis";
  526. opts.series[1].yaxis = "y2axis";
  527. opts.series[2].yaxis = "y2axis";
  528. opts.series[3].yaxis = "y2axis";
  529. break;
  530. case "mid":
  531. opts.series[0].yaxis = "yMidAxis";
  532. opts.series[1].yaxis = "yMidAxis";
  533. opts.series[2].yaxis = "yMidAxis";
  534. opts.series[3].yaxis = "yMidAxis";
  535. break;
  536. default:
  537. break;
  538. }
  539. plot1.replot(opts);
  540. });
  541. // bind to the data highlighting event to make custom tooltip:
  542. $(".jqplot-target").each(function(index){
  543. $(this).bind("jqplotDataHighlight", function(evt, seriesIndex, pointIndex, data) {
  544. // Here, assume first series is male poulation and second series is female population.
  545. // Adjust series indices as appropriate.
  546. var plot = $(this).data('jqplot');
  547. var malePopulation = Math.abs(plot.series[0].data[pointIndex][1]) * jsondata[0][1];
  548. var femalePopulation = Math.abs(plot.series[1].data[pointIndex][1]) * jsondata[0][2];
  549. var malePopulation = jsondata[1][pointIndex] * jsondata[0][1];
  550. var femalePopulation = jsondata[2][pointIndex] * jsondata[0][2];
  551. // var ratio = femalePopulation / malePopulation * 100;
  552. var ratio = jsondata[3][pointIndex];
  553. $('.tooltipMale').stop(true, true).fadeIn(350).html($.jqplot.sprintf("%'d", malePopulation));
  554. $('.tooltipFemale').stop(true, true).fadeIn(350).html($.jqplot.sprintf("%'d", femalePopulation));
  555. $('.tooltipRatio').stop(true, true).fadeIn(350).html($.jqplot.sprintf('%5.2f', ratio));
  556. // Since we don't know which axis is rendererd and acive with out a little extra work,
  557. // just use the supplied ticks array to get the age label.
  558. $('.tooltipAge').stop(true, true).fadeIn(350).html(ticks[pointIndex]);
  559. });
  560. });
  561. // bind to the data highlighting event to make custom tooltip:
  562. $(".jqplot-target").each(function() {
  563. $(this).bind("jqplotDataUnhighlight", function(evt, seriesIndex, pointIndex, data) {
  564. // clear out all the tooltips.
  565. $(".tooltip-item").fadeOut(250);
  566. });
  567. });
  568. $('.ui-icon-print').click(function(){
  569. $(this).parent().next().print();
  570. });
  571. $("input[type=checkbox][name=gridsVertical]").change(function(){
  572. // this refers to the html element we are binding to.
  573. // $(this) is jQuery object on that element.
  574. var opts = {axes: {xaxis: {tickOptions: {showGridline: this.checked}}}};
  575. plot1.replot(opts);
  576. });
  577. $("input[type=checkbox][name=gridsHorizontal]").change(function(){
  578. // this refers to the html element we are binding to.
  579. // $(this) is jQuery object on that element.
  580. var opts = {
  581. axes: {
  582. yaxis: {
  583. tickOptions: {showGridline: this.checked}
  584. },
  585. y2axis: {
  586. tickOptions: {showGridline: this.checked}
  587. },
  588. yMidAxis: {
  589. tickOptions: {showGridline: this.checked}
  590. }
  591. }
  592. };
  593. plot1.replot(opts);
  594. });
  595. $("input[type=checkbox][name=plotBands]").change(function(){
  596. // this refers to the html element we are binding to.
  597. // $(this) is jQuery object on that element.
  598. var opts = {grid:{ rendererOptions: {plotBands: { show: this.checked}}}};
  599. plot1.replot(opts);
  600. });
  601. ////
  602. // To-Do
  603. //
  604. // initialize form elements on reload.
  605. // figure out what overlay line would be.
  606. // have to adjust ticks to do show minor.
  607. // make like kcp_pyramid.php
  608. ////
  609. $("input[type=checkbox][name=showMinorTicks]").change(function(){
  610. // this refers to the html element we are binding to.
  611. // $(this) is jQuery object on that element.
  612. var opts = {
  613. axes: {
  614. yaxis: {
  615. showMinorTicks: !this.checked
  616. },
  617. y2axis: {
  618. showMinorTicks: !this.checked
  619. },
  620. yMidAxis: {
  621. showMinorTicks: !this.checked
  622. }
  623. }
  624. };
  625. plot1.replot(opts);
  626. });
  627. $("input[type=checkbox][name=barPadding]").change(function(){
  628. // this refers to the html element we are binding to.
  629. // $(this) is jQuery object on that element.
  630. if (this.checked) {
  631. var val = parseFloat($(this).val());
  632. var opts = {
  633. seriesDefaults: {
  634. rendererOptions: {
  635. barPadding: val
  636. }
  637. }
  638. };
  639. }
  640. else {
  641. var opts = {
  642. seriesDefaults: {
  643. rendererOptions: {
  644. barPadding: 0
  645. }
  646. }
  647. };
  648. }
  649. plot1.replot(opts);
  650. });
  651. $('.ui-icon-image').each(function() {
  652. $(this).bind('click', function(evt) {
  653. var chart = $(this).closest('div.quintile-outer-container').find('div.jqplot-target');
  654. var imgelem = chart.jqplotToImageElem();
  655. var div = $('div.overlay-chart-container-content');
  656. div.empty();
  657. div.append(imgelem);
  658. $('div.overlay-shadow').fadeIn(600);
  659. div.parent().fadeIn(1000);
  660. div = null;
  661. });
  662. });
  663. $('div.overlay-chart-container-header div.ui-icon-closethick').click(function(){
  664. var div = $('div.overlay-chart-container-content');
  665. div.parent().fadeOut(600);
  666. $('div.overlay-shadow').fadeOut(1000);
  667. });
  668. function applyColors () {
  669. var opts = {series:[{}, {}], grid:{rendererOptions:{plotBands:{}}}};
  670. opts.series[0].color = $('#colorMale').data('colorpicker').color.toCSS();
  671. opts.series[1].color = $('#colorFemale').data('colorpicker').color.toCSS();
  672. opts.grid.background = $('#colorBackground').data('colorpicker').color.toCSS();
  673. opts.grid.rendererOptions.plotBands.color = $('#colorPlotBands').data('colorpicker').color.toCSS();
  674. plot1.replot(opts);
  675. };
  676. // $('#colorMale').val(plot1.series[0].color);
  677. $('#colorMale').colorpicker({
  678. showOn: 'button',
  679. showHeader: true,
  680. showSwatches: true,
  681. buttonColorize: true,
  682. buttonImageOnly: true,
  683. parts: 'full',
  684. color: plot1.series[0].color,
  685. onClose: applyColors
  686. });
  687. $('#colorFemale').colorpicker({
  688. showOn: 'button',
  689. showHeader: true,
  690. showSwatches: true,
  691. buttonColorize: true,
  692. buttonImageOnly: true,
  693. parts: 'full',
  694. color: plot1.series[1].color,
  695. onClose: applyColors
  696. });
  697. $('#colorBackground').colorpicker({
  698. showOn: 'button',
  699. showHeader: true,
  700. showSwatches: true,
  701. buttonColorize: true,
  702. buttonImageOnly: true,
  703. parts: 'full',
  704. color: plot1.grid.background,
  705. onClose: applyColors
  706. });
  707. $('#colorPlotBands').colorpicker({
  708. showOn: 'button',
  709. showHeader: true,
  710. showSwatches: true,
  711. buttonColorize: true,
  712. buttonImageOnly: true,
  713. parts: 'full',
  714. color: plot1.grid.plotBands.color,
  715. onClose: applyColors
  716. });
  717. });
  718. </script>
  719. <script class="include" type="text/javascript" src="../jquery.jqplot.js"></script>
  720. <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
  721. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
  722. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
  723. <script class="include" type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.js"></script>
  724. <!-- 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. -->
  725. <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidAxisRenderer.js"></script>
  726. <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidGridRenderer.js"></script>
  727. <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidRenderer.js"></script>
  728. <script class="include" type="text/javascript" src="../plugins/jqplot.canvasTextRenderer.js"></script>
  729. <script class="include" type="text/javascript" src="../plugins/jqplot.canvasAxisLabelRenderer.js"></script>
  730. <script class="include" type="text/javascript" src="../plugins/jqplot.json2.js"></script>
  731. <script class="include" type="text/javascript" src="jquery-ui/js/jquery-ui.min.js"></script>
  732. <script class="include" type="text/javascript" src="kcp.print.js"></script>
  733. <script src="colorpicker/jquery.colorpicker.js"></script>
  734. <script type="text/javascript" src="example.js"></script>
  735. </body>
  736. </html>