| 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>Chart 2D labels shortening</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 |
</style> |
| 24 |
<script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true, has:{'dojo-bidi': true}"></script> |
| 25 |
<script type="text/javascript"> |
| 26 |
dojo.require("dojo.parser"); |
| 27 |
dojo.require("doh.runner"); |
| 28 |
|
| 29 |
dojo.require("dojox.charting.Chart"); |
| 30 |
dojo.require("dojox.charting.axis2d.Default"); |
| 31 |
dojo.require("dojox.charting.plot2d.Bars"); |
| 32 |
dojo.require("dojox.charting.plot2d.Columns"); |
| 33 |
dojo.require("dojox.charting.plot2d.Lines"); |
| 34 |
dojo.require("dojox.charting.plot2d.Areas"); |
| 35 |
dojo.require("dijit.Tooltip"); |
| 36 |
|
| 37 |
dojo.require("dijit.dijit"); |
| 38 |
dojo.require("dojox.charting.widget.Chart"); |
| 39 |
dojo.require("dojox.charting.plot2d.Grid"); |
| 40 |
dojo.require("dojox.charting.widget.Legend"); |
| 41 |
dojo.require("dojox.data.HtmlStore"); |
| 42 |
|
| 43 |
var seriesB = [260, 180, 200, 100, 140, 70, 200] |
| 44 |
, chart1, chart2, chart3, chart4; |
| 45 |
|
| 46 |
makeObjects = function(){ |
| 47 |
chart1 = new dojox.charting.Chart("test1", {textDir:"auto"}). |
| 48 |
addAxis("x", { |
| 49 |
fixLower: "major", fixUpper: "major", includeZero: true, |
| 50 |
labels: [ |
| 51 |
{value: 0, text: "11111111111\u05d0."}, |
| 52 |
{value: 2, text: "\u05e9\u05ea\u05d9\u05d9\u05dd\u0020\u05e9\u05dc\u05d5\u05e9\u0020\u05d0\u05e8\u05d1\u05e2\u05e2\u05e2\u05e2."}, |
| 53 |
{value: 3, text: "11111111111\u05d0."}, |
| 54 |
{value: 5, text: "\u05d0."} |
| 55 |
], |
| 56 |
maxLabelSize: 20, |
| 57 |
trailingSymbol: ".", |
| 58 |
htmlLabels: true |
| 59 |
}). |
| 60 |
addAxis("y", { |
| 61 |
vertical: true, fixLower: "major", fixUpper: "major", natural: true, |
| 62 |
labels: [{value: 0, text: ""}, |
| 63 |
{value: 1, text: "\u05d9\u05e0\u05d5\u05d0\u05e8."}, {value: 2, text: "February."}, |
| 64 |
{value: 3, text: "March."}, {value: 4, text: "\u05d0\u05e4\u05e8\u05d9\u05dc."}, |
| 65 |
{value: 5, text: "May."}, {value: 6, text: "11111111111\u05d0."} |
| 66 |
], |
| 67 |
maxLabelSize: 20 |
| 68 |
}). |
| 69 |
addPlot("default", {type: "Bars"}). |
| 70 |
addSeries("Series A.", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"}). |
| 71 |
addSeries("Series B.", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}). |
| 72 |
setDir("rtl"). |
| 73 |
render(); |
| 74 |
|
| 75 |
chart2 = new dojox.charting.Chart("test2"). |
| 76 |
addAxis("x", { |
| 77 |
fixLower: "major", fixUpper: "major", includeZero: true, |
| 78 |
labels: [ |
| 79 |
{value: 0, text: "first start point."}, |
| 80 |
{value: 2, text: "two."}, |
| 81 |
{value: 5, text: "111111111111111\u05d0."} |
| 82 |
], |
| 83 |
rotation: 180, |
| 84 |
maxLabelSize: 30 |
| 85 |
}). |
| 86 |
addAxis("y", { |
| 87 |
vertical: true, fixLower: "major", fixUpper: "major", natural: true, majorTickStep: 2, |
| 88 |
labels: [{value: 0, text: ""}, |
| 89 |
{value: 1, text: "\u05d9\u05e0\u05d5\u05d0\u05e8."}, {value: 2, text: "February."}, |
| 90 |
{value: 3, text: "March."}, {value: 4, text: "\u05d0\u05e4\u05e8\u05d9\u05dc."}, |
| 91 |
{value: 5, text: "May."}, {value: 6, text: "June."} |
| 92 |
], |
| 93 |
rotation: -30, |
| 94 |
maxLabelSize: 20 |
| 95 |
}). |
| 96 |
addPlot("default", {type: "Columns"}). |
| 97 |
addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"}). |
| 98 |
addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}). |
| 99 |
setDir("rtl"). |
| 100 |
render(); |
| 101 |
|
| 102 |
chart3 = new dojox.charting.Chart("test3"). |
| 103 |
addAxis("x", { |
| 104 |
fixLower: "major", fixUpper: "major", includeZero: true, |
| 105 |
labels: [ |
| 106 |
{value: 0, text: "first start point"}, |
| 107 |
{value: 2, text: "two"}, |
| 108 |
{value: 5, text: "1111111111111111111111111111\u05d0"} |
| 109 |
], |
| 110 |
maxLabelCharCount: 5 |
| 111 |
}). |
| 112 |
addAxis("y", { |
| 113 |
vertical: true, fixLower: "major", fixUpper: "major", natural: true, majorTickStep: 2, |
| 114 |
labels: [{value: 0, text: ""}, |
| 115 |
{value: 1, text: "\u05d9\u05e0\u05d5\u05d0\u05e8."}, {value: 2, text: "February."}, |
| 116 |
{value: 3, text: "March."}, {value: 4, text: "\u05d0\u05e4\u05e8\u05d9\u05dc."}, |
| 117 |
{value: 5, text: "May."}, {value: 6, text: "June."} |
| 118 |
], |
| 119 |
maxLabelCharCount: 2, |
| 120 |
trailingSymbol: "__" |
| 121 |
}). |
| 122 |
addPlot("default", {type: "Lines"}). |
| 123 |
addSeries("Series A.", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"}). |
| 124 |
addSeries("Series B.", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}). |
| 125 |
setDir("rtl"). |
| 126 |
render(); |
| 127 |
|
| 128 |
chart4 = new dojox.charting.Chart("test4", {textDir:"rtl"}). |
| 129 |
addAxis("x", { |
| 130 |
fixLower: "major", fixUpper: "major", includeZero: true, |
| 131 |
labels: [ |
| 132 |
{value: 0, text: "\u05e8\u05d0\u05e9\u05d5\u05df\u0020\u05e9\u05e0\u05d9\u0020\u05e9\u05dc\u05d9\u05e9\u05d9\u05e9"}, |
| 133 |
{value: 2, text: "second middle point"}, |
| 134 |
{value: 5, text: "1111111111111111111111111111\u05d0."} |
| 135 |
], |
| 136 |
maxLabelCharCount: 20, |
| 137 |
maxLabelSize: 30 |
| 138 |
}). |
| 139 |
addAxis("y", { |
| 140 |
vertical: true, fixLower: "major", fixUpper: "major", natural: true, majorTickStep: 2, |
| 141 |
labels: [{value: 0, text: ""}, |
| 142 |
{value: 1, text: "\u05d9\u05e0\u05d5\u05d0\u05e8"}, {value: 2, text: "February"}, |
| 143 |
{value: 3, text: "March"}, {value: 4, text: "\u05d0\u05e4\u05e8\u05d9\u05dc."}, |
| 144 |
{value: 5, text: "May"}, {value: 6, text: "June"} |
| 145 |
], |
| 146 |
maxLabelCharCount: 2, |
| 147 |
maxLabelSize: 40 |
| 148 |
}). |
| 149 |
addPlot("default", {type: "Areas"}). |
| 150 |
addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"}). |
| 151 |
addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}). |
| 152 |
setDir("rtl"). |
| 153 |
render(); |
| 154 |
}; |
| 155 |
|
| 156 |
dojo.addOnLoad(function(){ |
| 157 |
makeObjects(); |
| 158 |
|
| 159 |
doh.register("test textDir", [ |
| 160 |
{ |
| 161 |
name: "Pies textDir", |
| 162 |
|
| 163 |
runTest: function(){ |
| 164 |
doh.is("auto", chart1.textDir, "textDir of : chart1"); |
| 165 |
doh.is("ltr", chart2.textDir, "textDir of : chart2"); |
| 166 |
doh.is("ltr", chart3.textDir, "textDir of : chart3"); |
| 167 |
doh.is("rtl", chart4.textDir, "textDir of : chart4"); |
| 168 |
|
| 169 |
var node = dojo.byId("chart5"); |
| 170 |
var chart5 = dijit.byNode(node); |
| 171 |
doh.is("auto", chart5.textDir, "textDir of : chart4"); |
| 172 |
|
| 173 |
} |
| 174 |
} |
| 175 |
]); |
| 176 |
|
| 177 |
doh.run(); |
| 178 |
}); |
| 179 |
|
| 180 |
</script> |
| 181 |
</head> |
| 182 |
<body class="claro"> |
| 183 |
<h1>Chart 2D labels shortening</h1> |
| 184 |
<h2>Hover on the truncated label(end with default trailing Symbol: "..." or your customized trailing symbols) you will see the whole label on tooltip</h2> |
| 185 |
<h2>1: Label shortening.(x axis customized trailing Symbol) |
| 186 |
textDir = auto</h2> |
| 187 |
<div id="test1" style="width: 300px; height: 200px;"></div> |
| 188 |
<h2>2: Label shortening with rotation |
| 189 |
textDir inherited.</h2> |
| 190 |
<div id="test2" style="width: 300px; height: 200px;"></div> |
| 191 |
<h2>3: Label shortening with limited character.(y axis customized trailing Symbol) |
| 192 |
textDir inherited</h2> |
| 193 |
<div id="test3" style="width: 300px; height: 200px;"></div> |
| 194 |
<h2>4: Label shortening with both limited character and limited length in px |
| 195 |
textDir = rtl.</h2> |
| 196 |
<div id="test4" style="width: 300px; height: 200px;"></div> |
| 197 |
<h2>5: Label shortening for HTML declared chart |
| 198 |
textDir = auto.</h2> |
| 199 |
<div dojoType="dojox.data.HtmlStore" dataId="tableExample" data-dojo-id="tableStore"></div> |
| 200 |
<table id="tableExample" style="display: none;"> |
| 201 |
<thead> |
| 202 |
<tr><th>value</th></tr> |
| 203 |
</thead> |
| 204 |
<tbody> |
| 205 |
<tr><td>350</td></tr> |
| 206 |
<tr><td>275</td></tr> |
| 207 |
<tr><td>350 </td></tr> |
| 208 |
<tr><td>400</td></tr> |
| 209 |
<tr><td>250</td></tr> |
| 210 |
<tr><td>350</td></tr> |
| 211 |
<tr><td>200 </td></tr> |
| 212 |
</tbody> |
| 213 |
</table> |
| 214 |
<table border="0" cellspacing="30"> |
| 215 |
<tr> |
| 216 |
<td> |
| 217 |
<div dojoType="dojox.charting.widget.Chart" id="chart5" textDir="auto" style="width: 500px; height: 500px;" direction="rtl"> |
| 218 |
<div class="axis" name="x" maxLabelCharCount= 2 title="קוראים לי ציר X." titleOrientation= "away" font="italic normal normal 8pt Tahoma" labels="[{value:1, text:'First.'},{value:2, text:'שתיים שלוש.'},{value:4, text:'111111111ת.'}]"></div> |
| 219 |
<div class="axis" name="y" maxLabelCharCount= 2 title="קוראים לי ציר Y." vertical="true" fixUpper="major" includeZero="true" |
| 220 |
font="italic normal normal 8pt Tahoma"></div> |
| 221 |
<div class="plot" name="default" type="Areas"></div> |
| 222 |
<div class="plot" name="grid" type="Grid"></div> |
| 223 |
<div class="series" name="סדרה 1." data="100, 200, 50, 15, 100, 28, 40"></div> |
| 224 |
<div class="series" name="Run B." array="seriesB" ></div> |
| 225 |
<div class="series" name="Run C." store="tableStore" valueFn="Number(x)"></div> |
| 226 |
</div> |
| 227 |
<div dojoType="dojox.charting.widget.Legend" chartRef="chart5"></div> |
| 228 |
</td> |
| 229 |
</tr> |
| 230 |
</table> |
| 231 |
|
| 232 |
<p>That's all Folks!</p> |
| 233 |
</body> |
| 234 |
</html> |