4 <link rel=
"stylesheet" href=
"../css/dygraph.css">
5 <title>Independent Series
</title>
7 For production (minified) code, use:
8 <script type=
"text/javascript" src=
"dygraph-combined.js"></script>
10 <script type=
"text/javascript" src=
"../dist/dygraph.js"></script>
12 <style type=
"text/css">
18 border-collapse: collapse;
31 <h3>Independent Series
</h3>
32 <p>By using the connectSeparated attribute, it's possible to display a chart of several time series with completely independent x-values.
</p>
34 <p>The trick is to specify values for the series at the union of the x-values of all series. For one series' x values, specify
<code>null
</code> for each of the other series.
</p>
36 <div id=
"graph" style=
"float: right; margin-right: 50px; width: 400px; height: 300px;"></div>
37 <p>For example, say you had two series:
</p>
41 <table class=thinborder
>
42 <tr><th>x
</th><th>A
</th></tr>
43 <tr><td>2</td><td>2</td></tr>
44 <tr><td>4</td><td>6</td></tr>
45 <tr><td>6</td><td>4</td></tr>
48 <td valign=top
style=
"padding-left:25px;">
49 <table class=thinborder
>
50 <tr><th>x
</th><th>B
</th></tr>
51 <tr><td>1</td><td>3</td></tr>
52 <tr><td>3</td><td>7</td></tr>
53 <tr><td>5</td><td>5</td></tr>
58 <p>Then you would specify the following CSV or native data:
</p>
70 <td valign=top
style=
"padding-left: 25px;">
82 <script type=
"text/javascript">
84 document.getElementById(
"graph"),
94 labels: [
"x",
"A",
"B" ],
95 connectSeparatedPoints: true,
101 <h3>Encoding a gap
</h3>
102 <p>There's one extra wrinkle. What if one of the series has a missing
103 value, i.e. what if your series are something like
</p>
108 <table class=thinborder
>
109 <tr><th>x
</th><th>A
</th></tr>
110 <tr><td>2</td><td>2</td></tr>
111 <tr><td>4</td><td>4</td></tr>
112 <tr><td>6</td><td>(gap)
</td></tr>
113 <tr><td>8</td><td>8</td></tr>
114 <tr><td>10</td><td>10</td></tr>
117 <td valign=top
style=
"padding-left:25px;">
118 <table class=thinborder
>
119 <tr><th>x
</th><th>B
</th></tr>
120 <tr><td>1</td><td>3</td></tr>
121 <tr><td>3</td><td>5</td></tr>
122 <tr><td>5</td><td>7</td></tr>
127 <div id=
"graph3" style=
"float: right; margin-right: 50px; width: 400px; height: 300px;"></div>
128 <p>The gap would normally be encoded as a null, or missing value. But when you use
<code>connectSeparatedPoints
</code>, that has a special meaning. Instead, you have to use
<code>NaN
</code>. This is a bit of a hack, but it gets the job done.
</p>
130 <script type=
"text/javascript">
132 document.getElementById(
"graph3"),
143 connectSeparatedPoints: true,
162 <td valign=top
style=
"padding-left: 25px;">
171 [
10,
10, null] ]
</pre>
175 <h3>Behavior at the edges of the panel for independent series
</h3>
176 <p> In case only a part of the whole data is visible (e.g. after zooming in) the lines are
177 drawn to the respective next valid point outside the visible area.
</p>
182 <table class=thinborder
>
183 <tr><th>x
</th><th>A
</th></tr>
184 <tr><td>0</td><td>2</td></tr>
185 <tr><td>1</td><td>3</td></tr>
186 <tr><td>2</td><td>3</td></tr>
187 <tr><td>4</td><td>4</td></tr>
188 <tr><td>5</td><td>3</td></tr>
189 <tr><td>6</td><td>3</td></tr>
190 <tr><td>7</td><td>3</td></tr>
191 <tr><td>8</td><td>4</td></tr>
194 <td valign=top
style=
"padding-left:25px;">
195 <table class=thinborder
>
196 <tr><th>x
</th><th>B
</th></tr>
197 <tr><td>0</td><td>1</td></tr>
198 <tr><td>1</td><td>2</td></tr>
199 <tr><td>2</td><td>1</td></tr>
200 <tr><td>8</td><td>2</td></tr>
205 <div id=
"graph2" style=
"float: right; margin-right: 50px; width: 400px; height: 300px;"></div>
206 <p>Both graphs have no value at the right edge of the panel (x=
3). The lines that are drawn to the right edge are determined by their respective next valid value outside the visible area.
207 Therefore it is neither necessary that the next valid values are on the same point nor that they have the same index (index
4 for the green line and index
8 for the blue line).
</p>
208 <p>Use double click to unzoom and see the currently invisible points
</p>
210 <script type=
"text/javascript">
212 document.getElementById(
"graph2"),
225 connectSeparatedPoints: true,
228 highlightCircleSize:
5,
261 <td valign=top
style=
"padding-left: 25px;">