Reputation: 2347
I'm using Google Charts to show some timeseries data like that shown below. Typically the data has a high proportion of zero values so you get lots of points sitting along the x-axis. I think this makes the chart look cluttered and I'd like to not show points where y=0.
Any ideas / pointers much appreciated.
Thanks,
ct
Upvotes: 10
Views: 18163
Reputation: 436
The best option is to use null instead of 0 (there will be missing points). And then you can use option interpolateNulls which will join the values.
Upvotes: 8
Reputation: 495
If you don't want it to have all the points between the real values you can completely remove the values from your data. Keep the first 0 point right after the value and 0 point right before you have values again.
This:
[1000, 12],
[1001, 16],
[1002, 0],
[1003, 0],
[1004, 0],
[1005, 0],
[1006, 4],
[1007, 2],
[1008, 0],
[1009, 14]
Becomes:
[1000, 12],
[1001, 16],
[1002, 0],
[1005, 0],
[1006, 4],
[1007, 2],
[1008, 0],
[1009, 14]
This should only show a zero point at 1002 and one at 1005 and a line with no points between them.
Upvotes: 0
Reputation: 5808
Set your data to null
instead of 0
. However in the example chart you have shown if the first value is say 5
and the 2nd to 20th are 0
set the 2nd and 20th to 0
and the 3rd to 19th to null
. This will display the chart correctly.
Upvotes: 5