The problem you're encountering is because of time zone issues. All the dates will be offset by whatever your timezone offset to UTC is. To avoid this, don't rely on
new Date() to create
Date objects from your strings, but parse them explicitly. D3 provides a function to do this:
var parse = d3.time.format("%Y-%m-%d").parse;
Then you can parse like this:
Complete jsfiddle here.
- D3.js - Date ticks don't align with data path - offset to the right
- Creating a Path with The Right Numbers
- D3Js line graphs - align data points with ticks
- Bar chart: how could I align the data with countries when sorting in D3 v5?
- d3.js: Align text labels between ticks on the axis
- Is D3.js the right choice for real-time visualization of Neo4j Graph DB data
- D3 linechart, can't edit the amount of ticks with an ordinal scale?
- nvd3.js : unable to bind onClick event with the data points in the svg
- Join existing elements of the DOM to data with d3.js
- Data points and ticks in the scaleBand axis are not aligned
- x-axis dates don't align with y-axis data in nvd3
- Display only values from the data set into X axis ticks
- Date and time transition from data with line
- D3.js: Zooming the x-axis and data with mouse wheel scroll
- d3 multiline update path and transition path does not work with nested data
- Draw a map with D3.js: How to get the right scale() and translate()?
- d3 show labels only for ticks with data in a bar chart
- Mapping a relative path import to the right `@types` in Typescript
- Specifying Ticks on D3 Bar chart with Time Series data and scaleBand
- D3.js: plot dots on the existing line in a multiseries line chart with long formatted data
- Unable to reference d3.js data imported from a csv file with spaces in the header
- How to get SVG path data of TopoJSON feature without adding it to the DOM?
- Updating data values with HTML input and changing the data array
- Given a range of date intervals, create an array of all 1440 minutes in a day with the frequency each minute appears in the source intervals
- D3 How to update the chart after selection from drop down menu with new data
- Adding a new path when the updated data has additional sections
- Create a bar chart with local storage data (drawing the bars doesn't work)
- Load and display data with condition, but the condition is not met
- Multiline chart x-axis ticks not aligned with data points
More Query from same tag
- D3.js line plot pandas dataframe JSON
- d3.js add second label to bar chart
- D3 time scales being split onto two lines
- d3js v7, the circle moves in the opposite direction in y coordinate when I drag the circle by the cursor
- How to pass variable value into script tag in ejs file?
- Running D3 in node.js, what am I missing?
- Stop div element from auto resize with image
- How to print in console from d3 function
- Creating axis from array of strings in D3?
- Linear + threshold unified scale
- D3 Radial Tree with Tooltip?
- d3.js Line chart tooltip content not showing
- svg rect image is not displayed on firefox
- Hover on <p> element to highlight geographic boundary, D3 Choropleth
- How can I fill gaps in a dc.js series chart?
- setTimeout in D3.js
- Need assistance with adding text into nodes in codeflower graph via D3.js
- Dispatching drag-end event
- Customized chart using d3 in react native
- Call axis function causing problems D3
- How to display two (or more) different measures on a map?
- How to display property text on mouseover in d3 map
- d3.select(this) is not selecting the rect
- Marimekko chart cell titles not updating
- d3js create a force layout with fixed nodes
- d3.js Hierarchical Edge Bundling node color change on click
- How to render links as elbow connectors in d3 force directed graph
- Filtering json data D3.js
- creating a line chart using C3
- How do I use the d3 selection/join methods to change a line graph?