Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
875 lars 1
<!DOCTYPE html>
2
 
3
<html>
4
<head>
5
 
6
    <title>Pyramid Chart By Age</title>
7
 
8
    <link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
9
    <link rel="stylesheet" type="text/css" href="examples.min.css" />
10
    <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
11
    <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
12
 
13
    <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
14
    <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
15
 
16
 
17
</head>
18
<body>
19
    <div id="header">
20
        <div class="nav">
21
            <a class="nav" href="../../../index.php"><span>&gt;</span>Home</a>
22
            <a class="nav"  href="../../../docs/"><span>&gt;</span>Docs</a>
23
            <a class="nav"  href="../../download/"><span>&gt;</span>Download</a>
24
            <a class="nav" href="../../../info.php"><span>&gt;</span>Info</a>
25
            <a class="nav"  href="../../../donate.php"><span>&gt;</span>Donate</a>
26
        </div>
27
    </div>
28
    <div class="colmask leftmenu">
29
      <div class="colleft">
30
        <div class="col1" id="example-content">
31
 
32
 
33
<!-- Example scripts go here -->
34
    <link class="include" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/smoothness/jquery-ui.css" rel="Stylesheet" />
35
    <link href="colorpicker/jquery.colorpicker.css" rel="stylesheet" type="text/css"/>
36
    <style type="text/css">
37
 
38
        .quintile-outer-container {
39
            width: 97%;
40
            height: 97%;
41
            margin: auto;
42
        }
43
 
44
        .jqplot-chart {
45
            height: 600px;
46
        }
47
 
48
        .quintile-toolbar .ui-icon {
49
            float: right;
50
            margin: 3px 5px;
51
        }
52
 
53
        table.stats-table td, table.highlighted-stats-table td {
54
            background-color: rgb(230, 230, 230);
55
            padding: 0.5em;
56
        }
57
 
58
        col.label {
59
            width: 14em;
60
        }
61
 
62
        col.value {
63
            width: 7em;
64
        }
65
 
66
        td.quintile-value {
67
            width: 7em;
68
            text-align: right;
69
        }
70
 
71
        table.stats-table td.tooltip-header, table.highlighted-stats-table td.tooltip-header {
72
            background-color: rgb(200, 200, 200);
73
        }
74
 
75
        table.stats-table, table.highlighted-stats-table, td.contour-cell {
76
            font-size: 0.7em;
77
        }
78
 
79
        td.contour-cell {
80
            height: 1.5em;
81
            padding-left: 20px;
82
            padding-bottom: 1.5em;
83
        }
84
 
85
        table.highlighted-stats-table {
86
            margin-top: 15px;
87
        }
88
 
89
        div.stats-cell div.input {
90
            font-size: 0.7em;
91
            margin-top: 1.5em;
92
        }
93
 
94
        div.content-container {
95
            padding-left: 230px;   /* LC width */
96
            padding-right: 300px;  /* RC width */
97
            height: 100%;
98
        }
99
 
100
        div.content-container .column {
101
            position: relative;
102
            float: left;
103
        }
104
 
105
        div.controls {
106
            width: 170px;          /* LC width */
107
            right: 230px;          /* LC width */
108
            padding-left: 30px;
109
            padding-right: 30px;
110
            margin-left: -100%;
111
            margin-top: 30px;
112
        }
113
 
114
        div.chart-cell {
115
            width: 100%;
116
            height: 100%;
117
        }
118
 
119
        div.stats-cell {
120
            width: 270px;          /* RC width */
121
            margin-right: -300px;  /* RC width */
122
            padding-right: 30px;
123
            margin-top: 30px;
124
        }
125
 
126
        div.controls, div.controls select {
127
            font-size: 0.8em;
128
        }
129
 
130
        div.controls li {
131
            list-style-type: none;
132
        }
133
 
134
        div.controls ul {
135
            margin-top: 0.5em;
136
            padding-left: 0.2em;
137
        }
138
 
139
        div.overlay-chart-container {
140
            display: none;
141
            z-index: 11;
142
            position: fixed;
143
            width: 800px;
144
            left: 50%;
145
            margin-left: -400px;
146
            background-color: white;
147
        }
148
 
149
        div.overlay-chart-container div.ui-icon {
150
            float: right;
151
            margin: 3px 5px;
152
        }
153
 
154
        div.overlay-shadow {
155
            display: none;
156
            z-index: 10;
157
            background-color: rgba(0, 0, 0, 0.8);
158
            position: fixed;
159
            top: 0px;
160
            left: 0px;
161
            width: 100%;
162
            height: 100%;
163
        }
164
 
165
        div.ui-colorpicker div.ui-dialog-titlebar {
166
            padding: 0.1em 0.3em;
167
        }
