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