3 <title>labelsKMB
</title>
5 <script type=
"text/javascript" src=
"excanvas.js"></script>
7 <script type=
"text/javascript" src=
"../strftime/strftime-min.js"></script>
8 <script type=
"text/javascript" src=
"../rgbcolor/rgbcolor.js"></script>
9 <script type=
"text/javascript" src=
"../dygraph-canvas.js"></script>
10 <script type=
"text/javascript" src=
"../dygraph.js"></script>
14 <div id=
"labelsKMB" style=
"width:600px; height: 300px;"></div>
17 <div id=
"labelsKMG2" style=
"width:600px; height: 300px;"></div>
19 <p>labelsKMG2 with yValueFormatter:
</p>
20 <div id=
"labelsKMG2yValueFormatter" style=
"width:600px; height: 300px;"></div>
22 <p>The curves are exponentials. Zooming in should reveal each of the 'K',
23 'M', 'B', etc. labels.
</p>
25 <script type=
"text/javascript">
26 function round(num, places) {
27 var shift = Math.pow(
10, places);
28 return Math.round(num * shift)/shift;
32 for (var i =
0, n =
1; i <
43; i++, n *=
2) {
36 var suffixes = ['', 'k', 'M', 'G', 'T'];
37 function formatValue(v) {
38 if (v <
1000) return v;
40 var magnitude = Math.floor(String(Math.floor(v)).length /
3);
41 if (magnitude
> suffixes.length -
1)
42 magnitude = suffixes.length -
1;
43 return String(round(v / Math.pow(
10, magnitude *
3),
2)) +
47 new Dygraph(document.getElementById(
"labelsKMB"), data, { labelsKMB: true });
48 new Dygraph(document.getElementById(
"labelsKMG2"), data, { labelsKMG2: true });
49 var g = new Dygraph(document.getElementById(
"labelsKMG2yValueFormatter"), data,
50 { labelsKMG2: true, yValueFormatter: formatValue });