| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
<![if gte IE 9]> |
| 13 |
<!DOCTYPE HTML> |
| 14 |
<html lang="en"> |
| 15 |
<head> |
| 16 |
<![endif]> |
| 17 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 18 |
<title>Pie 2D: Smart Label</title> |
| 19 |
<style type="text/css"> |
| 20 |
@import "../../../../dojo/resources/dojo.css"; |
| 21 |
@import "../../../../dijit/tests/css/dijitTests.css"; |
| 22 |
@import "../../../../dijit/themes/claro/claro.css"; |
| 23 |
@import "../../resources/Legend.css"; |
| 24 |
</style> |
| 25 |
<script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="parseOnLoad:true, has:{'dojo-bidi': true}"> |
| 26 |
</script> |
| 27 |
<script type="text/javascript"> |
| 28 |
dojo.require("dojo.parser"); |
| 29 |
dojo.require("doh.runner"); |
| 30 |
|
| 31 |
dojo.require("dojox.charting.Chart"); |
| 32 |
dojo.require("dojox.charting.plot2d.Pie"); |
| 33 |
dojo.require("dojox.charting.action2d.Highlight"); |
| 34 |
dojo.require("dojox.charting.action2d.MoveSlice"); |
| 35 |
dojo.require("dojox.charting.action2d.Tooltip"); |
| 36 |
dojo.require("dojox.charting.themes.Tom"); |
| 37 |
dojo.require("dojox.charting.widget.Legend"); |
| 38 |
|
| 39 |
var pieChart = null; |
| 40 |
var legend = null; |
| 41 |
dojo.addOnLoad(function () { |
| 42 |
var dc = dojox.charting; |
| 43 |
pieChart = new dc.Chart("pieChart", { |
| 44 |
textDir: "rtl" |
| 45 |
}); |
| 46 |
pieChart.setTheme(dc.themes.Tom).addPlot("default", { |
| 47 |
type: "Pie", |
| 48 |
font: "normal normal 10pt Tahoma", |
| 49 |
fontColor: "#ccc", |
| 50 |
labelWiring: "#ccc", |
| 51 |
labelStyle: "columns", |
| 52 |
htmlLabels: true, |
| 53 |
startAngle: -10 |
| 54 |
}).addSeries("Series A", [{ |
| 55 |
y: 12.1, |
| 56 |
text: "The country is \u05e1\u05d9\u05df.", |
| 57 |
tooltip: "1,210 \u05de\u05dc\u05d9\u05d5\u05df." |
| 58 |
}, { |
| 59 |
y: 9.52, |
| 60 |
text: "\u05d4\u05de\u05d3\u05d9\u05e0\u05d4\u0020\u05d4\u05d9\u05d0 India.", |
| 61 |
tooltip: "952 million." |
| 62 |
}, { |
| 63 |
y: 2.66, |
| 64 |
text: "\u05d0\u05e8\u05d4\u0022\u05d1.", |
| 65 |
tooltip: "266 \u05de\u05dc\u05d9\u05d5\u05df." |
| 66 |
}, { |
| 67 |
y: 2.06, |
| 68 |
text: "Indonisia.", |
| 69 |
tooltip: "206 million." |
| 70 |
}, { |
| 71 |
y: 1.63, |
| 72 |
text: "Brazil.", |
| 73 |
tooltip: "163 million." |
| 74 |
}, { |
| 75 |
y: 1.48, |
| 76 |
text: "Russian.", |
| 77 |
tooltip: "148 million." |
| 78 |
}, { |
| 79 |
y: 1.29, |
| 80 |
text: "Pakistan.", |
| 81 |
tooltip: "129 million." |
| 82 |
}, { |
| 83 |
y: 1.25, |
| 84 |
text: "Japan.", |
| 85 |
tooltip: "125 million." |
| 86 |
}, { |
| 87 |
y: 1.23, |
| 88 |
text: "Bangladesh.", |
| 89 |
tooltip: "123 million." |
| 90 |
}, { |
| 91 |
y: 1.04, |
| 92 |
text: "Nigeria.", |
| 93 |
tooltip: "104 million." |
| 94 |
}, { |
| 95 |
y: 0.96, |
| 96 |
text: "Mexico.", |
| 97 |
tooltip: "96 million." |
| 98 |
}, { |
| 99 |
y: 0.84, |
| 100 |
text: "Germany.", |
| 101 |
tooltip: "84 million." |
| 102 |
}, { |
| 103 |
y: 0.74, |
| 104 |
text: "Phillippines.", |
| 105 |
tooltip: "74 million." |
| 106 |
}, { |
| 107 |
y: 0.74, |
| 108 |
text: "Viet Nam.", |
| 109 |
tooltip: "74 million." |
| 110 |
}, { |
| 111 |
y: 0.66, |
| 112 |
text: "Iran.", |
| 113 |
tooltip: "66 million." |
| 114 |
}, { |
| 115 |
y: 0.64, |
| 116 |
text: "Egypt.", |
| 117 |
tooltip: "64 million." |
| 118 |
}]); |
| 119 |
var anim_b = new dc.action2d.Highlight(pieChart, "default"); |
| 120 |
var anim_c = new dc.action2d.Tooltip(pieChart, "default"); |
| 121 |
pieChart.render(); |
| 122 |
legend = new dojox.charting.widget.Legend({ |
| 123 |
chart: pieChart, |
| 124 |
horizontal: false |
| 125 |
}, "legend"); |
| 126 |
|
| 127 |
doh.register("parse", function () { |
| 128 |
dojo.parser.parse(); |
| 129 |
}); |
| 130 |
|
| 131 |
doh.register("test textDir", [{ |
| 132 |
name: "Pies textDir", |
| 133 |
|
| 134 |
runTest: function () { |
| 135 |
doh.is("rtl", pieChart.textDir, "pieChart: internal labels"); |
| 136 |
doh.is("rtl", legend.textDir, "legend: external labels"); |
| 137 |
} |
| 138 |
}]); |
| 139 |
|
| 140 |
doh.run(); |
| 141 |
|
| 142 |
}); |
| 143 |
|
| 144 |
function refreshChart() { |
| 145 |
var newData = []; |
| 146 |
for (var i = 0; i < 16; i++) { |
| 147 |
newData.push(Math.random() * 10); |
| 148 |
} |
| 149 |
newData.sort(function (v1, v2) { |
| 150 |
return v2 - v1 |
| 151 |
}); |
| 152 |
pieChart.updateSeries("Series A", newData); |
| 153 |
pieChart.render(); |
| 154 |
legend.refresh(); |
| 155 |
} |
| 156 |
</script> |
| 157 |
</head> |
| 158 |
<body class="claro"> |
| 159 |
<h1>Pie 2D: Smart Label</h1> |
| 160 |
<p>Example of Pie chart using smart label:</p> |
| 161 |
<div style="margin:20px"> |
| 162 |
<div id="pieChart" style="width: 470px; height: 350px; float:left;"> |
| 163 |
</div> |
| 164 |
<div id="legend"> |
| 165 |
</div> |
| 166 |
</div> |
| 167 |
<button onclick="refreshChart()">Random Data Test</button> |
| 168 |
</body> |
| 169 |
</html> |