blasrodri
blasrodri

Reputation: 446

D3 x axis not showing all data

I am trying to perform a visualisation using D3's bar chart graph. Unfortunately, I am having some trouble to get it running as I expect.

Here's a link to what I am seeing: Block Example

  1. I would like to get a range of data from 2012 until the end of 2017 in the x-axis (even if the data point is zero).
  2. Have a label for each tick. Currently, the x axis has labels only for a few.

Upvotes: 1

Views: 678

Answers (1)

Gerardo Furtado
Gerardo Furtado

Reputation: 102198

For whatever reason, you are overriding the previously set domain for the x scale, which is the one you want (going from 2012 to 2018).

Thus, simply remove this line:

x.domain(data.map(function(d) { return timeFormatter(d.Date); }));

Here is your updated bl.ocks: https://bl.ocks.org/anonymous/be8f59fa47b9ca274934e377ac3d899a

Upvotes: 1

Related Questions