score:2
one possible solution is to add years to date
field like this
{
date: "2010-october",
price: "100"
}
if you are not going to display the year, it may be arbitrary, just make sure, that after december it increases by 1.
then replace var parsedate = d3.time.format("%b");
with var parsedate = d3.time.format("%y-%b");
also replace .call(xaxis.ticks(d3.time.year));
with .call(xaxis.ticks(d3.time.months));
here is the fiddle: https://jsfiddle.net/p68z0bqo/
edit: if you can't add years manually, you can try to do this automatically like this:
var parsedate = d3.time.format("%y-%b");
data.foreach(function(d) {
var year = 2000;
d.values.foreach(function(d) {
if (d.date === 'january') year++;
d.date = parsedate.parse(year.tostring() + '-' + d.date);
d.price = +d.price;
});
});
this code only works if all months are present (there are no gaps) and if january is represented exactly as "january"
(i.e. it has the same case).
Source: stackoverflow.com
Related Query
- D3 Multi Line Chart Not Displaying Properly With X Axis Value
- X axis not displaying on Multi Series Line Chart using d3.js
- Line chart not aligned with x axis
- Time series line chart is not sync with axis
- viewbox with pixel value to make d3 chart resposive is not working properly
- Line Chart path in D3 JS not displaying Properly
- D3 Multi Series Line chart not working with correct xAxis values
- D3 Line Chart not having proper X & Y axis plotting with Labels
- dc.js Stacked Bar Chart having only one column and with elastic X Axis is not rendered properly
- multi line chart nvd3 not shown properly
- Right Axis not displaying on Dual Axis Grouped Bar and Line Chart D3
- D3 Line chart - display value label on Y axis tick and a not scale
- D3 Multi Series Line chart with non time x axis
- D3 line chart axis text labels in multi line
- nvd3.js-Line Chart with View Finder: rotate axis labels and show line values when mouse over
- Y axis label not displaying large numbers - Multi-Bar Chart
- X axis not displaying on bar chart using d3.js
- How to line up x axis on stacked bar chart with a line overlay in d3.js
- simple multi line chart with D3
- d3 bar chart with fixed bar width and fixed spacing to align in center axis line
- How to create a % difference arrow line with value in a bar chart using D3.js
- Multiple line chart not working with date format
- d3js - line chart `circle` placement to the lines are not properly sets
- D3 bar chart not working properly with all negative and positive values
- Line and Rect intersection not calculated properly on one axis
- D3 line chart does not show tool tip and data points properly
- d3.js axis labels not displaying in responsive bar chart
- NVD3 Line Plus Bar With Focus Chart only displaying half width of first and last bar
- D3 chart Y axis line is not visible in some resolutions
- Line chart not hitting the right value on chart and has a smooth line
More Query from same tag
- Disable force in forcelayout algorithm in d3
- "Exporting" a Tributary example that makes use of the tributary object - d3.js
- D3js loop through variable length series for scatter plot
- d3 graph freezes with highcharts
- Points on d3 map not on the same scale or part of the svg
- d3-force: keep graph compact when filtering/removing nodes
- Element no longer draggable after adding parameter to d3 drag behavior
- Type 'Area<X>' is not assignable to type 'String' using @types/d3
- d3 transition for expanding div
- Why is d appearing as undefined in my d3 script?
- how parse this date Wed May 14 2014 11:15:12 GMT-0800 (Pacific Standard Time) using d3.format?
- Iterating through SVGElement paths with d3js?
- Merging two datasets in D3/JS
- Wrong display of csv input to nvd3 chart (related to timeformatting)
- Is it possible to have layered svg elements that interact with each other in d3?
- d3.js building a grid of rectangles
- groups.exit(...).watchTransition is not a function
- How to remove black area below/above metricsgraphs.js line graph?
- How to connect dots in D3 with a line?
- Building a flat calendar using D3.js
- Using adjacent data values in d3
- Insert scopedSlot into d3 svg using foreignObject
- Overlaying two AmCharts
- D3 zoom failing on two simultaneous touches
- D3 axes render on top of graph
- dc.js/crossfilter.js brushon filter - selected filtering not updating in other charts
- How to load CSV File in Angular JS to do charts
- d3 Stacked Bar Chart Not Updating
- Create unique DOM elements with D3.js and update them but not append them again
- nvd3 - how to draw a line over a scatterPlusLineChart, with specific cordinates