Debian Codegraph @

dojox/charting/tests/test_label_shortening.html

raw symbols SCIP
1 <!--[if IE 7]>
2 <!DOCTYPE>
3 <html lang="en">
4 <head>
5 <![endif]-->
6 <!--[if IE 8]>
7 <!DOCTYPE>
8 <html lang="en">
9 <head>
10 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
11 <![endif]-->
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"></script>
25 <script type="text/javascript">
26
27 dojo.require("dojox.charting.Chart");
28 dojo.require("dojox.charting.axis2d.Default");
29 dojo.require("dojox.charting.plot2d.Bars");
30 dojo.require("dojox.charting.plot2d.Columns");
31 dojo.require("dojox.charting.plot2d.Lines");
32 dojo.require("dojox.charting.plot2d.Areas");
33
34 makeObjects = function(){
35
36 var chart1 = new dojox.charting.Chart("test1").
37 addAxis("x", {
38 fixLower: "major", fixUpper: "major", includeZero: true,
39 labels: [
40 {value: 0, text: "first start point"},
41 {value: 2, text: "two"},
42 {value: 5, text: "last end point"}
43 ],
44 maxLabelSize: 20,
45 trailingSymbol: "."
46 }).
47 addAxis("y", {
48 vertical: true, fixLower: "major", fixUpper: "major", natural: true,
49 labels: [{value: 0, text: ""},
50 {value: 1, text: "January"}, {value: 2, text: "February"},
51 {value: 3, text: "March"}, {value: 4, text: "April"},
52 {value: 5, text: "May"}, {value: 6, text: "June"}
53 ],
54 maxLabelSize: 20
55 }).
56 addPlot("default", {type: "Bars"}).
57 addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"}).
58 addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}).
59 render();
60
61 var chart2 = new dojox.charting.Chart("test2").
62 addAxis("x", {
63 fixLower: "major", fixUpper: "major", includeZero: true,
64 labels: [
65 {value: 0, text: "first start point"},
66 {value: 2, text: "two"},
67 {value: 5, text: "last end point"}
68 ],
69 rotation: 180,
70 maxLabelSize: 30
71 }).
72 addAxis("y", {
73 vertical: true, fixLower: "major", fixUpper: "major", natural: true, majorTickStep: 2,
74 labels: [{value: 0, text: ""},
75 {value: 1, text: "January"}, {value: 2, text: "February"},
76 {value: 3, text: "March"}, {value: 4, text: "April"},
77 {value: 5, text: "May"}, {value: 6, text: "June"}
78 ],
79 rotation: -30,
80 maxLabelSize: 20
81 }).
82 addPlot("default", {type: "Columns"}).
83 addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"}).
84 addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}).
85 render();
86
87 var chart3 = new dojox.charting.Chart("test3").
88 addAxis("x", {
89 fixLower: "major", fixUpper: "major", includeZero: true,
90 labels: [
91 {value: 0, text: "first start point"},
92 {value: 2, text: "two"},
93 {value: 5, text: "last end point"}
94 ],
95 maxLabelCharCount: 5
96 }).
97 addAxis("y", {
98 vertical: true, fixLower: "major", fixUpper: "major", natural: true, majorTickStep: 2,
99 labels: [{value: 0, text: ""},
100 {value: 1, text: "January"}, {value: 2, text: "February"},
101 {value: 3, text: "March"}, {value: 4, text: "April"},
102 {value: 5, text: "May"}, {value: 6, text: "June"}
103 ],
104 maxLabelCharCount: 2,
105 trailingSymbol: "__"
106 }).
107 addPlot("default", {type: "Lines"}).
108 addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"}).
109 addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}).
110 render();
111
112 var chart4 = new dojox.charting.Chart("test4").
113 addAxis("x", {
114 fixLower: "major", fixUpper: "major", includeZero: true,
115 labels: [
116 {value: 0, text: "first start point"},
117 {value: 2, text: "second middle point"},
118 {value: 5, text: "last end point"}
119 ],
120 maxLabelCharCount: 20,
121 maxLabelSize: 30
122 }).
123 addAxis("y", {
124 vertical: true, fixLower: "major", fixUpper: "major", natural: true, majorTickStep: 2,
125 labels: [{value: 0, text: ""},
126 {value: 1, text: "January"}, {value: 2, text: "February"},
127 {value: 3, text: "March"}, {value: 4, text: "April"},
128 {value: 5, text: "May"}, {value: 6, text: "June"}
129 ],
130 maxLabelCharCount: 2,
131 maxLabelSize: 40
132 }).
133 addPlot("default", {type: "Areas"}).
134 addSeries("Series A", [1, 2, 3, 4, 5], {stroke: {color: "red"}, fill: "lightpink"}).
135 addSeries("Series B", [5, 4, 3, 2, 1], {stroke: {color: "blue"}, fill: "lightblue"}).
136 render();
137 };
138
139 dojo.addOnLoad(makeObjects);
140
141 </script>
142 </head>
143 <body class="claro">
144 <h1>Chart 2D labels shortening</h1>
145 <p>Hover on the truncated label(end with default trailing Symbol: "..." or your customized trailing symbols) you will see the whole label on tooltip</p>
146 <p>1: Label shortening.(x axis customized trailing Symbol)</p>
147 <div id="test1" style="width: 300px; height: 200px;"></div>
148 <p>2: Label shortening with rotation.</p>
149 <div id="test2" style="width: 300px; height: 200px;"></div>
150 <p>3: Label shortening with limited character.(y axis customized trailing Symbol)</p>
151 <div id="test3" style="width: 300px; height: 200px;"></div>
152 <p>4: Label shortening with both limited character and limited length in px.</p>
153 <div id="test4" style="width: 300px; height: 200px;"></div>
154 <p>That's all Folks!</p>
155 </body>
156 </html>