Skip to content

Draft: Support custom geometry for vtkChartParallelCoordinates.

dcbr requested to merge dcbr/vtk:custom_parallel_chart_geometry into master

Similar to the changes in !8618 (merged), support custom geometries for vtkChartParallelCoordinates.

Script to reproduce below plots
import vtk

def create_parallel_chart():
    data = [(1, 2, 3), (2, 0, 1), (3, 1, 2)]
    chart = vtk.vtkChartParallelCoordinates()

    table = vtk.vtkTable()
    numFields = len(data)
    for f in range(numFields):
        arr = vtk.vtkFloatArray()
        arr.SetName(f"Field{f}")
        table.AddColumn(arr)

    numPoints = len(data[0])
    table.SetNumberOfRows(numPoints)
    for f in range(numFields):
        for p in range(numPoints):
            table.SetValue(p, f, data[f][p])

    plot = chart.GetPlot(0)
    plot.SetInputData(table)
    return chart


if __name__ == "__main__":
    width, height = 400, 400
    border = 50

    renwin = vtk.vtkRenderWindow()
    renwin.SetSize(width+2*border, height+2*border)
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renwin)

    renderer = vtk.vtkRenderer()
    renderer.SetBackground([1, 1, 1])
    renwin.AddRenderer(renderer)

    chart_scene = vtk.vtkContextScene()
    chart_actor = vtk.vtkContextActor()
    chart_actor.SetScene(chart_scene)
    renderer.AddActor(chart_actor)
    chart_scene.SetRenderer(renderer)

    chart = create_parallel_chart()
    chart.SetAutoSize(False)
    chart.SetSize(vtk.vtkRectf(border, border, width, height))
    chart_scene.AddItem(chart)

    style = vtk.vtkContextInteractorStyle()
    style.SetScene(chart_scene)
    iren.SetInteractorStyle(style)
    renwin.Render()
    iren.Start()
Before After
image image
Edited by dcbr

Merge request reports

Loading