4 <meta http-equiv=
"X-UA-Compatible" content=
"IE=EmulateIE7; IE=EmulateIE9">
5 <title>Independent Series
</title>
7 <script type=
"text/javascript" src=
"../excanvas.js"></script>
10 For production (minified) code, use:
11 <script type=
"text/javascript" src=
"dygraph-combined.js"></script>
13 <script type=
"text/javascript" src=
"../dygraph-dev.js"></script>
15 <style type=
"text/css">
21 border-collapse: collapse;
34 <h3>Independent Series
</h3>
35 <p>By using the connectSeparated attribute, it's possible to display a chart of several time series with completely independent x-values.
</p>
37 <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>
39 <div id=
"graph" style=
"float: right; margin-right: 50px; width: 400px; height: 300px;"></div>
40 <p>For example, say you had two series:
</p>
44 <table class=thinborder
>
45 <tr><th>x
</th><th>A
</th></tr>
46 <tr><td>2</td><td>2</td></tr>
47 <tr><td>4</td><td>6</td></tr>
48 <tr><td>6</td><td>4</td></tr>
51 <td valign=top
style=
"padding-left:25px;">
52 <table class=thinborder
>
53 <tr><th>x
</th><th>B
</th></tr>
54 <tr><td>1</td><td>3</td></tr>
55 <tr><td>3</td><td>7</td></tr>
56 <tr><td>5</td><td>5</td></tr>
61 <p>Then you would specify the following CSV or native data:
</p>
73 <td valign=top
style=
"padding-left: 25px;">
85 <script type=
"text/javascript">
87 document.getElementById(
"graph"),
97 labels: [
"x",
"A",
"B" ],
98 connectSeparatedPoints: true,
104 <h3>Behavior at the edges of the panel for independent series
</h3>
105 <p> In case only a part of the whole data is visible (e.g. after zooming in) the lines are
106 drawn to the respective next valid point outside the visible area.
</p>
111 <table class=thinborder
>
112 <tr><th>x
</th><th>A
</th></tr>
113 <tr><td>0</td><td>2</td></tr>
114 <tr><td>1</td><td>3</td></tr>
115 <tr><td>2</td><td>3</td></tr>
116 <tr><td>4</td><td>4</td></tr>
117 <tr><td>5</td><td>3</td></tr>
118 <tr><td>6</td><td>3</td></tr>
119 <tr><td>7</td><td>3</td></tr>
120 <tr><td>8</td><td>4</td></tr>
123 <td valign=top
style=
"padding-left:25px;">
124 <table class=thinborder
>
125 <tr><th>x
</th><th>B
</th></tr>
126 <tr><td>0</td><td>1</td></tr>
127 <tr><td>1</td><td>2</td></tr>
128 <tr><td>2</td><td>1</td></tr>
129 <tr><td>8</td><td>2</td></tr>
134 <div id=
"graph2" style=
"float: right; margin-right: 50px; width: 400px; height: 300px;"></div>
135 <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.
136 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>
137 <p>Use double click to unzoom and see the currently invisible points
</p>
139 <script type=
"text/javascript">
141 document.getElementById(
"graph2"),
154 connectSeparatedPoints: true,
157 highlightCircleSize:
5,
190 <td valign=top
style=
"padding-left: 25px;">
205 <h3>Encoding a gap
</h3>
206 <p>There's one extra wrinkle. What if one of the series has a missing
207 value, i.e. what if your series are something like
</p>
212 <table class=thinborder
>
213 <tr><th>x
</th><th>A
</th></tr>
214 <tr><td>2</td><td>2</td></tr>
215 <tr><td>4</td><td>4</td></tr>
216 <tr><td>6</td><td>(gap)
</td></tr>
217 <tr><td>8</td><td>8</td></tr>
218 <tr><td>10</td><td>10</td></tr>
221 <td valign=top
style=
"padding-left:25px;">
222 <table class=thinborder
>
223 <tr><th>x
</th><th>B
</th></tr>
224 <tr><td>1</td><td>3</td></tr>
225 <tr><td>3</td><td>5</td></tr>
226 <tr><td>5</td><td>7</td></tr>
231 <div id=
"graph3" style=
"float: right; margin-right: 50px; width: 400px; height: 300px;"></div>
232 <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>
234 <script type=
"text/javascript">
236 document.getElementById(
"graph3"),
247 connectSeparatedPoints: true,
266 <td valign=top
style=
"padding-left: 25px;">
275 [
10,
10, null] ]
</pre>