kcp_quintiles.html 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Quintile Pyramid Charts</title>
  5. <link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
  6. <link rel="stylesheet" type="text/css" href="examples.min.css" />
  7. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
  8. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
  9. <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
  10. <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  11. </head>
  12. <body>
  13. <div id="header">
  14. <div class="nav">
  15. <a class="nav" href="../../../index.php"><span>&gt;</span>Home</a>
  16. <a class="nav" href="../../../docs/"><span>&gt;</span>Docs</a>
  17. <a class="nav" href="../../download/"><span>&gt;</span>Download</a>
  18. <a class="nav" href="../../../info.php"><span>&gt;</span>Info</a>
  19. <a class="nav" href="../../../donate.php"><span>&gt;</span>Donate</a>
  20. </div>
  21. </div>
  22. <div class="colmask leftmenu">
  23. <div class="colleft">
  24. <div class="col1" id="example-content">
  25. <!-- Example scripts go here -->
  26. <link class="include" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/smoothness/jquery-ui.css" rel="Stylesheet" />
  27. <style type="text/css">
  28. .quintile-outer-container {
  29. width: 900px;
  30. margin-bottom: 25px;
  31. }
  32. .jqplot-chart {
  33. width: 500px;
  34. height: 400px;
  35. }
  36. pre.code {
  37. margin-top: 45px;
  38. clear: both;
  39. }
  40. .quintile-toolbar .ui-icon {
  41. float: right;
  42. margin: 3px 5px;
  43. }
  44. table.stats-table td, table.highlighted-stats-table td {
  45. background-color: rgb(230, 230, 230);
  46. padding: 0.5em;
  47. }
  48. col.label {
  49. width: 14em;
  50. }
  51. col.value {
  52. width: 7em;
  53. }
  54. td.quintile-value {
  55. width: 7em;
  56. text-align: right;
  57. }
  58. table.stats-table td.tooltip-header, table.highlighted-stats-table td.tooltip-header {
  59. background-color: rgb(200, 200, 200);
  60. }
  61. table.stats-table, table.highlighted-stats-table, td.contour-cell {
  62. font-size: 0.7em;
  63. }
  64. td.contour-cell {
  65. height: 1.5em;
  66. padding-left: 20px;
  67. padding-bottom: 1.5em;
  68. }
  69. table.highlighted-stats-table {
  70. margin-top: 15px;
  71. }
  72. td.stats-cell {
  73. padding-left: 20px;
  74. padding-top: 20px;
  75. vertical-align: top;
  76. }
  77. td.stats-cell div.input {
  78. font-size: 0.7em;
  79. margin-top: 1.5em;
  80. }
  81. div.overlay-chart-container {
  82. display: none;
  83. z-index: 11;
  84. position: fixed;
  85. width: 588px;
  86. left: 50%;
  87. margin-left: -294px;
  88. background-color: white;
  89. }
  90. div.overlay-chart-container .ui-icon {
  91. float: right;
  92. margin: 3px 5px;
  93. }
  94. div.overlay-shadow {
  95. display: none;
  96. z-index: 10;
  97. background-color: rgba(0, 0, 0, 0.8);
  98. position: fixed;
  99. top: 0px;
  100. left: 0px;
  101. width: 100%;
  102. height: 100%;
  103. }
  104. @media print {
  105. td.stats-cell {
  106. vertical-align: top;
  107. padding-top: 35px;
  108. }
  109. table.stats-table, table.stats-table td {
  110. color: #aaaaaa;
  111. border: 1px solid #bbbbbb;
  112. border-collapse: collapse;
  113. }
  114. table.stats-table tr {
  115. font-family: Verdana,Arial,sans-serif;
  116. /*font-size: 0.7em;*/
  117. }
  118. }
  119. </style>
  120. <div class="overlay-shadow"></div>
  121. <div class="overlay-chart-container ui-corner-all">
  122. <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>
  123. <div class="overlay-chart-container-content ui-corner-bottom"></div>
  124. </div>
  125. <div class="quintile-outer-container ui-widget ui-corner-all">
  126. <div class="quintile-toolbar ui-widget-header ui-corner-top">
  127. <span class="quintile-title">Income Level: First Quintile</span>
  128. <div class="quintile-toggle ui-icon ui-icon-arrowthickstop-1-n"></div>
  129. <div class="ui-icon ui-icon-newwin"></div>
  130. </div>
  131. <div class="quintile-content ui-widget-content ui-corner-bottom">
  132. <table class="quintile-display">
  133. <tr>
  134. <td class="chart-cell" rowspan="2">
  135. <div class="jqplot-chart"></div>
  136. </td>
  137. <td class="stats-cell">
  138. <table class="stats-table">
  139. <colgroup>
  140. <col class="label">
  141. <col class="value">
  142. </colgroup>
  143. <tbody>
  144. <tr>
  145. <td class="ui-corner-tl">Mean Age:</td>
  146. <td class="quintile-value summary-meanAge ui-corner-tr"></td>
  147. </tr>
  148. <tr>
  149. <td>Sex Ratio:</td>
  150. <td class="quintile-value summary-sexRatio"></td>
  151. </tr>
  152. <tr>
  153. <td>Age Dependency Ratio:</td>
  154. <td class="quintile-value summary-ageDependencyRatio"></td>
  155. </tr>
  156. <tr>
  157. <td>Population, Total:</td>
  158. <td class="quintile-value summary-populationTotal"></td>
  159. </tr>
  160. <tr>
  161. <td>Population, Male:</td>
  162. <td class="quintile-value summary-populationMale"></td>
  163. </tr>
  164. <tr>
  165. <td class="ui-corner-bl">Population, Female:</td>
  166. <td class="quintile-value summary-populationFemale ui-corner-br"></td>
  167. </tr>
  168. </tbody>
  169. </table>
  170. <table class="highlighted-stats-table">
  171. <colgroup>
  172. <col class="label">
  173. <col class="value">
  174. </colgroup>
  175. <tbody>
  176. <tr class="tooltip-header">
  177. <td class="tooltip-header ui-corner-top" colspan="2">Highlighted Range: <span class="tooltip-item tooltipAge">&nbsp;</span></td>
  178. </tr>
  179. <tr>
  180. <td>Population, Male: </td>
  181. <td class="quintile-value"><span class="tooltip-item tooltipMale">&nbsp;</span></td>
  182. </tr>
  183. <tr>
  184. <td>Population, Female: </td>
  185. <td class="quintile-value"><span class="tooltip-item tooltipFemale">&nbsp;</span></td>
  186. </tr>
  187. <tr>
  188. <td class="ui-corner-bl">Sex Ratio: </td>
  189. <td class="quintile-value ui-corner-br"><span class="tooltip-item tooltipRatio">&nbsp;</span></td>
  190. </tr>
  191. <tbody>
  192. </table>
  193. </td>
  194. </tr>
  195. <tr>
  196. <td class="contour-cell">
  197. <input name="showContour" type="checkbox" /> Use as overlay on other charts?
  198. </td>
  199. </tr>
  200. </table>
  201. </div>
  202. </div>
  203. <script class="code" type="text/javascript" language="javascript">
  204. $(document).ready(function(){
  205. // if browser supports canvas, show additional toolbar icons
  206. if (!$.jqplot.use_excanvas) {
  207. $('div.quintile-toolbar').append('<div class="ui-icon ui-icon-image"></div><div class="ui-icon ui-icon-print"></div>');
  208. }
  209. var quintHash = {0: 'First Quintile', 1: 'Second Quintile', 2: 'Third Quintile', 3: 'Fourth Quintile', 4: 'Fifth Quintile'}
  210. // Add the needed containers:
  211. for (var i=1; i<5; i++) {
  212. var el = $('div.quintile-outer-container:last')
  213. var clone = el.clone();
  214. clone.find('span.quintile-title').html('Income Level: ' + quintHash[i]);
  215. clone.insertAfter(el);
  216. }
  217. var male;
  218. var female;
  219. var summaryTable;
  220. var sexRatios;
  221. var quintiles = [ [ [27777522, 13657657, 14119865, 22.96185242727780, 22.92340104876670, 22.99840039165770, 95.15435452471940],
  222. [0.16814981778556500, 0.16938884829023600, 0.13029899959403300, 0.08445061806046640, 0.05811840452702920, 0.05631028061504850, 0.06512242137179920, 0.06861163659177230, 0.06020567860988050, 0.04355880225459750, 0.02803499342457000, 0.01912758869230340, 0.01515038483762410, 0.01223701332240520, 0.00869244058559189, 0.00529469386492945, 0.00328609724536106, 0.00194751964322071, 0.00114713861262733, 0.00086662207093871],
  223. [0.15777933298339800, 0.15671077815250300, 0.12447815070139100, 0.08939377850853680, 0.07830223837100820, 0.08053563812713150, 0.07682071635522590, 0.06269916689630620, 0.04365876627610810, 0.03084162032257200, 0.02432244409407740, 0.02120157090634930, 0.01791380814933710, 0.01326354596024400, 0.00968643784396050, 0.00633359323592785, 0.00349435421488265, 0.00158514030722019, 0.00062587894057936, 0.00035303965324001],
  224. [0.96726540940724300, 1.03084161446685000, 1.04551821911720000, 1.01249668698901000, 0.91377904610163700, 0.71793506186340200, 0.67630912102504800, 0.81996977584158100, 1.05847758500203000, 1.33386431492214000, 1.36610600401065000, 1.11490766666616000, 0.87264547467534200, 0.81805292713174800, 0.89240386671080400, 0.86800712885521700, 0.80860485322858600, 0.90961820179781800, 1.18839220506104000, 1.77284683642290000, 2.37438923518884000] ],
  225. [ [27749565, 13838477, 13911088, 24.59760821726010, 24.93140692365050, 24.25806641635340, 77.89121151531350],
  226. [0.13460476947529500, 0.14372006850062500, 0.12847108657610600, 0.09875785820893480, 0.07155805029015120, 0.06299959058572970, 0.06669930695548060, 0.06620210601954020, 0.05883374707069510, 0.04833706700819440, 0.03521801565126300, 0.02559536412958920, 0.02062306586521670, 0.01576211515574400, 0.01023801649094930, 0.00572503164287636, 0.00307516687772024, 0.00165330051290922, 0.00104697926747485, 0.00087929371550523],
  227. [0.13970508453303800, 0.13975442365362800, 0.11681679473806300, 0.09435373241811580, 0.08802952295423720, 0.08580953135424240, 0.07740975573970180, 0.06538018068005290, 0.04960049471620990, 0.03735678030431880, 0.02976493031984740, 0.02384624281925690, 0.01786909883056510, 0.01280223896627530, 0.00854305561048803, 0.00534781144388522, 0.00336845668342047, 0.00201559921183726, 0.00124722944598909, 0.00097903557682698],
  228. [0.99478035075329800, 0.95846318148882600, 1.02300804808641000, 1.09402516010135000, 1.04121346671673000, 0.80864396372867400, 0.73034724501018900, 0.85714209189972800, 1.00728620755889000, 1.17996112502462000, 1.28717635944761000, 1.17702912743046000, 1.06774746443199000, 1.14809486978252000, 1.22477345443636000, 1.19214694369792000, 1.06494947429125000, 0.90816533289574900, 0.81597117843348200, 0.83506239070880300, 0.89343444858290900] ],
  229. [ [27773083, 14068521, 13704562, 26.03124974398200, 26.46223974345070, 25.59233340000260, 66.99286359589060],
  230. [0.11075465721807600, 0.12531352270434800, 0.12461977157255700, 0.11125959454297800, 0.08638877858554280, 0.06731675090789110, 0.06187750302195390, 0.06283663484842800, 0.05868334457568110, 0.05026814063111530, 0.04079416969542070, 0.03139012243581270, 0.02388339994025160, 0.01756428234835730, 0.01203845901370310, 0.00701750790134651, 0.00386618590184589, 0.00206610447696370, 0.00117506121489637, 0.00088600846283140],
  231. [0.11432537302481000, 0.12667609073231400, 0.11974891524623500, 0.10506132545858400, 0.09301444384053810, 0.08267846594852100, 0.07221670745205490, 0.06493541188927070, 0.05720135869997910, 0.04682451198762990, 0.03485427327295350, 0.02629070404866000, 0.01998999845792230, 0.01428519039077750, 0.00980039073555805, 0.00599266397652053, 0.00331791767499821, 0.00156650907345305, 0.00072094415435746, 0.00049880393486330],
  232. [1.02655750690901000, 0.99449511323857500, 1.01551553024478000, 1.06831332671397000, 1.08712098857701000, 0.95343309606544400, 0.83582242597784900, 0.87958614394243600, 0.99337814815975000, 1.05315379343805000, 1.10205392288684000, 1.20150435531963000, 1.22567146812179000, 1.22649751828565000, 1.26219850103057000, 1.26098752647638000, 1.20211569414631000, 1.19619066818704000, 1.35395006440030000, 1.67317801793479000, 1.82343918147671000] ],
  233. [ [27763227, 14197178, 13566049, 27.18018253648030, 27.20726467467510, 27.15223055717600, 58.62068064918010],
  234. [0.09684619409307840, 0.11118728522535100, 0.12478646127724500, 0.11986149426641600, 0.09520840637648180, 0.07266436962641580, 0.06157942773922730, 0.05776990145557140, 0.05595079146694350, 0.05422906155293650, 0.04606394160905190, 0.03460401579477880, 0.02431694855838520, 0.01695117276859440, 0.01211661291564830, 0.00784551008485565, 0.00430794264393258, 0.00206401896375649, 0.00099084255721430, 0.00065560102411584],
  235. [0.09693358901304290, 0.10652960384957600, 0.11580433409088400, 0.11321777793810400, 0.09912292067710200, 0.08131783917502760, 0.07048109387720830, 0.06833459006738460, 0.06313644652192900, 0.05255568033191890, 0.03903863379099840, 0.02910689297792140, 0.02269025908501970, 0.01651322011205660, 0.01126491285383100, 0.00657328507941835, 0.00372023325715849, 0.00195236631466226, 0.00099341991698984, 0.00071290106976617],
  236. [1.04652268320717000, 1.04557914271650000, 1.09227868937597000, 1.12769408251422000, 1.10793353197135000, 1.00519391705143000, 0.93515656400210500, 0.91434829403035100, 0.88472781091218400, 0.92741634411137500, 1.07984413189527000, 1.23485263418514000, 1.24416877771066000, 1.12154903817441000, 1.07427786276195000, 1.12564654732811000, 1.24907168423899000, 1.21184866195041000, 1.10637161065473000, 1.04380755195023000, 0.96240750921599800] ],
  237. [ [27754352, 14075999, 13678353, 29.11682279982730, 29.25251358929000, 28.97478042663600, 50.90167162031000],
  238. [0.07773301902264660, 0.09756477612918870, 0.11769211568808000, 0.11953094319783700, 0.10070874902748300, 0.07710380627667010, 0.06107481209270700, 0.05557245339785060, 0.05625960991605260, 0.05655944052572760, 0.05050018273054490, 0.03998167380585820, 0.03018284824156070, 0.02178128532719260, 0.01546004923447120, 0.01053184010191340, 0.00618324070639374, 0.00309253762350306, 0.00148564380196157, 0.00100097315235749],
  239. [0.07414870947175290, 0.08945795766137910, 0.11321883781048900, 0.11651658562245200, 0.09931926283967810, 0.08029240511352740, 0.07198971835798040, 0.07305219001114050, 0.06968907391161920, 0.06031073521142600, 0.04701710534217110, 0.03436632086919040, 0.02578058253156860, 0.01918327371957260, 0.01236986721101920, 0.00632468067099160, 0.00324813634215291, 0.00173308253350124, 0.00107597562154257, 0.00090549914684498],
  240. [1.02907119007676000, 1.07881594924275000, 1.12232721275485000, 1.06972980730035000, 1.05569391096106000, 1.04346799653703000, 0.98820437091643300, 0.87304591541007500, 0.78283773210481600, 0.83076356851850300, 0.96506352588551000, 1.10530588311237000, 1.19721831153422000, 1.20479432618776000, 1.16843941971104000, 1.28614891275391000, 1.71360639234849000, 1.95896791328722000, 1.83628956559048000, 1.42088092397757000, 1.13757438283678000] ] ]
  241. $('td.summary-meanAge').each(function(index) {
  242. $(this).html($.jqplot.sprintf('%5.2f', quintiles[index][0][3]));
  243. });
  244. $('td.summary-sexRatio').each(function(index) {
  245. $(this).html($.jqplot.sprintf('%5.2f', quintiles[index][3][0]));
  246. });
  247. $('td.summary-ageDependencyRatio').each(function(index) {
  248. $(this).html($.jqplot.sprintf('%5.2f', quintiles[index][0][6]));
  249. });
  250. $('td.summary-populationTotal').each(function(index) {
  251. $(this).html($.jqplot.sprintf("%'d", quintiles[index][0][0]));
  252. });
  253. $('td.summary-populationMale').each(function(index) {
  254. $(this).html($.jqplot.sprintf("%'d", quintiles[index][0][1]));
  255. });
  256. $('td.summary-populationFemale').each(function(index) {
  257. $(this).html($.jqplot.sprintf("%'d", quintiles[index][0][2]));
  258. });
  259. // These two variables should be removed outside of the jqplot.com example environment.
  260. $.jqplot._noToImageButton = true;
  261. $.jqplot._noCodeBlock = true;
  262. // the "x" values from the data will go into the ticks array.
  263. // ticks should be strings for this case where we have values like "75+"
  264. var ticks = ["0-4", "5-9", "10-14", "15-19", "20-24", "25-29", "30-34", "35-39", "40-44", "45-49", "50-54", "55-59", "60-64", "65-69", "70-74", "75-79", "80-84", "85-90", "90-94", "95+"];
  265. // Custom color arrays are set up for each series to get the look that is desired.
  266. // Two color arrays are created for the default and optional color which the user can pick.
  267. var greenColors = ["#526D2C", "#77933C"];
  268. // These options are common to all plots.
  269. var plotOptions = {
  270. // We set up a customized title which acts as labels for the left and right sides of the pyramid.
  271. title: {
  272. text: '<span style="position:relative;left:25%;">Male</span><span style="position:relative;left:50%;">Female</span>',
  273. textAlign: 'left'
  274. },
  275. // by default, the series will use the green color scheme.
  276. seriesColors: greenColors,
  277. grid: {
  278. drawBorder: false,
  279. shadow: false,
  280. background: "white",
  281. rendererOptions: {
  282. // plotBands is an option of the pyramidGridRenderer.
  283. // it will put banding at starting at a specified value
  284. // along the y axis with an adjustable interval.
  285. plotBands: {
  286. show: true,
  287. interval: 2,
  288. color: 'rgb(250, 240, 225)'
  289. }
  290. }
  291. },
  292. // This makes the effective starting value of the axes 0 instead of 1.
  293. // For display, the y axis will use the ticks we supplied.
  294. defaultAxisStart: 0,
  295. seriesDefaults: {
  296. renderer: $.jqplot.PyramidRenderer,
  297. rendererOptions: {
  298. barPadding: 4,
  299. fill: false
  300. },
  301. yaxis: "yaxis",
  302. shadow: false,
  303. show: false
  304. },
  305. // We have 10 series, but only 2 will be shown at a time unless an overlay is turned on.
  306. // Set up options for all series now, so when turned on they will look right.
  307. series: [
  308. // For pyramid plots, the default side is right.
  309. // We want to override here to put first set of bars
  310. // on left.
  311. {
  312. rendererOptions:{
  313. side: "left"
  314. }
  315. },
  316. {
  317. yaxis: "y2axis"
  318. },
  319. {
  320. rendererOptions: {
  321. side: 'left'
  322. }
  323. },
  324. {
  325. yaxis: 'y2axis'
  326. },
  327. {
  328. rendererOptions: {
  329. side: 'left'
  330. }
  331. },
  332. {
  333. yaxis: 'y2axis'
  334. },
  335. {
  336. rendererOptions: {
  337. side: 'left'
  338. }
  339. },
  340. {
  341. yaxis: 'y2axis'
  342. },
  343. {
  344. rendererOptions: {
  345. side: 'left'
  346. }
  347. },
  348. {
  349. yaxis: 'y2axis'
  350. }
  351. ],
  352. axesDefaults: {
  353. tickOptions: {
  354. showGridline: false
  355. },
  356. pad: 0,
  357. rendererOptions: {
  358. baselineWidth: 2
  359. },
  360. scaleToHiddenSeries: true
  361. },
  362. // Set up all the y axes, since users are allowed to switch between them.
  363. // The only axis that will show is the one that the series are "attached" to.
  364. // We need the appropriate options for the others for when the user switches.
  365. axes: {
  366. xaxis: {
  367. tickOptions: {
  368. formatter: $.jqplot.PercentTickFormatter,
  369. formatString: '%d%%'
  370. }
  371. },
  372. yaxis: {
  373. label: "Age",
  374. // Use canvas label renderer to get rotated labels.
  375. labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
  376. // include empty tick options, they will be used
  377. // as users set options with plot controls.
  378. tickOptions: {},
  379. showMinorTicks: true,
  380. ticks: ticks,
  381. rendererOptions: {
  382. category: true
  383. }
  384. },
  385. y2axis: {
  386. label: "Age",
  387. // Use canvas label renderer to get rotated labels.
  388. labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
  389. // include empty tick options, they will be used
  390. // as users set options with plot controls.
  391. tickOptions: {},
  392. showMinorTicks: true,
  393. ticks: ticks,
  394. rendererOptions: {
  395. category: true
  396. }
  397. }
  398. }
  399. };
  400. // These options are different for each series.
  401. // sopts are common options for the overlay series in each plot.
  402. var sopts = {color: '#C57225'};
  403. // An array of 5 elements, one for each plot.
  404. var plotOptsArr = [];
  405. // Options for each individual plot
  406. plotOptsArr[0] = $.extend(true, {}, plotOptions, {series:[{show: true, rendererOptions:{synchronizeHighlight: 1, fill: true}}, {show: true, rendererOptions: {synchronizeHighlight: 0, fill: true}}, sopts, sopts, sopts, sopts, sopts, sopts, sopts, sopts]});
  407. plotOptsArr[1] = $.extend(true, {}, plotOptions, {series:[sopts, sopts, {show: true, rendererOptions:{synchronizeHighlight: 3, fill: true}}, {show: true, rendererOptions: {synchronizeHighlight: 2, fill: true}}, sopts, sopts, sopts, sopts, sopts, sopts]});
  408. plotOptsArr[2] = $.extend(true, {}, plotOptions, {series:[sopts, sopts, sopts, sopts, {show: true, rendererOptions:{synchronizeHighlight: 5, fill: true}}, {show: true, rendererOptions: {synchronizeHighlight: 4, fill: true}}, sopts, sopts, sopts, sopts]});
  409. plotOptsArr[3] = $.extend(true, {}, plotOptions, {series:[sopts, sopts, sopts, sopts, sopts, sopts, {show: true, rendererOptions:{synchronizeHighlight: 7, fill: true}}, {show: true, rendererOptions: {synchronizeHighlight: 6, fill: true}}, sopts, sopts]});
  410. plotOptsArr[4] = $.extend(true, {}, plotOptions, {series:[sopts, sopts, sopts, sopts, sopts, sopts, sopts, sopts, {show: true, rendererOptions:{synchronizeHighlight: 9, fill: true}}, {show: true, rendererOptions: {synchronizeHighlight: 8, fill: true}}]});
  411. // Create all the plots at one time.
  412. // Use jQuery selecctor syntax to select all the plot targets. Here, no id's were specified on the targets, so they are auto generated.
  413. // You can get a reference to the individual plot object by:
  414. // var plot = $('div.jqplot-chart').eq(0).data('jqplot');
  415. //
  416. $('div.jqplot-chart').jqplot([quintiles[0][1], quintiles[0][2], quintiles[1][1], quintiles[1][2], quintiles[2][1], quintiles[2][2], quintiles[3][1], quintiles[3][2], quintiles[4][1], quintiles[4][2]], plotOptsArr[0], plotOptsArr[1], plotOptsArr[2], plotOptsArr[3], plotOptsArr[4]);
  417. //////
  418. // The followng functions use verbose css selectors to make
  419. // it clear exactly which elements they are binging to/operating on
  420. //////
  421. // bind to the data highlighting event to make custom tooltip:
  422. $(".jqplot-target").each(function(index){
  423. $(this).bind("jqplotDataHighlight", function(evt, seriesIndex, pointIndex, data) {
  424. // Here, assume first series is male poulation and second series is female population.
  425. // Adjust series indices as appropriate.
  426. var plot = $(this).data('jqplot');
  427. var malePopulation = Math.abs(plot.series[0].data[pointIndex][1]) * quintiles[index][0][1];
  428. var femalePopulation = Math.abs(plot.series[1].data[pointIndex][1]) * quintiles[index][0][2];
  429. var malePopulation = quintiles[index][1][pointIndex] * quintiles[index][0][1];
  430. var femalePopulation = quintiles[index][2][pointIndex] * quintiles[index][0][2];
  431. // var ratio = femalePopulation / malePopulation * 100;
  432. var ratio = quintiles[index][3][pointIndex+1];
  433. $(this).closest('table').find('.tooltipMale').stop(true, true).fadeIn(350).html($.jqplot.sprintf("%'d", malePopulation));
  434. $(this).closest('table').find('.tooltipFemale').stop(true, true).fadeIn(350).html($.jqplot.sprintf("%'d", femalePopulation));
  435. $(this).closest('table').find('.tooltipRatio').stop(true, true).fadeIn(350).html($.jqplot.sprintf('%5.2f', ratio));
  436. // Since we don't know which axis is rendererd and acive with out a little extra work,
  437. // just use the supplied ticks array to get the age label.
  438. $(this).closest('table').find('.tooltipAge').stop(true, true).fadeIn(350).html(ticks[pointIndex]);
  439. });
  440. });
  441. // bind to the data highlighting event to make custom tooltip:
  442. $(".jqplot-target").each(function() {
  443. $(this).bind("jqplotDataUnhighlight", function(evt, seriesIndex, pointIndex, data) {
  444. // clear out all the tooltips.
  445. $(this).closest('table').find(".tooltip-item").fadeOut(250);
  446. });
  447. });
  448. // Open and close the plot container.
  449. $('.quintile-toggle').each(function() {
  450. $(this).click(function(e) {
  451. if ($(this).hasClass('ui-icon-arrowthickstop-1-n')) {
  452. $(this).parent().next('.quintile-content').effect('blind', {mode:'hide'}, 600);
  453. // $('.quintile-content').jqplotEffect('blind', {mode: 'hide'}, 600);
  454. $(this).removeClass('ui-icon-arrowthickstop-1-n');
  455. $(this).addClass('ui-icon-arrowthickstop-1-s');
  456. }
  457. else if ($(this).hasClass('ui-icon-arrowthickstop-1-s')) {
  458. $(this).parent().next('.quintile-content').effect('blind', {mode:'show'}, 600, function() {
  459. $(this).find('div.jqplot-chart').data('jqplot').replot();
  460. });
  461. // $('.quintile-content').jqplotEffect('blind', {mode: 'show'}, 150);
  462. $(this).removeClass('ui-icon-arrowthickstop-1-s');
  463. $(this).addClass('ui-icon-arrowthickstop-1-n');
  464. }
  465. });
  466. });
  467. // Handle each of the checkboxes to display overlays.
  468. $('input[type=checkbox][name=showContour]').each(function(index) {
  469. // on load/reload, clear all the check boxes.
  470. $(this).get(0).checked = false;
  471. // bind to change event event on the checkbox.
  472. $(this).change(function(evt){
  473. // if check box is checked.
  474. if (this.checked) {
  475. // uncheck all other check boxes.
  476. $('input[type=checkbox][name=showContour]').each(function(cidx) {
  477. if (cidx !== index) {
  478. this.checked = false;
  479. }
  480. });
  481. // On each chart, show the checked plot's overlay and
  482. // show the original plot.
  483. $('div.jqplot-chart').each(function(pidx) {
  484. var plot = $(this).data('jqplot');
  485. // Set up options to hide all series.
  486. var seriesOpts = [{show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}];
  487. // Show series for this particular plot (pidx) and for the checked plot (index).
  488. seriesOpts[2 * pidx].show = true;
  489. seriesOpts[2 * pidx + 1].show = true;
  490. seriesOpts[2 * index].show = true;
  491. seriesOpts[2 * index + 1].show = true;
  492. // replot with the new options.
  493. plot.replot({series: seriesOpts});
  494. });
  495. }
  496. // if check box is not checked.
  497. else {
  498. $('div.jqplot-chart').each(function(pidx) {
  499. // Set up options to hide all series.
  500. var seriesOpts = [{show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}, {show: false}];
  501. var plot = $(this).data('jqplot');
  502. // Here showing only the series for this particular plot (pidx).
  503. seriesOpts[2 * pidx].show = true;
  504. seriesOpts[2 * pidx + 1].show = true;
  505. // replot with the new options.
  506. plot.replot({series: seriesOpts});
  507. });
  508. }
  509. })
  510. });
  511. $('.ui-icon-print').click(function(){
  512. $(this).parent().next().print();
  513. });
  514. $('.ui-icon-image').each(function() {
  515. $(this).bind('click', function(evt) {
  516. var chart = $(this).closest('div.quintile-outer-container').find('div.jqplot-target');
  517. var imgelem = chart.jqplotToImageElem();
  518. var div = $('div.overlay-chart-container-content');
  519. div.empty();
  520. div.append(imgelem);
  521. $('div.overlay-shadow').fadeIn(600);
  522. div.parent().fadeIn(1000);
  523. div = null;
  524. });
  525. });
  526. $('.ui-icon-newwin').each(function(index) {
  527. $(this).bind('click', function(evt) {
  528. var url = 'kcp_pyramid_by_age.html?qidx='+index;
  529. window.open(url);
  530. });
  531. });
  532. $('div.overlay-chart-container-header div.ui-icon-closethick').click(function(){
  533. var div = $('div.overlay-chart-container-content');
  534. div.parent().fadeOut(600);
  535. $('div.overlay-shadow').fadeOut(1000);
  536. });
  537. });
  538. </script>
  539. <!-- End example scripts -->
  540. <!-- Don't touch this! -->
  541. <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
  542. <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
  543. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
  544. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
  545. <!-- End Don't touch this! -->
  546. <!-- Additional plugins go here -->
  547. <script class="include" type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.min.js"></script>
  548. <!-- 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. -->
  549. <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidAxisRenderer.min.js"></script>
  550. <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidGridRenderer.min.js"></script>
  551. <script class="include" type="text/javascript" src="../plugins/jqplot.pyramidRenderer.min.js"></script>
  552. <script class="include" type="text/javascript" src="../plugins/jqplot.canvasTextRenderer.min.js"></script>
  553. <script class="include" type="text/javascript" src="../plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
  554. <script class="include" type="text/javascript" src="http:/ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
  555. <script class="include" type="text/javascript" src="kcp.print.js"></script>
  556. <!-- End additional plugins -->
  557. </div>
  558. <div class="col2">
  559. <div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
  560. <div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
  561. <div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
  562. <div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
  563. <div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
  564. <div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
  565. <div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
  566. <div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
  567. <div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
  568. <div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
  569. <div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
  570. <div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
  571. <div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
  572. <div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
  573. <div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
  574. <div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
  575. <div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
  576. <div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
  577. <div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
  578. <div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
  579. <div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
  580. <div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
  581. <div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
  582. <div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
  583. <div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
  584. <div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
  585. <div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
  586. <div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
  587. <div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
  588. <div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
  589. <div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
  590. <div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
  591. <div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
  592. <div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
  593. <div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
  594. <div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
  595. <div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
  596. <div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
  597. <div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
  598. <div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
  599. <div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
  600. <div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
  601. <div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
  602. <div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
  603. <div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
  604. <div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
  605. <div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
  606. <div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
  607. <div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
  608. <div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
  609. <div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
  610. <div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
  611. <div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
  612. <div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
  613. <div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
  614. <div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
  615. </div>
  616. </div>
  617. </div>
  618. <script type="text/javascript" src="example.min.js"></script>
  619. </body>
  620. </html>