4 <meta http-equiv=
"X-UA-Compatible" content=
"IE=EmulateIE7; IE=EmulateIE9">
5 <title>dygraphs per-series and per-axis options
</title>
6 <style type=
"text/css">
7 code { white-space: pre; border:
1px dashed black; display: block; }
8 pre { white-space: pre; border:
1px dashed black; }
9 body { max-width:
800px; }
13 <h2>dygraphs per-series and per-axis options
</h2>
15 <p>When you create a Dygraph object, your code looks something like
19 g = new Dygraph(document.getElementById(
"div"),
24 <p>This document is about some of the values you can put in the
25 <i>options
</i> parameter.
</p>
27 <h3>per-series options
</h3>
29 <p>Typically, an option applies to the whole chart: if you set the
30 strokeWidth option, it will apply to all data-series equally:
</p>
33 g = new Dygraph(document.getElementById(
"div"),
42 <p>Some options, however, can be applied on a per-series or a per-axis
43 basis. For instance, to set three different strokeWidths, you could
47 g = new Dygraph(document.getElementById(
"div"),
52 strokeWidth:
5, // default stroke width
54 strokeWidth:
3 // Y1 gets a special value.
57 strokeWidth:
1 // so does Y3.
62 <p>The result of these options is that Y1 will have a strokeWidth of
1, Y2 will have a strokeWidth of
5 and Y3 will have a strokeWidth of
1. You can see a demonstration of this
<a href='tests/per-series.html'
>here
</a>.
</p>
64 <h3>per-axis options
</h3>
66 <p>Some options make more sense when applied to an entire axis, rather than to individual series. For instance, the axisLabelFormatter option lets you specify a function for format the labels on axis tick marks for display. You might want one function for the x-axis and another one for the y-axis.
</p>
68 <p>Here's how you can do that:
</p>
71 g = new Dygraph(document.getElementById(
"div"),
78 axisLabelFormatter: function(x) {
83 axisLabelFormatter: function(y) {
91 <p>The keys in the 'axes' option are always 'x', 'y' and, if you have a
92 secondary y-axis, 'y2'. If you set the
"axisLabelFormatter" option at the
93 top level, it will apply to all axes.
</p>
95 <p>To see this in practice, check out the
<a
96 href=
"tests/two-axes.html">two-axes
</a> test.
</p>
98 <!-- Google Analytics --
>
99 <script type=
"text/javascript">
100 var _gaq = _gaq || [];
101 _gaq.push(['_setAccount', 'UA-
769809-
2']);
102 _gaq.push(['_trackPageview']);
104 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
105 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
106 var s = document.getElementsByTagName('script')[
0]; s.parentNode.insertBefore(ga, s);