score:1
I'm not a D3 expert; heck I'm not even a D3 novice. It seems however that the library is paying attention to the fact that your timestamps are for a point between two day boundaries (midnight I guess). Thus the dots on the graph show up to the right of the day labels, because it's treating time as more-or-less continuous and not at the granularity of a single day.
score:0
Omigosh!! I ran into the same problem with d3 axes.
The previous answer led me to finding the answer that helped me. Thanks!!!!
The problem was that D3 was adding hours to dates without telling me. It defaulted the time to something like 8:00 every day instead of midnight.
Solution: Everywhere where I read a date into D3, I set the time with setHours(0,0,0,0).
Here's some example code:
svgContainer.selectAll(".dot") .data(spaceCircleData) .enter().append("circle") .attr("class", "dot") .attr("r", 3) .attr("cx", function(d) { return xAxisScale(new Date(d.date).setHours(0,0,0,0)) + horizMargin; }) .attr("cy", function(d) { return yAxisScale(d.amount) - vertMargin; });
Had I read all the data from 1 place, I would have changed this one the data.foreach.
score:1
your isuue is regarding the timzone problem...
I accept the fact of Timezone changes in your input ...
Incase still got problem in alignment
//offset to handle the Timezone priblem
var offset=(new Date().getTimezoneOffset()/60)+1;
This gives you the Offset of your timeZone..
(may be the calculation for offset chages check it out using log)
//Formatise the data
data.forEach(function(d) {
d.date =d3.time.hour.offset(new Date(d.date),offset);
});
this will formatise your date according to your timezone
Source: stackoverflow.com
Related Query
- How do I make D3 draw the axis from the start of a dataset?
- How can I make a bar chart starting from the 0 point of the y axis and not from the bottom of the svg?
- How to draw a path smoothly from start point to end point in D3.js
- D3 bubble chart / pack layout - How to make bubbles radiate out from the largest bubbles to the smallest?
- How to make the NVD3 discreteBarChart labels on the X axis to adapt to the width or to the number of labels?
- How to cut y axis to make the chart look better?
- d3.js appending two labels from a dataset on the Y axis
- How to transition from the start position in a loop?
- how to make the x axis scrollable in a d3 line chart graph
- nvD3 - multiBarChart - How to start from 0 and how to change the shape of controls
- In a d3 scatterplot using data from a csv file, how do i draw lines connecting related points when the mouse is over a point?
- How do I draw line from the outer most arc of the circle
- How to make axis "smart" and "flexible" so that the starting/end points on axis are sensible in D3 V4?
- How can I get the d3.js bar chart start from 0 instead of from the top
- How to make the distance from nodes in d3.js force layout larger?
- How to draw from the last radius finish
- How can I customize the label of X axis, that means the label in X axis is different from the data
- how to get the radial gradient to start from the centre of the pie chart?
- How do I assign ticks to be equal to a different key value from the same object from the one on which the axis is based on in D3.js?
- How to make bar chart with additional vertical lines below the x axis
- Unable to make pie chart from the dataset
- How do I prevent graph elements from reaching the axis of my graph in D3 and scale properly?
- How to create an y axis containing hours from noon to noon on the next day
- How to control the space between the start of a bar and the axis in a bar-chart constructed using d3?
- How do I select one group of values from dataset to plot a linechart using D3.js and not the whole dataset
- How Do I make this sunburst start with the inner ring consuming the entire diameter of the chart?
- How to make axis label of stacked bar chart in the middle of ticks chart in D3?
- d3 graph - How do I make the JS get the JSON from PHP script and then select axes and plot?
- How can I get the D3.js axis ticks and positions as an array?
- How to use the D3 diagonal function to draw curved lines?
More Query from same tag
- How to visualize an event timeline in D3?
- How to create d3 graph using data from Rails database
- change bootstrap button text before rendering d3 svg object
- d3.js - stacked graphs that are both zoomed in and out/scrolled when using scrollwheel/drag on either graph
- D3 axis origin changes as per its scales range
- Closure with D3.Transition.Each Callback
- How do you set a default focus() on an element
- Text and Rectangle not align
- Add a Toggle function to d3 tree chart v4
- How to add non linear curve between any two points of area chart in d3.js
- Insert SVG element before another SVG element with class
- Javascript Tooltip not showing up in box as defined by style
- How to override the dragging events in C3.js
- Building a Graph Editor - How to create a data driven graph
- D3 adding pie chart prevents sortability of bar chart
- dc.js: stacked barchart cant display
- Using Angular ng-class with d3.js on svg element
- D3 lineRadial - what is the math behind this?
- Animated SVG prevents D3 from transitioning `top` style of separate divs in iOS only
- Getting Undefined property from Object created with d3.js
- SVG does not show up on Firefox but does on Chrome
- How to assign dynamic x axis value and y axis from variable?
- How to set Minimum Radius for Circle Pack in D3JS?
- D3 Canvas Globe With Text At LongLat
- How to fix d3.js axis mis match when using clip paths for linear filtered line charts
- Convert number to month in d3js
- Animating circle clip on D3 Geo Azimuthal
- Is there a way to get a subset/section of a path in d3.js?
- How do I create and write to a new file (csv) and have the browser download it with javascript or D3.js?
- Uncaught ReferenceError: d3Scale is not defined / D3 V4 / rollup.js