While creating a D3 Area Chart, I noticed that my X Axis tick marks are off shifted the the right just slightly:
For my code, I generate the xAxis like:
const x = d3.scaleTime()
.domain(d3.extent(data, d => Date.parse(d.date)))
.range([margin.left, width - margin.right]);
const xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3
.axisBottom(x)
.tickValues(data.map(d => {
return timeParse(d.date);
}))
.tickFormat(timeFormat)
.tickSizeOuter(0)
)
svg.append("g")
.call(xAxis);
Not sure what I am doing wrong that is causing the tick marks to be slightly shifted to the right. If I don't include the .tickSizeOuter(0)
part, the start and end tick marks look to be in normal spots but the data point ticks are still off.
How can I adjust these to be in the correct spot?
EDIT
Here is my data for this graph:
data = [
{date: "2019-02-01", value: 100},
{date: "2019-03-01", value: 1}]
]
And here is the timeParse
var:
var timeParse = d3.timeParse("%Y-%m-%d");