From 75c589da9e8e764d354a24c9c7640733e7f036e9 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Wed, 2 Mar 2011 18:26:47 -0500 Subject: [PATCH] demonstration of independent series w/ NaN --- tests/independent-series.html | 146 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 tests/independent-series.html diff --git a/tests/independent-series.html b/tests/independent-series.html new file mode 100644 index 0000000..ad03574 --- /dev/null +++ b/tests/independent-series.html @@ -0,0 +1,146 @@ + + + Independent Series + + + + + + + + +

By using the connectSeparated attribute, it's possible to display a chart of several time series with completely independent x-values.

+ +

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 null for each of the other series.

+ +
+

For example, say you had two series:

+ + + +
+ +
+ + + + +
xA
22
44
66
+
+ + + + + +
xB
13
35
57
+
+ +

Then you would specify the following CSV or native data:

+ + + +
+ (CSV) +
X,A,B
+1,,3
+2,2,
+3,,5
+4,4,
+5,,7
+6,6,
+
+ (native) +
[
+[1, null, 3],
+[2, 2, null],
+[3, null, 5],
+[4, 4, null],
+[5, null, 7],
+[6, 6, null] ]
+
+ + + +

There's one extra wrinkle. What if one of the series has a missing value, i.e. what if your series are something like + + + + +
+ +
+ + + + + + +
xA
22
44
6(gap)
88
1010
+
+ + + + + +
xB
13
35
57
+
+ +

+

The gap would normally be encoded as a null, or missing value. But when you use connectSeparatedPoints, that has a special meaning. Instead, you have to use NaN. This is a bit of a hack, but it gets the job done.

+ + + + + -- 2.7.4