168
 
169
        input.color {
170
            display: none;
171
        }
172
 
173
        div.colorpicker-container span {
174
            padding: 3px;
175
        }
176
 
177
        div.quintile-content {
178
            width: 100%;
179
            height: 100%;
180
        }
181
 
182
 
183
        @media print {
184
            div.stats-cell {
185
                vertical-align: top;
186
                padding-top: 35px;
187
            }
188
 
189
            table.stats-table, table.stats-table td {
190
                 color: #aaaaaa;
191
                 border: 1px solid #bbbbbb;
192
                 border-collapse: collapse;
193
            }
194
 
195
            table.stats-table tr {
196
                font-family: Verdana,Arial,sans-serif;
197
                /*font-size: 0.7em;*/
198
            }
199
        }
200
 
201
    </style>
202
 
203
    <div class="overlay-shadow"></div>
204
 
205
    <div class="overlay-chart-container ui-corner-all">
206
        <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>
207
        <div class="overlay-chart-container-content ui-corner-bottom"></div>
208
    </div>
209
 
210
    <div class="quintile-outer-container ui-widget ui-corner-all">
211
        <div class="quintile-toolbar ui-widget-header  ui-corner-top">
212
            <span class="quintile-title">Income Level:</span>
213
        </div>
214
        <div class="quintile-content ui-widget-content ui-corner-bottom">
215
 
216
            <div class="content-container">
217
 
218
 
219
            <div class="chart-cell column">
220
                <div id="agesChart" class="jqplot-chart"></div>
221
            </div>
222
 
223
            <div class="controls column">
224
                <table>
225
                    <tr>
226
                        <td>
227
                            Axes:
228
                        </td>
229
                        <td>
230
                            <select name="axisPosition">
231
                                <option value="both">Left &amp; Right</option>
232
                                <option value = "left">Left</option>
233
                                <option value = "right">Right</option>
234
                                <option value = "mid">Mid</option>
235
                            </select>
236
                        </td>
237
                    </tr>
238
                    <tr>
239
                        <td>
240
                            Colors:
241
                        </td>
242
                        <td>
243
                            <ul>
244
                                <li><input class="color" type="color" id="colorMale" value="#526D2C" /> Male</li>
245
                                <li><input class="color" type="color" id="colorFemale" value="#77933C" /> Female</li>
246
                                <li><input class="color" type="color" id="colorBackground" value="#ffffff" /> Background</li>
247
                                <li><input class="color" type="color" id="colorPlotBands" value="f5ebd7" /> Plot Bands</li>
248
                            </ul>
249
                        </td>
250
                    </tr>
251
                    <tr>
252
                        <td>
253
                            Grids:
254
                        </td>
255
                        <td>
256
                            <ul>
257
                                <li><input name="gridsVertical" value="vertical" type="checkbox" />Vertical</li>
258
                                <li><input name="gridsHorizontal" value="horizontal" type="checkbox" />Horizontal</li>
259
                                <li><input name="showMinorTicks" value="true" type="checkbox" checked />Only major</li>
260
                                <li><input name="plotBands" value="true" type="checkbox" checked />Plot Bands</li>
261
                            </ul>
262
                        </td>
263
                    </tr>
264
                    <tr>
265
                        <td colspan="2">
266
                            <ul>
267
                                <li><input name="barPadding" value="2" type="checkbox" checked />Gap between bars</li>
268
                                <!-- value for showContour is speed at which to fade lines in/out -->
269
                                <li><input name="showContour" value="500" type="checkbox" />Comparison Line</li>
270
                            </ul>
271
                        </td>
272
                    </tr>
273
                </table>
274
            </div>
275
 
276
            <div class="stats-cell column">
277
                <table class="stats-table">
278
                <colgroup>
279
                    <col class="label">
280
                    <col class="value">
281
                </colgroup>
282
                <tbody>
283
                    <tr>
284
                        <td class="ui-corner-tl">Mean Age:</td>
285
                        <td class="quintile-value summary-meanAge ui-corner-tr"></td>
286
                    </tr>
287
                    <tr>
288
                        <td>Sex Ratio:</td>
289
                        <td class="quintile-value summary-sexRatio"></td>
290
                    </tr>
291
                    <tr>
292
                        <td>Age Dependency Ratio:</td>
293
                        <td class="quintile-value summary-ageDependencyRatio"></td>
294
                    </tr>
295
                    <tr>
296
                        <td>Population, Total:</td>
297
                        <td class="quintile-value summary-populationTotal"></td>
298
                    </tr>
299
                    <tr>
300
                        <td>Population, Male:</td>
