Source

jqplot-dataflow / examples / kcp_pyramid_by_age.php

  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
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
<!DOCTYPE html>

<html>
<head>
    
    <title>Quintile Chart</title>

    <link class="include" rel="stylesheet" type="text/css" href="../src/jquery.jqplot.css" />
    <link rel="stylesheet" type="text/css" href="examples.css" />
    <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
    <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
  
  <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../src/excanvas.js"></script><![endif]-->
    <script class="include" type="text/javascript" src="../src/jquery.min.js"></script>
    
     <link class="include" type="text/css" href="jquery-ui/css/smoothness/jquery-ui.min.css" rel="Stylesheet" /> 
    <link href="colorpicker/jquery.colorpicker.css" rel="stylesheet" type="text/css"/>

    <style type="text/css">
        
        body {
            width: 98%;
            height: 98%;
            padding: 12px;
        }

        .quintile-outer-container {
            width: 96%;
            height: 96%;
            margin: auto;
        }

        .jqplot-chart {
            width: 800px;
            height: 800px;
        }

        .quintile-toolbar .ui-icon {
            float: right;
            margin: 3px 5px;
        }

        table.stats-table td, table.highlighted-stats-table td {
            background-color: rgb(230, 230, 230);
            padding: 0.5em;
        }

        col.label {
            width: 14em;
        }

        col.value {
            width: 7em;
        }

        td.quintile-value {
            width: 7em;
            text-align: right;
        }

        table.stats-table td.tooltip-header, table.highlighted-stats-table td.tooltip-header {
            background-color: rgb(200, 200, 200);
        }

        table.stats-table, table.highlighted-stats-table, td.contour-cell {
            font-size: 0.7em;
        }

        td.contour-cell {
            height: 1.5em;
            padding-left: 20px;
            padding-bottom: 1.5em;
        }

        table.highlighted-stats-table {
            margin-top: 15px;
        }

        td.stats-cell {
            padding-left: 20px;
            padding-top: 40px;
            vertical-align: top;

        }

        td.stats-cell div.input {
            font-size: 0.7em;
            margin-top: 1.5em;
        }

        td.controls, td.controls select {
            font-size: 0.8em;
        }

        td.controls li {
            list-style-type: none;
        }

        td.controls ul {
            margin-top: 0.5em;
            padding-left: 0.2em;
        }

        div.overlay-chart-container {
            display: none;
            z-index: 11;
            position: fixed;
            width: 800px;
            left: 50%;
            margin-left: -400px;
            background-color: white;
        }

        div.overlay-chart-container div.ui-icon {
            float: right;
            margin: 3px 5px;
        }

        div.overlay-shadow {
            display: none;
            z-index: 10;
            background-color: rgba(0, 0, 0, 0.8);
            position: fixed;
            top: 0px;
            left: 0px;
            width: 100%;
            height: 100%;
        }

        div.ui-colorpicker div.ui-dialog-titlebar {
            padding: 0.1em 0.3em;
        }

        input.color {
            display: none;
        }

        div.colorpicker-container span {
            padding: 3px;
        }

        @media print {
            td.stats-cell {
                vertical-align: top;
                padding-top: 35px;
            }

            table.stats-table, table.stats-table td {
                 color: #aaaaaa;
                 border: 1px solid #bbbbbb;
                 border-collapse: collapse;
            }

            table.stats-table tr {
                font-family: Verdana,Arial,sans-serif;
                /*font-size: 0.7em;*/
            }
        }

    </style>

   
</head>
<body>

