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>Encoding a gap
</h3>
105 <p>There's one extra wrinkle. What if one of the series has a missing
106 value, i.e. what if your series are something like
</p>
111 <table class=thinborder
>
112 <tr><th>x
</th><th>A
</th></tr>
113 <tr><td>2</td><td>2</td></tr>
114 <tr><td>4</td><td>4</td></tr>
115 <tr><td>6</td><td>(gap)
</td></tr>
116 <tr><td>8</td><td>8</td></tr>
117 <tr><td>10</td><td>10</td></tr>
120 <td valign=top
style=
"padding-left:25px;">
121 <table class=thinborder
>
122 <tr><th>x
</th><th>B
</th></tr>
123 <tr><td>1</td><td>3</td></tr>
124 <tr><td>3</td><td>5</td></tr>
125 <tr><td>5</td><td>7</td></tr>
130 <div id=
"graph2" style=
"float: right; margin-right: 50px; width: 400px; height: 300px;"></div>
131 <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>
133 <script type=
"text/javascript">
135 document.getElementById(
"graph2"),
146 connectSeparatedPoints: true,
165 <td valign=top
style=
"padding-left: 25px;">
174 [
10,
10, null] ]
</pre>