301
                        <td class="quintile-value summary-populationMale"></td>
302
                    </tr>
303
                    <tr>
304
                        <td class="ui-corner-bl">Population, Female:</td>
305
                        <td class="quintile-value summary-populationFemale ui-corner-br"></td>
306
                    </tr>
307
                </tbody>
308
                </table>
309
                <table class="highlighted-stats-table">
310
                <colgroup>
311
                    <col class="label">
312
                    <col class="value">
313
                </colgroup>
314
                <tbody>
315
                    <tr class="tooltip-header">
316
                        <td class="tooltip-header ui-corner-top" colspan="2">Highlighted Age: <span class="tooltip-item tooltipAge">&nbsp;</span></td>
317
                    </tr>
318
                    <tr>
319
                        <td>Population, Male: </td>
320
                        <td class="quintile-value"><span class="tooltip-item tooltipMale">&nbsp;</span></td>
321
                    </tr>
322
                    <tr>
323
                        <td>Population, Female: </td>
324
                        <td class="quintile-value"><span class="tooltip-item tooltipFemale">&nbsp;</span></td>
325
                    </tr>
326
                    <tr>
327
                        <td class="ui-corner-bl">Sex Ratio: </td>
328
                        <td class="quintile-value ui-corner-br"><span class="tooltip-item tooltipRatio">&nbsp;</span></td>
329
                    </tr>
330
                <tbody>
331
                </table>
332
            </div>
333
 
334
            </div>
335
 
336
        </div>
337
    </div>
338
 
339
 
340
 
341
    <script class="code" type="text/javascript">