<!-- Example scripts go here -->

 
    <div class="overlay-shadow"></div>

    <div class="overlay-chart-container ui-corner-all">
        <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>
        <div class="overlay-chart-container-content ui-corner-bottom"></div>
    </div>

    <div class="quintile-outer-container ui-widget ui-corner-all">
        <div class="quintile-toolbar ui-widget-header  ui-corner-top">
            <span class="quintile-title">Income Level:</span>
        </div>
        <div class="quintile-content ui-widget-content ui-corner-bottom">
            <table class="quintile-display">
                <tr>

                    <td class="controls">
                        <table>
                            <tr>
                                <td>
                                    Axes:
                                </td>
                                <td>
                                    <select name="axisPosition">
                                        <option value="both">Left &amp; Right</option>
                                        <option value = "left">Left</option>
                                        <option value = "right">Right</option>
                                        <option value = "mid">Mid</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Colors:
                                </td>
                                <td>
                                    <ul>
                                        <li><input class="color" type="color" id="colorMale" /> Male</li>
                                        <li><input class="color" type="color" id="colorFemale" /> Female</li>
                                        <li><input class="color" type="color" id="colorBackground"  /> Background</li>
                                        <li><input class="color" type="color" id="colorPlotBands" /> Plot Bands</li>
                                    </ul>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Grids:
                                </td>
                                <td>
                                    <ul>
                                        <li><input name="gridsVertical" value="vertical" type="checkbox" />Vertical</li>
                                        <li><input name="gridsHorizontal" value="horizontal" type="checkbox" />Horizontal</li>
                                        <li><input name="showMinorTicks" value="true" type="checkbox" />Only major</li>
                                        <li><input name="plotBands" value="true" type="checkbox" checked />Plot Bands</li>
                                    </ul>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <ul>
                                        <li><input name="barPadding" value="2" type="checkbox" checked />Gap between bars</li>
                                        <!-- value for showContour is speed at which to fade lines in/out -->
                                        <li><input name="showContour" value="500" type="checkbox" />Comparison Line</li>
                                    </ul>
                                </td>
                            </tr>
                        </table>
                    </td>


                    <td class="chart-cell">
                        <div id="agesChart" class="jqplot-chart"></div>
                    </td>
                    <td class="stats-cell">
                        <table class="stats-table">
                        <colgroup>
                            <col class="label">
                            <col class="value">
                        </colgroup>
                        <tbody>
                            <tr>
                                <td class="ui-corner-tl">Mean Age:</td>
                                <td class="quintile-value summary-meanAge ui-corner-tr"></td>
                            </tr>
                            <tr>
                                <td>Sex Ratio:</td>
                                <td class="quintile-value summary-sexRatio"></td>
                            </tr>
                            <tr>
                                <td>Age Dependency Ratio:</td>
                                <td class="quintile-value summary-ageDependencyRatio"></td>
                            </tr>
                            <tr>
                                <td>Population, Total:</td>
                                <td class="quintile-value summary-populationTotal"></td>
                            </tr>
                            <tr>
                                <td>Population, Male:</td>
                                <td class="quintile-value summary-populationMale"></td>
                            </tr>
                            <tr>
                                <td class="ui-corner-bl">Population, Female:</td>
                                <td class="quintile-value summary-populationFemale ui-corner-br"></td>
                            </tr>
                        </tbody>
                        </table>
                        <table class="highlighted-stats-table">
                        <colgroup>
                            <col class="label">
                            <col class="value">
                        </colgroup>
                        <tbody>
                            <tr class="tooltip-header">
                                <td class="tooltip-header ui-corner-top" colspan="2">Highlighted Age: <span class="tooltip-item tooltipAge">&nbsp;</span></td>
                            </tr>
                            <tr>
                                <td>Population, Male: </td>
                                <td class="quintile-value"><span class="tooltip-item tooltipMale">&nbsp;</span></td>
                            </tr>
                            <tr>
                                <td>Population, Female: </td>
                                <td class="quintile-value"><span class="tooltip-item tooltipFemale">&nbsp;</span></td>
                            </tr>
                            <tr>
                                <td class="ui-corner-bl">Sex Ratio: </td>
                                <td class="quintile-value ui-corner-br"><span class="tooltip-item tooltipRatio">&nbsp;</span></td>
                            </tr>
                        <tbody>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
    </div> 
  


    <script class="code" type="text/javascript">
    $(document).ready(function(){

        // if browser supports canvas, show additional toolbar icons
        if (!$.jqplot.use_excanvas) {
            $('div.quintile-toolbar').append('<div class="ui-icon ui-icon-image"></div><div class="ui-icon ui-icon-print"></div>');
        }

        var quintileIndex = parseInt(<?php echo $_GET["qidx"]; ?>);

        var male;
        var female;
        var summaryTable;
        var sexRatios;
        quintiles = [];


        // the "x" values from the data will go into the ticks array.  
        // ticks should be strings for this case where we have values like "75+"
        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+", ""];


        $.ajax({
            type: "GET",
            dataType: 'json',
            async: false,
            url: "ages.json",
            contentType: "application/json",
            success: function (retdata) {
                // array of arrays of data for each quintile
                // each quintile array has data for following:
                //  0: summary table
                //  1: male data
                //  2: female data
                //  3: ratios
                quintiles = retdata;
            },
            error: function (xhr) { console.log("ERROR: ", xhr.statusText) }
        });

        $('td.summary-meanAge').each(function(index) {
            $(this).html($.jqplot.sprintf('%5.2f', quintiles[quintileIndex][0][3]));
        });

        $('td.summary-sexRatio').each(function(index) {
            $(this).html($.jqplot.sprintf('%5.2f', quintiles[quintileIndex][3][0]));
        });

        $('td.summary-ageDependencyRatio').each(function(index) {
            $(this).html($.jqplot.sprintf('%5.2f', quintiles[quintileIndex][0][6]));
        });

        $('td.summary-populationTotal').each(function(index) {
            $(this).html($.jqplot.sprintf("%'d", quintiles[quintileIndex][0][0]));
        });

        $('td.summary-populationMale').each(function(index) {
            $(this).html($.jqplot.sprintf("%'d", quintiles[quintileIndex][0][1]));
        });

        $('td.summary-populationFemale').each(function(index) {
            $(this).html($.jqplot.sprintf("%'d", quintiles[quintileIndex][0][2]));
        });
        
        // These two variables should be removed outside of the jqplot.com example environment.
        $.jqplot._noToImageButton = true;
        $.jqplot._noCodeBlock = true;

        // Custom color arrays are set up for each series to get the look that is desired.
        // Two color arrays are created for the default and optional color which the user can pick.
        var greenColors = ["#526D2C", "#77933C", "#C57225", "#C57225"];
        var blueColors = ["#3F7492", "#4F9AB8", "#C57225", "#C57225"];

        // To accomodate changing y axis, need to keep track of plot options.
        // changing axes will require recreating the plot, so need to keep 
        // track of state changes.
        var plotOptions = {
            // We set up a customized title which acts as labels for the left and right sides of the pyramid.
            title: {
                text: '<span style="position:relative;left:25%;">Male</span><span style="position:relative;left:50%;">Female</span>',
                textAlign: 'left'
            },
            // by default, the series will use the green color scheme.
            seriesColors: greenColors,

            grid: {
                drawBorder: false,
                shadow: false,
                background: "#ffffff",
                rendererOptions: {
                    // plotBands is an option of the pyramidGridRenderer.
                    // it will put banding at starting at a specified value
                    // along the y axis with an adjustable interval.
                    plotBands: {
                        show: true,
                        interval: 10,
                        color: 'rgb(245, 235, 215)'
                    }
                }
            },

            // This makes the effective starting value of the axes 0 instead of 1.
            // For display, the y axis will use the ticks we supplied.
            defaultAxisStart: 0,
            seriesDefaults: {
                renderer: $.jqplot.PyramidRenderer,
                rendererOptions: {
                    barPadding: 2,
                    offsetBars: true
                },
                yaxis: "yaxis",
                shadow: false
            },

            // We have 4 series, the left and right pyramid bars and
            // the left and rigt overlay lines.
            series: [
                // For pyramid plots, the default side is right.
                // We want to override here to put first set of bars
                // on left.
                {
                    rendererOptions:{
                        side: "left",
                        synchronizeHighlight: 1
                    }
                },
                {
                    yaxis: "y2axis",
                    rendererOptions: {
                        synchronizeHighlight: 0
                    }
                },
                {
                    rendererOptions: {
                        fill: false,
                        side: 'left'
                    }
                },
                {
                    yaxis: 'y2axis',
                    rendererOptions: {
                        fill: false
                    }
                }
            ],
            axesDefaults: {
                tickOptions: {
                    showGridline: false
                },
                pad: 0,
                rendererOptions: {
                    baselineWidth: 2
                }
            },

            // Set up all the y axes, since users are allowed to switch between them.
            // The only axis that will show is the one that the series are "attached" to.
            // We need the appropriate options for the others for when the user switches.
            axes: {
                xaxis: {
                    tickOptions: {
                        formatter: $.jqplot.PercentTickFormatter,
                        formatString: '%d%%'
                    }
                },
                yaxis: {
                    label: "Age",
                    // Use canvas label renderer to get rotated labels.
                    labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
                    // include empty tick options, they will be used
                    // as users set options with plot controls.
                    tickOptions: {},
                    showMinorTicks: true,
                    ticks: ticks,
                    rendererOptions: {
                        tickSpacingFactor: 15
                    }
                },
                y2axis: {
                    label: "Age",
                    // Use canvas label renderer to get rotated labels.
                    labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
                    // include empty tick options, they will be used
                    // as users set options with plot controls.
                    tickOptions: {},
                    showMinorTicks: true,
                    ticks: ticks,
                    rendererOptions: {
                        tickSpacingFactor: 15
                    }
                }
            }
        };

        // $('#agesChart').jqplot([quintiles[quintileIndex][1], quintiles[quintileIndex][2]], plotOptions);
        $.jqplot.config.addDomReference = true;
        var plot1 = $.jqplot('agesChart', [quintiles[quintileIndex][1], quintiles[quintileIndex][2]], plotOptions);

        // initialize form elements
        // set these before attaching event handlers.

        $("input[type=checkbox][name=gridsVertical]").attr("checked", false);
        $("input[type=checkbox][name=gridsHorizontal]").attr("checked", false);
        $("input[type=checkbox][name=showMinorTicks]").attr("checked", false);
        $("input[type=checkbox][name=plotBands]").attr("checked", true);
        $("input[type=checkbox][name=showContour]").attr("checked", true);
        $("input[type=checkbox][name=barPadding]").attr("checked", true);
        $("select[name=axisPosition]").val("both");

        //////
        // The followng functions use verbose css selectors to make
        // it clear exactly which elements they are binging to/operating on
        //////

        // bind to the data highlighting event to make custom tooltip:
        $(".jqplot-target").each(function(index){
            $(this).bind("jqplotDataHighlight", function(evt, seriesIndex, pointIndex, data) {
                // Here, assume first series is male poulation and second series is female population.
                // Adjust series indices as appropriate.
                var plot = $(this).data('jqplot');
                var malePopulation = Math.abs(plot.series[0].data[pointIndex][1]) * quintiles[quintileIndex][0][1];
                var femalePopulation = Math.abs(plot.series[1].data[pointIndex][1]) * quintiles[quintileIndex][0][2];
                var malePopulation = quintiles[quintileIndex][1][pointIndex] * quintiles[quintileIndex][0][1];
                var femalePopulation = quintiles[quintileIndex][2][pointIndex] * quintiles[quintileIndex][0][2];
                // var ratio = femalePopulation / malePopulation * 100;
                var ratio = quintiles[quintileIndex][3][pointIndex+1];

                $(this).closest('table').find('.tooltipMale').stop(true, true).fadeIn(350).html($.jqplot.sprintf("%'d", malePopulation));
                $(this).closest('table').find('.tooltipFemale').stop(true, true).fadeIn(350).html($.jqplot.sprintf("%'d", femalePopulation));
                $(this).closest('table').find('.tooltipRatio').stop(true, true).fadeIn(350).html($.jqplot.sprintf('%5.2f', ratio));

                // Since we don't know which axis is rendererd and acive with out a little extra work,
                // just use the supplied ticks array to get the age label.
                $(this).closest('table').find('.tooltipAge').stop(true, true).fadeIn(350).html(ticks[pointIndex]);
            });
        });

        // bind to the data highlighting event to make custom tooltip:
        $(".jqplot-target").each(function() {
            $(this).bind("jqplotDataUnhighlight", function(evt, seriesIndex, pointIndex, data) {
                // clear out all the tooltips.
                $(this).closest('table').find(".tooltip-item").fadeOut(250);
            });
        });

        $('.ui-icon-print').click(function(){
            $(this).parent().next().print();
        });


        $("input[type=checkbox][name=gridsVertical]").change(function(){
            // this refers to the html element we are binding to.
            // $(this) is jQuery object on that element.
            var opts = {axes: {xaxis: {tickOptions: {showGridline: this.checked}}}};
            plot1.replot(opts);
        });


        $("input[type=checkbox][name=gridsHorizontal]").change(function(){
            // this refers to the html element we are binding to.
            // $(this) is jQuery object on that element.
            var opts = {
                axes: {
                    yaxis: {
                        tickOptions: {showGridline: this.checked}
                    },
                    y2axis: {
                        tickOptions: {showGridline: this.checked}
                    },
                    yMidAxis: {
                        tickOptions: {showGridline: this.checked}
                    }
                }
            };
            plot1.replot(opts);
        });

        $("input[type=checkbox][name=plotBands]").change(function(){
            // this refers to the html element we are binding to.
            // $(this) is jQuery object on that element.
            var opts = {grid:{ rendererOptions: {plotBands: { show: this.checked}}}};
            plot1.replot(opts);
        });

        ////
        // To-Do
        //
        // initialize form elements on reload.
        // figure out what overlay line would be.
        // have to adjust ticks to do show minor.
        // make like kcp_pyramid.php
        ////
        $("input[type=checkbox][name=showMinorTicks]").change(function(){
            // this refers to the html element we are binding to.
            // $(this) is jQuery object on that element.
            var opts = {
                axes: {
                    yaxis: {
                        showMinorTicks: !this.checked
                    },
                    y2axis: {
                        showMinorTicks: !this.checked
                    },
                    yMidAxis: {
                        showMinorTicks: !this.checked
                    }
                }
            };
            plot1.replot(opts);
        });

        $("input[type=checkbox][name=barPadding]").change(function(){
            // this refers to the html element we are binding to.
            // $(this) is jQuery object on that element.
            if (this.checked) {
                var val = parseFloat($(this).val());
                var opts = {
                    seriesDefaults: {
                        rendererOptions: {
                            barPadding: val
                        }
                    }
                };
            }
            else {
                var opts = {
                    seriesDefaults: {
                        rendererOptions: {
                            barPadding: 0
                        }
                    }
                };
            }
            plot1.replot(opts);
        });


        $('.ui-icon-image').each(function() {
            $(this).bind('click', function(evt) {
                var chart = $(this).closest('div.quintile-outer-container').find('div.jqplot-target');
                var imgelem = chart.jqplotToImageElem();
                var div = $('div.overlay-chart-container-content');
                div.empty();
                div.append(imgelem);
                $('div.overlay-shadow').fadeIn(600);
                div.parent().fadeIn(1000);
                div = null;
            });
        });

        $('div.overlay-chart-container-header div.ui-icon-closethick').click(function(){
            var div = $('div.overlay-chart-container-content');
            div.parent().fadeOut(600);
            $('div.overlay-shadow').fadeOut(1000);
        });

        function applyColors () {
            var opts = {series:[{}, {}], grid:{rendererOptions:{plotBands:{}}}};
            opts.series[0].color = $('#colorMale').data('colorpicker').color.toCSS();
            opts.series[1].color = $('#colorFemale').data('colorpicker').color.toCSS();
            opts.grid.background = $('#colorBackground').data('colorpicker').color.toCSS();
            opts.grid.rendererOptions.plotBands.color = $('#colorPlotBands').data('colorpicker').color.toCSS();

            plot1.replot(opts);

        };

        // $('#colorMale').val(plot1.series[0].color);

        $('#colorMale').colorpicker({
            showOn: 'button',
            showHeader: true,
            showSwatches: true,
            buttonColorize: true,
            buttonImageOnly: true,
            parts: 'full',
            color: plot1.series[0].color,
            onClose: applyColors

        });

        $('#colorFemale').colorpicker({
            showOn: 'button',
            showHeader: true,
            showSwatches: true,
            buttonColorize: true,
            buttonImageOnly: true,
            parts: 'full',
            color: plot1.series[1].color,
            onClose: applyColors

        });

        $('#colorBackground').colorpicker({
            showOn: 'button',
            showHeader: true,
            showSwatches: true,
            buttonColorize: true,
            buttonImageOnly: true,
            parts: 'full',
            color: plot1.grid.background,
            onClose: applyColors

        });

        $('#colorPlotBands').colorpicker({
            showOn: 'button',
            showHeader: true,
            showSwatches: true,
            buttonColorize: true,
            buttonImageOnly: true,
            parts: 'full',
            color: plot1.grid.plotBands.color,
            onClose: applyColors

        });

    });
    </script>


    <script class="include" type="text/javascript" src="../src/jquery.jqplot.js"></script>
    <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
    <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
    <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>


    <script class="include" type="text/javascript" src="../src/plugins/jqplot.categoryAxisRenderer.js"></script>

    <!-- 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. -->
    <script class="include" type="text/javascript" src="../src/plugins/jqplot.pyramidAxisRenderer.js"></script>
    <script class="include" type="text/javascript" src="../src/plugins/jqplot.pyramidGridRenderer.js"></script> 

    <script class="include" type="text/javascript" src="../src/plugins/jqplot.pyramidRenderer.js"></script>
    <script class="include" type="text/javascript" src="../src/plugins/jqplot.canvasTextRenderer.js"></script>
    <script class="include" type="text/javascript" src="../src/plugins/jqplot.canvasAxisLabelRenderer.js"></script>
    <script class="include" type="text/javascript" src="../src/plugins/jqplot.json2.js"></script>
    <script class="include" type="text/javascript" src="jquery-ui/js/jquery-ui.min.js"></script>
    <script class="include" type="text/javascript" src="kcp.print.js"></script>

    <script src="colorpicker/jquery.colorpicker.js"></script>
 
    <script type="text/javascript" src="example.js"></script>

</body>


</html>