It's a little hard to find a solution, but once you find out, it's pretty straight forward.
You just need to update the d3.select('#chart svg').datum(sendyouNewData) call d3.select('#chart svg').datum(sendyouNewData)
I used the same code as on the NVD3 website, the only code I added was the function of updating the chart when the button was pressed, o and added the width and height to the chart.
The following code is a validated code. Live code here
Your html
<input type="button" id="change1" value="Change 1"/> <input type="button" id="change2" value="Change 2"/> <div id="chart"> <svg></svg> </div>
Your javascript
var dynamic_lineWithFocusChart, lineWithFocusChart; var width = 500, height = 500; nv.addGraph(function () { var chart = nv.models.lineWithFocusChart().width(width).height(height); chart.xAxis.tickFormat(d3.format(',f')); chart.yAxis.tickFormat(d3.format(',.2f')); chart.y2Axis.tickFormat(d3.format(',.2f')); dynamic_lineWithFocusChart = d3.select('#chart svg').datum(testData()); dynamic_lineWithFocusChart.transition().duration(1000).call(chart).attr('width', width).attr('height', height); nv.utils.windowResize(chart.update); lineWithFocusChart = chart; return chart; }); function testData() { return stream_layers(3, 128, .1).map(function (data, i) { return { key: 'Stream' + i, values: data }; }); } $("#change1,#change2 ").click(function () { dynamic_lineWithFocusChart.datum(testData()); dynamic_lineWithFocusChart.transition().duration(1000).call(lineWithFocusChart); dynamic_lineWithFocusChart.update });
I hope he answers your question: D
source share