15 #include <QGridLayout> 16 #include <QWebChannel> 17 #include <QWebEngineSettings> 18 #include <QWebEngineView> 25 class CustomPage :
public QWebEnginePage
28 CustomPage(QObject *parent =
nullptr) : QWebEnginePage(parent) {}
29 virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel ,
30 const QString &message,
32 const QString & )
override 34 MITK_INFO <<
"JS > " << lineNumber <<
": " << message.toStdString();
38 class QmitkChartWidget::Impl final
41 explicit Impl(QWidget *parent);
44 Impl(
const Impl &) =
delete;
45 Impl &operator=(
const Impl &) =
delete;
48 void AddData2D(
const std::vector< std::pair<double, double> > &data2D,
49 const std::string &label,
52 void AddChartExampleData(
const std::vector< std::pair<double, double> >& data2D,
53 const std::string& label,
54 const std::string& type,
55 const std::string& color,
56 const std::string& style,
57 const std::string& pieLabelsData = 0);
59 void UpdateData1D(
const std::vector<double> &data1D,
const std::string &label);
60 void UpdateData2D(
const std::vector< std::pair<double, double> > &data2D,
const std::string &label);
61 void UpdateChartExampleData(
const std::vector< std::pair<double, double> >& data2D,
62 const std::string& label,
63 const std::string& type,
64 const std::string& color,
65 const std::string& lineStyle,
66 const std::string& pieLabelsData = 0);
68 void RemoveData(
const std::string &label);
70 void UpdateLabel(
const std::string &existingLabel,
const std::string &newLabel);
76 void SetColor(
const std::string &label,
const std::string &colorName);
78 void SetLineStyle(
const std::string &label, LineStyle style);
80 void SetMarkerSymbol(
const std::string &label, MarkerSymbol symbol);
82 void SetYAxisScale(AxisScale scale);
84 void SetXAxisLabel(
const std::string &label);
86 void SetYAxisLabel(
const std::string &label);
88 void SetPieLabels(
const std::vector<std::string> &pieLabels,
const std::string &label);
90 void SetTitle(
const std::string &title);
92 void SetXErrorBars(
const std::string &label,
93 const std::vector<double> &errorPlus,
94 const std::vector<double> &errorMinus = std::vector<double>());
95 void SetYErrorBars(
const std::string &label,
96 const std::vector<double> &errorPlus,
97 const std::vector<double> &errorMinus = std::vector<double>());
98 std::string GetThemeName()
const;
99 void SetThemeName(ColorTheme style);
101 void SetLegendPosition(LegendPosition position);
103 void Show(
bool showSubChart);
105 void SetShowLegend(
bool show);
106 void SetShowErrorBars(
bool show);
108 void SetStackedData(
bool stacked);
110 void SetShowDataPoints(
bool showDataPoints =
false);
112 void SetShowSubchart(
bool showSubChart);
116 void SetMinMaxValueXView(
double minValueX,
double maxValueX);
117 void SetMinMaxValueYView(
double minValueY,
double maxValueY);
119 QList<QVariant> ConvertErrorVectorToQList(
const std::vector<double> &error);
120 QList<QVariant> ConvertVectorToQList(
const std::vector<std::string> &vec);
124 void ClearJavaScriptChart();
125 void InitializeJavaScriptChart();
126 void CallJavaScriptFuntion(
const QString &command);
128 QSize sizeHint()
const;
133 using ChartxyDataVector = std::vector<std::unique_ptr<QmitkChartxyData>>;
134 std::string GetUniqueLabelName(
const QList<QVariant> &labelList,
const std::string &label)
const;
135 QList<QVariant> GetDataLabels(
const ChartxyDataVector &c3xyData)
const;
137 QWebChannel *m_WebChannel;
138 QWebEngineView *m_WebEngineView;
141 ChartxyDataVector m_C3xyData;
142 std::map<QmitkChartWidget::ChartType, std::string> m_ChartTypeToName;
143 std::map<QmitkChartWidget::ChartColor, std::string> m_ChartColorToName;
144 std::map<QmitkChartWidget::ColorTheme, std::string> m_ColorThemeToName;
145 std::map<QmitkChartWidget::LegendPosition, std::string> m_LegendPositionToName;
146 std::map<QmitkChartWidget::LineStyle, std::string> m_LineStyleToName;
147 std::map<QmitkChartWidget::MarkerSymbol, std::string> m_MarkerSymbolToName;
148 std::map<QmitkChartWidget::AxisScale, std::string> m_AxisScaleToName;
151 QmitkChartWidget::Impl::Impl(QWidget *parent)
152 : m_WebChannel(new QWebChannel(parent)), m_WebEngineView(new QWebEngineView(parent))
155 m_WebEngineView->setContextMenuPolicy(Qt::NoContextMenu);
157 m_WebEngineView->setPage(
new CustomPage());
161 m_WebEngineView->load(QUrl(QStringLiteral(
"qrc:///Chart/empty.html")));
162 m_WebEngineView->page()->setWebChannel(m_WebChannel);
164 m_WebEngineView->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled,
false);
166 connect(m_WebEngineView, SIGNAL(loadFinished(
bool)), parent, SLOT(OnLoadFinished(
bool)));
167 auto layout =
new QGridLayout(parent);
168 layout->setMargin(0);
169 layout->addWidget(m_WebEngineView);
170 m_ChartTypeToName.emplace(ChartType::bar,
"bar");
172 m_ChartTypeToName.emplace(ChartType::spline,
"spline");
173 m_ChartTypeToName.emplace(ChartType::pie,
"pie");
174 m_ChartTypeToName.emplace(ChartType::area,
"area");
175 m_ChartTypeToName.emplace(ChartType::area_spline,
"area-spline");
176 m_ChartTypeToName.emplace(ChartType::scatter,
"scatter");
178 m_ChartColorToName.emplace(ChartColor::red,
"red");
179 m_ChartColorToName.emplace(ChartColor::orange,
"orange");
180 m_ChartColorToName.emplace(ChartColor::yellow,
"yellow");
181 m_ChartColorToName.emplace(ChartColor::green,
"green");
182 m_ChartColorToName.emplace(ChartColor::blue,
"blue");
183 m_ChartColorToName.emplace(ChartColor::purple,
"purple");
184 m_ChartColorToName.emplace(ChartColor::brown,
"brown");
185 m_ChartColorToName.emplace(ChartColor::magenta,
"magenta");
186 m_ChartColorToName.emplace(ChartColor::tan,
"tan");
187 m_ChartColorToName.emplace(ChartColor::cyan,
"cyan");
188 m_ChartColorToName.emplace(ChartColor::olive,
"olive");
189 m_ChartColorToName.emplace(ChartColor::maroon,
"maroon");
190 m_ChartColorToName.emplace(ChartColor::navy,
"navy");
191 m_ChartColorToName.emplace(ChartColor::aquamarine,
"aquamarine");
192 m_ChartColorToName.emplace(ChartColor::turqouise,
"turqouise");
193 m_ChartColorToName.emplace(ChartColor::silver,
"silver");
194 m_ChartColorToName.emplace(ChartColor::lime,
"lime");
195 m_ChartColorToName.emplace(ChartColor::teal,
"teal");
196 m_ChartColorToName.emplace(ChartColor::indigo,
"indigo");
197 m_ChartColorToName.emplace(ChartColor::violet,
"violet");
198 m_ChartColorToName.emplace(ChartColor::pink,
"pink");
199 m_ChartColorToName.emplace(ChartColor::black,
"black");
200 m_ChartColorToName.emplace(ChartColor::white,
"white");
201 m_ChartColorToName.emplace(ChartColor::grey,
"grey");
203 m_LegendPositionToName.emplace(LegendPosition::bottomMiddle,
"bottomMiddle");
204 m_LegendPositionToName.emplace(LegendPosition::bottomRight,
"bottomRight");
205 m_LegendPositionToName.emplace(LegendPosition::topRight,
"topRight");
206 m_LegendPositionToName.emplace(LegendPosition::topLeft,
"topLeft");
207 m_LegendPositionToName.emplace(LegendPosition::middleRight,
"middleRight");
209 m_LineStyleToName.emplace(LineStyle::solid,
"solid");
210 m_LineStyleToName.emplace(LineStyle::dashed,
"dashed");
212 m_MarkerSymbolToName.emplace(MarkerSymbol::circle,
"circle");
213 m_MarkerSymbolToName.emplace(MarkerSymbol::cross,
"cross");
214 m_MarkerSymbolToName.emplace(MarkerSymbol::diamond,
"diamond");
215 m_MarkerSymbolToName.emplace(MarkerSymbol::pentagon,
"pentagon");
217 m_MarkerSymbolToName.emplace(MarkerSymbol::star,
"star");
218 m_MarkerSymbolToName.emplace(MarkerSymbol::x,
"x");
220 m_MarkerSymbolToName.emplace(MarkerSymbol::diamond_tall,
"diamond-tall");
221 m_MarkerSymbolToName.emplace(MarkerSymbol::star_diamond,
"star-diamond");
222 m_MarkerSymbolToName.emplace(MarkerSymbol::star_triangle_up,
"star-triangle-up");
223 m_MarkerSymbolToName.emplace(MarkerSymbol::star_triangle_down,
"star-triangle-down");
224 m_MarkerSymbolToName.emplace(MarkerSymbol::asterisk,
"asterisk");
225 m_MarkerSymbolToName.emplace(MarkerSymbol::cross_thin,
"cross-thin");
226 m_MarkerSymbolToName.emplace(MarkerSymbol::x_thin,
"x-thin");
228 m_AxisScaleToName.emplace(AxisScale::linear,
"");
229 m_AxisScaleToName.emplace(AxisScale::log,
"log");
231 m_ColorThemeToName.emplace(ColorTheme::lightstyle,
"light");
232 m_ColorThemeToName.emplace(ColorTheme::darkstyle,
"dark");
235 QmitkChartWidget::Impl::~Impl() {}
237 std::string QmitkChartWidget::Impl::GetThemeName()
const 239 return m_C3Data.GetThemeName().toString().toStdString();
244 std::regex rgx(
"([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})");
247 if (!colorName.empty() && colorName.at(0) !=
'#' && std::regex_search(colorName.begin(), colorName.end(), match, rgx))
249 return "#" + colorName;
257 void QmitkChartWidget::Impl::GetImageUrl()
259 m_C3Data.EmitSignalImageUrl();
262 void QmitkChartWidget::Impl::AddData1D(
const std::vector<double> &data1D,
263 const std::string &label,
266 std::vector< std::pair<double, double> > transformedData2D;
267 unsigned int count = 0;
269 for (
const auto &ele : data1D)
271 transformedData2D.emplace_back(count, ele);
275 AddData2D(transformedData2D, label, type);
278 void QmitkChartWidget::Impl::AddData2D(
const std::vector< std::pair<double, double> > &data2D,
279 const std::string &label,
282 const std::string chartTypeName(m_ChartTypeToName.at(type));
284 auto definedLabels = GetDataLabels(m_C3xyData);
285 auto uniqueLabel = GetUniqueLabelName(definedLabels, label);
287 unsigned int sizeOfC3xyData =
static_cast<unsigned int>(m_C3xyData.size());
288 m_C3xyData.push_back(std::make_unique<QmitkChartxyData>(data2D,
289 QVariant(QString::fromStdString(uniqueLabel)),
290 QVariant(QString::fromStdString(chartTypeName)),
291 QVariant(sizeOfC3xyData)));
294 void QmitkChartWidget::Impl::AddChartExampleData(
const std::vector< std::pair<double, double> >& data2D,
295 const std::string& label,
296 const std::string& type,
297 const std::string& color,
298 const std::string& lineStyle,
299 const std::string& pieLabelsData)
301 auto definedLabels = GetDataLabels(m_C3xyData);
302 auto uniqueLabel = GetUniqueLabelName(definedLabels, label);
303 if (type ==
"scatter")
305 SetShowDataPoints(
true);
306 MITK_INFO <<
"Enabling data points for all because of scatter plot";
308 unsigned int sizeOfC3xyData =
static_cast<unsigned int>(m_C3xyData.size());
310 std::unique_ptr<QmitkChartxyData> chartData =
311 std::make_unique<QmitkChartxyData>(
313 QVariant(QString::fromStdString(uniqueLabel)),
314 QVariant(QString::fromStdString(type)),
315 QVariant(sizeOfC3xyData));
317 chartData->
SetColor(QVariant(QString::fromStdString(color)));
318 chartData->
SetLineStyle(QVariant(QString::fromStdString(lineStyle)));
320 if (pieLabelsData !=
"")
322 std::string pieLabelsDataWorkingString = pieLabelsData;
324 QList<QVariant> pieLabelsDataList;
325 while (pieLabelsDataWorkingString.size() != 0)
327 QVariant oneElement = QString::fromStdString(pieLabelsDataWorkingString.substr(0, pieLabelsDataWorkingString.find(
";")));
328 pieLabelsDataList.push_back(oneElement);
330 if (pieLabelsDataWorkingString.find(
";") != std::string::npos)
332 pieLabelsDataWorkingString.erase(0, pieLabelsDataWorkingString.find(
";") + 1);
336 pieLabelsDataWorkingString.erase(pieLabelsDataWorkingString.begin(), pieLabelsDataWorkingString.end());
343 m_C3xyData.push_back(std::move(chartData));
346 void QmitkChartWidget::Impl::UpdateData1D(
const std::vector<double> &data1D,
const std::string &label)
348 std::vector< std::pair<double, double> > transformedData2D;
349 unsigned int count = 0;
351 for (
const auto &ele : data1D)
353 transformedData2D.emplace_back( count, ele );
357 UpdateData2D(transformedData2D, label);
360 void QmitkChartWidget::Impl::UpdateData2D(
const std::vector< std::pair<double, double> > &data2D,
const std::string &label)
362 auto element = GetDataElementByLabel(label);
364 element->SetData(data2D);
367 void QmitkChartWidget::Impl::UpdateChartExampleData(
const std::vector< std::pair<double, double> >& data2D,
368 const std::string& label,
369 const std::string& type,
370 const std::string& color,
371 const std::string& lineStyle,
372 const std::string& pieLabelsData)
374 UpdateData2D(data2D, label);
376 auto element = GetDataElementByLabel(label);
379 element->SetChartType(QString::fromStdString(type));
380 element->SetColor(QString::fromStdString(color));
381 element->SetLineStyle(QString::fromStdString(lineStyle));
383 if (pieLabelsData !=
"")
385 std::string pieLabelsDataWorkingString = pieLabelsData;
387 QList<QVariant> pieLabelsDataList;
388 while (pieLabelsDataWorkingString.size() != 0)
390 QVariant oneElement = QString::fromStdString(pieLabelsDataWorkingString.substr(0, pieLabelsDataWorkingString.find(
";")));
391 pieLabelsDataList.push_back(oneElement);
393 if (pieLabelsDataWorkingString.find(
";") != std::string::npos)
395 pieLabelsDataWorkingString.erase(0, pieLabelsDataWorkingString.find(
";") + 1);
399 pieLabelsDataWorkingString.erase(pieLabelsDataWorkingString.begin(), pieLabelsDataWorkingString.end());
403 element->SetPieLabels(pieLabelsDataList);
408 void QmitkChartWidget::Impl::RemoveData(
const std::string &label)
410 for (ChartxyDataVector::iterator iter = m_C3xyData.begin(); iter != m_C3xyData.end(); ++iter)
412 if ((*iter)->GetLabel().toString().toStdString() == label)
414 m_C3xyData.erase(iter);
419 throw std::invalid_argument(
"Cannot Remove Data because the label does not exist.");
422 void QmitkChartWidget::Impl::ClearData()
424 for (
auto &xyData : m_C3xyData)
426 m_WebChannel->deregisterObject(xyData.get());
432 void QmitkChartWidget::Impl::UpdateLabel(
const std::string &existingLabel,
const std::string &newLabel) {
433 auto element = GetDataElementByLabel(existingLabel);
436 auto definedLabels = GetDataLabels(m_C3xyData);
437 auto uniqueLabel = GetUniqueLabelName(definedLabels, newLabel);
438 element->SetLabel(QString::fromStdString(uniqueLabel));
442 void QmitkChartWidget::Impl::SetColor(
const std::string &label,
const std::string &colorName)
444 auto element = GetDataElementByLabel(label);
448 element->SetColor(QVariant(QString::fromStdString(colorChecked)));
452 void QmitkChartWidget::Impl::SetLineStyle(
const std::string &label, LineStyle style)
454 auto element = GetDataElementByLabel(label);
455 const std::string lineStyleName(m_LineStyleToName.at(style));
456 element->SetLineStyle(QVariant(QString::fromStdString(lineStyleName)));
459 void QmitkChartWidget::Impl::SetMarkerSymbol(
const std::string &label, MarkerSymbol symbol)
461 auto element = GetDataElementByLabel(label);
462 const std::string markerSymbolName(m_MarkerSymbolToName.at(symbol));
463 element->SetMarkerSymbol(QVariant(QString::fromStdString(markerSymbolName)));
466 void QmitkChartWidget::Impl::SetYAxisScale(AxisScale scale)
468 const std::string axisScaleName(m_AxisScaleToName.at(scale));
469 m_C3Data.SetYAxisScale(QString::fromStdString(axisScaleName));
472 QmitkChartxyData *QmitkChartWidget::Impl::GetDataElementByLabel(
const std::string &label)
const 474 for (
const auto &qmitkChartxyData : m_C3xyData)
476 if (qmitkChartxyData->GetLabel().toString() == label.c_str())
478 return qmitkChartxyData.get();
484 QList<QVariant> QmitkChartWidget::Impl::GetDataLabels(
const ChartxyDataVector &c3xyData)
const 486 QList<QVariant> dataLabels;
487 for (
auto element = c3xyData.begin(); element != c3xyData.end(); ++element)
489 dataLabels.push_back((*element)->GetLabel());
494 void QmitkChartWidget::Impl::SetXAxisLabel(
const std::string &label)
496 m_C3Data.SetXAxisLabel(QString::fromStdString(label));
499 void QmitkChartWidget::Impl::SetYAxisLabel(
const std::string &label)
501 m_C3Data.SetYAxisLabel(QString::fromStdString(label));
504 void QmitkChartWidget::Impl::SetPieLabels(
const std::vector<std::string> &pieLabels,
const std::string &label)
506 auto element = GetDataElementByLabel(label);
509 if (element->GetChartType() == QVariant(
"pie"))
511 auto dataY = element->GetYData();
512 element->SetPieLabels(ConvertVectorToQList(pieLabels));
513 if (static_cast<unsigned>(dataY.size()) != pieLabels.size())
515 MITK_INFO <<
"data has " << dataY.size() <<
" entries whereas pie labels have " << pieLabels.size()
516 <<
" entries. Unnamed pie labels automatically get a numerical label.";
521 MITK_INFO <<
"label" << label <<
"has chart type " << element->GetChartType().toString().toStdString() <<
", but pie is required";
526 void QmitkChartWidget::Impl::SetTitle(
const std::string &title)
528 m_C3Data.SetTitle(QString::fromStdString(title));
533 const std::string themeName(m_ColorThemeToName.at(style));
534 m_C3Data.SetThemeName(QString::fromStdString(themeName));
539 const std::string legendPositionName(m_LegendPositionToName.at(legendPosition));
540 m_C3Data.SetLegendPosition(QString::fromStdString(legendPositionName));
543 void QmitkChartWidget::Impl::Show(
bool showSubChart)
545 if (m_C3xyData.empty())
547 MITK_WARN <<
"no data available for display in chart";
552 m_C3Data.SetAppearance(showSubChart, m_C3xyData.front()->GetChartType() == QVariant(
"pie"));
555 InitializeJavaScriptChart();
558 void QmitkChartWidget::Impl::SetShowLegend(
bool show)
560 m_C3Data.SetShowLegend(show);
563 void QmitkChartWidget::Impl::SetStackedData(
bool stacked)
565 m_C3Data.SetStackedData(stacked);
568 void QmitkChartWidget::Impl::SetShowErrorBars(
bool show)
570 m_C3Data.SetShowErrorBars(show);
573 void QmitkChartWidget::Impl::SetShowDataPoints(
bool showDataPoints)
575 if (showDataPoints ==
true)
577 m_C3Data.SetDataPointSize(6.5);
581 m_C3Data.SetDataPointSize(0);
585 void QmitkChartWidget::Impl::SetShowSubchart(
bool showSubChart) {
586 m_C3Data.SetShowSubchart(showSubChart);
591 auto element = GetDataElementByLabel(label);
594 if (chartType == ChartType::scatter)
596 SetShowDataPoints(
true);
597 MITK_INFO <<
"Enabling data points for all because of scatter plot";
599 const std::string chartTypeName(m_ChartTypeToName.at(chartType));
600 element->SetChartType(QVariant(QString::fromStdString(chartTypeName)));
604 void QmitkChartWidget::Impl::SetMinMaxValueXView(
double minValueX,
double maxValueX) {
605 m_C3Data.SetMinValueXView(minValueX);
606 m_C3Data.SetMaxValueXView(maxValueX);
609 void QmitkChartWidget::Impl::SetMinMaxValueYView(
double minValueY,
double maxValueY) {
610 m_C3Data.SetMinValueYView(minValueY);
611 m_C3Data.SetMaxValueYView(maxValueY);
614 QList<QVariant> QmitkChartWidget::Impl::ConvertErrorVectorToQList(
const std::vector<double> &error)
616 QList<QVariant> errorConverted;
617 for (
const auto &aValue : error)
619 errorConverted.append(aValue);
622 return errorConverted;
625 QList<QVariant> QmitkChartWidget::Impl::ConvertVectorToQList(
const std::vector<std::string> &vec)
627 QList<QVariant> vecConverted;
628 for (
const auto &aValue : vec)
630 vecConverted.append(QString::fromStdString(aValue));
636 void QmitkChartWidget::Impl::SetXErrorBars(
const std::string &label,
637 const std::vector<double> &errorPlus,
638 const std::vector<double> &errorMinus)
640 auto element = GetDataElementByLabel(label);
643 auto errorConvertedPlus = ConvertErrorVectorToQList(errorPlus);
644 auto errorConvertedMinus = ConvertErrorVectorToQList(errorMinus);
646 element->SetXErrorDataPlus(errorConvertedPlus);
647 element->SetXErrorDataMinus(errorConvertedMinus);
651 void QmitkChartWidget::Impl::SetYErrorBars(
const std::string &label,
652 const std::vector<double> &errorPlus,
653 const std::vector<double> &errorMinus)
655 auto element = GetDataElementByLabel(label);
658 auto errorConvertedPlus = ConvertErrorVectorToQList(errorPlus);
659 auto errorConvertedMinus = ConvertErrorVectorToQList(errorMinus);
661 element->SetYErrorDataPlus(errorConvertedPlus);
662 element->SetYErrorDataMinus(errorConvertedMinus);
668 return m_ChartTypeToName.at(chartType);
671 QSize QmitkChartWidget::Impl::sizeHint()
const 673 return QSize(400, 300);
676 void QmitkChartWidget::Impl::CallJavaScriptFuntion(
const QString &command)
678 m_WebEngineView->page()->runJavaScript(command);
681 void QmitkChartWidget::Impl::ClearJavaScriptChart()
683 m_WebEngineView->load(QUrl(QStringLiteral(
"qrc:///Chart/empty.html")));
686 void QmitkChartWidget::Impl::InitializeJavaScriptChart()
688 auto alreadyRegisteredObjects = m_WebChannel->registeredObjects();
689 auto alreadyRegisteredObjectsValues = alreadyRegisteredObjects.values();
691 if (alreadyRegisteredObjectsValues.indexOf(&m_C3Data) == -1)
693 m_WebChannel->registerObject(QStringLiteral(
"chartData"), &m_C3Data);
697 for (
auto &xyData : m_C3xyData)
700 if (alreadyRegisteredObjectsValues.indexOf(xyData.get()) == -1)
702 QString variableName =
"xyData" + QString::number(count);
703 m_WebChannel->registerObject(variableName, xyData.get());
708 m_WebEngineView->load(QUrl(QStringLiteral(
"qrc:///Chart/QmitkChartWidget.html")));
711 std::string QmitkChartWidget::Impl::GetUniqueLabelName(
const QList<QVariant> &labelList,
const std::string &label)
const 713 QString currentLabel = QString::fromStdString(label);
715 while (labelList.contains(currentLabel))
717 currentLabel = QString::fromStdString(label + std::to_string(counter));
720 return currentLabel.toStdString();
731 m_Impl->SetColor(label, colorName);
736 m_Impl->SetLineStyle(label, style);
741 m_Impl->SetMarkerSymbol(label, symbol);
746 m_Impl->SetYAxisScale(scale);
751 m_Impl->AddData1D(data1D, label, type);
756 m_Impl->AddData2D(data2D, label, type);
760 const std::string& label,
761 const std::string& type,
762 const std::string& color,
763 const std::string& lineStyle,
764 const std::string& pieLabelsData)
766 m_Impl->AddChartExampleData(data2D, label, type, color, lineStyle, pieLabelsData);
771 m_Impl->UpdateData1D(data1D, label);
776 m_Impl->UpdateData2D(data2D, label);
780 const std::string& label,
781 const std::string& type,
782 const std::string& color,
783 const std::string& lineStyle,
784 const std::string& pieLabelsData)
786 m_Impl->UpdateChartExampleData(data2D, label, type, color, lineStyle, pieLabelsData);
791 m_Impl->RemoveData(label);
795 m_Impl->UpdateLabel(existingLabel, newLabel);
800 return m_Impl->GetDataElementByLabel(label);
805 m_Impl->SetXAxisLabel(label);
810 m_Impl->SetYAxisLabel(label);
815 m_Impl->SetPieLabels(pieLabels, label);
820 m_Impl->SetTitle(title);
825 m_Impl->SetShowDataPoints(showDataPoints);
830 m_Impl->SetChartType(label, type);
834 const std::vector<double> &errorPlus,
835 const std::vector<double> &errorMinus)
837 m_Impl->SetXErrorBars(label, errorPlus, errorMinus);
841 const std::vector<double> &errorPlus,
842 const std::vector<double> &errorMinus)
844 m_Impl->SetYErrorBars(label, errorPlus, errorMinus);
849 m_Impl->SetLegendPosition(position);
854 m_Impl->SetShowLegend(show);
859 m_Impl->SetStackedData(stacked);
864 m_Impl->Show(showSubChart);
870 m_Impl->ClearJavaScriptChart();
875 if (isLoadSuccessful)
883 auto themeName = m_Impl->GetThemeName();
885 if (themeName ==
"dark")
887 command = QString(
"changeTheme('dark')");
891 command = QString(
"changeTheme('light')");
894 m_Impl->CallJavaScriptFuntion(command);
899 m_Impl->SetThemeName(themeEnabled);
904 m_Impl->SetShowSubchart(showSubChart);
909 m_Impl->SetShowErrorBars(showErrorBars);
914 m_Impl->SetMinMaxValueXView(minValueX, maxValueX);
919 m_Impl->SetMinMaxValueYView(minValueY, maxValueY);
924 const QString command = QString(
"Reload()");
925 m_Impl->CallJavaScriptFuntion(command);
930 return m_Impl->sizeHint();
935 m_Impl->GetImageUrl();
This class holds the relevant properties for the chart generation with C3 such as labels and diagram ...
Q_INVOKABLE void SetPieLabels(const QList< QVariant > &pieLabels)
Q_INVOKABLE void SetLineStyle(const QVariant &lineStyle)
Q_INVOKABLE void SetColor(const QVariant &color)