Cole Ogrodnick
Cole Ogrodnick

Reputation: 134

How to graph dates on X axis while skipping weekends d3.js?

I am trying to plot stock data with a d3 line Chart. It has ugly spaces for weekends because there is no data available for weekends. What is the best way to make the X axis chart only the dates that I have data for?

const x = d3
      .scaleTime()
      .domain(d3.extent(data, (d) => d.datetime))
      .range([0, width]);

d3 newbie experiencing a heavy learning curve at the moment.

Upvotes: 0

Views: 503

Answers (1)

Cole Ogrodnick
Cole Ogrodnick

Reputation: 134

For anyone who may have the same question:

const x = d3
      .scaleBand()
      .domain(data.map((d) => d.datetime))
      .range([0, width]);

Band scale graphs only the dates you have data for.

Upvotes: 1

Related Questions