342
    $(document).ready(function(){
343
 
344
        // if browser supports canvas, show additional toolbar icons
345
        if (!$.jqplot.use_excanvas) {
346
            $('div.quintile-toolbar').append('<div class="ui-icon ui-icon-image"></div><div class="ui-icon ui-icon-print"></div>');
347
        }
348
 
349
        // for this demo, all data is same for each quintile.
350
        // could do something like this to get the index of the quintile.
351
        // <!-- var quintileIndex = parseInt(< ? php echo $_GET["qidx"]; ? >); -->
352
 
353
        var male;
354
        var female;
355
        var summaryTable;
356
        var sexRatios;
357
        var jsondata = [[1043353182,539695335,503657847,28.24,27.51,29.01,51.78],
358
          [0.0085318435343400800,0.0088774027062416400,0.0094714560875224100,0.0101640893891056000,0.0108249758696292000,0.0113773174183149000,0.0117954271696904000,0.0120868766491156000,0.0122726357410028000,0.0123620512208843000,0.0124092312631522000,0.0123929933989534000,0.0123170841477326000,0.0121788940682660000,0.0119848553256476000,0.0117367932349178000,0.0114334768233470000,0.0110840887113746000,0.0107005336950161000,0.0102889073661635000,0.0098746874267631800,0.0094727992165526500,0.0091066817836288100,0.0087853078056091400,0.0085176451289595700,0.0082955898249666400,0.0081021034227657000,0.0079410857437656400,0.0078129432771183200,0.0077041517746791700,0.0076076629996558600,0.0075063773837400400,0.0074212932416191700,0.0073577960797626100,0.0073199937766648000,0.0072872222696609900,0.0072249036551971000,0.0071436496521446000,0.0070535868312601700,0.0069442503777637000,0.0068032069975035000,0.0066093294501292200,0.0063936409488174700,0.0061768176372133200,0.0059737878831400300,0.0057724507581444500,0.0055456647375558400,0.0053139201135624000,0.0050952395722700100,0.0048873227886988200,0.0046839194356973000,0.0044709211871979300,0.0042683374557587400,0.0040886232834079100,0.0039394433696905200,0.0038097165950705600,0.0036797119436340500,0.0035595490798891500,0.0034559622921317600,0.0033586853733251200,0.0032515219944251700,0.0031141174480235800,0.0029601056879342400,0.0027997057390388600,0.0026388958299152400,0.0024706340765107900,0.0022829305753990900,0.0020900571013307600,0.0019037152224417700,0.0017251049256371200,0.0015499961243315000,0.0013709889555399900,0.0011982773790103000,0.0010401790931594200,0.0009015220565900700,0.0007812832602556460,0.0006749752626942340,0.0005833580512023270,0.0005061657847658260,0.0004399544894590220,0.0003808034210932470,0.0003273788998735520,0.0002794993115460400,0.0002369793671257210,0.0001995479850687680,0.0001668101805315270,0.0001383186716039340,0.0001138075253115040,0.0000929924552954457,0.0000755223736670678,0.0000610047525059652,0.0000490638302928227,0.0000396489252832302,0.0000330891826825378,0.0000281195284929135,0.0001070412478036410],
359
          [0.0071192629623232800,0.0072839317935624000,0.0075693293189514500,0.0079091875498352200,0.0082360857829773300,0.0084979038169712600,0.0086893986451354100,0.0088353986277422900,0.0089633895658643000,0.0090878796761182500,0.0092337667384807200,0.0093792123312149900,0.0095192745279032600,0.0096463104169553400,0.0097588790000607600,0.0098544841215461300,0.0099282199747865200,0.0099763812248601700,0.0099957597226035700,0.0099801585489242500,0.0099375446097938400,0.0098709094654945100,0.0097926096630396900,0.0097014318757340600,0.0095968423362564000,0.0094699215837397400,0.0093120985109391200,0.0091337644254482100,0.0089445678055607600,0.0087423328014590000,0.0085321350430430500,0.0083104164267343500,0.0081040369311665900,0.0079207770770160300,0.0077675098774536000,0.0076284130950824500,0.0074765938644635800,0.0073237591351693500,0.0071772210497332700,0.0070244435483804400,0.0068550745015274400,0.0066526057090785200,0.0064404461001358000,0.0062305720357510500,0.0060342707683446500,0.0058408705961082800,0.0056264339860478000,0.0054065565344313600,0.0051920462742280000,0.0049765895152515200,0.0047558832991186200,0.0045207003388048400,0.0042899070487080500,0.0040745089551306800,0.0038817655555785800,0.0037053224400247200,0.0035332134254902200,0.0033727187145046400,0.0032284905944481100,0.0030937679725170100,0.0029582187048090100,0.0028081834596732200,0.0026513461722362800,0.0024926069125082600,0.0023353006048059200,0.0021744630786167700,0.0020021420693961100,0.0018298895084829500,0.0016671380010344600,0.0015153637133401800,0.0013712248188900700,0.0012284616818527500,0.0010934572254154500,0.0009707133813897040,0.0008622603131043950,0.0007661899219731710,0.0006786114871838230,0.0006005435486257860,0.0005322956370150040,0.0004715229254612440,0.0004158721219136000,0.0003645948643149670,0.0003176904909297340,0.0002751152300590630,0.0002367021156783720,0.0002021700726755280,0.0001712214234345020,0.0001437557719387760,0.0001197138111336940,0.0000989925882290494,0.0000814263200020563,0.0000667991474109870,0.0000549164545704749,0.0000455518367647343,0.0000384480445034309,0.0001437755914949950],
360
          [1.284165231,1.3059697282,1.3408259576,1.3770498469,1.4083776842,1.4346340126,1.4545779876,1.4658887137,1.4671638972,1.457608962,1.4400548643,1.4158684686,1.3864911961,1.3528812542,1.3159697978,1.27622903,1.2340137083,1.1905291022,1.1471037258,1.1047013276,1.0647737249,1.0283340659,0.9964942039,0.9703629438,0.9510519527,0.9386721807,0.932316307,0.9316292996,0.9359838821,0.9443012277,0.9554470086,0.9678781103,0.9812761433,0.9953894103,1.0098153246,1.0236249732,1.035479081,1.0451994053,1.0530930686,1.0593183708,1.0634438538,1.0645809137,1.0637641578,1.0623066923,1.0608111193,1.0589993944,1.0561690641,1.0531914677,1.0515722425,1.052330754,1.0553372965,1.0597522653,1.0661637808,1.0752634417,1.0874733411,1.1017415355,1.1159815378,1.1309096828,1.1470504754,1.1633078085,1.1777943775,1.1882903501,1.1963378464,1.2035708256,1.2108560457,1.2175013424,1.2218302494,1.2239011525,1.223611334,1.2198647763,1.2112533925,1.1958739376,1.1742717733,1.1482333683,1.1203430352,1.0926602484,1.0658097999,1.040887396,1.0189501507,0.9998112064,0.9811922123,0.9621730704,0.9427349027,0.9230154312,0.903354613,0.8841353287,0.8656369091,0.8483181293,0.8323701879,0.8174967062,0.8028084248,0.7870522949,0.7736454722,0.7783827557,0.7836945697,0.7977724963],
361
          [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,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,"95+", ""]];
362
 
363
 
364
        // the "x" values from the data will go into the ticks array.
365
        // ticks should be strings for this case where we have values like "75+"
366
        var ticks = jsondata[4];
367
 
368
        $('td.summary-meanAge').each(function(index) {
369
            $(this).html($.jqplot.sprintf('%5.2f', jsondata[0][3]));
370
        });
371
 
372
        $('td.summary-sexRatio').each(function(index) {
373
            $(this).html($.jqplot.sprintf('%5.2f', jsondata[3][0]));
374
        });
375
 
376
        $('td.summary-ageDependencyRatio').each(function(index) {
377
            $(this).html($.jqplot.sprintf('%5.2f', jsondata[0][6]));
378
        });
379
 
380
        $('td.summary-populationTotal').each(function(index) {
381
            $(this).html($.jqplot.sprintf("%'d", jsondata[0][0]));
382
        });
383
 
384
        $('td.summary-populationMale').each(function(index) {
385
            $(this).html($.jqplot.sprintf("%'d", jsondata[0][1]));
386
        });
387
 
388
        $('td.summary-populationFemale').each(function(index) {
389
            $(this).html($.jqplot.sprintf("%'d", jsondata[0][2]));
390
        });
391
 
392
        // These two variables should be removed outside of the jqplot.com example environment.
393
        $.jqplot._noToImageButton = true;
394
        $.jqplot._noCodeBlock = true;
395
 
396
        // Custom color arrays are set up for each series to get the look that is desired.
397
        // Two color arrays are created for the default and optional color which the user can pick.
398
        var greenColors = ["#526D2C", "#77933C", "#C57225", "#C57225"];
399
        var blueColors = ["#3F7492", "#4F9AB8", "#C57225", "#C57225"];
400
 
401
        // To accomodate changing y axis, need to keep track of plot options.
402
        // changing axes will require recreating the plot, so need to keep
403
        // track of state changes.
404
        var plotOptions = {
405
            // We set up a customized title which acts as labels for the left and right sides of the pyramid.
406
            title: {
407
                text: '<span style="margin-left:25%;">Male</span><span style="margin-left:33%;">Female</span>',
408
                textAlign: 'left'
409
            },
410
            // by default, the series will use the green color scheme.
411
            seriesColors: greenColors,
412
 
413
            grid: {
414
                drawBorder: false,
415
                shadow: false,
416
                background: "#ffffff",
417
                rendererOptions: {
418
                    // plotBands is an option of the pyramidGridRenderer.
419
                    // it will put banding at starting at a specified value
420
                    // along the y axis with an adjustable interval.
421
                    plotBands: {
422
                        show: true,
423
                        interval: 10,
424
                        color: 'rgb(245, 235, 215)'
425
                    }
426
                }
427
            },
428
 
429
            // This makes the effective starting value of the axes 0 instead of 1.
430
            // For display, the y axis will use the ticks we supplied.
431
            defaultAxisStart: 0,
432
            seriesDefaults: {
433
                renderer: $.jqplot.PyramidRenderer,
434
                rendererOptions: {
435
                    barPadding: 1.5,
436
                    offsetBars: true
437
                },
438
                yaxis: "yaxis",
439
                shadow: false
440
            },
441
 
442
            // We have 4 series, the left and right pyramid bars and
443
            // the left and rigt overlay lines.
444
            series: [
445
                // For pyramid plots, the default side is right.
446
                // We want to override here to put first set of bars
447
                // on left.
448
                {
449
                    rendererOptions:{
450
                        side: "left",
451
                        synchronizeHighlight: 1
452
                    }
453
                },
454
                {
455
                    yaxis: "y2axis",
456
                    rendererOptions: {
457
                        synchronizeHighlight: 0
458
                    }
459
                },
460
                {
461
                    rendererOptions: {
462
                        fill: false,
463
                        side: 'left'
464
                    }
465
                },
466
                {
467
                    yaxis: 'y2axis',
468
                    rendererOptions: {
469
                        fill: false
470
                    }
471
                }
472
            ],
473
            axesDefaults: {
474
                tickOptions: {
475
                    showGridline: false
476
                },
477
                pad: 0,
478
                rendererOptions: {
479
                    baselineWidth: 2
480
                }
481
            },
482
 
483
            // Set up all the y axes, since users are allowed to switch between them.
484
            // The only axis that will show is the one that the series are "attached" to.
485
            // We need the appropriate options for the others for when the user switches.
486
            axes: {
487
                xaxis: {
488
                    tickOptions: {
489
                        formatter: $.jqplot.PercentTickFormatter,
490
                        formatString: '%.1f%%'
491
                    }
492
                },
493
                yaxis: {
494
                    label: "Age",
495
                    // Use canvas label renderer to get rotated labels.
496
                    labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
497
                    // include empty tick options, they will be used
498
                    // as users set options with plot controls.
499
                    tickOptions: {},
500
                    showMinorTicks: false,
501
                    tickInterval: 5,
502
                    ticks: ticks,
503
                    rendererOptions: {
504
                        tickSpacingFactor: 15,
505
                        category: false
506
                    }
507
                },
508
                yMidAxis: {
509
                    label: "Age",
510
                    // include empty tick options, they will be used
511
                    // as users set options with plot controls.
512
                    tickOptions: {},
513
                    showMinorTicks: false,
514
                    tickInterval: 5,
515
                    ticks: ticks,
516
                    rendererOptions: {
517
                        tickSpacingFactor: 15,
518
                        category: false
519
                    }
520
                },
521
                y2axis: {
522
                    label: "Age",
523
                    // Use canvas label renderer to get rotated labels.
524
                    labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
525
                    // include empty tick options, they will be used
526
                    // as users set options with plot controls.
527
                    tickOptions: {},
528
                    showMinorTicks: false,
529
                    tickInterval: 5,
530
                    ticks: ticks,
531
                    rendererOptions: {
532
                        tickSpacingFactor: 15,
533
                        category: false
534
                    }
535
                }
536
            }
537
        };
538
 
539
        // resize the chart container to fill the space
540
        $('#agesChart').height($('div.chart-cell').height()*0.96);
541
        $('#agesChart').width($('div.chart-cell').width()*0.97);
542
 
543
        // $('#agesChart').jqplot([jsondata[1], jsondata[2]], plotOptions);
544
        $.jqplot.config.addDomReference = true;
545
        var plot1 = $.jqplot('agesChart', [jsondata[1], jsondata[2]], plotOptions);
546
 
547
        $(window).resize (function(event, ui) {
548
            // pass in resetAxes: true option to get rid of old ticks and axis properties
549
            // which should be recomputed based on new plot size.
550
            $('#agesChart').height($('div.chart-cell').height()*0.96);
551
            $('#agesChart').width($('div.chart-cell').width()*0.97);
552
            plot1.replot( { resetAxes: true } );
553
        });
554
 
555
        // initialize form elements
556
        // set these before attaching event handlers.
557
 
558
        $("input[type=checkbox][name=gridsVertical]").attr("checked", false);
559
        $("input[type=checkbox][name=gridsHorizontal]").attr("checked", false);
560
        $("input[type=checkbox][name=showMinorTicks]").attr("checked", true);
561
        $("input[type=checkbox][name=plotBands]").attr("checked", true);
562
        $("input[type=checkbox][name=showContour]").attr("checked", true);
563
        $("input[type=checkbox][name=barPadding]").attr("checked", true);
564
        $("select[name=axisPosition]").val("both");
565
 
566
        //////
567
        // The followng functions use verbose css selectors to make
568
        // it clear exactly which elements they are binging to/operating on
569
        //////
570
 
571
        $("select[name=axisPosition]").change(function(){
572
            // this refers to the html element we are binding to.
573
            // $(this) is jQuery object on that element.
574
 
575
            var opts = {series:[{}, {}, {}, {}]};
576
 
577
            switch ($(this).val()) {
578
                case "both":
579
                    opts.series[0].yaxis = "yaxis";
580
                    opts.series[1].yaxis = "y2axis";
581
                    opts.series[2].yaxis = "yaxis";
582
                    opts.series[3].yaxis = "y2axis";
583
                    break;
584
                case "left":
585
                    opts.series[0].yaxis = "yaxis";
586
                    opts.series[1].yaxis = "yaxis";
587
                    opts.series[2].yaxis = "yaxis";
588
                    opts.series[3].yaxis = "yaxis";
589
                    break;
590
                case "right":
591
                    opts.series[0].yaxis = "y2axis";
592
                    opts.series[1].yaxis = "y2axis";
593
                    opts.series[2].yaxis = "y2axis";
594
                    opts.series[3].yaxis = "y2axis";
595
                    break;
596
                case "mid":
597
                    opts.series[0].yaxis = "yMidAxis";
598
                    opts.series[1].yaxis = "yMidAxis";
599
                    opts.series[2].yaxis = "yMidAxis";
600
                    opts.series[3].yaxis = "yMidAxis";
601
                    break;
602
                default:
603
                    break;
604
 
605
            }
606
 
607
            plot1.replot(opts);
608
        });
609
 
610
        // bind to the data highlighting event to make custom tooltip:
611
        $(".jqplot-target").each(function(index){
612
            $(this).bind("jqplotDataHighlight", function(evt, seriesIndex, pointIndex, data) {
613
                // Here, assume first series is male poulation and second series is female population.
614
                // Adjust series indices as appropriate.
615
                var plot = $(this).data('jqplot');
616
                var malePopulation = Math.abs(plot.series[0].data[pointIndex][1]) * jsondata[0][1];
617
                var femalePopulation = Math.abs(plot.series[1].data[pointIndex][1]) * jsondata[0][2];
618
                var malePopulation = jsondata[1][pointIndex] * jsondata[0][1];
619
                var femalePopulation = jsondata[2][pointIndex] * jsondata[0][2];
620
                // var ratio = femalePopulation / malePopulation * 100;
621
                var ratio = jsondata[3][pointIndex];
622
 
623
                $('.tooltipMale').stop(true, true).fadeIn(350).html($.jqplot.sprintf("%'d", malePopulation));
624
                $('.tooltipFemale').stop(true, true).fadeIn(350).html($.jqplot.sprintf("%'d", femalePopulation));
625
                $('.tooltipRatio').stop(true, true).fadeIn(350).html($.jqplot.sprintf('%5.2f', ratio));
626
 
627
                // Since we don't know which axis is rendererd and acive with out a little extra work,
628
                // just use the supplied ticks array to get the age label.
629
                $('.tooltipAge').stop(true, true).fadeIn(350).html(ticks[pointIndex]);
630
            });
631
        });
632
 
633
        // bind to the data highlighting event to make custom tooltip:
634
        $(".jqplot-target").each(function() {
635
            $(this).bind("jqplotDataUnhighlight", function(evt, seriesIndex, pointIndex, data) {
636
                // clear out all the tooltips.
637
                $(".tooltip-item").fadeOut(250);
638
            });
639
        });
640
 
641
        $('.ui-icon-print').click(function(){
642
            $(this).parent().next().print();
643
        });
644
 
645
 
646
        $("input[type=checkbox][name=gridsVertical]").change(function(){
647
            // this refers to the html element we are binding to.
648
            // $(this) is jQuery object on that element.
649
            var opts = {axes: {xaxis: {tickOptions: {showGridline: this.checked}}}};
650
            plot1.replot(opts);
651
        });
652
 
653
 
654
        $("input[type=checkbox][name=gridsHorizontal]").change(function(){
655
            // this refers to the html element we are binding to.
656
            // $(this) is jQuery object on that element.
657
            var opts = {
658
                axes: {
659
                    yaxis: {
660
                        tickOptions: {showGridline: this.checked}
661
                    },
662
                    y2axis: {
663
                        tickOptions: {showGridline: this.checked}
664
                    },
665
                    yMidAxis: {
666
                        tickOptions: {showGridline: this.checked}
667
                    }
668
                }
669
            };
670
            plot1.replot(opts);
671
        });
672
 
673
        $("input[type=checkbox][name=plotBands]").change(function(){
674
            // this refers to the html element we are binding to.
675
            // $(this) is jQuery object on that element.
676
            var opts = {grid:{ rendererOptions: {plotBands: { show: this.checked}}}};
677
            plot1.replot(opts);
678
        });
679
 
680
        ////
681
        // To-Do
682
        //
683
        // initialize form elements on reload.
684
        // figure out what overlay line would be.
685
        // have to adjust ticks to do show minor.
686
        // make like kcp_pyramid.php
687
        ////
688
        $("input[type=checkbox][name=showMinorTicks]").change(function(){
689
            // this refers to the html element we are binding to.
690
            // $(this) is jQuery object on that element.
691
            var opts = {
692
                axes: {
693
                    yaxis: {
694
                        showMinorTicks: !this.checked
695
                    },
696
                    y2axis: {
697
                        showMinorTicks: !this.checked
698
                    },
699
                    yMidAxis: {
700
                        showMinorTicks: !this.checked
701
                    }
702
                }
703
            };
704
            plot1.replot(opts);
705
        });
706
 
707
        $("input[type=checkbox][name=barPadding]").change(function(){
708
            // this refers to the html element we are binding to.
709
            // $(this) is jQuery object on that element.
710
            if (this.checked) {
711
                var val = parseFloat($(this).val());
712
                var opts = {
713
                    seriesDefaults: {
714
                        rendererOptions: {
715
                            barPadding: val
716
                        }
717
                    }
718
                };
719
            }
720
            else {
721
                var opts = {
722
                    seriesDefaults: {
723
                        rendererOptions: {
724
                            barPadding: 0
725
                        }
726
                    }
727
                };
728
            }
729
            plot1.replot(opts);
730
        });
731
 
732
 
733
        $('.ui-icon-image').each(function() {
734
            $(this).bind('click', function(evt) {
735
                var chart = $(this).closest('div.quintile-outer-container').find('div.jqplot-target');
736
                var imgelem = chart.jqplotToImageElem();
737
                var div = $('div.overlay-chart-container-content');
738
                div.empty();
739
                div.append(imgelem);
740
                $('div.overlay-shadow').fadeIn(600);
741
                div.parent().fadeIn(1000);
742
                div = null;
743
            });
744
        });
745
 
746
        $('div.overlay-chart-container-header div.ui-icon-closethick').click(function(){
747
            var div = $('div.overlay-chart-container-content');
748
            div.parent().fadeOut(600);
749
            $('div.overlay-shadow').fadeOut(1000);
750
        });
751
 
752
        function applyColors(maleColor, femaleColor, backgroundColor, bandColor) {
753
            var opts = {series:[{}, {}], grid:{rendererOptions:{plotBands:{}}}};
754
            opts.series[0].color = maleColor;
755
            opts.series[1].color = femaleColor;
756
            opts.grid.background = backgroundColor;
757
            opts.grid.rendererOptions.plotBands.color = bandColor;
758
            plot1.replot(opts);
759
        };
760
 
761
        $('#colorMale').colorpicker({
762
            colorFormat: '#HEX',
763
            showOn: 'button',
764
            buttonColorize: true,
765
            buttonImageOnly: true,
766
            parts: 'full',
767
            close: function(ui, color) {
768
                applyColors(color.formatted, plot1.series[1].color, plot1.grid.background, plot1.grid.plotBands.color);
769
            }
770
        });
771
 
772
        $('#colorFemale').colorpicker({
773
            colorFormat: '#HEX',
774
            showOn: 'button',
775
            buttonColorize: true,
776
            buttonImageOnly: true,
777
            parts: 'full',
778
            close: function(ui, color) {
779
                applyColors(plot1.series[0].color, color.formatted, plot1.grid.background, plot1.grid.plotBands.color);
780
            }
781
        });
782
 
783
        $('#colorBackground').colorpicker({
784
            colorFormat: '#HEX',
785
            showOn: 'button',
786
            buttonColorize: true,
787
            buttonImageOnly: true,
788
            parts: 'full',
789
            close: function(ui, color) {
790
                applyColors(plot1.series[0].color, plot1.series[1].color, color.formatted, plot1.grid.plotBands.color);
791
            }
792
        });
793
 
794
        $('#colorPlotBands').colorpicker({
795
            colorFormat: '#HEX',
796
            showOn: 'button',
797
            buttonColorize: true,
798
            buttonImageOnly: true,
799
            parts: 'full',
800
            close: function(ui, color) {
801
                applyColors(plot1.series[0].color, plot1.series[1].color, plot1.grid.background, color.formatted);
802
            }
803
        });
804
 
805
    });
