From: Koteswara R. R. <ru...@ya...> - 2017-04-14 00:08:56
|
I converted the C++ PieChart example at http://www.vtk.org/Wiki/VTK/Examples/Cxx/Plotting/PieChartat to Python. It is crashing with the following error: vtkPlotPie [000002153DB80AA0]: No data set [index 0]. Looks like it is failing at pie = vtk.vtkPlotPie.SafeDownCast(chart.AddPlot(0))Not able to figure it out why? Following is the Python code: import vtk data = [77938,9109,2070,12806,19514]labels = ["Books","New and Popular","Periodical","Audiobook","Video"] numItems = 5 #Create a pie chart object and contextview = vtk.vtkContextView()view.GetRenderer().SetBackground(1.0, 1.0, 1.0)view.GetRenderWindow().SetSize(600, 350) chart = vtk.vtkChartPie()view.GetScene().AddItem(chart) #Create a table with some points in it...table = vtk.vtkTable()arrData = vtk.vtkIntArray()labelArray = vtk.vtkStringArray() for i in range(numItems): arrData.InsertNextValue(data[i]) labelArray.InsertNextValue(labels[i]) arrData.SetName("Distance Distribution") table.AddColumn(arrData) colorSeries = vtk.vtkColorSeries()colorSeries.SetColorScheme(vtk.vtkColorSeries.WARM) #Add multiple line plots, setting the colors etcpie = vtk.vtkPlotPie.SafeDownCast(chart.AddPlot(0))pie.SetColorSeries(colorSeries) pie.SetInputData(table)pie.SetInputArray(0,"2008 Circulation")pie.SetLabels(labelArray )chart.SetShowLegend(True)chart.SetTitle("Circulation 2008") #Finally render the scene and compare the image to a reference imageview.GetRenderWindow().SetMultiSamples(0)view.GetRenderWindow().Render()view.GetInteractor().Initialize()view.GetInteractor().Start() |