4 <meta http-equiv=
"X-UA-Compatible" content=
"IE=EmulateIE7; IE=EmulateIE9">
5 <title>labelsKMB
</title>
7 <script type=
"text/javascript" src=
"../excanvas.js"></script>
9 <script type=
"text/javascript" src=
"../strftime/strftime-min.js"></script>
10 <script type=
"text/javascript" src=
"../rgbcolor/rgbcolor.js"></script>
11 <script type=
"text/javascript" src=
"../dygraph-canvas.js"></script>
12 <script type=
"text/javascript" src=
"../dygraph.js"></script>
16 <div id=
"labelsKMB" style=
"width:600px; height: 300px;"></div>
19 <div id=
"labelsKMG2" style=
"width:600px; height: 300px;"></div>
21 <p>labelsKMG2 with yValueFormatter:
</p>
22 <div id=
"labelsKMG2yValueFormatter" style=
"width:600px; height: 300px;"></div>
24 <p>The curves are exponentials. Zooming in should reveal each of the 'K',
25 'M', 'B', etc. labels.
</p>
27 <script type=
"text/javascript">
28 function round(num, places) {
29 var shift = Math.pow(
10, places);
30 return Math.round(num * shift)/shift;
34 for (var i =
0, n =
1; i <
43; i++, n *=
2) {
38 var suffixes = ['', 'k', 'M', 'G', 'T'];
39 function formatValue(v) {
40 if (v <
1000) return v;
42 var magnitude = Math.floor(String(Math.floor(v)).length /
3);
43 if (magnitude
> suffixes.length -
1)
44 magnitude = suffixes.length -
1;
45 return String(round(v / Math.pow(
10, magnitude *
3),
2)) +
49 new Dygraph(document.getElementById(
"labelsKMB"), data, { labelsKMB: true });
50 new Dygraph(document.getElementById(
"labelsKMG2"), data, { labelsKMG2: true });
51 var g = new Dygraph(document.getElementById(
"labelsKMG2yValueFormatter"), data,
52 { labelsKMG2: true, yValueFormatter: formatValue });