score:11
Second Answer (after comment)
I looked at source for cumulativeLineChart. You can see the display.y property get created during chart creation. It relies on a private method: "indexify". If some derivative of that method was made public, then perhaps you could do something like chart.reindexify()
before redrawing.
As a temporary workaround, you could recreate the chart from scratch on every update. If you remove the transition, that seems to work okay. Example jsfiddle: http://jsfiddle.net/kaliatech/PGyKF/.
First Answer
I believe there is bug in cumulativeLineChart. It appears that the cumulativeLineChart adds a "display.y" property dynamically to data values in the series. However, it does not regenerate this property when new values are added to the series for a redraw. I don't know of anyway to make it do this, although I'm new to NVD3.
Do you really need a CumulativeLineChart, or would a normal line chart be sufficient? If so, I had to make the following changes to your code:
- Change from cumulativeLineChart to lineChart
- Change from using 2 dimension arrays of data, to using objects of data (with x,y properties)
- (I'm not familiar enough with NVD3 to say what data formats is expects. The 2D array obviously works for initial loads, but I think it fails to work for subsequent redraws. This is likely related to the same issue you are having with cumulativeLineChart. I thought changing to objects would fix cumulativeLineChart as well, but it didn't seem to.)
I also changed the following, although not as important:
Modified your getData function to create a new instance of Date to avoid unexpected consequences of sharing a reference as the date gets incremented.
Modified the update interval function to generate new data in increments of days (not months) with y values in the same range as the getData function.
Here's a working jsfiddle with those changes:
score:0
I ran into the same issue. I changed the y() function on the lines from
.y(function(d) { return d.display.y })
to
.y(function(d) { return d.display ? d.display.y : d.y })
This gets rid of the error. Obviously it won't be displaying the (non-existent) indexed value in the error case, but in my experience, the chart gets updated again with display defined, and it looks correct.
score:1
I found what I think is a better solution. The problem occurs because the cumulative chart sets the y function during processing. Whenever your want to refresh the chart, first set it back to a default which returns the correct original y. In your redraw function do this before updating:
chart.y(function (d) { return d.y; });
Even better would be if the cumulative chart could do this for itself (store the original access function before setting the new one, and put it back before re-indexing). If I get a chance, I'll try to push a fix.
Source: stackoverflow.com
Related Query
- NVD3 line chart with realtime data
- Angular NVD3 Multibar Chart with dual y-axis to showup only line using json data
- nvd3 line chart with string values on x-axis
- javascript charting - nvd3 line chart with two Y-axis
- NVD3 line chart with vertical line
- Visualize date specific data with a line chart in browser with javascript
- d3.js realtime updating svg line with python websocket data
- C3js - combination chart with data labels only for line
- D3.js: plot dots on the existing line in a multiseries line chart with long formatted data
- NVD3 Line Chart doesn't display when data passed using ajax - data.map is not a function
- Loading csv data with d3.csv in nvd3 multiBar Chart example (JSON format)
- Simple D3.js line chart with data that are values collect every hours
- NVD3 Line Plus Bar With Focus Chart only displaying half width of first and last bar
- How do you get JSON data and create a line chart with d3.js?
- Time in x-axis and data for the y-axis for line chart in d3.js doesn't match/show with what (data) is on JSON
- Uncaught TypeError: Cannot read property 'length' of undefined in line chart with json data
- Top line padding with Nvd3 chart
- D3 single line chart with tsv data
- Show values on Y Axis as it is with Higher and lower limits NVD3 Line Chart
- D3.JS how to load 3 csv files and change data on line chart with button click event?
- Trouble with nvd3 date-data line chart
- replacing null data d3js with focus context chart line
- d3.js realtime line chart with circle
- D3.js line chart with CSV multi-level data
- Create a multiple line chart with Text data in x-axis using d3.js
- Large or unknown number of data arrays with Multiple XY Line Chart in c3.js
- NVD3 time formatting , line with focus chart
- Drawing a Polygon on an NVD3 Line Chart with D3
- How to render multi line chart with DC.js with the following type of data - JAVASCRIPT (DC.js)
- How to expand a data scale on NVD3 line chart
More Query from same tag
- dc.js - how to group by unique id
- d3.brush does not work in Firefox or Edge when embedded
- D3.js Ordinal Scale Axis mis alignment
- jsGrid - get data typed by the user in a search navGrid
- Why does d3.select() return array of array?
- value not showingcorrectly on hover in d3-sankey
- Mouse event handling in a node and its children
- Is it possible to get D3js charts into xml?
- Multiple Shape annotations on D3plus line plot
- How to format seconds to H:M:S using d3js.org
- d3 remove and exit are not removing items properly in a stacked bar
- line break in d3 tag Cloud
- How to add a tooltip to D3.js subplot
- D3.js - Highlight chart elements when interacting with the legend & vice versa
- d3.js plot not displaying within R Shiny plot area
- Add circles to a line
- Counting data items in d3.js
- Drawing multiple bars per date
- How can I make my lines spin with the globe?
- Use d3 stack layout with data organized per points, instead of per layers
- Pencil-like functionality
- Filtering quantity by month by product in D3
- Uncaught TypeError: n.getMonth is not a function in d3 bar chart
- ID of d3 selection undefined
- Adding text label
- Button with text label: How do I keep the hover color even when over text label?
- d3.stack(), Cannot read property '1' of undefined
- D3.js visualization with node.js
- Generating Occupied DIVs with Javascript
- d3 multi-series chart zoom - pivoted json