Debian Codegraph @

tests/manual/chartviewer/charts/barseries/verticalpercentbarchart.cpp

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 #undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
5
6 #include "charts.h"
7 #include <QtCharts/QChart>
8 #include <QtCharts/QPercentBarSeries>
9 #include <QtCharts/QBarSet>
10
11 class VerticalPercentBarChart: public Chart
12 {
13 public:
14 QString name() { return QObject::tr("VerticalPercentBarChart"); }
15 QString category() { return QObject::tr("BarSeries"); }
16 QString subCategory() { return QObject::tr("Vertical"); }
17
18 QChart *createChart(const DataTable &table)
19 {
20 QChart *chart = new QChart();
21 chart->setTitle("Percent bar chart");
22 QPercentBarSeries *series = new QPercentBarSeries(chart);
23 for (int i(0); i < table.count(); i++) {
24 QBarSet *set = new QBarSet("Bar set " + QString::number(i));
25 foreach (Data data, table[i])
26 *set << data.first.y();
27 series->append(set);
28 }
29 chart->addSeries(series);
30 chart->createDefaultAxes();
31 return chart;
32 }
33 };
34
35 DECLARE_CHART(VerticalPercentBarChart)
36