<div dir="ltr"><div>I attempted to do the same thing you did (with Python VTK6.3), but it wouldn't work for me either. The only way I was able to get it to work as needed was to remove and re-create the line.</div><div><br></div><div>I came to this solution because of this: <a href="http://vtk.1045678.n5.nabble.com/How-to-update-a-2d-plot-vtkChartXY-with-new-data-online-using-C-td5725677.html">http://vtk.1045678.n5.nabble.com/How-to-update-a-2d-plot-vtkChartXY-with-new-data-online-using-C-td5725677.html</a></div><div><br></div><div>However, it would be great is someone who was more familiar with VTK had a better solution.</div><div><br></div><div>-Andrew</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 29, 2015 at 9:42 AM, Elvis Chen <span dir="ltr"><<a href="mailto:elvis.chen@gmail.com" target="_blank">elvis.chen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">hi all,<div><br></div><div>I am trying to utilize vtkChartXY to plot a simple 2D curve but ran into some trouble, I seek your help.</div><div><br></div><div>The 2D plot is a function of time and is been updated incrementally. I tried to follow the example at:</div><div><br></div><div><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Plotting/LinePlot" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Plotting/LinePlot</a><br></div><div><br></div><div>to create an initial plot. As the data come in, I extended the vtkTable, and calls the renderer again, but only the initial table/plot was shown. A code demonstrating is the follow. Basically what I did was:</div><div><br></div><div>- create a vtkTable with 3 data point, and plot it,</div><div>- modify the vtkTable to include 1 more data point (4 total), and plot it again,</div><div>- but the resulting plot only shows the original curve.</div><div><br></div><div>Any help is very much appreciated,</div><div><br></div><div>thanks,</div><div><br></div><div><br></div><div><br></div><div><div>// arrX and arrY are vtkFloatArray</div><div><br></div><div> table->AddColumn( arrX );</div><div> table->AddColumn( arrY );</div><div><br></div><div>// create a table of 3 data points</div><div> table->SetNumberOfRows( 3 );</div><div> table->SetValue( 0, 0, 0 );</div><div> table->SetValue( 0, 1, 0 );</div><div> table->SetValue( 1, 0, 1 );</div><div> table->SetValue( 1, 1, 1 );</div><div> table->SetValue( 2, 0, 2 );</div><div> table->SetValue( 2, 1, 3 );</div><div><br></div><div>// render the chart</div><div> view->GetRenderer()->SetBackground( 1, 1, 1 );</div><div> view->GetScene()->AddItem( chart );</div><div> chart->SetShowLegend( true );</div><div> line = chart->AddPlot( vtkChart::LINE );</div><div> line->SetInput( table, 0, 1 );</div><div> line->SetColor( 1, 0, 0 );</div><div> line->SetWidth( 5.0 );</div><div> </div><div>// shows a plot of 3 data point</div><div> view->GetRenderer()->Render();</div><div><br></div><div>// add a new point to the vtkTable</div><div> table->SetNumberOfRows( 4 );</div><div> table->SetValue( 0, 0, 0 );</div><div> table->SetValue( 0, 1, 0 );</div><div> table->SetValue( 1, 0, 1 );</div><div> table->SetValue( 1, 1, 1 );</div><div> table->SetValue( 2, 0, 2 );</div><div> table->SetValue( 2, 1, 3 );</div><div> table->SetValue( 3, 0, 5 );</div><div> table->SetValue( 3, 1, 5 );</div><div> table->Modified();</div><div> view->Modified();</div><div> line->Modified();</div><div><br></div><div>// render it again, but still, only 3 data points were plot</div><div> view->GetRenderer()->Render();</div><div> view->GetInteractor()->Initialize();</div><div> view->GetInteractor()->Start();</div></div><div><br></div><div><br></div><div><br></div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>