@@ -1,155 +1,155 | |||
|
1 | 1 | /*! |
|
2 | 2 | \class Widget |
|
3 | 3 | \brief Ui for the application. |
|
4 | 4 | */ |
|
5 | 5 | |
|
6 | 6 | #include "widget.h" |
|
7 | 7 | #include <QGridLayout> |
|
8 | 8 | #include <QPushButton> |
|
9 | 9 | #include <QLabel> |
|
10 | 10 | |
|
11 | 11 | #include <QSqlQuery> |
|
12 | 12 | #include <qscatterseries.h> |
|
13 | 13 | #include <qchartview.h> |
|
14 | 14 | #include <qchartaxis.h> |
|
15 | 15 | #include <qbarchartseries.h> |
|
16 | 16 | #include <qbarcategory.h> |
|
17 | 17 | #include <qbarset.h> |
|
18 | 18 | #include <QListWidget> |
|
19 | 19 | |
|
20 | 20 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
21 | 21 | |
|
22 | 22 | Widget::Widget(QWidget *parent) |
|
23 | 23 | : QWidget(parent) |
|
24 | { | |
|
24 | { | |
|
25 | 25 | setGeometry(100, 100, 800, 600); |
|
26 | 26 | |
|
27 | 27 | // right panel layout |
|
28 | 28 | countrieslist = new QListWidget; |
|
29 | 29 | countrieslist->setSelectionMode(QAbstractItemView::MultiSelection); |
|
30 | 30 | |
|
31 | 31 | yearslist = new QListWidget; |
|
32 | 32 | yearslist->setSelectionMode(QAbstractItemView::ExtendedSelection); |
|
33 | 33 | for (int i = 1990; i < 2011; i++) |
|
34 | 34 | yearslist->addItem(QString("%1").arg(i)); |
|
35 | 35 | |
|
36 | 36 | QPushButton* refreshButton = new QPushButton(tr("Refresh")); |
|
37 | 37 | connect(refreshButton, SIGNAL(clicked()), this, SLOT(refreshChart())); |
|
38 | 38 | |
|
39 | 39 | QVBoxLayout* rightPanelLayout = new QVBoxLayout; |
|
40 | 40 | rightPanelLayout->addWidget(countrieslist); |
|
41 | 41 | rightPanelLayout->addWidget(yearslist); |
|
42 | 42 | rightPanelLayout->addWidget(refreshButton); |
|
43 | 43 | rightPanelLayout->setStretch(0, 1); |
|
44 | 44 | rightPanelLayout->setStretch(1, 0); |
|
45 | 45 | |
|
46 | 46 | // main layout |
|
47 | 47 | chartArea = new QChartView(this); |
|
48 | 48 | chartArea->setChartTitle("GDP by country"); |
|
49 | 49 | QGridLayout* mainLayout = new QGridLayout; |
|
50 | 50 | mainLayout->addWidget(chartArea, 0, 0); |
|
51 | 51 | mainLayout->addLayout(rightPanelLayout, 0, 1); |
|
52 | 52 | mainLayout->setColumnStretch(0,1); |
|
53 | 53 | setLayout(mainLayout); |
|
54 | 54 | |
|
55 | 55 | // connect to the database |
|
56 | 56 | db = QSqlDatabase::addDatabase("QSQLITE"); |
|
57 | 57 | db.setDatabaseName("gdpData"); |
|
58 | 58 | if(!db.open()) |
|
59 | 59 | { |
|
60 | 60 | qDebug() << "could not open database. SQLite db file missing (?)"; |
|
61 | 61 | return; |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | // get the list of all countires and regions. |
|
65 | 65 | QSqlQuery query; |
|
66 | 66 | query.exec("SELECT DISTINCT country FROM gdp2"); |
|
67 | 67 | |
|
68 | 68 | // add the countries to the country filter |
|
69 | 69 | while (query.next()) { |
|
70 | 70 | countrieslist->addItem(query.value(0).toString()); |
|
71 | 71 | } |
|
72 | 72 | |
|
73 | 73 | // hide axis X labels |
|
74 |
QChartAxis |
|
|
75 |
|
|
|
74 | QChartAxis* axis = chartArea->axisX(); | |
|
75 | axis->setLabelsVisible(false); | |
|
76 | 76 | // newAxis.setLabelsOrientation(QChartAxis::LabelsOrientationSlide); |
|
77 | chartArea->setDefaultAxisX(newAxis); | |
|
77 | ||
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | Widget::~Widget() |
|
81 | 81 | { |
|
82 | 82 | // |
|
83 | 83 | db.close(); |
|
84 | 84 | } |
|
85 | 85 | |
|
86 | 86 | /*! |
|
87 | 87 | refreshes the chart |
|
88 | 88 | */ |
|
89 | 89 | void Widget::refreshChart() |
|
90 | 90 | { |
|
91 | 91 | // selected countries items list is not sorted. copy the values to QStringlist and sort them. |
|
92 | 92 | QStringList selectedCountriesStrings; |
|
93 | 93 | QList<QListWidgetItem*> selectedCountriesItems = countrieslist->selectedItems(); |
|
94 | 94 | for (int i = 0; i < selectedCountriesItems.size(); i++) |
|
95 | 95 | selectedCountriesStrings.append(selectedCountriesItems[i]->text()); |
|
96 | 96 | selectedCountriesStrings.sort(); |
|
97 | 97 | |
|
98 | 98 | // use the sorted selected coutries list to initialize BarCategory |
|
99 | 99 | QBarCategory* category = new QBarCategory; |
|
100 | 100 | for (int i = 0; i < selectedCountriesStrings.size(); i++) |
|
101 | 101 | *category << selectedCountriesStrings[i]; |
|
102 | 102 | QBarChartSeries* series0 = new QBarChartSeries(category); |
|
103 | 103 | |
|
104 | 104 | // prepare the selected counries SQL query |
|
105 | 105 | QString countriesQuery = "country IN ("; |
|
106 | 106 | for (int i = 0; i < selectedCountriesStrings.size(); i++) |
|
107 | 107 | { |
|
108 | 108 | countriesQuery.append("'" + selectedCountriesStrings[i] + "'"); |
|
109 | 109 | if ( i < selectedCountriesStrings.size() - 1) |
|
110 | 110 | countriesQuery.append(","); |
|
111 | 111 | else |
|
112 | 112 | countriesQuery.append(")"); |
|
113 | 113 | } |
|
114 | 114 | |
|
115 | 115 | QSqlQuery query; |
|
116 | 116 | // selected years items list is not sorted. copy the values to QList<Integer> and sort them. |
|
117 | 117 | QList<int> selectedYearsInts; |
|
118 | 118 | QList<QListWidgetItem*> selectedYearsItems = yearslist->selectedItems(); |
|
119 | 119 | for (int i = 0; i < selectedYearsItems.size(); i++) |
|
120 | 120 | selectedYearsInts.append(selectedYearsItems[i]->text().toInt()); |
|
121 | 121 | qSort(selectedYearsInts); |
|
122 | 122 | |
|
123 | 123 | // perform a query for each selected year |
|
124 | 124 | for (int i = 0; i < selectedYearsInts.size(); i++) |
|
125 | 125 | { |
|
126 | 126 | query.exec("SELECT country,gdpvalue FROM gdp2 where year=" + QString("%1").arg(selectedYearsInts[i]) + " AND " + countriesQuery); |
|
127 | 127 | QBarSet* barSet = new QBarSet; |
|
128 | 128 | // while (query.next()) { |
|
129 | 129 | // qDebug() << query.value(0).toString() << " : " << query.value(1).toString(); |
|
130 | 130 | // } |
|
131 | 131 | query.first(); |
|
132 | 132 | |
|
133 | 133 | // the data for some of the coutries for some years might be missing. |
|
134 | 134 | // QBarChart needs bars to have same size |
|
135 | 135 | for (int k = 0; k < selectedCountriesStrings.size(); k++) |
|
136 | 136 | { |
|
137 | 137 | if (selectedCountriesStrings[k] == query.value(0).toString()) |
|
138 | 138 | { |
|
139 | 139 | *barSet << query.value(1).toReal(); |
|
140 | 140 | qDebug() << query.value(0).toString() << query.value(1).toReal() << " : " << QString("%1").arg(selectedYearsInts[i]); |
|
141 | 141 | query.next(); |
|
142 | 142 | } |
|
143 | 143 | else |
|
144 | 144 | { |
|
145 | 145 | // data missing, put 0 |
|
146 | 146 | *barSet << 0.0f; |
|
147 | 147 | qDebug() << "Putting 0 for Bosnia" << " : " << QString("%1").arg(selectedYearsInts[i]); |
|
148 | 148 | } |
|
149 | 149 | } |
|
150 | 150 | series0->addBarSet(barSet); |
|
151 | 151 | } |
|
152 | 152 | |
|
153 | 153 | // add the serie to the chart |
|
154 | 154 | chartArea->addSeries(series0); |
|
155 | 155 | } |
@@ -1,21 +1,16 | |||
|
1 | 1 | #ifndef CHARTWIDGET_H |
|
2 | 2 | #define CHARTWIDGET_H |
|
3 | 3 | |
|
4 | 4 | #include <qchartview.h> |
|
5 | 5 | |
|
6 | 6 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
7 | 7 | |
|
8 | 8 | |
|
9 | 9 | class ChartWidget : public QChartView |
|
10 | 10 | { |
|
11 | 11 | Q_OBJECT |
|
12 | 12 | public: |
|
13 | 13 | explicit ChartWidget(QWidget *parent = 0); |
|
14 | ||
|
15 | signals: | |
|
16 | ||
|
17 | public slots: | |
|
18 | ||
|
19 | 14 | }; |
|
20 | 15 | |
|
21 | 16 | #endif // CHARTWIDGET_H |
@@ -1,91 +1,94 | |||
|
1 | 1 | #include "declarativeseries.h" |
|
2 | 2 | #include "declarativechart.h" |
|
3 | 3 | #include <qscatterseries.h> |
|
4 | 4 | #include <qlinechartseries.h> |
|
5 | #include <qpieseries.h> | |
|
5 | 6 | #include <cmath> |
|
6 | 7 | #include <QDebug> |
|
7 | 8 | |
|
8 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 10 | |
|
10 | 11 | DeclarativeSeries::DeclarativeSeries(QDeclarativeItem *parent) : |
|
11 | 12 | QDeclarativeItem(parent), |
|
12 | 13 | m_seriesType(SeriesTypeInvalid), // TODO: default type? |
|
13 | 14 | m_chart(0), |
|
14 | 15 | m_series(0) |
|
15 | 16 | { |
|
16 | 17 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
17 | 18 | connect(this, SIGNAL(parentChanged()), |
|
18 | 19 | this, SLOT(setParentForSeries())); |
|
19 | 20 | } |
|
20 | 21 | |
|
21 | 22 | void DeclarativeSeries::setSeriesType(SeriesType type) |
|
22 | 23 | { |
|
23 | 24 | if (!m_series || type != m_seriesType) { |
|
24 | 25 | m_seriesType = type; |
|
25 | 26 | initSeries(); |
|
26 | 27 | } else { |
|
27 | 28 | m_seriesType = type; |
|
28 | 29 | } |
|
29 | 30 | } |
|
30 | 31 | |
|
31 | 32 | void DeclarativeSeries::setParentForSeries() |
|
32 | 33 | { |
|
33 | 34 | if (!m_series) |
|
34 | 35 | initSeries(); |
|
35 | 36 | else if (m_series->type() != m_seriesType) |
|
36 | 37 | initSeries(); |
|
37 | 38 | } |
|
38 | 39 | |
|
39 | 40 | void DeclarativeSeries::initSeries() |
|
40 | 41 | { |
|
41 | 42 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(parent()); |
|
42 | 43 | |
|
43 | 44 | if (declarativeChart && m_seriesType != SeriesTypeInvalid) { |
|
44 | 45 | delete m_series; |
|
45 | 46 | m_series = 0; |
|
46 | 47 | |
|
47 | 48 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); |
|
48 | 49 | qDebug() << "creating series for chart: " << chart; |
|
49 | 50 | Q_ASSERT(chart); |
|
50 | 51 | |
|
51 | 52 | switch (m_seriesType) { |
|
52 | 53 | case SeriesTypeLine: { |
|
53 | 54 | m_series = new QLineChartSeries(this); |
|
54 | 55 | for (qreal i(0.0); i < 100.0; i += 1.0) |
|
55 | 56 | ((QLineChartSeries *)m_series)->add(i, i); |
|
56 | 57 | chart->addSeries(m_series); |
|
57 | 58 | break; |
|
58 | 59 | } |
|
59 | 60 | case SeriesTypeBar: |
|
60 | 61 | // fallthrough; bar and scatter use the same test data |
|
61 | 62 | case SeriesTypeScatter: { |
|
62 | m_series = chart->createSeries((QChartSeries::QChartSeriesType) m_seriesType); | |
|
63 | m_series = new QScatterSeries(); | |
|
64 | chart->addSeries(m_series); | |
|
63 | 65 | QScatterSeries *scatter = qobject_cast<QScatterSeries *>(m_series); |
|
64 | 66 | Q_ASSERT(scatter); |
|
65 | 67 | for (qreal i = 0; i < 100; i += 0.1) |
|
66 | 68 | scatter->addData(QPointF(i + (rand() % 5), |
|
67 | 69 | abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5))); |
|
68 | 70 | break; |
|
69 | 71 | } |
|
70 | 72 | case SeriesTypeStackedBar: |
|
71 | 73 | break; |
|
72 | 74 | case SeriesTypePercentBar: |
|
73 | 75 | break; |
|
74 | 76 | case SeriesTypePie: { |
|
75 | m_series = chart->createSeries((QChartSeries::QChartSeriesType) m_seriesType); | |
|
77 | m_series = new QPieSeries(); | |
|
78 | chart->addSeries(m_series); | |
|
76 | 79 | QList<qreal> data; |
|
77 | 80 | data << 1.0; |
|
78 | 81 | data << 12.0; |
|
79 | 82 | data << 4.0; |
|
80 | 83 | Q_ASSERT(m_series->setData(data)); |
|
81 | 84 | break; |
|
82 | 85 | } |
|
83 | 86 | default: |
|
84 | 87 | break; |
|
85 | 88 | } |
|
86 | 89 | } |
|
87 | 90 | } |
|
88 | 91 | |
|
89 | 92 | #include "moc_declarativeseries.cpp" |
|
90 | 93 | |
|
91 | 94 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,337 +1,334 | |||
|
1 | 1 | #include "chartdataset_p.h" |
|
2 | 2 | #include "qchartaxis.h" |
|
3 | 3 | //series |
|
4 | 4 | #include "qlinechartseries.h" |
|
5 | 5 | #include "qbarchartseries.h" |
|
6 | 6 | #include "qstackedbarchartseries.h" |
|
7 | 7 | #include "qpercentbarchartseries.h" |
|
8 | 8 | #include "qpieseries.h" |
|
9 | 9 | #include "qscatterseries.h" |
|
10 | 10 | |
|
11 | 11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
12 | 12 | |
|
13 | 13 | ChartDataSet::ChartDataSet(QObject *parent):QObject(parent), |
|
14 | 14 | m_axisX(new QChartAxis(this)), |
|
15 | 15 | m_axisY(new QChartAxis(this)), |
|
16 | 16 | m_domainIndex(0), |
|
17 | 17 | m_axisXInitialized(false) |
|
18 | 18 | { |
|
19 | 19 | } |
|
20 | 20 | |
|
21 | 21 | ChartDataSet::~ChartDataSet() |
|
22 | 22 | { |
|
23 | 23 | // TODO Auto-generated destructor stub |
|
24 | 24 | } |
|
25 | 25 | |
|
26 | 26 | const Domain ChartDataSet::domain(QChartAxis *axisY) const |
|
27 | 27 | { |
|
28 | 28 | int i = m_domainMap.count(axisY); |
|
29 | 29 | if(i == 0){ |
|
30 | 30 | return Domain(); |
|
31 | 31 | } |
|
32 | 32 | i = i - m_domainIndex -1; |
|
33 | 33 | return m_domainMap.values(axisY).at(i); |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | void ChartDataSet::addSeries(QChartSeries* series, QChartAxis *axisY) |
|
37 | 37 | { |
|
38 | 38 | // TODO: we should check the series not already added |
|
39 | 39 | series->setParent(this); // take ownership |
|
40 | 40 | |
|
41 | 41 | series->setParent(this); // take ownership |
|
42 | 42 | clearDomains(); |
|
43 | 43 | |
|
44 | 44 | if(axisY==0) axisY = m_axisY; |
|
45 | 45 | |
|
46 | 46 | QList<QChartSeries*> seriesList = m_seriesMap.values(axisY); |
|
47 | 47 | |
|
48 | 48 | QList<Domain> domainList = m_domainMap.values(axisY); |
|
49 | 49 | |
|
50 | 50 | Q_ASSERT(domainList.size()<=1); |
|
51 | 51 | |
|
52 | 52 | Domain domain; |
|
53 | 53 | |
|
54 | 54 | if(domainList.size()>0) domain = domainList.at(0); |
|
55 | 55 | |
|
56 | 56 | switch(series->type()) |
|
57 | 57 | { |
|
58 | 58 | case QChartSeries::SeriesTypeLine: { |
|
59 | 59 | |
|
60 | 60 | QLineChartSeries* xyseries = static_cast<QLineChartSeries*>(series); |
|
61 | 61 | |
|
62 | 62 | for (int i = 0; i < xyseries->count(); i++) |
|
63 | 63 | { |
|
64 | 64 | qreal x = xyseries->x(i); |
|
65 | 65 | qreal y = xyseries->y(i); |
|
66 | 66 | domain.m_minX = qMin(domain.m_minX,x); |
|
67 | 67 | domain.m_minY = qMin(domain.m_minY,y); |
|
68 | 68 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
69 | 69 | domain.m_maxY = qMax(domain.m_maxY,y); |
|
70 | 70 | } |
|
71 | 71 | break; |
|
72 | 72 | } |
|
73 | 73 | case QChartSeries::SeriesTypeBar: { |
|
74 | <<<<<<< HEAD | |
|
75 | 74 | qDebug() << "QChartSeries::SeriesTypeBar"; |
|
76 | ======= | |
|
77 | >>>>>>> Common naming convention for barcharts | |
|
78 | 75 | QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series); |
|
79 | 76 | qreal x = barSeries->countCategories(); |
|
80 | 77 | qreal y = barSeries->max(); |
|
81 | 78 | domain.m_minX = qMin(domain.m_minX,x); |
|
82 | 79 | domain.m_minY = qMin(domain.m_minY,y); |
|
83 | 80 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
84 | 81 | domain.m_maxY = qMax(domain.m_maxY,y); |
|
85 | 82 | break; |
|
86 | 83 | } |
|
87 | 84 | case QChartSeries::SeriesTypeStackedBar: { |
|
88 | 85 | qDebug() << "QChartSeries::SeriesTypeStackedBar"; |
|
89 | 86 | |
|
90 | 87 | QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series); |
|
91 | 88 | qreal x = stackedBarSeries->countCategories(); |
|
92 | 89 | qreal y = stackedBarSeries->maxCategorySum(); |
|
93 | 90 | domain.m_minX = qMin(domain.m_minX,x); |
|
94 | 91 | domain.m_minY = qMin(domain.m_minY,y); |
|
95 | 92 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
96 | 93 | domain.m_maxY = qMax(domain.m_maxY,y); |
|
97 | 94 | break; |
|
98 | 95 | } |
|
99 | 96 | case QChartSeries::SeriesTypePercentBar: { |
|
100 | 97 | qDebug() << "QChartSeries::SeriesTypePercentBar"; |
|
101 | 98 | |
|
102 | 99 | QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series); |
|
103 | 100 | qreal x = percentBarSeries->countCategories(); |
|
104 | 101 | domain.m_minX = qMin(domain.m_minX,x); |
|
105 | 102 | domain.m_minY = 0; |
|
106 | 103 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
107 | 104 | domain.m_maxY = 100; |
|
108 | 105 | break; |
|
109 | 106 | } |
|
110 | 107 | |
|
111 | 108 | case QChartSeries::SeriesTypePie: { |
|
112 | 109 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
113 | 110 | // TODO: domain stuff |
|
114 | 111 | break; |
|
115 | 112 | } |
|
116 | 113 | |
|
117 | 114 | case QChartSeries::SeriesTypeScatter: { |
|
118 | 115 | QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series); |
|
119 | 116 | Q_ASSERT(scatterSeries); |
|
120 | 117 | foreach (QPointF point, scatterSeries->data()) { |
|
121 | 118 | domain.m_minX = qMin(domain.m_minX, point.x()); |
|
122 | 119 | domain.m_maxX = qMax(domain.m_maxX, point.x()); |
|
123 | 120 | domain.m_minY = qMin(domain.m_minY, point.y()); |
|
124 | 121 | domain.m_maxY = qMax(domain.m_maxY, point.y()); |
|
125 | 122 | } |
|
126 | 123 | break; |
|
127 | 124 | } |
|
128 | 125 | |
|
129 | 126 | default: { |
|
130 | 127 | qDebug()<<__FUNCTION__<<"type" << series->type()<<"not supported"; |
|
131 | 128 | return; |
|
132 | 129 | break; |
|
133 | 130 | } |
|
134 | 131 | |
|
135 | 132 | } |
|
136 | 133 | |
|
137 | 134 | if(!m_domainMap.contains(axisY)) |
|
138 | 135 | { |
|
139 | 136 | emit axisAdded(axisY); |
|
140 | 137 | QObject::connect(axisY,SIGNAL(minChanged(qreal)),this,SLOT(handleMinChanged(qreal))); |
|
141 | 138 | QObject::connect(axisY,SIGNAL(maxChanged(qreal)),this,SLOT(handleMaxChanged(qreal))); |
|
142 | 139 | QObject::connect(axisY,SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*))); |
|
143 | 140 | } |
|
144 | 141 | m_domainMap.replace(axisY,domain); |
|
145 | 142 | m_seriesMap.insert(axisY,series); |
|
146 | 143 | |
|
147 | 144 | if(!m_axisXInitialized) |
|
148 | 145 | { |
|
149 | 146 | emit axisAdded(axisX()); |
|
150 | 147 | QObject::connect(axisX(),SIGNAL(minChanged(qreal)),this,SLOT(handleMinChanged(qreal))); |
|
151 | 148 | QObject::connect(axisX(),SIGNAL(maxChanged(qreal)),this,SLOT(handleMaxChanged(qreal))); |
|
152 | 149 | QObject::connect(axisX(),SIGNAL(ticksChanged(QChartAxis*)),this,SLOT(handleTickChanged(QChartAxis*))); |
|
153 | 150 | m_axisXInitialized=true; |
|
154 | 151 | } |
|
155 | 152 | |
|
156 | 153 | |
|
157 | 154 | emit seriesAdded(series); |
|
158 | 155 | QStringList ylabels = createLabels(axisY,domain.m_minY,domain.m_maxY); |
|
159 | 156 | QStringList xlabels = createLabels(axisX(),domain.m_minX,domain.m_maxX); |
|
160 | 157 | emit axisLabelsChanged(axisY,ylabels); |
|
161 | 158 | emit axisLabelsChanged(axisX(),xlabels); |
|
162 | 159 | emit seriesDomainChanged(series,domain); |
|
163 | 160 | |
|
164 | 161 | } |
|
165 | 162 | |
|
166 | 163 | void ChartDataSet::removeSeries(QChartSeries* series) |
|
167 | 164 | { |
|
168 | 165 | QList<QChartAxis*> keys = m_seriesMap.uniqueKeys(); |
|
169 | 166 | foreach(QChartAxis* axis , keys) { |
|
170 | 167 | if(m_seriesMap.contains(axis,series)){ |
|
171 | 168 | emit seriesRemoved(series); |
|
172 | 169 | m_seriesMap.remove(axis,series); |
|
173 | 170 | //remove axis if no longer there |
|
174 | 171 | if(!m_seriesMap.contains(axis) && axis != m_axisY){ |
|
175 | 172 | emit axisRemoved(axis); |
|
176 | 173 | m_domainMap.remove(axis); |
|
177 | 174 | delete axis; |
|
178 | 175 | } |
|
179 | 176 | break; |
|
180 | 177 | } |
|
181 | 178 | } |
|
182 | 179 | } |
|
183 | 180 | |
|
184 | 181 | bool ChartDataSet::nextDomain() |
|
185 | 182 | { |
|
186 | 183 | int limit = (m_domainMap.values().size()/m_domainMap.uniqueKeys().size())-1; |
|
187 | 184 | |
|
188 | 185 | if (m_domainIndex < limit) { |
|
189 | 186 | m_domainIndex++; |
|
190 | 187 | setDomain(m_domainIndex); |
|
191 | 188 | return true; |
|
192 | 189 | } |
|
193 | 190 | else { |
|
194 | 191 | return false; |
|
195 | 192 | } |
|
196 | 193 | } |
|
197 | 194 | |
|
198 | 195 | bool ChartDataSet::previousDomain() |
|
199 | 196 | { |
|
200 | 197 | if (m_domainIndex > 0) { |
|
201 | 198 | m_domainIndex--; |
|
202 | 199 | setDomain(m_domainIndex); |
|
203 | 200 | return true; |
|
204 | 201 | } |
|
205 | 202 | else { |
|
206 | 203 | return false; |
|
207 | 204 | } |
|
208 | 205 | } |
|
209 | 206 | |
|
210 | 207 | void ChartDataSet::setDomain(int index) |
|
211 | 208 | { |
|
212 | 209 | QList<QChartAxis*> domainList = m_domainMap.uniqueKeys(); |
|
213 | 210 | foreach (QChartAxis* axis , domainList) { |
|
214 | 211 | int i = m_domainMap.count(axis) - index -1; |
|
215 | 212 | Q_ASSERT(i>=0); |
|
216 | 213 | Domain domain = m_domainMap.values(axis).at(i); |
|
217 | 214 | QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY); |
|
218 | 215 | QList<QChartSeries*> seriesList = m_seriesMap.values(axis); |
|
219 | 216 | foreach(QChartSeries* series, seriesList) { |
|
220 | 217 | emit seriesDomainChanged(series,domain); |
|
221 | 218 | } |
|
222 | 219 | emit axisLabelsChanged(axis,labels); |
|
223 | 220 | } |
|
224 | 221 | |
|
225 | 222 | Domain domain = m_domainMap.value(axisY()); |
|
226 | 223 | QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX); |
|
227 | 224 | emit axisLabelsChanged(axisX(),labels); |
|
228 | 225 | } |
|
229 | 226 | |
|
230 | 227 | void ChartDataSet::clearDomains(int toIndex) |
|
231 | 228 | { |
|
232 | 229 | Q_ASSERT(toIndex>=0); |
|
233 | 230 | |
|
234 | 231 | m_domainIndex = toIndex; |
|
235 | 232 | |
|
236 | 233 | QList<QChartAxis*> keys = m_domainMap.uniqueKeys(); |
|
237 | 234 | |
|
238 | 235 | foreach (QChartAxis* key , keys) |
|
239 | 236 | { |
|
240 | 237 | QList<Domain> domains = m_domainMap.values(key); |
|
241 | 238 | m_domainMap.remove(key); |
|
242 | 239 | int i = domains.size() - toIndex - 1; |
|
243 | 240 | while(i--){ |
|
244 | 241 | domains.removeFirst(); |
|
245 | 242 | } |
|
246 | 243 | for(int j=domains.size()-1; j>=0 ;j--) |
|
247 | 244 | m_domainMap.insert(key,domains.at(j)); |
|
248 | 245 | } |
|
249 | 246 | } |
|
250 | 247 | |
|
251 | 248 | void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport) |
|
252 | 249 | { |
|
253 | 250 | Q_ASSERT(rect.isValid()); |
|
254 | 251 | Q_ASSERT(viewport.isValid()); |
|
255 | 252 | |
|
256 | 253 | clearDomains(m_domainIndex); |
|
257 | 254 | |
|
258 | 255 | QList<QChartAxis*> domainList = m_domainMap.uniqueKeys(); |
|
259 | 256 | |
|
260 | 257 | foreach (QChartAxis* axis , domainList){ |
|
261 | 258 | Domain domain(m_domainMap.value(axis).subDomain(rect,viewport.width(),viewport.height())); |
|
262 | 259 | QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY); |
|
263 | 260 | QList<QChartSeries*> seriesList = m_seriesMap.values(axis); |
|
264 | 261 | foreach(QChartSeries* series, seriesList){ |
|
265 | 262 | emit seriesDomainChanged(series,domain); |
|
266 | 263 | } |
|
267 | 264 | emit axisLabelsChanged(axis,labels); |
|
268 | 265 | m_domainMap.insert(axis,domain); |
|
269 | 266 | } |
|
270 | 267 | |
|
271 | 268 | Domain domain = m_domainMap.value(axisY()); |
|
272 | 269 | QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX); |
|
273 | 270 | emit axisLabelsChanged(axisX(),labels); |
|
274 | 271 | |
|
275 | 272 | m_domainIndex++; |
|
276 | 273 | } |
|
277 | 274 | |
|
278 | 275 | QChartAxis* ChartDataSet::axisY(QChartSeries* series) const |
|
279 | 276 | { |
|
280 | 277 | if(series == 0) return m_axisY; |
|
281 | 278 | |
|
282 | 279 | QList<QChartAxis*> keys = m_seriesMap.uniqueKeys(); |
|
283 | 280 | |
|
284 | 281 | foreach(QChartAxis* axis , keys) { |
|
285 | 282 | if(m_seriesMap.contains(axis,series)){ |
|
286 | 283 | return axis; |
|
287 | 284 | } |
|
288 | 285 | } |
|
289 | 286 | return 0; |
|
290 | 287 | } |
|
291 | 288 | |
|
292 | 289 | QStringList ChartDataSet::createLabels(QChartAxis* axis,qreal min, qreal max) |
|
293 | 290 | { |
|
294 | 291 | Q_ASSERT(max>=min); |
|
295 | 292 | |
|
296 | 293 | QStringList labels; |
|
297 | 294 | |
|
298 | 295 | int ticks = axis->ticksCount(); |
|
299 | 296 | |
|
300 | 297 | for(int i=0; i<= ticks; i++){ |
|
301 | 298 | qreal value = min + (i * (max - min)/ ticks); |
|
302 | 299 | QString label = axis->axisTickLabel(value); |
|
303 | 300 | if(label.isEmpty()){ |
|
304 | 301 | labels << QString::number(value); |
|
305 | 302 | }else{ |
|
306 | 303 | labels << label; |
|
307 | 304 | } |
|
308 | 305 | } |
|
309 | 306 | return labels; |
|
310 | 307 | } |
|
311 | 308 | |
|
312 | 309 | |
|
313 | 310 | void ChartDataSet::handleMinChanged(qreal min) |
|
314 | 311 | { |
|
315 | 312 | |
|
316 | 313 | } |
|
317 | 314 | |
|
318 | 315 | void ChartDataSet::handleMaxChanged(qreal max) |
|
319 | 316 | { |
|
320 | 317 | |
|
321 | 318 | } |
|
322 | 319 | |
|
323 | 320 | void ChartDataSet::handleTickChanged(QChartAxis* axis) |
|
324 | 321 | { |
|
325 | 322 | Domain domain = m_domainMap.value(axisY()); |
|
326 | 323 | if(axis==axisX()){ |
|
327 | 324 | QStringList labels = createLabels(axis,domain.m_minX,domain.m_maxX); |
|
328 | 325 | emit axisLabelsChanged(axis,labels); |
|
329 | 326 | }else{ |
|
330 | 327 | QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY); |
|
331 | 328 | emit axisLabelsChanged(axis,labels); |
|
332 | 329 | } |
|
333 | 330 | } |
|
334 | 331 | |
|
335 | 332 | #include "moc_chartdataset_p.cpp" |
|
336 | 333 | |
|
337 | 334 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,230 +1,229 | |||
|
1 | 1 | #include "charttheme_p.h" |
|
2 | 2 | #include "qchart.h" |
|
3 | 3 | #include "qchartaxis.h" |
|
4 | 4 | |
|
5 | 5 | |
|
6 | 6 | //series |
|
7 | 7 | #include "qbarset.h" |
|
8 | 8 | #include "qbarchartseries.h" |
|
9 | 9 | #include "qstackedbarchartseries.h" |
|
10 | 10 | #include "qpercentbarchartseries.h" |
|
11 | 11 | #include "qlinechartseries.h" |
|
12 | 12 | #include "qscatterseries.h" |
|
13 | 13 | #include "qpieseries.h" |
|
14 | 14 | #include "qpieslice.h" |
|
15 | 15 | |
|
16 | 16 | //items |
|
17 | 17 | #include "axisitem_p.h" |
|
18 | 18 | #include "barpresenter.h" |
|
19 | 19 | #include "stackedbarpresenter.h" |
|
20 | 20 | #include "linechartitem_p.h" |
|
21 | 21 | #include "percentbarpresenter.h" |
|
22 | #include "percentbargroup.h" | |
|
23 | 22 | #include "scatterpresenter_p.h" |
|
24 | 23 | #include "piepresenter.h" |
|
25 | 24 | |
|
26 | 25 | //themes |
|
27 | 26 | #include "chartthemevanilla_p.h" |
|
28 | 27 | #include "chartthemeicy_p.h" |
|
29 | 28 | #include "chartthemegrayscale_p.h" |
|
30 | 29 | #include "chartthemescientific_p.h" |
|
31 | 30 | |
|
32 | 31 | |
|
33 | 32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | 33 | |
|
35 | 34 | /* TODO |
|
36 | 35 | case QChart::ChartThemeUnnamed1: |
|
37 | 36 | m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff3fa9f5)), 2)); |
|
38 | 37 | m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff7AC943)), 2)); |
|
39 | 38 | m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF931E)), 2)); |
|
40 | 39 | m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF1D25)), 2)); |
|
41 | 40 | m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF7BAC)), 2)); |
|
42 | 41 | |
|
43 | 42 | m_gradientStartColor = QColor(QRgb(0xfff3dc9e)); |
|
44 | 43 | m_gradientEndColor = QColor(QRgb(0xffafafaf)); |
|
45 | 44 | */ |
|
46 | 45 | |
|
47 | 46 | ChartTheme::ChartTheme(QChart::ChartTheme id) |
|
48 | 47 | { |
|
49 | 48 | m_id = id; |
|
50 | 49 | m_seriesColor.append(QRgb(0xff000000)); |
|
51 | 50 | m_seriesColor.append(QRgb(0xff707070)); |
|
52 | 51 | m_gradientStartColor = QColor(QRgb(0xffffffff)); |
|
53 | 52 | m_gradientEndColor = QColor(QRgb(0xffafafaf)); |
|
54 | 53 | } |
|
55 | 54 | |
|
56 | 55 | |
|
57 | 56 | ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme) |
|
58 | 57 | { |
|
59 | 58 | switch(theme) { |
|
60 | 59 | case QChart::ChartThemeDefault: |
|
61 | 60 | return new ChartTheme(); |
|
62 | 61 | case QChart::ChartThemeVanilla: |
|
63 | 62 | return new ChartThemeVanilla(); |
|
64 | 63 | case QChart::ChartThemeIcy: |
|
65 | 64 | return new ChartThemeIcy(); |
|
66 | 65 | case QChart::ChartThemeGrayscale: |
|
67 | 66 | return new ChartThemeGrayscale(); |
|
68 | 67 | case QChart::ChartThemeScientific: |
|
69 | 68 | return new ChartThemeScientific(); |
|
70 | 69 | } |
|
71 | 70 | } |
|
72 | 71 | |
|
73 | 72 | void ChartTheme::decorate(QChart* chart) |
|
74 | 73 | { |
|
75 | 74 | QLinearGradient backgroundGradient; |
|
76 | 75 | backgroundGradient.setColorAt(0.0, m_gradientStartColor); |
|
77 | 76 | backgroundGradient.setColorAt(1.0, m_gradientEndColor); |
|
78 | 77 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
79 | 78 | chart->setChartBackgroundBrush(backgroundGradient); |
|
80 | 79 | } |
|
81 | 80 | //TODO helper to by removed later |
|
82 | 81 | void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count) |
|
83 | 82 | { |
|
84 | 83 | switch(series->type()) |
|
85 | 84 | { |
|
86 | 85 | case QChartSeries::SeriesTypeLine: { |
|
87 | 86 | QLineChartSeries* s = static_cast<QLineChartSeries*>(series); |
|
88 | 87 | LineChartItem* i = static_cast<LineChartItem*>(item); |
|
89 | 88 | decorate(i,s,count); |
|
90 | 89 | break; |
|
91 | 90 | } |
|
92 | 91 | case QChartSeries::SeriesTypeBar: { |
|
93 | 92 | QBarChartSeries* b = static_cast<QBarChartSeries*>(series); |
|
94 | 93 | BarPresenter* i = static_cast<BarPresenter*>(item); |
|
95 | 94 | decorate(i,b,count); |
|
96 | 95 | break; |
|
97 | 96 | } |
|
98 | 97 | case QChartSeries::SeriesTypeStackedBar: { |
|
99 | 98 | QStackedBarChartSeries* s = static_cast<QStackedBarChartSeries*>(series); |
|
100 | 99 | StackedBarPresenter* i = static_cast<StackedBarPresenter*>(item); |
|
101 | 100 | decorate(i,s,count); |
|
102 | 101 | break; |
|
103 | 102 | } |
|
104 | 103 | case QChartSeries::SeriesTypePercentBar: { |
|
105 | 104 | QPercentBarChartSeries* s = static_cast<QPercentBarChartSeries*>(series); |
|
106 | 105 | PercentBarPresenter* i = static_cast<PercentBarPresenter*>(item); |
|
107 | 106 | decorate(i,s,count); |
|
108 | 107 | break; |
|
109 | 108 | } |
|
110 | 109 | case QChartSeries::SeriesTypeScatter: { |
|
111 | 110 | QScatterSeries* s = qobject_cast<QScatterSeries*>(series); |
|
112 | 111 | Q_ASSERT(s); |
|
113 | 112 | ScatterPresenter* i = static_cast<ScatterPresenter*>(item); |
|
114 | 113 | Q_ASSERT(i); |
|
115 | 114 | decorate(i, s, count); |
|
116 | 115 | break; |
|
117 | 116 | } |
|
118 | 117 | case QChartSeries::SeriesTypePie: { |
|
119 | 118 | QPieSeries* s = static_cast<QPieSeries*>(series); |
|
120 | 119 | PiePresenter* i = static_cast<PiePresenter*>(item); |
|
121 | 120 | decorate(i,s,count); |
|
122 | 121 | break; |
|
123 | 122 | } |
|
124 | 123 | default: |
|
125 | 124 | qDebug()<<"Wrong item to be decorated by theme"; |
|
126 | 125 | break; |
|
127 | 126 | } |
|
128 | 127 | |
|
129 | 128 | } |
|
130 | 129 | |
|
131 | 130 | void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int count) |
|
132 | 131 | { |
|
133 | 132 | QPen pen; |
|
134 | 133 | if(pen != series->pen()){ |
|
135 | 134 | item->setPen(series->pen()); |
|
136 | 135 | return; |
|
137 | 136 | } |
|
138 | 137 | pen.setColor(m_seriesColor.at(count%m_seriesColor.size())); |
|
139 | 138 | pen.setWidthF(2); |
|
140 | 139 | item->setPen(pen); |
|
141 | 140 | } |
|
142 | 141 | |
|
143 | 142 | void ChartTheme::decorate(BarPresenter* item, QBarChartSeries* series,int count) |
|
144 | 143 | { |
|
145 | 144 | for (int i=0; i<series->countSets(); i++) { |
|
146 | 145 | series->nextSet(0==i)->setBrush(QBrush(m_seriesColor.at(i%m_seriesColor.count()))); |
|
147 | 146 | } |
|
148 | 147 | } |
|
149 | 148 | |
|
150 | 149 | void ChartTheme::decorate(StackedBarPresenter* item, QStackedBarChartSeries* series,int count) |
|
151 | 150 | { |
|
152 | 151 | for (int i=0; i<series->countSets(); i++) { |
|
153 | 152 | series->nextSet(0==i)->setBrush(QBrush(m_seriesColor.at(i%m_seriesColor.count()))); |
|
154 | 153 | } |
|
155 | 154 | } |
|
156 | 155 | |
|
157 | 156 | void ChartTheme::decorate(PercentBarPresenter* item, QPercentBarChartSeries* series,int count) |
|
158 | 157 | { |
|
159 | 158 | for (int i=0; i<series->countSets(); i++) { |
|
160 | 159 | series->nextSet(0==i)->setBrush(QBrush(m_seriesColor.at(i%m_seriesColor.count()))); |
|
161 | 160 | } |
|
162 | 161 | } |
|
163 | 162 | |
|
164 | 163 | void ChartTheme::decorate(ScatterPresenter* presenter, QScatterSeries* series, int count) |
|
165 | 164 | { |
|
166 | 165 | Q_ASSERT(presenter); |
|
167 | 166 | Q_ASSERT(series); |
|
168 | 167 | |
|
169 | 168 | QColor color = m_seriesColor.at(count % m_seriesColor.size()); |
|
170 | 169 | // TODO: define alpha in the theme? or in the series? |
|
171 | 170 | color.setAlpha(120); |
|
172 | 171 | |
|
173 | 172 | QBrush brush(color, Qt::SolidPattern); |
|
174 | 173 | presenter->m_markerBrush = brush; |
|
175 | 174 | |
|
176 | 175 | QPen pen(brush, 1); |
|
177 | 176 | pen.setColor(color); |
|
178 | 177 | presenter->m_markerPen = pen; |
|
179 | 178 | } |
|
180 | 179 | |
|
181 | 180 | void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/) |
|
182 | 181 | { |
|
183 | 182 | // create a list of slice colors based on current theme |
|
184 | 183 | int i = 0; |
|
185 | 184 | QList<QColor> colors; |
|
186 | 185 | while (colors.count() < series->count()) { |
|
187 | 186 | |
|
188 | 187 | // get base color |
|
189 | 188 | QColor c = m_seriesColor[i++]; |
|
190 | 189 | i = i % m_seriesColor.count(); |
|
191 | 190 | |
|
192 | 191 | // -1 means achromatic color -> cannot manipulate lightness |
|
193 | 192 | // TODO: find a better way to randomize lightness |
|
194 | 193 | if (c.toHsv().hue() == -1) |
|
195 | 194 | qWarning() << "ChartTheme::decorate() warning: achromatic theme color"; |
|
196 | 195 | |
|
197 | 196 | // randomize lightness |
|
198 | 197 | qreal f = 50 + (qrand() % 100); // 50 is 50% darker, 100 is the same, 150 is 50% lighter |
|
199 | 198 | c = c.lighter(f); |
|
200 | 199 | |
|
201 | 200 | // find duplicates |
|
202 | 201 | bool isUnique = true; |
|
203 | 202 | foreach (QColor color, colors) { |
|
204 | 203 | if (c == color) |
|
205 | 204 | isUnique = false; |
|
206 | 205 | } |
|
207 | 206 | |
|
208 | 207 | // add to array if unique |
|
209 | 208 | //if (isUnique) |
|
210 | 209 | colors << c; |
|
211 | 210 | } |
|
212 | 211 | |
|
213 | 212 | // finally update colors |
|
214 | 213 | foreach (QPieSlice* s, series->slices()) { |
|
215 | 214 | s->setPen(QPen(Qt::black)); // TODO: get from theme |
|
216 | 215 | s->setBrush(colors.takeFirst()); |
|
217 | 216 | } |
|
218 | 217 | } |
|
219 | 218 | |
|
220 | 219 | |
|
221 | 220 | void ChartTheme::decorate(QChartAxis* axis,AxisItem* item) |
|
222 | 221 | { |
|
223 | 222 | //TODO: dummy defults for now |
|
224 | 223 | axis->setLabelsBrush(Qt::black); |
|
225 | 224 | axis->setLabelsPen(Qt::NoPen); |
|
226 | 225 | axis->setShadesPen(Qt::NoPen); |
|
227 | 226 | axis->setShadesOpacity(0.5); |
|
228 | 227 | } |
|
229 | 228 | |
|
230 | 229 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,430 +1,431 | |||
|
1 | 1 | #include "mainwidget.h" |
|
2 | 2 | #include "dataseriedialog.h" |
|
3 | 3 | #include "qchartseries.h" |
|
4 | 4 | #include "qpieseries.h" |
|
5 | 5 | #include "qscatterseries.h" |
|
6 | 6 | #include <qlinechartseries.h> |
|
7 | 7 | #include <qbarset.h> |
|
8 | 8 | #include <qbarcategory.h> |
|
9 | 9 | #include <qbarchartseries.h> |
|
10 | 10 | #include <qstackedbarchartseries.h> |
|
11 | 11 | #include <qpercentbarchartseries.h> |
|
12 | 12 | #include <QPushButton> |
|
13 | 13 | #include <QComboBox> |
|
14 | 14 | #include <QSpinBox> |
|
15 | 15 | #include <QCheckBox> |
|
16 | 16 | #include <QGridLayout> |
|
17 | 17 | #include <QHBoxLayout> |
|
18 | 18 | #include <QLabel> |
|
19 | 19 | #include <QSpacerItem> |
|
20 | 20 | #include <QMessageBox> |
|
21 | 21 | #include <cmath> |
|
22 | 22 | #include <QDebug> |
|
23 | 23 | #include <QStandardItemModel> |
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | 27 | |
|
28 | 28 | MainWidget::MainWidget(QWidget *parent) : |
|
29 | 29 | QWidget(parent) |
|
30 | 30 | { |
|
31 | 31 | m_chartWidget = new QChartView(this); |
|
32 | 32 | m_chartWidget->setRubberBandPolicy(QChartView::HorizonalRubberBand); |
|
33 | 33 | |
|
34 | 34 | // Grid layout for the controls for configuring the chart widget |
|
35 | 35 | QGridLayout *grid = new QGridLayout(); |
|
36 | 36 | QPushButton *addSeriesButton = new QPushButton("Add series"); |
|
37 | 37 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); |
|
38 | 38 | grid->addWidget(addSeriesButton, 0, 1); |
|
39 | 39 | initBackroundCombo(grid); |
|
40 | 40 | initScaleControls(grid); |
|
41 | 41 | initThemeCombo(grid); |
|
42 | 42 | QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom"); |
|
43 | 43 | connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartWidget, SLOT(setZoomEnabled(bool))); |
|
44 | 44 | zoomCheckBox->setChecked(true); |
|
45 | 45 | grid->addWidget(zoomCheckBox, grid->rowCount(), 0); |
|
46 | 46 | // add row with empty label to make all the other rows static |
|
47 | 47 | grid->addWidget(new QLabel(""), grid->rowCount(), 0); |
|
48 | 48 | grid->setRowStretch(grid->rowCount() - 1, 1); |
|
49 | 49 | |
|
50 | 50 | // Another grid layout as a main layout |
|
51 | 51 | QGridLayout *mainLayout = new QGridLayout(); |
|
52 | 52 | mainLayout->addLayout(grid, 0, 0); |
|
53 | 53 | |
|
54 | 54 | // Init series type specific controls |
|
55 | 55 | initPieControls(); |
|
56 | 56 | mainLayout->addLayout(m_pieLayout, 2, 0); |
|
57 | 57 | // Scatter series specific settings |
|
58 | 58 | // m_scatterLayout = new QGridLayout(); |
|
59 | 59 | // m_scatterLayout->addWidget(new QLabel("scatter"), 0, 0); |
|
60 | 60 | // m_scatterLayout->setEnabled(false); |
|
61 | 61 | // mainLayout->addLayout(m_scatterLayout, 1, 0); |
|
62 | 62 | |
|
63 | 63 | // Add layouts and the chart widget to the main layout |
|
64 | 64 | mainLayout->addWidget(m_chartWidget, 0, 1, 3, 1); |
|
65 | 65 | setLayout(mainLayout); |
|
66 | 66 | |
|
67 | 67 | // force an update to test data |
|
68 | 68 | testDataChanged(0); |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | // Combo box for selecting the chart's background |
|
72 | 72 | void MainWidget::initBackroundCombo(QGridLayout *grid) |
|
73 | 73 | { |
|
74 | 74 | QComboBox *backgroundCombo = new QComboBox(this); |
|
75 | 75 | backgroundCombo->addItem("Color"); |
|
76 | 76 | backgroundCombo->addItem("Gradient"); |
|
77 | 77 | backgroundCombo->addItem("Image"); |
|
78 | 78 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), |
|
79 | 79 | this, SLOT(backgroundChanged(int))); |
|
80 | 80 | |
|
81 | 81 | grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0); |
|
82 | 82 | grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1); |
|
83 | 83 | } |
|
84 | 84 | |
|
85 | 85 | // Scale related controls (auto-scale vs. manual min-max values) |
|
86 | 86 | void MainWidget::initScaleControls(QGridLayout *grid) |
|
87 | 87 | { |
|
88 | 88 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); |
|
89 | 89 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); |
|
90 | 90 | // Allow setting also non-sense values (like -2147483648 and 2147483647) |
|
91 | 91 | m_xMinSpin = new QSpinBox(); |
|
92 | 92 | m_xMinSpin->setMinimum(INT_MIN); |
|
93 | 93 | m_xMinSpin->setMaximum(INT_MAX); |
|
94 | 94 | m_xMinSpin->setValue(0); |
|
95 | 95 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); |
|
96 | 96 | m_xMaxSpin = new QSpinBox(); |
|
97 | 97 | m_xMaxSpin->setMinimum(INT_MIN); |
|
98 | 98 | m_xMaxSpin->setMaximum(INT_MAX); |
|
99 | 99 | m_xMaxSpin->setValue(10); |
|
100 | 100 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); |
|
101 | 101 | m_yMinSpin = new QSpinBox(); |
|
102 | 102 | m_yMinSpin->setMinimum(INT_MIN); |
|
103 | 103 | m_yMinSpin->setMaximum(INT_MAX); |
|
104 | 104 | m_yMinSpin->setValue(0); |
|
105 | 105 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); |
|
106 | 106 | m_yMaxSpin = new QSpinBox(); |
|
107 | 107 | m_yMaxSpin->setMinimum(INT_MIN); |
|
108 | 108 | m_yMaxSpin->setMaximum(INT_MAX); |
|
109 | 109 | m_yMaxSpin->setValue(10); |
|
110 | 110 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); |
|
111 | 111 | |
|
112 | 112 | grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0); |
|
113 | 113 | grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0); |
|
114 | 114 | grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1); |
|
115 | 115 | grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0); |
|
116 | 116 | grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1); |
|
117 | 117 | grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0); |
|
118 | 118 | grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1); |
|
119 | 119 | grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0); |
|
120 | 120 | grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1); |
|
121 | 121 | |
|
122 | 122 | m_autoScaleCheck->setChecked(true); |
|
123 | 123 | } |
|
124 | 124 | |
|
125 | 125 | // Combo box for selecting theme |
|
126 | 126 | void MainWidget::initThemeCombo(QGridLayout *grid) |
|
127 | 127 | { |
|
128 | 128 | QComboBox *chartTheme = new QComboBox(); |
|
129 | 129 | chartTheme->addItem("Default"); |
|
130 | 130 | chartTheme->addItem("Vanilla"); |
|
131 | 131 | chartTheme->addItem("Icy"); |
|
132 | 132 | chartTheme->addItem("Grayscale"); |
|
133 | 133 | chartTheme->addItem("Scientific"); |
|
134 | 134 | chartTheme->addItem("Unnamed1"); |
|
135 | 135 | connect(chartTheme, SIGNAL(currentIndexChanged(int)), |
|
136 | 136 | this, SLOT(changeChartTheme(int))); |
|
137 | 137 | grid->addWidget(new QLabel("Chart theme:"), 8, 0); |
|
138 | 138 | grid->addWidget(chartTheme, 8, 1); |
|
139 | 139 | } |
|
140 | 140 | |
|
141 | 141 | void MainWidget::initPieControls() |
|
142 | 142 | { |
|
143 | 143 | // Pie series specific settings |
|
144 | 144 | // Pie size factory |
|
145 | 145 | QDoubleSpinBox *pieSizeSpin = new QDoubleSpinBox(); |
|
146 | 146 | pieSizeSpin->setMinimum(LONG_MIN); |
|
147 | 147 | pieSizeSpin->setMaximum(LONG_MAX); |
|
148 | 148 | pieSizeSpin->setValue(1.0); |
|
149 | 149 | pieSizeSpin->setSingleStep(0.1); |
|
150 | 150 | connect(pieSizeSpin, SIGNAL(valueChanged(double)), this, SLOT(setPieSizeFactor(double))); |
|
151 | 151 | // Pie position |
|
152 | 152 | QComboBox *piePosCombo = new QComboBox(this); |
|
153 | 153 | piePosCombo->addItem("Maximized"); |
|
154 | 154 | piePosCombo->addItem("Top left"); |
|
155 | 155 | piePosCombo->addItem("Top right"); |
|
156 | 156 | piePosCombo->addItem("Bottom left"); |
|
157 | 157 | piePosCombo->addItem("Bottom right"); |
|
158 | 158 | connect(piePosCombo, SIGNAL(currentIndexChanged(int)), |
|
159 | 159 | this, SLOT(setPiePosition(int))); |
|
160 | 160 | m_pieLayout = new QGridLayout(); |
|
161 | 161 | m_pieLayout->setEnabled(false); |
|
162 | 162 | m_pieLayout->addWidget(new QLabel("Pie size factor"), 0, 0); |
|
163 | 163 | m_pieLayout->addWidget(pieSizeSpin, 0, 1); |
|
164 | 164 | m_pieLayout->addWidget(new QLabel("Pie position"), 1, 0); |
|
165 | 165 | m_pieLayout->addWidget(piePosCombo, 1, 1); |
|
166 | 166 | } |
|
167 | 167 | |
|
168 | 168 | void MainWidget::addSeries() |
|
169 | 169 | { |
|
170 | 170 | DataSerieDialog dialog(m_defaultSeriesName, this); |
|
171 | 171 | connect(&dialog, SIGNAL(accepted(QString, QString)), this, SLOT(addSeries(QString, QString))); |
|
172 | 172 | dialog.exec(); |
|
173 | 173 | } |
|
174 | 174 | |
|
175 | 175 | void MainWidget::addSeries(QString series, QString data) |
|
176 | 176 | { |
|
177 | 177 | qDebug() << "addSeries: " << series << " data: " << data; |
|
178 | 178 | m_defaultSeriesName = series; |
|
179 | 179 | |
|
180 | 180 | // TODO: a dedicated data class for storing x and y values |
|
181 | 181 | QList<qreal> x; |
|
182 | 182 | QList<qreal> y; |
|
183 | 183 | |
|
184 | 184 | QBarSet *set0 = new QBarSet; |
|
185 | 185 | QBarSet *set1 = new QBarSet; |
|
186 | 186 | QBarSet *set2 = new QBarSet; |
|
187 | 187 | QBarSet *set3 = new QBarSet; |
|
188 | 188 | QBarSet *set4 = new QBarSet; |
|
189 | 189 | |
|
190 | 190 | if (data == "linear") { |
|
191 | 191 | for (int i = 0; i < 20; i++) { |
|
192 | 192 | x.append(i); |
|
193 | 193 | y.append(i); |
|
194 | 194 | } |
|
195 | 195 | } else if (data == "linear, 1M") { |
|
196 | 196 | // 1 million data points from 0.0001 to 100 |
|
197 | 197 | // TODO: What is the requirement? Should we be able to show this kind of data with |
|
198 | 198 | // reasonable performance, or can we expect the application developer to do "data mining" |
|
199 | 199 | // for us, so that the count of data points given to QtCommercial Chart is always |
|
200 | 200 | // reasonable? |
|
201 | 201 | for (qreal i = 0; i < 100; i += 0.0001) { |
|
202 | 202 | x.append(i); |
|
203 | 203 | y.append(20); |
|
204 | 204 | } |
|
205 | 205 | } else if (data == "SIN") { |
|
206 | 206 | for (int i = 0; i < 100; i++) { |
|
207 | 207 | x.append(i); |
|
208 | 208 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100)); |
|
209 | 209 | } |
|
210 | 210 | } else if (data == "SIN + random") { |
|
211 | 211 | for (qreal i = 0; i < 100; i += 0.1) { |
|
212 | 212 | x.append(i + (rand() % 5)); |
|
213 | 213 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); |
|
214 | 214 | } |
|
215 | 215 | } else if (data == "Table, 5 series"){ |
|
216 | 216 | // Create some test data to chart |
|
217 | 217 | *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; |
|
218 | 218 | *set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2; |
|
219 | 219 | *set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5; |
|
220 | 220 | *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7; |
|
221 | 221 | *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; |
|
222 | 222 | } else { |
|
223 | 223 | // TODO: check if data has a valid file name |
|
224 | 224 | Q_ASSERT(false); |
|
225 | 225 | } |
|
226 | 226 | |
|
227 | 227 | // TODO: color of the series |
|
228 | 228 | QChartSeries *newSeries = 0; |
|
229 | 229 | if (series == "Scatter") { |
|
230 | 230 | QScatterSeries *scatter = new QScatterSeries(); |
|
231 | 231 | for (int i(0); i < x.count() && i < y.count(); i++) |
|
232 | 232 | (*scatter) << QPointF(x.at(i), y.at(i)); |
|
233 | 233 | m_chartWidget->addSeries(scatter); |
|
234 | 234 | } else if (series == "Pie") { |
|
235 | newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypePie); | |
|
235 | newSeries = new QPieSeries(); | |
|
236 | m_chartWidget->addSeries(newSeries); | |
|
236 | 237 | Q_ASSERT(newSeries->setData(y)); |
|
237 | 238 | } else if (series == "Line") { |
|
238 | 239 | // TODO: adding data to an existing line series does not give any visuals for some reason |
|
239 | 240 | // newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypeLine); |
|
240 | 241 | // QXYChartSeries *lineSeries = static_cast<QXYChartSeries *>(newSeries); |
|
241 | 242 | // lineSeries->setColor(Qt::blue); |
|
242 | 243 | // for (int i(0); i < x.count() && i < y.count(); i++) { |
|
243 | 244 | // lineSeries->add(x.at(i), y.at(i)); |
|
244 | 245 | // } |
|
245 | 246 | //Q_ASSERT(newSeries->setData(x, y)); |
|
246 | 247 | QLineChartSeries* series0 = new QLineChartSeries(); |
|
247 | 248 | for (int i(0); i < x.count() && i < y.count(); i++) |
|
248 | 249 | series0->add(x.at(i), y.at(i)); |
|
249 | 250 | m_chartWidget->addSeries(series0); |
|
250 | 251 | newSeries = series0; |
|
251 | 252 | } else if (series == "Bar") { |
|
252 | 253 | qDebug() << "Bar chart series"; |
|
253 | 254 | |
|
254 | 255 | QBarCategory *category = new QBarCategory; |
|
255 | 256 | *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; |
|
256 | 257 | |
|
257 | BarChartSeries* series0 = new BarChartSeries(category, this); | |
|
258 | QBarChartSeries* series0 = new QBarChartSeries(category, this); | |
|
258 | 259 | |
|
259 | 260 | series0->addBarSet(set0); |
|
260 | 261 | series0->addBarSet(set1); |
|
261 | 262 | series0->addBarSet(set2); |
|
262 | 263 | series0->addBarSet(set3); |
|
263 | 264 | series0->addBarSet(set4); |
|
264 | 265 | |
|
265 | 266 | m_chartWidget->addSeries(series0); |
|
266 | 267 | newSeries = series0; |
|
267 | 268 | } else if (series == "StackedBar") { |
|
268 | 269 | qDebug() << "Stacked bar chart series"; |
|
269 | 270 | |
|
270 | 271 | QBarCategory *category = new QBarCategory; |
|
271 | 272 | *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; |
|
272 | 273 | |
|
273 | StackedBarChartSeries* series0 = new StackedBarChartSeries(category, this); | |
|
274 | QStackedBarChartSeries* series0 = new QStackedBarChartSeries(category, this); | |
|
274 | 275 | |
|
275 | 276 | series0->addBarSet(set0); |
|
276 | 277 | series0->addBarSet(set1); |
|
277 | 278 | series0->addBarSet(set2); |
|
278 | 279 | series0->addBarSet(set3); |
|
279 | 280 | series0->addBarSet(set4); |
|
280 | 281 | |
|
281 | 282 | m_chartWidget->addSeries(series0); |
|
282 | 283 | newSeries = series0; |
|
283 | 284 | } else if (series == "PercentBar") { |
|
284 | 285 | qDebug() << "Percent bar chart series"; |
|
285 | 286 | |
|
286 | 287 | QBarCategory *category = new QBarCategory; |
|
287 | 288 | *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; |
|
288 | 289 | |
|
289 | PercentBarChartSeries* series0 = new PercentBarChartSeries(category, this); | |
|
290 | QPercentBarChartSeries* series0 = new QPercentBarChartSeries(category, this); | |
|
290 | 291 | |
|
291 | 292 | series0->addBarSet(set0); |
|
292 | 293 | series0->addBarSet(set1); |
|
293 | 294 | series0->addBarSet(set2); |
|
294 | 295 | series0->addBarSet(set3); |
|
295 | 296 | series0->addBarSet(set4); |
|
296 | 297 | |
|
297 | 298 | m_chartWidget->addSeries(series0); |
|
298 | 299 | newSeries = series0; |
|
299 | 300 | } else { |
|
300 | 301 | qDebug() << "Something weird going on in MainWidget::addSeries"; |
|
301 | 302 | } |
|
302 | 303 | |
|
303 | 304 | setCurrentSeries(newSeries); |
|
304 | 305 | } |
|
305 | 306 | |
|
306 | 307 | void MainWidget::setCurrentSeries(QChartSeries *series) |
|
307 | 308 | { |
|
308 | 309 | if (series) { |
|
309 | 310 | m_currentSeries = series; |
|
310 | 311 | switch (m_currentSeries->type()) { |
|
311 | 312 | case QChartSeries::SeriesTypeLine: |
|
312 | 313 | break; |
|
313 | 314 | case QChartSeries::SeriesTypeScatter: |
|
314 | 315 | break; |
|
315 | 316 | case QChartSeries::SeriesTypePie: |
|
316 | 317 | break; |
|
317 | 318 | case QChartSeries::SeriesTypeBar: |
|
318 | 319 | qDebug() << "setCurrentSeries (bar)"; |
|
319 | 320 | break; |
|
320 | 321 | case QChartSeries::SeriesTypeStackedBar: |
|
321 | 322 | qDebug() << "setCurrentSeries (Stackedbar)"; |
|
322 | 323 | break; |
|
323 | 324 | case QChartSeries::SeriesTypePercentBar: |
|
324 | 325 | qDebug() << "setCurrentSeries (Percentbar)"; |
|
325 | 326 | break; |
|
326 | 327 | default: |
|
327 | 328 | Q_ASSERT(false); |
|
328 | 329 | break; |
|
329 | 330 | } |
|
330 | 331 | } |
|
331 | 332 | } |
|
332 | 333 | |
|
333 | 334 | void MainWidget::testDataChanged(int itemIndex) |
|
334 | 335 | { |
|
335 | 336 | qDebug() << "testDataChanged: " << itemIndex; |
|
336 | 337 | |
|
337 | 338 | // switch (itemIndex) { |
|
338 | 339 | // case 0: { |
|
339 | 340 | // QList<QChartDataPoint> data; |
|
340 | 341 | // for (int x = 0; x < 20; x++) { |
|
341 | 342 | // data.append(QChartDataPoint() << x << x / 2); |
|
342 | 343 | // } |
|
343 | 344 | // m_chartWidget->setData(data); |
|
344 | 345 | // break; |
|
345 | 346 | // } |
|
346 | 347 | // case 1: { |
|
347 | 348 | // QList<QChartDataPoint> data; |
|
348 | 349 | // for (int x = 0; x < 100; x++) { |
|
349 | 350 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); |
|
350 | 351 | // } |
|
351 | 352 | // m_chartWidget->setData(data); |
|
352 | 353 | // break; |
|
353 | 354 | // } |
|
354 | 355 | // case 2: { |
|
355 | 356 | // QList<QChartDataPoint> data; |
|
356 | 357 | // for (int x = 0; x < 1000; x++) { |
|
357 | 358 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
358 | 359 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
359 | 360 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
360 | 361 | // } |
|
361 | 362 | // m_chartWidget->setData(data); |
|
362 | 363 | // break; |
|
363 | 364 | // } |
|
364 | 365 | // default: |
|
365 | 366 | // break; |
|
366 | 367 | // } |
|
367 | 368 | } |
|
368 | 369 | |
|
369 | 370 | void MainWidget::backgroundChanged(int itemIndex) |
|
370 | 371 | { |
|
371 | 372 | qDebug() << "backgroundChanged: " << itemIndex; |
|
372 | 373 | } |
|
373 | 374 | |
|
374 | 375 | void MainWidget::autoScaleChanged(int value) |
|
375 | 376 | { |
|
376 | 377 | if (value) { |
|
377 | 378 | // TODO: enable auto scaling |
|
378 | 379 | } else { |
|
379 | 380 | // TODO: set scaling manually (and disable auto scaling) |
|
380 | 381 | } |
|
381 | 382 | |
|
382 | 383 | m_xMinSpin->setEnabled(!value); |
|
383 | 384 | m_xMaxSpin->setEnabled(!value); |
|
384 | 385 | m_yMinSpin->setEnabled(!value); |
|
385 | 386 | m_yMaxSpin->setEnabled(!value); |
|
386 | 387 | } |
|
387 | 388 | |
|
388 | 389 | void MainWidget::xMinChanged(int value) |
|
389 | 390 | { |
|
390 | 391 | qDebug() << "xMinChanged: " << value; |
|
391 | 392 | } |
|
392 | 393 | |
|
393 | 394 | void MainWidget::xMaxChanged(int value) |
|
394 | 395 | { |
|
395 | 396 | qDebug() << "xMaxChanged: " << value; |
|
396 | 397 | } |
|
397 | 398 | |
|
398 | 399 | void MainWidget::yMinChanged(int value) |
|
399 | 400 | { |
|
400 | 401 | qDebug() << "yMinChanged: " << value; |
|
401 | 402 | } |
|
402 | 403 | |
|
403 | 404 | void MainWidget::yMaxChanged(int value) |
|
404 | 405 | { |
|
405 | 406 | qDebug() << "yMaxChanged: " << value; |
|
406 | 407 | } |
|
407 | 408 | |
|
408 | 409 | void MainWidget::changeChartTheme(int themeIndex) |
|
409 | 410 | { |
|
410 | 411 | qDebug() << "changeChartTheme: " << themeIndex; |
|
411 | 412 | m_chartWidget->setChartTheme((QChart::ChartTheme) themeIndex); |
|
412 | 413 | //TODO: remove this hack. This is just to make it so that theme change is seen immediately. |
|
413 | 414 | QSize s = size(); |
|
414 | 415 | s.setWidth(s.width()+1); |
|
415 | 416 | resize(s); |
|
416 | 417 | } |
|
417 | 418 | |
|
418 | 419 | void MainWidget::setPieSizeFactor(double size) |
|
419 | 420 | { |
|
420 | 421 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); |
|
421 | 422 | if (pie) |
|
422 | 423 | pie->setSizeFactor(qreal(size)); |
|
423 | 424 | } |
|
424 | 425 | |
|
425 | 426 | void MainWidget::setPiePosition(int position) |
|
426 | 427 | { |
|
427 | 428 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); |
|
428 | 429 | if (pie) |
|
429 | 430 | pie->setPosition((QPieSeries::PiePosition) position); |
|
430 | 431 | } |
General Comments 0
You need to be logged in to leave comments.
Login now