Medical Imaging Interaction Toolkit
2023.04.00
Medical Imaging Interaction Toolkit
|
QmitkChartWidget is a widget to display various charts based on the javascript chart library plotly. More...
#include <QmitkChartWidget.h>
Public Slots | |
void | OnLoadFinished (bool isLoadSuccessful) |
void | OnPageSuccessfullyLoaded () |
Signals | |
void | PageSuccessfullyLoaded () |
Public Member Functions | |
QmitkChartWidget (QWidget *parent=nullptr) | |
QmitkChartWidget (QWidget *parent, bool unitTest) | |
~QmitkChartWidget () override | |
void | AddData1D (const std::vector< double > &data1D, const std::string &label, ChartType chartType=ChartType::bar) |
Adds 1D data to the widget. More... | |
void | UpdateData1D (const std::vector< double > &data1D, const std::string &label) |
Updates data of an existing label. More... | |
void | UpdateData2D (const std::vector< std::pair< double, double > > &data2D, const std::string &label) |
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=0) |
void | AddData2D (const std::vector< std::pair< double, double > > &data2D, const std::string &label, ChartType chartType=ChartType::bar) |
Adds 2D data to the widget. Call repeatedly for displaying multiple charts. 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=0) |
void | RemoveData (const std::string &label) |
Removes data from the widget, works for 1D and 2D Data. More... | |
void | UpdateLabel (const std::string &existingLabel, const std::string &newLabel) |
QmitkChartxyData * | GetDataElementByLabel (const std::string &label) const |
void | SetColor (const std::string &label, const std::string &colorName) |
Sets the color of one data entry (identifier is previously assigned label) More... | |
void | SetLineStyle (const std::string &label, LineStyle style) |
Sets the line style of one data entry (identifier is previously assigned label) More... | |
void | SetMarkerSymbol (const std::string &label, MarkerSymbol symbol) |
Sets the marker style of one data entry (identifier is previously assigned label) More... | |
void | SetYAxisScale (AxisScale scale) |
Sets the axis scale to either linear (default) or logarithmic. More... | |
void | SetXAxisLabel (const std::string &label) |
void | SetYAxisLabel (const std::string &label) |
void | SetPieLabels (const std::vector< std::string > &pieLabels, const std::string &label) |
Sets labels for pie chart data. More... | |
void | SetTitle (const std::string &title) |
Sets a title for the chart. More... | |
void | SetChartType (const std::string &label, ChartType type) |
Sets the chart type for a data entry. More... | |
void | SetXErrorBars (const std::string &label, const std::vector< double > &errorPlus, const std::vector< double > &errorMinus=std::vector< double >()) |
Sets error bars for data in x direction. More... | |
void | SetYErrorBars (const std::string &label, const std::vector< double > &errorPlus, const std::vector< double > &errorMinus=std::vector< double >()) |
Sets error bars for data in y direction. More... | |
void | SetLegendPosition (LegendPosition position) |
Sets the legend position. More... | |
void | SetShowLegend (bool show) |
void | SetStackedData (bool stacked) |
void | Show (bool showSubChart=false) |
Displays the chart in the widget. More... | |
void | SetShowDataPoints (bool showDataPoints) |
Either displays the dataPoints or not. More... | |
void | Clear () |
Clears all data inside and resets the widget. More... | |
void | SetTheme (ColorTheme themeEnabled) |
Sets the theme of the widget. More... | |
void | SetShowSubchart (bool showSubChart) |
Sets whether the subchart shall be shown. More... | |
void | SetShowErrorBars (bool showErrorBars) |
Sets whether the error bars shall be shown. More... | |
void | SetMinMaxValueXView (double minValueX, double maxValueX) |
Sets the min and max x values of the chart. More... | |
void | SetMinMaxValueYView (double minValueY, double maxValueY) |
Sets the min and max y values of the chart. More... | |
void | Reload () |
Reloads the chart in the widget. More... | |
QSize | sizeHint () const override |
void | SavePlotAsImage () |
QmitkChartWidget is a widget to display various charts based on the javascript chart library plotly.
Data is added via AddData1D() or AddData2D().
There can be multiple charts (of different types with different properties) created by calling AddData1D or AddData2D multiple times.
The following chart types are supported:
Technical details: The javascript code is embedded in a QWebEngineView. The actual js code is implemented in resource\Chart.js.
Definition at line 40 of file QmitkChartWidget.h.
|
strong |
Enumerator | |
---|---|
linear | |
log |
Definition at line 110 of file QmitkChartWidget.h.
|
strong |
Enumerator | |
---|---|
red | |
orange | |
yellow | |
green | |
blue | |
purple | |
brown | |
magenta | |
tan | |
cyan | |
olive | |
maroon | |
navy | |
aquamarine | |
turqouise | |
silver | |
lime | |
teal | |
indigo | |
violet | |
pink | |
black | |
white | |
grey |
Definition at line 84 of file QmitkChartWidget.h.
|
strong |
enum of diagram types.
Enumerator | |
---|---|
bar | bar chart, see https://plot.ly/javascript/bar-charts/ |
line | line chart, see https://plot.ly/javascript/line-charts/ |
spline | spline chart (smoothed line chart), see https://plot.ly/~jduelfer/23/spline/#/ |
pie | pie chart, see https://plot.ly/javascript/pie-charts/ |
area | area chart, see https://plot.ly/javascript/filled-area-plots/ |
area_spline | area-spline chart, similar to https://plot.ly/~jduelfer/23/spline/#/ |
scatter | scatter chart, see https://plot.ly/javascript/line-and-scatter/ |
Definition at line 48 of file QmitkChartWidget.h.
|
strong |
enum of chart style (modifies background and line color).
Enumerator | |
---|---|
darkstyle | background color: dark gray, foreground color: white |
lightstyle | background color: white, foreground color: black |
Definition at line 60 of file QmitkChartWidget.h.
|
strong |
enum of legend position. See https://plot.ly/javascript/legend/
Enumerator | |
---|---|
bottomMiddle | |
bottomRight | |
topRight | |
topLeft | |
middleRight |
Definition at line 119 of file QmitkChartWidget.h.
|
strong |
Enumerator | |
---|---|
solid | |
dashed |
Definition at line 64 of file QmitkChartWidget.h.
|
strong |
Enumerator | |
---|---|
circle | |
diamond | |
cross | |
square | |
pentagon | |
star | |
x | |
diamond_tall | |
star_diamond | |
star_triangle_up | |
star_triangle_down | |
asterisk | |
cross_thin | |
x_thin |
Definition at line 68 of file QmitkChartWidget.h.
|
explicit |
|
explicit |
|
override |
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 = 0 |
||
) |
void QmitkChartWidget::AddData1D | ( | const std::vector< double > & | data1D, |
const std::string & | label, | ||
ChartType | chartType = ChartType::bar |
||
) |
Adds 1D data to the widget.
internally, the list is converted to a map with increasing integers keys starting at 0.
data1D | |
label | the name of the data that is also used as identifier. |
chartType | the chart type that should be used for this data entry |
void QmitkChartWidget::AddData2D | ( | const std::vector< std::pair< double, double > > & | data2D, |
const std::string & | label, | ||
ChartType | chartType = ChartType::bar |
||
) |
Adds 2D data to the widget. Call repeatedly for displaying multiple charts.
each entry represents a data point: key: value --> x-value: y-value.
data2D | |
label | the name of the data that is also used as identifier. |
chartType | the chart type that should be used for this data entry |
void QmitkChartWidget::Clear | ( | ) |
Clears all data inside and resets the widget.
QmitkChartxyData* QmitkChartWidget::GetDataElementByLabel | ( | const std::string & | label | ) | const |
|
slot |
|
slot |
|
signal |
void QmitkChartWidget::Reload | ( | ) |
Reloads the chart in the widget.
reloading may be needed to display added data in an existing chart
void QmitkChartWidget::RemoveData | ( | const std::string & | label | ) |
Removes data from the widget, works for 1D and 2D Data.
label | the name of the data that is also used as identifier. |
Invalid | Argument Exception when the label cannot be found |
void QmitkChartWidget::SavePlotAsImage | ( | ) |
void QmitkChartWidget::SetChartType | ( | const std::string & | label, |
ChartType | type | ||
) |
Sets the chart type for a data entry.
for available types, see ChartType
void QmitkChartWidget::SetColor | ( | const std::string & | label, |
const std::string & | colorName | ||
) |
Sets the color of one data entry (identifier is previously assigned label)
the color name can be "red" or a hex number (#FF0000
).
void QmitkChartWidget::SetLegendPosition | ( | LegendPosition | position | ) |
void QmitkChartWidget::SetLineStyle | ( | const std::string & | label, |
LineStyle | style | ||
) |
Sets the line style of one data entry (identifier is previously assigned label)
two line styles are possible: LineStyle::solid and LineStyle::dashed. The default line style is solid.
void QmitkChartWidget::SetMarkerSymbol | ( | const std::string & | label, |
MarkerSymbol | symbol | ||
) |
Sets the marker style of one data entry (identifier is previously assigned label)
void QmitkChartWidget::SetMinMaxValueXView | ( | double | minValueX, |
double | maxValueX | ||
) |
Sets the min and max x values of the chart.
Zooms in to view the values between minValue and maxValue in x direction
void QmitkChartWidget::SetMinMaxValueYView | ( | double | minValueY, |
double | maxValueY | ||
) |
Sets the min and max y values of the chart.
Zooms in to view the values between minValue and maxValue in y direction
void QmitkChartWidget::SetPieLabels | ( | const std::vector< std::string > & | pieLabels, |
const std::string & | label | ||
) |
Sets labels for pie chart data.
void QmitkChartWidget::SetShowDataPoints | ( | bool | showDataPoints | ) |
Either displays the dataPoints or not.
showDataPoints | if dataPoints are displayed inside the widget or not. |
: example for not showing points: https://plot.ly/javascript/line-charts/#styling-line-plot example for showing the points: https://plot.ly/javascript/pointcloud/
void QmitkChartWidget::SetShowErrorBars | ( | bool | showErrorBars | ) |
Sets whether the error bars shall be shown.
Changes the state of the current chart object.
showErrorBars | if error bars are displayed or not. |
void QmitkChartWidget::SetShowLegend | ( | bool | show | ) |
void QmitkChartWidget::SetShowSubchart | ( | bool | showSubChart | ) |
Sets whether the subchart shall be shown.
Changes the state of the current chart object.
void QmitkChartWidget::SetStackedData | ( | bool | stacked | ) |
void QmitkChartWidget::SetTheme | ( | ColorTheme | themeEnabled | ) |
void QmitkChartWidget::SetTitle | ( | const std::string & | title | ) |
Sets a title for the chart.
void QmitkChartWidget::SetXAxisLabel | ( | const std::string & | label | ) |
void QmitkChartWidget::SetXErrorBars | ( | const std::string & | label, |
const std::vector< double > & | errorPlus, | ||
const std::vector< double > & | errorMinus = std::vector< double >() |
||
) |
Sets error bars for data in x direction.
label | the name of the data that is also used as identifier. |
errorPlus | the error in positive direction |
errorMinus | the error in negative direction. Same as error plus if omitted |
void QmitkChartWidget::SetYAxisLabel | ( | const std::string & | label | ) |
void QmitkChartWidget::SetYAxisScale | ( | AxisScale | scale | ) |
Sets the axis scale to either linear (default) or logarithmic.
void QmitkChartWidget::SetYErrorBars | ( | const std::string & | label, |
const std::vector< double > & | errorPlus, | ||
const std::vector< double > & | errorMinus = std::vector< double >() |
||
) |
Sets error bars for data in y direction.
for parameters, see SetXErrorBars
void QmitkChartWidget::Show | ( | bool | showSubChart = false | ) |
|
override |
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 = 0 |
||
) |
void QmitkChartWidget::UpdateData1D | ( | const std::vector< double > & | data1D, |
const std::string & | label | ||
) |
Updates data of an existing label.
data1D | the 1D data , |
label | the (existing) label |
void QmitkChartWidget::UpdateData2D | ( | const std::vector< std::pair< double, double > > & | data2D, |
const std::string & | label | ||
) |
void QmitkChartWidget::UpdateLabel | ( | const std::string & | existingLabel, |
const std::string & | newLabel | ||
) |