| 1 | <!DOCTYPE HTML> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 5 | <title>Pie 2D: Smart Label</title> |
| 6 | <style type="text/css"> |
| 7 | @import "../../../dojo/resources/dojo.css"; |
| 8 | @import "../../../dijit/tests/css/dijitTests.css"; |
| 9 | @import "../../../dijit/themes/claro/claro.css"; |
| 10 | @import "../resources/Legend.css"; |
| 11 | </style> |
| 12 | <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="parseOnLoad:true, async: true"></script> |
| 13 | <script type="text/javascript"> |
| 14 | require([ |
| 15 | "dojox/charting/Chart", |
| 16 | "dojox/charting/plot2d/Pie", |
| 17 | "dojox/charting/action2d/Tooltip", |
| 18 | "dojox/charting/themes/Tom", |
| 19 | "dojox/charting/widget/Legend", |
| 20 | "dojo/domReady!" |
| 21 | ], function (Chart, Pie, TooltipAction, Tom, Legend) { |
| 22 | var pieChart = null; |
| 23 | var legend = null; |
| 24 | pieChart = new Chart("pieChart"); |
| 25 | pieChart.setTheme(Tom).addPlot("default", { |
| 26 | type: Pie, |
| 27 | font: "normal normal 10pt Tahoma", |
| 28 | fontColor: "#ccc", |
| 29 | labelWiring: "#ccc", |
| 30 | labelStyle: "columns", |
| 31 | htmlLabels: true, |
| 32 | startAngle: -10 |
| 33 | }).addSeries("Series A", [{ |
| 34 | y: 12.1, |
| 35 | text: "China", |
| 36 | tooltip: "1,210 million" |
| 37 | }, { |
| 38 | y: 9.52, |
| 39 | text: "India", |
| 40 | tooltip: "952 million" |
| 41 | }, { |
| 42 | y: 2.66, |
| 43 | text: "USA", |
| 44 | tooltip: "266 million" |
| 45 | }, { |
| 46 | y: 2.06, |
| 47 | text: "Indonisia", |
| 48 | tooltip: "206 million" |
| 49 | }, { |
| 50 | y: 1.63, |
| 51 | text: "Brazil", |
| 52 | tooltip: "163 million" |
| 53 | }, { |
| 54 | y: 1.48, |
| 55 | text: "Russian", |
| 56 | tooltip: "148 million" |
| 57 | }, { |
| 58 | y: 1.29, |
| 59 | text: "Pakistan", |
| 60 | tooltip: "129 million" |
| 61 | }, { |
| 62 | y: 1.25, |
| 63 | text: "Japan", |
| 64 | tooltip: "125 million" |
| 65 | }, { |
| 66 | y: 1.23, |
| 67 | text: "Bangladesh", |
| 68 | tooltip: "123 million" |
| 69 | }, { |
| 70 | y: 1.04, |
| 71 | text: "Nigeria", |
| 72 | tooltip: "104 million" |
| 73 | }, { |
| 74 | y: 0.96, |
| 75 | text: "Mexico", |
| 76 | tooltip: "96 million" |
| 77 | }, { |
| 78 | y: 0.84, |
| 79 | text: "Germany", |
| 80 | tooltip: "84 million" |
| 81 | }, { |
| 82 | y: 0.74, |
| 83 | text: "Phillippines", |
| 84 | tooltip: "74 million" |
| 85 | }, { |
| 86 | y: 0.74, |
| 87 | text: "Viet Nam", |
| 88 | tooltip: "74 million" |
| 89 | }, { |
| 90 | y: 0.66, |
| 91 | text: "Iran", |
| 92 | tooltip: "66 million" |
| 93 | }, { |
| 94 | y: 0.64, |
| 95 | text: "Egypt", |
| 96 | tooltip: "64 million" |
| 97 | }]); |
| 98 | var anim_c = new TooltipAction(pieChart, "default"); |
| 99 | pieChart.render(); |
| 100 | legend = new Legend({ |
| 101 | chart: pieChart, |
| 102 | horizontal: false |
| 103 | }, "legend"); |
| 104 | |
| 105 | refreshChart = function () { |
| 106 | var newData = []; |
| 107 | for (var i = 0; i < 16; i++) { |
| 108 | newData.push(Math.random() * 10); |
| 109 | } |
| 110 | newData.sort(function (v1, v2) { |
| 111 | return v2 - v1 |
| 112 | }); |
| 113 | pieChart.updateSeries("Series A", newData); |
| 114 | pieChart.render(); |
| 115 | legend.refresh(); |
| 116 | } |
| 117 | }); |
| 118 | </script> |
| 119 | </head> |
| 120 | <body class="claro"> |
| 121 | <h1>Pie 2D: Smart Label</h1> |
| 122 | <p>Example of Pie chart using smart label:</p> |
| 123 | <div style="margin:20px"> |
| 124 | <div id="pieChart" style="width: 470px; height: 350px; float:left;"> |
| 125 | </div> |
| 126 | <div id="legend"> |
| 127 | </div> |
| 128 | </div> |
| 129 | <button onclick="refreshChart()">Random Data Test</button> |
| 130 | </body> |
| 131 | </html> |
| 132 |