score:6
Where you update the line paths, via
plots.selectAll("path")
it needs to be
plots.select("path")
see mbostock's explanation of the subtle but crucial difference.
Here's a working fiddle, which also has a second path added, to verify that it works across plots.
score:0
I actually had the same issue today. So I may be able to help out. I noticed you're calling setTimeout to update the data in your html.
It seems you are calling chart() inside of that setTimeout. The only problem with that is that you aren't resetting your ranges.
Instead you should try calling demoChart(), or adding new ranges inside of your chart(). Your ranges are:
function xs(d) { return xScale(d[0]) }
function ys(d) { return yScale(d[1]) }
var xScale = d3.scale.linear().domain([0, 500]).range([0, 400]),
yScale = d3.scale.linear().domain([0, 1]).range([400, 0]),
line = d3.svg.line().x(xs).y(ys);
If that doesn't fix it, it may because you are updating with two setTimeouts initiating each second simultaneously. So the second data is overwriting the first immediately here:
setTimeout(function() {
console.log("Modifying data array");
pts[0][2][1] = 0.5;
d3.select("#demo").datum(pts).call(chart);
},1000);
setTimeout(function() {
console.log("Passing new data array");
d3.select("#demo").datum([[[0,1],[200,0.45],[500,0]]]).call(chart);
},1000);
Here's an article I found helpful: http://www.d3noob.org/2013/02/update-d3js-data-dynamically-button.html
Source: stackoverflow.com
Related Query
- d3 line and area charts not updating with new data array
- Updating data values with HTML input and changing the data array
- d3.js not updating graph with new data
- d3 bar chart labels not getting updated on updating the chart with the new data
- Chart not updating with new data with transitions in D3
- updating d3 chart with new data, the old data points not removed
- consolidating data from a json in a new array and drawing shapes with it using d3.js
- consolidating data from a json in a new array and drawing shapes with it using d3.js
- C3.js SVG visualization to Canvas with canvg - Line charts filled with black rectangles , "ERROR: Element 'parsererror' not yet implemented"
- Mix bar and line charts with Rickshaw (d3 based graphing library for js)
- d3.js realtime updating svg line with python websocket data
- d3.js chart not updated with new data
- Date and time transition from data with line
- Make a chart with area charts having both positive and negative y axis in dc or d3.js
- d3 multiline update path and transition path does not work with nested data
- How to draw line charts with complex data structures in d3
- Updating D3 streamgraph with new data
- d3 with bootstrap tooltip: titles not working with data updating
- Updating nodes and links with labels in d3 force directed network graph is not removing the nodes properly
- d3js chart dots and area not updating
- Load and display data with condition, but the condition is not met
- How to make a mouseover interactive line graph with multiple data series and 2 y axes?
- D3 line chart does not show tool tip and data points properly
- Reconstructing D3 Animated Choropleth with a new Map and Data
- Data bound to children is not updated with new data
- Updating D3 column chart with different values and different data sizes
- How do you get JSON data and create a line chart with d3.js?
- How can I apply a clipPath in SVG with multiple paths and NOT clip out the area between the paths?
- Why animated d3 svg line is not synchronized with the axis shift in IE9 but synchronized in IE11 and Chrome?
- 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
More Query from same tag
- Disable brush on range chart before selecting a scale from the dropdown/on page load(dc.js,d3.js)
- D3 collapsible trees without flare.json
- D3: Order grouped column chart
- Texts in bubbles overlap in force simulation
- MySQL to JSON (For use with NVD3.js)
- d3 conventional indentation with eslint
- Event handlers not responding
- Show percentage value greater than 100 in c3 gauge chart
- d3.js version 4 - rect zoom - cannot get the transformation right
- Pie layout produces different ordering on Firefox and Chrome for the same dataset
- Hiding visible elements on click D3.js
- Why d3 line generator fails when to and from 0 or both
- Is it possible to nest one (or more) layout(s) within another, different layout(s) in d3?
- Labeling animated line graphs using D3
- d3: duplicating paths with more dimensional array
- Text transformation and Datetime format issue on Linechart Zoom D3 V4
- How to calculate the x and y coordinates of individual points within a radial line?
- D3.js - Removing other bars except one
- D3 nesting - inconsistent number of levels
- Assigning hyperlinks to nodes in dagre-d3
- Hover effects in D3.js
- I would like to restrict circles within a shape & partitions within that shape
- Transition/animate the creation/removal of a DOM element
- Distributed json loading in force collapsable layout
- d3.js : attribute setting not working after binding data and entering elements
- Angular directive within d3 SVG
- D3: How do I set "click" event and "dbclick" event at the same time?
- Power BI custom D3 chart Could not find plugin "proposal-numeric-separator"
- D3 Multiple Pie Chart Updates
- D3.js custom ticks on x axis of scatterplot