MCPcopy Create free account
hub / github.com/Kitware/VTK / testBarGraph

Method testBarGraph

Charts/Core/Testing/Python/TestBarGraph.py:18–74  ·  view source on GitHub ↗

Test if bar graphs can be built with python

(self)

Source from the content-addressed store, hash-verified

16
17class TestBarGraph(vtkmodules.test.Testing.vtkTest):
18 def testBarGraph(self):
19 "Test if bar graphs can be built with python"
20
21 # Set up a 2D scene, add an XY chart to it
22 view = vtkContextView()
23 view.GetRenderer().SetBackground(1.0,1.0,1.0)
24 view.GetRenderWindow().SetSize(400,300)
25 chart = vtkChartXY()
26 view.GetScene().AddItem(chart)
27
28 # Create a table with some points in it
29 table = vtkTable()
30
31 arrMonth = vtkIntArray()
32 arrMonth.SetName("Month")
33
34 arr2008 = vtkIntArray()
35 arr2008.SetName("2008")
36
37 arr2009 = vtkIntArray()
38 arr2009.SetName("2009")
39
40 arr2010 = vtkIntArray()
41 arr2010.SetName("2010")
42
43 numMonths = 12
44
45 for i in range(0,numMonths):
46 arrMonth.InsertNextValue(i + 1)
47 arr2008.InsertNextValue(data_2008[i])
48 arr2009.InsertNextValue(data_2009[i])
49 arr2010.InsertNextValue(data_2010[i])
50
51 table.AddColumn(arrMonth)
52 table.AddColumn(arr2008)
53 table.AddColumn(arr2009)
54 table.AddColumn(arr2010)
55
56 # Now add the line plots with appropriate colors
57 line = chart.AddPlot(2)
58 line.SetInputData(table,0,1)
59 line.SetColor(0,255,0,255)
60
61 line = chart.AddPlot(2)
62 line.SetInputData(table,0,2)
63 line.SetColor(255,0,0,255)
64
65 line = chart.AddPlot(2)
66 line.SetInputData(table,0,3)
67 line.SetColor(0,0,255,255)
68
69 view.GetRenderWindow().SetMultiSamples(0)
70 view.GetRenderWindow().Render()
71
72 img_file = "TestBarGraph.png"
73 vtkmodules.test.Testing.compareImage(view.GetRenderWindow(),vtkmodules.test.Testing.getAbsImagePath(img_file))
74 vtkmodules.test.Testing.interact()
75

Callers

nothing calls this directly

Calls 15

SetMultiSamplesMethod · 0.80
interactMethod · 0.80
RenderMethod · 0.65
vtkTableClass · 0.50
vtkIntArrayFunction · 0.50
rangeClass · 0.50
GetRendererMethod · 0.45
SetSizeMethod · 0.45
GetRenderWindowMethod · 0.45
AddItemMethod · 0.45
GetSceneMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected