From c6a0ebbac1ac1454b2d633e6623eef7e1913f5e1 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Wed, 2 Mar 2011 18:37:41 -0500 Subject: [PATCH] csv format does not work --- tests/independent-series.html | 93 ++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/tests/independent-series.html b/tests/independent-series.html index ad03574..e3ae8a4 100644 --- a/tests/independent-series.html +++ b/tests/independent-series.html @@ -31,7 +31,7 @@

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:

@@ -39,16 +39,16 @@ - - + +
xA
22
44
66
46
64
- - + +
xB
13
35
57
37
55
@@ -60,20 +60,20 @@
X,A,B
 1,,3
 2,2,
-3,,5
-4,4,
-5,,7
-6,6,
+3,,7 +4,6, +5,,5 +6,4, (native)
[
 [1, null, 3],
 [2, 2, null],
-[3, null, 5],
-[4, 4, null],
-[5, null, 7],
-[6, 6, null] ]
+[3, null, 7], +[4, 6, null], +[5, null, 5], +[6, 4, null] ] @@ -83,19 +83,22 @@ [ [1, null, 3], [2, 2, null], - [3, null, 5], - [4, 4, null], - [5, null, 7], - [6, 6, null] + [3, null, 7], + [4, 5, null], + [5, null, 5], + [6, 3, null] ], { labels: ["x", "A", "B" ], - connectSeparatedPoints: true + connectSeparatedPoints: true, + drawPoints: true } ); -

There's one extra wrinkle. What if one of the series has a missing value, i.e. what if your series are something like +

Encoding a gap

+

There's one extra wrinkle. What if one of the series has a missing + value, i.e. what if your series are something like

@@ -119,28 +122,54 @@
-
+

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.

+ + + +
+ (CSV) +
x,A,B
+1,,3
+2,2,
+3,,5
+4,4,
+5,,7
+6,NaN,
+8,8,
+10,10,
+
+ (native) +
[ [1, null, 3],
+  [2, 2, null],
+  [3, null, 5],
+  [4, 4, null],
+  [5, null, 7],
+  [6, NaN, null],
+  [8, 8, null],
+  [10, 10, null] ]
+
+ -- 2.7.4