|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Qt widget for displaying interactive charts based on the plotly.js library. More...
#include <QmitkChartWidget.h>


Public Types | |
| enum class | ChartType { bar , line , spline , pie , area , area_spline , scatter } |
| Enumeration of supported chart types. More... | |
| enum class | ColorTheme { darkstyle , lightstyle } |
| Enumeration of chart color themes. More... | |
| enum class | LineStyle { solid , dashed } |
| Enumeration of line drawing styles. More... | |
| enum class | MarkerSymbol { circle , diamond , cross , square , pentagon , star , x , diamond_tall , star_diamond , star_triangle_up , star_triangle_down , asterisk , cross_thin , x_thin } |
| Enumeration of data point marker symbols. More... | |
| enum class | ChartColor { red , orange , yellow , green , blue , purple , brown , magenta , tan , cyan , olive , maroon , navy , aquamarine , turqouise , silver , lime , teal , indigo , violet , pink , black , white , grey } |
| Enumeration of named chart colors. More... | |
| enum class | AxisScale { linear , log } |
| Enumeration of axis scale types. More... | |
| enum class | LegendPosition { bottomMiddle , bottomRight , topRight , topLeft , middleRight } |
| Enumeration of legend positions within the chart. More... | |
Public Slots | |
| void | OnLoadFinished (bool isLoadSuccessful) |
| Slot called when the web page finishes loading. More... | |
| void | OnPageSuccessfullyLoaded () |
| Slot called when the chart page has been successfully loaded and is ready. More... | |
Signals | |
| void | PageSuccessfullyLoaded () |
| Emitted when the chart page has been successfully loaded and is ready for use. More... | |
Public Member Functions | |
| QmitkChartWidget (QWidget *parent=nullptr) | |
| Construct a chart widget. More... | |
| QmitkChartWidget (QWidget *parent, bool unitTest) | |
| Construct a chart widget for unit testing. More... | |
| ~QmitkChartWidget () override | |
| Destructor. More... | |
| void | AddData1D (const std::vector< double > &data1D, const std::string &label, ChartType chartType=ChartType::bar) |
| Add a 1D data series to the chart. More... | |
| void | UpdateData1D (const std::vector< double > &data1D, const std::string &label) |
| Update the data of an existing 1D data series. More... | |
| void | UpdateData2D (const std::vector< std::pair< double, double > > &data2D, const std::string &label) |
| Update the data of an existing 2D data series. More... | |
| void | UpdateChartExampleData (const std::vector< std::pair< double, double > > &data2D, const std::string &label, const std::string &type, const std::string &color, const std::string &lineStyle, const std::string &pieLabelsData={}) |
| Update chart example data with full property specification. More... | |
| void | AddData2D (const std::vector< std::pair< double, double > > &data2D, const std::string &label, ChartType chartType=ChartType::bar) |
| Add a 2D data series to the chart. More... | |
| void | AddChartExampleData (const std::vector< std::pair< double, double > > &data2D, const std::string &label, const std::string &type, const std::string &color, const std::string &style, const std::string &pieLabelsData={}) |
| Add chart example data with full property specification. More... | |
| void | RemoveData (const std::string &label) |
| Remove a data series from the chart. More... | |
| void | UpdateLabel (const std::string &existingLabel, const std::string &newLabel) |
| Rename an existing data series. More... | |
| QmitkChartxyData * | GetDataElementByLabel (const std::string &label) const |
| Retrieve the data element for a given label. More... | |
| void | SetColor (const std::string &label, const std::string &colorName) |
| Set the color of a data series. More... | |
| void | SetLineStyle (const std::string &label, LineStyle style) |
| Set the line style of a data series. More... | |
| void | SetMarkerSymbol (const std::string &label, MarkerSymbol symbol) |
| Set the marker symbol for a data series. More... | |
| void | SetYAxisScale (AxisScale scale) |
| Set the Y axis scale type. More... | |
| void | SetXAxisLabel (const std::string &label) |
| Set the X axis label text. More... | |
| void | SetYAxisLabel (const std::string &label) |
| Set the Y axis label text. More... | |
| void | SetPieLabels (const std::vector< std::string > &pieLabels, const std::string &label) |
| Set category labels for pie chart segments. More... | |
| void | SetTitle (const std::string &title) |
| Set the chart title. More... | |
| void | SetChartType (const std::string &label, ChartType type) |
| Change the chart type of an existing data series. More... | |
| void | SetXErrorBars (const std::string &label, const std::vector< double > &errorPlus, const std::vector< double > &errorMinus=std::vector< double >()) |
| Set error bars in the X direction for a data series. More... | |
| void | SetYErrorBars (const std::string &label, const std::vector< double > &errorPlus, const std::vector< double > &errorMinus=std::vector< double >()) |
| Set error bars in the Y direction for a data series. More... | |
| void | SetLegendPosition (LegendPosition position) |
| Set the legend position. More... | |
| void | SetShowLegend (bool show) |
| Set whether the chart legend is visible. More... | |
| void | SetStackedData (bool stacked) |
| Set whether data series are displayed in stacked mode. More... | |
| void | Show (bool showSubChart=false) |
| Render and display the chart in the widget. More... | |
| void | SetShowDataPoints (bool showDataPoints) |
| Set whether data point markers are visible. More... | |
| void | Clear () |
| Clear all data series and reset the widget. More... | |
| void | SetTheme (ColorTheme themeEnabled) |
| Set the chart color theme. More... | |
| void | SetShowSubchart (bool showSubChart) |
| Set whether the subchart (overview navigator) is shown. More... | |
| void | SetShowErrorBars (bool showErrorBars) |
| Set whether error bars are shown. More... | |
| void | SetMinMaxValueXView (double minValueX, double maxValueX) |
| Set the visible X axis range (zoom). More... | |
| void | SetMinMaxValueYView (double minValueY, double maxValueY) |
| Set the visible Y axis range (zoom). More... | |
| void | Reload () |
| Reload the chart to reflect property or data changes. More... | |
| QSize | sizeHint () const override |
| Return the recommended size for the widget. More... | |
| void | SavePlotAsImage () |
| Save the current chart as an SVG image file. More... | |
Qt widget for displaying interactive charts based on the plotly.js library.
QmitkChartWidget provides a high-level C++ API for creating interactive charts within MITK applications. Data is added via AddData1D() or AddData2D(), and multiple data series with different chart types and properties can be displayed simultaneously.
Supported chart types:
Features include configurable colors, line styles, marker symbols, error bars, legend positioning, axis labels and scales, themes, and data point visibility.
Internally, chart rendering is handled by JavaScript (plotly.js) embedded in a QWebEngineView. Data and configuration are passed to JavaScript via QWebChannel.
Definition at line 50 of file QmitkChartWidget.h.
|
strong |
Enumeration of axis scale types.
| Enumerator | |
|---|---|
| linear | Linear axis scale (default). |
| log | Logarithmic axis scale. |
Definition at line 137 of file QmitkChartWidget.h.
|
strong |
Enumeration of named chart colors.
Definition at line 107 of file QmitkChartWidget.h.
|
strong |
Enumeration of supported chart types.
| Enumerator | |
|---|---|
| bar | Bar chart. |
| line | Line chart. |
| spline | Spline chart (smoothed line). |
| pie | Pie chart. |
| area | Filled area chart. |
| area_spline | Area chart with spline interpolation. |
| scatter | Scatter chart. |
Definition at line 58 of file QmitkChartWidget.h.
|
strong |
Enumeration of chart color themes.
| Enumerator | |
|---|---|
| darkstyle | Dark gray background, white foreground. |
| lightstyle | White background, black foreground. |
Definition at line 71 of file QmitkChartWidget.h.
|
strong |
Enumeration of legend positions within the chart.
| Enumerator | |
|---|---|
| bottomMiddle | Bottom center of the chart. |
| bottomRight | Bottom right corner. |
| topRight | Top right corner (default). |
| topLeft | Top left corner. |
| middleRight | Middle right side. |
Definition at line 146 of file QmitkChartWidget.h.
|
strong |
Enumeration of line drawing styles.
| Enumerator | |
|---|---|
| solid | Solid line. |
| dashed | Dashed line. |
Definition at line 79 of file QmitkChartWidget.h.
|
strong |
Enumeration of data point marker symbols.
Definition at line 87 of file QmitkChartWidget.h.
|
explicit |
Construct a chart widget.
| [in] | parent | The parent QWidget (default: nullptr). |
|
explicit |
Construct a chart widget for unit testing.
| [in] | parent | The parent QWidget. |
| [in] | unitTest | If true, the widget is constructed in unit test mode. |
|
override |
Destructor.
| void QmitkChartWidget::AddChartExampleData | ( | const std::vector< std::pair< double, double > > & | data2D, |
| const std::string & | label, | ||
| const std::string & | type, | ||
| const std::string & | color, | ||
| const std::string & | style, | ||
| const std::string & | pieLabelsData = {} |
||
| ) |
Add chart example data with full property specification.
Convenience method for the chart example plugin that accepts chart properties as strings rather than enum values.
| [in] | data2D | The (x, y) data pairs. |
| [in] | label | The data series label. |
| [in] | type | The chart type as a string. |
| [in] | color | The color as a string. |
| [in] | style | The line style as a string. |
| [in] | pieLabelsData | Optional pie chart labels (default: empty). |
| void QmitkChartWidget::AddData1D | ( | const std::vector< double > & | data1D, |
| const std::string & | label, | ||
| ChartType | chartType = ChartType::bar |
||
| ) |
Add a 1D data series to the chart.
The values are automatically assigned integer x-values starting at 0.
| [in] | data1D | The y-values of the data series. |
| [in] | label | A unique name for this data series, also used as the display label. |
| [in] | chartType | The chart type to use for this series (default: bar). |
| void QmitkChartWidget::AddData2D | ( | const std::vector< std::pair< double, double > > & | data2D, |
| const std::string & | label, | ||
| ChartType | chartType = ChartType::bar |
||
| ) |
Add a 2D data series to the chart.
Each entry is an (x, y) pair. Call repeatedly to display multiple series.
| [in] | data2D | The (x-value, y-value) data pairs. |
| [in] | label | A unique name for this data series. |
| [in] | chartType | The chart type to use (default: bar). |
| void QmitkChartWidget::Clear | ( | ) |
Clear all data series and reset the widget.
| QmitkChartxyData* QmitkChartWidget::GetDataElementByLabel | ( | const std::string & | label | ) | const |
Retrieve the data element for a given label.
| [in] | label | The label identifier of the data series. |
|
slot |
Slot called when the web page finishes loading.
| [in] | isLoadSuccessful | true if the page loaded successfully. |
|
slot |
Slot called when the chart page has been successfully loaded and is ready.
|
signal |
Emitted when the chart page has been successfully loaded and is ready for use.
| void QmitkChartWidget::Reload | ( | ) |
Reload the chart to reflect property or data changes.
Call this after modifying chart properties or adding data to an already-displayed chart.
| void QmitkChartWidget::RemoveData | ( | const std::string & | label | ) |
Remove a data series from the chart.
Works for both 1D and 2D data.
| [in] | label | The label identifier of the data series to remove. |
| std::invalid_argument | If the label is not found. |
| void QmitkChartWidget::SavePlotAsImage | ( | ) |
Save the current chart as an SVG image file.
Triggers the JavaScript side to generate the SVG, which is then saved via a file dialog.
| void QmitkChartWidget::SetChartType | ( | const std::string & | label, |
| ChartType | type | ||
| ) |
Change the chart type of an existing data series.
| [in] | label | The label identifier of the data series. |
| [in] | type | The new chart type. |
| void QmitkChartWidget::SetColor | ( | const std::string & | label, |
| const std::string & | colorName | ||
| ) |
Set the color of a data series.
| [in] | label | The label identifier of the data series. |
| [in] | colorName | The color as a CSS color name or hex code (e.g. "red" or "#FF0000"). |
| void QmitkChartWidget::SetLegendPosition | ( | LegendPosition | position | ) |
| void QmitkChartWidget::SetLineStyle | ( | const std::string & | label, |
| LineStyle | style | ||
| ) |
Set the line style of a data series.
| [in] | label | The label identifier of the data series. |
| [in] | style | The line style (solid or dashed). |
| void QmitkChartWidget::SetMarkerSymbol | ( | const std::string & | label, |
| MarkerSymbol | symbol | ||
| ) |
Set the marker symbol for a data series.
| [in] | label | The label identifier of the data series. |
| [in] | symbol | The marker symbol to use. |
| void QmitkChartWidget::SetMinMaxValueXView | ( | double | minValueX, |
| double | maxValueX | ||
| ) |
Set the visible X axis range (zoom).
| [in] | minValueX | The minimum X value to display. |
| [in] | maxValueX | The maximum X value to display. |
| void QmitkChartWidget::SetMinMaxValueYView | ( | double | minValueY, |
| double | maxValueY | ||
| ) |
Set the visible Y axis range (zoom).
| [in] | minValueY | The minimum Y value to display. |
| [in] | maxValueY | The maximum Y value to display. |
| void QmitkChartWidget::SetPieLabels | ( | const std::vector< std::string > & | pieLabels, |
| const std::string & | label | ||
| ) |
Set category labels for pie chart segments.
| [in] | pieLabels | The category labels, one per data element. |
| [in] | label | The label of the pie chart data series. |
| void QmitkChartWidget::SetShowDataPoints | ( | bool | showDataPoints | ) |
Set whether data point markers are visible.
| [in] | showDataPoints | true to display data point markers. |
| void QmitkChartWidget::SetShowErrorBars | ( | bool | showErrorBars | ) |
Set whether error bars are shown.
| [in] | showErrorBars | true to display error bars. |
| void QmitkChartWidget::SetShowLegend | ( | bool | show | ) |
Set whether the chart legend is visible.
| [in] | show | true to show the legend, false to hide it. |
| void QmitkChartWidget::SetShowSubchart | ( | bool | showSubChart | ) |
Set whether the subchart (overview navigator) is shown.
| [in] | showSubChart | true to show the subchart. |
| void QmitkChartWidget::SetStackedData | ( | bool | stacked | ) |
Set whether data series are displayed in stacked mode.
| [in] | stacked | true to stack data series. |
| void QmitkChartWidget::SetTheme | ( | ColorTheme | themeEnabled | ) |
| void QmitkChartWidget::SetTitle | ( | const std::string & | title | ) |
Set the chart title.
| [in] | title | The title text displayed above the chart. |
| void QmitkChartWidget::SetXAxisLabel | ( | const std::string & | label | ) |
Set the X axis label text.
| [in] | label | The label text. |
| void QmitkChartWidget::SetXErrorBars | ( | const std::string & | label, |
| const std::vector< double > & | errorPlus, | ||
| const std::vector< double > & | errorMinus = std::vector< double >() |
||
| ) |
Set error bars in the X direction for a data series.
| [in] | label | The label identifier of the data series. |
| [in] | errorPlus | The error values in the positive X direction. |
| [in] | errorMinus | The error values in the negative X direction. If empty, symmetric error bars (same as errorPlus) are used. |
| void QmitkChartWidget::SetYAxisLabel | ( | const std::string & | label | ) |
Set the Y axis label text.
| [in] | label | The label text. |
| void QmitkChartWidget::SetYAxisScale | ( | AxisScale | scale | ) |
Set the Y axis scale type.
| [in] | scale | The axis scale (linear or logarithmic). |
| void QmitkChartWidget::SetYErrorBars | ( | const std::string & | label, |
| const std::vector< double > & | errorPlus, | ||
| const std::vector< double > & | errorMinus = std::vector< double >() |
||
| ) |
Set error bars in the Y direction for a data series.
| [in] | label | The label identifier of the data series. |
| [in] | errorPlus | The error values in the positive Y direction. |
| [in] | errorMinus | The error values in the negative Y direction. If empty, symmetric error bars (same as errorPlus) are used. |
| void QmitkChartWidget::Show | ( | bool | showSubChart = false | ) |
|
override |
Return the recommended size for the widget.
| void QmitkChartWidget::UpdateChartExampleData | ( | const std::vector< std::pair< double, double > > & | data2D, |
| const std::string & | label, | ||
| const std::string & | type, | ||
| const std::string & | color, | ||
| const std::string & | lineStyle, | ||
| const std::string & | pieLabelsData = {} |
||
| ) |
Update chart example data with full property specification.
| [in] | data2D | The (x, y) data pairs. |
| [in] | label | The data series label. |
| [in] | type | The chart type as a string. |
| [in] | color | The color as a string. |
| [in] | lineStyle | The line style as a string. |
| [in] | pieLabelsData | Optional pie chart labels (default: empty). |
| void QmitkChartWidget::UpdateData1D | ( | const std::vector< double > & | data1D, |
| const std::string & | label | ||
| ) |
Update the data of an existing 1D data series.
| [in] | data1D | The new y-values. |
| [in] | label | The label of the existing data series. |
| void QmitkChartWidget::UpdateData2D | ( | const std::vector< std::pair< double, double > > & | data2D, |
| const std::string & | label | ||
| ) |
Update the data of an existing 2D data series.
| [in] | data2D | The new (x, y) value pairs. |
| [in] | label | The label of the existing data series. |
| void QmitkChartWidget::UpdateLabel | ( | const std::string & | existingLabel, |
| const std::string & | newLabel | ||
| ) |
Rename an existing data series.
| [in] | existingLabel | The current label of the data series. |
| [in] | newLabel | The new label to assign. |