Medical Imaging Interaction Toolkit
2018.4.99-389bf124
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) |
Adds 2D data to the widget. Call repeatedly for displaying multiple charts. More... | |
void | AddData2D (const std::vector< std::pair< double, double > > &data2D, const std::string &label, ChartType chartType=ChartType::bar) |
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 |
Definition at line 723 of file QmitkChartWidget.cpp.
References OnPageSuccessfullyLoaded(), and PageSuccessfullyLoaded().
|
explicit |
|
override |
Definition at line 728 of file QmitkChartWidget.cpp.
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 |
||
) |
Definition at line 759 of file QmitkChartWidget.cpp.
Referenced by mitk::ChartExampleTestHelper::Add().
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.
label | the name of the data that is also used as identifier. |
chartType | the chart type that should be used for this data entry |
Definition at line 749 of file QmitkChartWidget.cpp.
void QmitkChartWidget::AddData2D | ( | const std::vector< std::pair< double, double > > & | data2D, |
const std::string & | label, | ||
ChartType | chartType = ChartType::bar |
||
) |
Definition at line 754 of file QmitkChartWidget.cpp.
void QmitkChartWidget::Clear | ( | ) |
Clears all data inside and resets the widget.
Definition at line 867 of file QmitkChartWidget.cpp.
Referenced by mitk::ChartExampleTestHelper::ClearMemory().
QmitkChartxyData * QmitkChartWidget::GetDataElementByLabel | ( | const std::string & | label | ) | const |
Definition at line 798 of file QmitkChartWidget.cpp.
|
slot |
Definition at line 873 of file QmitkChartWidget.cpp.
References PageSuccessfullyLoaded().
|
slot |
Definition at line 881 of file QmitkChartWidget.cpp.
Referenced by QmitkChartWidget().
|
signal |
Referenced by OnLoadFinished(), QmitkChartWidget(), and QmitkIntensityProfileVisualizationWidget::SetTheme().
void QmitkChartWidget::Reload | ( | ) |
Reloads the chart in the widget.
reloading may be needed to display added data in an existing chart
Definition at line 922 of file QmitkChartWidget.cpp.
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 |
Definition at line 789 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SavePlotAsImage | ( | ) |
Definition at line 933 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetChartType | ( | const std::string & | label, |
ChartType | type | ||
) |
Sets the chart type for a data entry.
for available types, see ChartType
Definition at line 828 of file QmitkChartWidget.cpp.
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).
Definition at line 729 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetLegendPosition | ( | LegendPosition | position | ) |
Sets the legend position.
Default position is bottom.
Definition at line 847 of file QmitkChartWidget.cpp.
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.
Definition at line 734 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetMarkerSymbol | ( | const std::string & | label, |
MarkerSymbol | symbol | ||
) |
Sets the marker style of one data entry (identifier is previously assigned label)
Definition at line 739 of file QmitkChartWidget.cpp.
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
Definition at line 912 of file QmitkChartWidget.cpp.
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
Definition at line 917 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetPieLabels | ( | const std::vector< std::string > & | pieLabels, |
const std::string & | label | ||
) |
Sets labels for pie chart data.
Definition at line 813 of file QmitkChartWidget.cpp.
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/
Definition at line 823 of file QmitkChartWidget.cpp.
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. |
Definition at line 907 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetShowLegend | ( | bool | show | ) |
Definition at line 852 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetShowSubchart | ( | bool | showSubChart | ) |
Sets whether the subchart shall be shown.
Changes the state of the current chart object.
Definition at line 902 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetStackedData | ( | bool | stacked | ) |
Definition at line 857 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetTheme | ( | ColorTheme | themeEnabled | ) |
Sets the theme of the widget.
default is dark theme as in MITK.
Definition at line 897 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetTitle | ( | const std::string & | title | ) |
Sets a title for the chart.
Definition at line 818 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetXAxisLabel | ( | const std::string & | label | ) |
Definition at line 803 of file QmitkChartWidget.cpp.
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 |
Definition at line 833 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetYAxisLabel | ( | const std::string & | label | ) |
Definition at line 808 of file QmitkChartWidget.cpp.
void QmitkChartWidget::SetYAxisScale | ( | AxisScale | scale | ) |
Sets the axis scale to either linear (default) or logarithmic.
Definition at line 744 of file QmitkChartWidget.cpp.
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
Definition at line 840 of file QmitkChartWidget.cpp.
void QmitkChartWidget::Show | ( | bool | showSubChart = false | ) |
Displays the chart in the widget.
showSubChart | if a subchart is displayed inside the widget or not. |
Definition at line 862 of file QmitkChartWidget.cpp.
|
override |
Definition at line 928 of file QmitkChartWidget.cpp.
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 |
||
) |
Adds 2D data to the widget. Call repeatedly for displaying multiple charts.
each entry represents a data point: key: value –> x-value: y-value.
label | the name of the data that is also used as identifier. |
chartType | the chart type that should be used for this data entry |
Definition at line 779 of file QmitkChartWidget.cpp.
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 |
Definition at line 769 of file QmitkChartWidget.cpp.
void QmitkChartWidget::UpdateData2D | ( | const std::vector< std::pair< double, double > > & | data2D, |
const std::string & | label | ||
) |
Definition at line 774 of file QmitkChartWidget.cpp.
void QmitkChartWidget::UpdateLabel | ( | const std::string & | existingLabel, |
const std::string & | newLabel | ||
) |
Definition at line 794 of file QmitkChartWidget.cpp.