1

I have data like this:

document: [{"key":"01/01/2001","values":2},
 {"key":"02/01/2001","values":1},
 {"key":"31/01/2001","values":2}]

I am creating an area chart with .interpolate("linear") to create the following: The idea being to represent number of documents "created" throughout January.

enter image description here

However, this is kind of a misleading output as it would imply there are values throughout January, when there aren't just 2 at the start and one at the end.

My questions are:

  1. Fundamentally is this the wrong graph to represent this data, and should a bar chart be used instead?
  2. Can D3 add evenly spaced "zero" values for each day in January?
  3. Is the best we can do is use .interpolate("cardinal") to produce something like:

enter image description here

Thanks in advance!

ukmikeb
  • 303
  • 1
  • 3
  • 15
  • Is your data that granular for all of the months, or just in this one instance? Picking a plot type requires knowing about what the whole dataset looks like. – roippi Jul 18 '13 at 16:35
  • possible duplicate of [How to handle layers with missing data points in d3.layout.stack()](http://stackoverflow.com/questions/14713503/how-to-handle-layers-with-missing-data-points-in-d3-layout-stack). See also the comments on [this question](http://stackoverflow.com/questions/17415406/filling-the-gaps-in-d3-array-nesting) – explunit Jul 18 '13 at 16:41
  • The data could be irregularly spaced over days, months years... I want to show where there is no data, as zero... because there would be no documents "created" at that point. – ukmikeb Jul 18 '13 at 16:52

1 Answers1

2

I think the answer from this other SO post gives a usable answer, reposting it here so that this is not a dead-end for visitors coming from Google and finding this post first (as I did).

d3 linechart - Show 0 on the y-axis without passing in all points?

Community
  • 1
  • 1
cheepychappy
  • 468
  • 3
  • 12