806
    </script>
807
 
808
<!-- End example scripts -->
809
 
810
<!-- Don't touch this! -->
811
 
812
 
813
    <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
814
    <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
815
    <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
816
    <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
817
<!-- End Don't touch this! -->
818
 
819
<!-- Additional plugins go here -->
820
 
821
    <script class="include" type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.min.js"></script>
822
 
823
    <!-- 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. -->
824
    <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidAxisRenderer.min.js"></script>
825
    <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidGridRenderer.min.js"></script>
826
 
827
    <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidRenderer.min.js"></script>
828
    <script class="include" type="text/javascript" src="../plugins/jqplot.canvasTextRenderer.min.js"></script>
829
    <script class="include" type="text/javascript" src="../plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
830
    <script class="include" type="text/javascript" src="../plugins/jqplot.json2.min.js"></script>
831
    <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
832
    <script class="include" type="text/javascript" src="kcp.print.js"></script>
833
 
834
    <script src="colorpicker/jquery.colorpicker.js"></script>
835
 
836
<!-- End additional plugins -->
837
 
838
        </div>
839
         <div class="col2">
840
 
841
           <div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
842
           <div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
843
           <div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
844
           <div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
845
           <div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
846
           <div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
847
           <div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
848
           <div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
849
           <div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
850
           <div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
851
           <div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
852
           <div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
853
           <div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
854
           <div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
855
           <div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
856
           <div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
857
           <div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
858
           <div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
859
           <div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
860
           <div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
861
           <div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
862
           <div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
863
           <div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
864
           <div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
865
           <div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
866
           <div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
867
           <div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
868
           <div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
869
           <div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
870
           <div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
871
           <div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
872
           <div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
873
           <div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
874
           <div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
875
           <div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
876
           <div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
877
           <div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
878
           <div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
879
           <div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
880
           <div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
881
           <div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
882
           <div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
883
           <div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
884
           <div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
885
           <div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
886
           <div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
887
           <div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
888
           <div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
889
           <div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
890
           <div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
891
           <div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
892
           <div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
893
           <div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
894
           <div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
895
           <div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
896
           <div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
897
 
898
         </div>
899
               </div>
900
    </div>
901
    <script type="text/javascript" src="example.min.js"></script>
902
 
903
</body>
904
 
905
 
906
</html>