Views
One of the main features of VIKTOR is to present data in a clear and structured way. This data can range from
calculation results to a three-dimensional model of a bridge. Presentation of such data in VIKTOR is done in so-called
views
.
New in v12.10.0
PlotlyView
and PlotlyAndDataView
New in v12.7.0
An update_label
can be added to a View to change the default text presented on the update button
New in v12.5.0
A description
can be added to a View to provide more information to the user through a tooltip
Implementation
With each type of data, a specific View
can be constructed. These views are defined on
the ViktorController
by means of a so-called decorator, similar to the @property
decorator that you may already be
using in an app. One should always specify the label
and duration_guess
of a view. The latter is used by the
front-end to distinguish between a quick and a slow visualization:
duration_guess
<= 3: Quick visualization, which updates with every change in the editor.duration_guess
> 3: Slow visualization, which can be refreshed manually by means of an update button.
The "view method" should return the corresponding ViewResult
.
The ViktorController
takes care of the rest:
Define the view(s) decorators with specific view settings:
class Controller(ViktorController):
...
@GeometryView("3D Model", duration_guess=2)
@DataView("Cost overview", duration_guess=1)
@GeometryAndDataView("Combined", duration_guess=3)Define the view method(s) and return the visualization data as ViewResult. The input parameters are passed to a view method by using the
params
argument in the method's signature:class Controller(ViktorController):
...
@GeometryView("3D Model", duration_guess=2)
def my_geometry_view(self, params, **kwargs):
geometries = ...
return GeometryResult(geometries)
Additional view settings can also be passed in a View decorator:
description
(>= v12.5.0): provide more information to the user through a tooltipupdate_label
(>= v12.7.0): change the default text presented on the update button
Supported views
The following views can be implemented:
GeometryView
(2D/3D) (how-to)DataView
(how-to)SVGView
(how-to)PNGView
(how-to)JPGView
(how-to)MapView
(how-to)GeoJSONView
(how-to)WebView
(how-to)PlotlyView
(how-to)PDFView
(how-to)GeometryAndDataView
SVGAndDataView
PNGAndDataView
JPGAndDataView
MapAndDataView
GeoJSONAndDataView
WebAndDataView
PlotlyAndDataView
Geometry view 3D
Geometry view 2D
Data view
SVG/PNG/JPG view
Map/GeoJSON view
Web/Plotly view (source: plot.ly)
PDF view
Interaction
For more information on view interaction, see here.
Testing
For more information on writing (automated) tests for view methods, please see each individual view guide for a specific example.