@@ -0,0 +1,42 | |||||
|
1 | #include "qhbarmodelmapper.h" | |||
|
2 | ||||
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
4 | ||||
|
5 | QHBarModelMapper::QHBarModelMapper(QObject *parent) : | |||
|
6 | QBarModelMapper(parent) | |||
|
7 | { | |||
|
8 | } | |||
|
9 | ||||
|
10 | int QHBarModelMapper::firstBarRow() const | |||
|
11 | { | |||
|
12 | return QBarModelMapper::firstBarSection(); | |||
|
13 | } | |||
|
14 | ||||
|
15 | void QHBarModelMapper::setFirstBarRow(int firstBarRow) | |||
|
16 | { | |||
|
17 | return QBarModelMapper::setFirstBarSection(firstBarRow); | |||
|
18 | } | |||
|
19 | ||||
|
20 | int QHBarModelMapper::lastBarRow() const | |||
|
21 | { | |||
|
22 | return QBarModelMapper::lastBarSection(); | |||
|
23 | } | |||
|
24 | ||||
|
25 | void QHBarModelMapper::setLastBarRow(int lastBarRow) | |||
|
26 | { | |||
|
27 | return QBarModelMapper::setLastBarSection(lastBarRow); | |||
|
28 | } | |||
|
29 | ||||
|
30 | int QHBarModelMapper::categoriesRow() const | |||
|
31 | { | |||
|
32 | return QBarModelMapper::categoriesSection(); | |||
|
33 | } | |||
|
34 | ||||
|
35 | void QHBarModelMapper::setCategoriesRow(int categoriesRow) | |||
|
36 | { | |||
|
37 | return QBarModelMapper::setCategoriesSection(categoriesRow); | |||
|
38 | } | |||
|
39 | ||||
|
40 | #include "moc_qhbarmodelmapper.cpp" | |||
|
41 | ||||
|
42 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,30 | |||||
|
1 | #ifndef QHBARMODELMAPPER_H | |||
|
2 | #define QHBARMODELMAPPER_H | |||
|
3 | ||||
|
4 | #include <QBarModelMapper> | |||
|
5 | ||||
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
7 | ||||
|
8 | class QTCOMMERCIALCHART_EXPORT QHBarModelMapper : public QBarModelMapper | |||
|
9 | { | |||
|
10 | Q_OBJECT | |||
|
11 | Q_PROPERTY(int firstBarRow READ firstBarRow WRITE setFirstBarRow) | |||
|
12 | Q_PROPERTY(int lastBarRow READ lastBarRow WRITE setLastBarRow) | |||
|
13 | ||||
|
14 | public: | |||
|
15 | explicit QHBarModelMapper(QObject *parent = 0); | |||
|
16 | ||||
|
17 | int firstBarRow() const; | |||
|
18 | void setFirstBarRow(int firstBarRow); | |||
|
19 | ||||
|
20 | int lastBarRow() const; | |||
|
21 | void setLastBarRow(int lastBarRow); | |||
|
22 | ||||
|
23 | int categoriesRow() const; | |||
|
24 | void setCategoriesRow(int categoriesRow); | |||
|
25 | ||||
|
26 | }; | |||
|
27 | ||||
|
28 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
29 | ||||
|
30 | #endif // QHBARMODELMAPPER_H |
@@ -0,0 +1,42 | |||||
|
1 | #include "qvbarmodelmapper.h" | |||
|
2 | ||||
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
4 | ||||
|
5 | QVBarModelMapper::QVBarModelMapper(QObject *parent) : | |||
|
6 | QBarModelMapper(parent) | |||
|
7 | { | |||
|
8 | } | |||
|
9 | ||||
|
10 | int QVBarModelMapper::firstBarColumn() const | |||
|
11 | { | |||
|
12 | return QBarModelMapper::firstBarSection(); | |||
|
13 | } | |||
|
14 | ||||
|
15 | void QVBarModelMapper::setFirstBarColumn(int firstBarColumn) | |||
|
16 | { | |||
|
17 | return QBarModelMapper::setFirstBarSection(firstBarColumn); | |||
|
18 | } | |||
|
19 | ||||
|
20 | int QVBarModelMapper::lastBarColumn() const | |||
|
21 | { | |||
|
22 | return QBarModelMapper::lastBarSection(); | |||
|
23 | } | |||
|
24 | ||||
|
25 | void QVBarModelMapper::setLastBarColumn(int lastBarColumn) | |||
|
26 | { | |||
|
27 | return QBarModelMapper::setLastBarSection(lastBarColumn); | |||
|
28 | } | |||
|
29 | ||||
|
30 | int QVBarModelMapper::categoriesColumn() const | |||
|
31 | { | |||
|
32 | return QBarModelMapper::categoriesSection(); | |||
|
33 | } | |||
|
34 | ||||
|
35 | void QVBarModelMapper::setCategoriesColumn(int categoriesColumn) | |||
|
36 | { | |||
|
37 | return QBarModelMapper::setCategoriesSection(categoriesColumn); | |||
|
38 | } | |||
|
39 | ||||
|
40 | #include "moc_qvbarmodelmapper.cpp" | |||
|
41 | ||||
|
42 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,30 | |||||
|
1 | #ifndef QVBARMODELMAPPER_H | |||
|
2 | #define QVBARMODELMAPPER_H | |||
|
3 | ||||
|
4 | #include <QBarModelMapper> | |||
|
5 | ||||
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
7 | ||||
|
8 | class QTCOMMERCIALCHART_EXPORT QVBarModelMapper : public QBarModelMapper | |||
|
9 | { | |||
|
10 | Q_OBJECT | |||
|
11 | Q_PROPERTY(int firstBarColumn READ firstBarColumn WRITE setFirstBarColumn) | |||
|
12 | Q_PROPERTY(int lastBarColumn READ lastBarColumn WRITE setLastBarColumn) | |||
|
13 | ||||
|
14 | public: | |||
|
15 | explicit QVBarModelMapper(QObject *parent = 0); | |||
|
16 | ||||
|
17 | int firstBarColumn() const; | |||
|
18 | void setFirstBarColumn(int firstBarColumn); | |||
|
19 | ||||
|
20 | int lastBarColumn() const; | |||
|
21 | void setLastBarColumn(int lastBarColumn); | |||
|
22 | ||||
|
23 | int categoriesColumn() const; | |||
|
24 | void setCategoriesColumn(int categoriesColumn); | |||
|
25 | ||||
|
26 | }; | |||
|
27 | ||||
|
28 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
29 | ||||
|
30 | #endif // QVBARMODELMAPPER_H |
@@ -12,7 +12,9 SOURCES += \ | |||||
12 | $$PWD/qstackedbarseries.cpp \ |
|
12 | $$PWD/qstackedbarseries.cpp \ | |
13 | $$PWD/qgroupedbarseries.cpp \ |
|
13 | $$PWD/qgroupedbarseries.cpp \ | |
14 | $$PWD/stackedbarchartitem.cpp \ |
|
14 | $$PWD/stackedbarchartitem.cpp \ | |
15 | $$PWD/qbarmodelmapper.cpp |
|
15 | $$PWD/qbarmodelmapper.cpp \ | |
|
16 | $$PWD/qvbarmodelmapper.cpp \ | |||
|
17 | $$PWD/qhbarmodelmapper.cpp | |||
16 |
|
18 | |||
17 | PRIVATE_HEADERS += \ |
|
19 | PRIVATE_HEADERS += \ | |
18 | $$PWD/bar_p.h \ |
|
20 | $$PWD/bar_p.h \ | |
@@ -33,4 +35,6 PUBLIC_HEADERS += \ | |||||
33 | $$PWD/qpercentbarseries.h \ |
|
35 | $$PWD/qpercentbarseries.h \ | |
34 | $$PWD/qstackedbarseries.h \ |
|
36 | $$PWD/qstackedbarseries.h \ | |
35 | $$PWD/qgroupedbarseries.h \ |
|
37 | $$PWD/qgroupedbarseries.h \ | |
36 | $$PWD/qbarmodelmapper.h |
|
38 | $$PWD/qbarmodelmapper.h \ | |
|
39 | $$PWD/qvbarmodelmapper.h \ | |||
|
40 | $$PWD/qhbarmodelmapper.h |
@@ -208,6 +208,10 void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex botto | |||||
208 | { |
|
208 | { | |
209 | Q_UNUSED(topLeft) |
|
209 | Q_UNUSED(topLeft) | |
210 | Q_UNUSED(bottomRight) |
|
210 | Q_UNUSED(bottomRight) | |
|
211 | ||||
|
212 | if (m_model == 0 || m_series == 0) | |||
|
213 | return; | |||
|
214 | ||||
211 | if (m_modelSignalsBlock) |
|
215 | if (m_modelSignalsBlock) | |
212 | return; |
|
216 | return; | |
213 |
|
217 |
@@ -12,6 +12,12 QPieModelMapper::QPieModelMapper(QObject *parent) : | |||||
12 | { |
|
12 | { | |
13 | } |
|
13 | } | |
14 |
|
14 | |||
|
15 | QPieModelMapper::~QPieModelMapper() | |||
|
16 | { | |||
|
17 | // Q_D(QPieModelMapper); | |||
|
18 | // disconnect(d->m_model, 0, d, 0); | |||
|
19 | } | |||
|
20 | ||||
15 | QAbstractItemModel* QPieModelMapper::model() const |
|
21 | QAbstractItemModel* QPieModelMapper::model() const | |
16 | { |
|
22 | { | |
17 | Q_D(const QPieModelMapper); |
|
23 | Q_D(const QPieModelMapper); |
@@ -42,6 +42,7 class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject | |||||
42 |
|
42 | |||
43 | protected: |
|
43 | protected: | |
44 | QPieModelMapper(QObject *parent = 0); |
|
44 | QPieModelMapper(QObject *parent = 0); | |
|
45 | ~QPieModelMapper(); | |||
45 |
|
46 | |||
46 | public: |
|
47 | public: | |
47 | QAbstractItemModel* model() const; |
|
48 | QAbstractItemModel* model() const; |
@@ -11,6 +11,13 QXYModelMapper::QXYModelMapper(QObject *parent): | |||||
11 | { |
|
11 | { | |
12 | } |
|
12 | } | |
13 |
|
13 | |||
|
14 | QXYModelMapper::~QXYModelMapper() | |||
|
15 | { | |||
|
16 | Q_D(QXYModelMapper); | |||
|
17 | disconnect(d->m_model, 0, d, 0); | |||
|
18 | // disconnect(d->m_series, 0, d, 0); | |||
|
19 | } | |||
|
20 | ||||
14 | QAbstractItemModel* QXYModelMapper::model() const |
|
21 | QAbstractItemModel* QXYModelMapper::model() const | |
15 | { |
|
22 | { | |
16 | Q_D(const QXYModelMapper); |
|
23 | Q_D(const QXYModelMapper); | |
@@ -360,9 +367,9 void QXYModelMapperPrivate::removeData(int start, int end) | |||||
360 | if (m_count != -1 && start >= m_first + m_count) { |
|
367 | if (m_count != -1 && start >= m_first + m_count) { | |
361 | return; |
|
368 | return; | |
362 | } else { |
|
369 | } else { | |
363 |
int toRemove = qMin(m_series-> |
|
370 | int toRemove = qMin(m_series->count(), removedCount); // first find how many items can actually be removed | |
364 | int first = qMax(start, m_first); // get the index of the first item that will be removed. |
|
371 | int first = qMax(start, m_first); // get the index of the first item that will be removed. | |
365 |
int last = qMin(first + toRemove - 1, m_series-> |
|
372 | int last = qMin(first + toRemove - 1, m_series->count() + m_first - 1); // get the index of the last item that will be removed. | |
366 | for (int i = last; i >= first; i--) { |
|
373 | for (int i = last; i >= first; i--) { | |
367 | m_series->remove(m_series->points().at(i - m_first)); |
|
374 | m_series->remove(m_series->points().at(i - m_first)); | |
368 | } |
|
375 | } | |
@@ -370,13 +377,13 void QXYModelMapperPrivate::removeData(int start, int end) | |||||
370 | if (m_count != -1) { |
|
377 | if (m_count != -1) { | |
371 | int itemsAvailable; // check how many are available to be added |
|
378 | int itemsAvailable; // check how many are available to be added | |
372 | if (m_orientation == Qt::Vertical) |
|
379 | if (m_orientation == Qt::Vertical) | |
373 |
itemsAvailable = m_model->rowCount() - m_first - m_series-> |
|
380 | itemsAvailable = m_model->rowCount() - m_first - m_series->count(); | |
374 | else |
|
381 | else | |
375 |
itemsAvailable = m_model->columnCount() - m_first - m_series-> |
|
382 | itemsAvailable = m_model->columnCount() - m_first - m_series->count(); | |
376 |
int toBeAdded = qMin(itemsAvailable, m_count - m_series-> |
|
383 | int toBeAdded = qMin(itemsAvailable, m_count - m_series->count()); // add not more items than there is space left to be filled. | |
377 |
int currentSize = m_series-> |
|
384 | int currentSize = m_series->count(); | |
378 | if (toBeAdded > 0) |
|
385 | if (toBeAdded > 0) | |
379 |
for (int i = m_series-> |
|
386 | for (int i = m_series->count(); i < currentSize + toBeAdded; i++) { | |
380 | QPointF point; |
|
387 | QPointF point; | |
381 | point.setX(m_model->data(xModelIndex(i), Qt::DisplayRole).toDouble()); |
|
388 | point.setX(m_model->data(xModelIndex(i), Qt::DisplayRole).toDouble()); | |
382 | point.setY(m_model->data(yModelIndex(i), Qt::DisplayRole).toDouble()); |
|
389 | point.setY(m_model->data(yModelIndex(i), Qt::DisplayRole).toDouble()); |
@@ -37,6 +37,7 public: | |||||
37 |
|
37 | |||
38 | protected: |
|
38 | protected: | |
39 | explicit QXYModelMapper(QObject *parent = 0); |
|
39 | explicit QXYModelMapper(QObject *parent = 0); | |
|
40 | ~QXYModelMapper(); | |||
40 |
|
41 | |||
41 | Qt::Orientation orientation() const; |
|
42 | Qt::Orientation orientation() const; | |
42 | void setOrientation(Qt::Orientation orientation); |
|
43 | void setOrientation(Qt::Orientation orientation); |
@@ -35,7 +35,7 | |||||
35 | #include <QBarSeries> |
|
35 | #include <QBarSeries> | |
36 | #include <QGroupedBarSeries> |
|
36 | #include <QGroupedBarSeries> | |
37 | #include <QBarSet> |
|
37 | #include <QBarSet> | |
38 | #include <QBarModelMapper> |
|
38 | #include <QVBarModelMapper> | |
39 | #include <QPushButton> |
|
39 | #include <QPushButton> | |
40 | #include <QRadioButton> |
|
40 | #include <QRadioButton> | |
41 | #include <QLabel> |
|
41 | #include <QLabel> | |
@@ -44,7 +44,12 | |||||
44 | #include <QHeaderView> |
|
44 | #include <QHeaderView> | |
45 |
|
45 | |||
46 | TableWidget::TableWidget(QWidget *parent) |
|
46 | TableWidget::TableWidget(QWidget *parent) | |
47 | : QWidget(parent) |
|
47 | : QWidget(parent), | |
|
48 | m_series(0), | |||
|
49 | m_mapper(0), | |||
|
50 | m_model(0), | |||
|
51 | m_pieMapper(0), | |||
|
52 | m_pieMapper2(0) | |||
48 | // specialPie(0) |
|
53 | // specialPie(0) | |
49 | { |
|
54 | { | |
50 | setGeometry(1900, 100, 1000, 600); |
|
55 | setGeometry(1900, 100, 1000, 600); | |
@@ -130,13 +135,13 TableWidget::TableWidget(QWidget *parent) | |||||
130 | connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
135 | connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | |
131 | connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
136 | connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | |
132 | connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
137 | connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | |
133 |
m_ |
|
138 | m_barRadioButton->setChecked(true); | |
134 |
|
139 | |||
135 | // radio buttons layout |
|
140 | // radio buttons layout | |
136 | QVBoxLayout* radioLayout = new QVBoxLayout; |
|
141 | QVBoxLayout* radioLayout = new QVBoxLayout; | |
137 | radioLayout->addWidget(m_lineRadioButton); |
|
142 | radioLayout->addWidget(m_lineRadioButton); | |
138 | radioLayout->addWidget(m_splineRadioButton); |
|
143 | radioLayout->addWidget(m_splineRadioButton); | |
139 |
|
|
144 | radioLayout->addWidget(m_scatterRadioButton); | |
140 | radioLayout->addWidget(m_pieRadioButton); |
|
145 | radioLayout->addWidget(m_pieRadioButton); | |
141 | // radioLayout->addWidget(m_areaRadioButton); |
|
146 | // radioLayout->addWidget(m_areaRadioButton); | |
142 | radioLayout->addWidget(m_barRadioButton); |
|
147 | radioLayout->addWidget(m_barRadioButton); | |
@@ -186,8 +191,28 void TableWidget::updateChartType(bool toggle) | |||||
186 | if (toggle) { |
|
191 | if (toggle) { | |
187 | // specialPie = 0; |
|
192 | // specialPie = 0; | |
188 | m_chart->removeAllSeries(); |
|
193 | m_chart->removeAllSeries(); | |
|
194 | m_series = 0; | |||
189 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
195 | // m_chart->axisX()->setNiceNumbersEnabled(false); | |
190 | // m_chart->axisY()->setNiceNumbersEnabled(false); |
|
196 | // m_chart->axisY()->setNiceNumbersEnabled(false); | |
|
197 | if (m_mapper) { | |||
|
198 | m_mapper->deleteLater(); | |||
|
199 | m_mapper = 0; | |||
|
200 | } | |||
|
201 | ||||
|
202 | if (m_pieMapper) { | |||
|
203 | m_pieMapper->deleteLater(); | |||
|
204 | m_pieMapper = 0; | |||
|
205 | } | |||
|
206 | ||||
|
207 | if (m_pieMapper2) { | |||
|
208 | m_pieMapper2->deleteLater(); | |||
|
209 | m_pieMapper2 = 0; | |||
|
210 | } | |||
|
211 | ||||
|
212 | // if (m_series) { | |||
|
213 | // delete m_series; | |||
|
214 | // m_series = 0; | |||
|
215 | // } | |||
191 |
|
216 | |||
192 | // renable axes of the chart (pie hides them) |
|
217 | // renable axes of the chart (pie hides them) | |
193 | // x axis |
|
218 | // x axis | |
@@ -213,15 +238,15 void TableWidget::updateChartType(bool toggle) | |||||
213 | m_chart->setAnimationOptions(QChart::NoAnimation); |
|
238 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
214 |
|
239 | |||
215 | // series 1 |
|
240 | // series 1 | |
216 |
m_series = new QLineSeries |
|
241 | m_series = new QLineSeries; | |
217 |
|
242 | |||
218 |
|
|
243 | m_mapper = new QVXYModelMapper; | |
219 | mapper->setModel(m_model); |
|
244 | m_mapper->setModel(m_model); | |
220 | mapper->setSeries(m_series); |
|
245 | m_mapper->setSeries(m_series); | |
221 | mapper->setXColumn(0); |
|
246 | m_mapper->setXColumn(0); | |
222 | mapper->setYColumn(1); |
|
247 | m_mapper->setYColumn(1); | |
223 | mapper->setFirst(3); |
|
248 | m_mapper->setFirst(3); | |
224 | mapper->setCount(4); |
|
249 | m_mapper->setCount(4); | |
225 |
|
250 | |||
226 | // m_series->setModelMapping(0,1, Qt::Vertical); |
|
251 | // m_series->setModelMapping(0,1, Qt::Vertical); | |
227 | // m_series->setModelMappingRange(3, 4); |
|
252 | // m_series->setModelMappingRange(3, 4); | |
@@ -268,13 +293,13 void TableWidget::updateChartType(bool toggle) | |||||
268 | m_series = new QSplineSeries; |
|
293 | m_series = new QSplineSeries; | |
269 | // m_series->setModel(m_model); |
|
294 | // m_series->setModel(m_model); | |
270 |
|
295 | |||
271 |
|
|
296 | m_mapper = new QVXYModelMapper; | |
272 | mapper->setSeries(m_series); |
|
297 | m_mapper->setSeries(m_series); | |
273 | mapper->setModel(m_model); |
|
298 | m_mapper->setModel(m_model); | |
274 | mapper->setXColumn(0); |
|
299 | m_mapper->setXColumn(0); | |
275 | mapper->setYColumn(1); |
|
300 | m_mapper->setYColumn(1); | |
276 | mapper->setFirst(0); |
|
301 | m_mapper->setFirst(0); | |
277 | mapper->setCount(-1); |
|
302 | m_mapper->setCount(-1); | |
278 |
|
303 | |||
279 | // m_series->setModelMapper(mapper); |
|
304 | // m_series->setModelMapper(mapper); | |
280 |
|
305 | |||
@@ -313,21 +338,24 void TableWidget::updateChartType(bool toggle) | |||||
313 | // m_chart->addSeries(m_series); |
|
338 | // m_chart->addSeries(m_series); | |
314 | // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
339 | // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
315 | // m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); |
|
340 | // m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); | |
316 | } |
|
341 | } else if (m_scatterRadioButton->isChecked()) | |
317 | // else if (m_scatterRadioButton->isChecked()) |
|
342 | { | |
318 | // { |
|
343 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
319 | // m_chart->setAnimationOptions(QChart::NoAnimation); |
|
|||
320 |
|
344 | |||
321 |
|
|
345 | // series 1 | |
322 |
|
|
346 | m_series = new QScatterSeries; | |
323 | // m_series->setModel(m_model); |
|
|||
324 | // m_series->setModelMapping(0,1, Qt::Vertical); |
|
|||
325 | // // m_series->setModelMappingRange(2, 0); |
|
|||
326 | // // series->setModelMapping(0,1, Qt::Horizontal); |
|
|||
327 | // m_chart->addSeries(m_series); |
|
|||
328 |
|
347 | |||
329 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
348 | m_mapper = new QVXYModelMapper; | |
330 | // m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000)); |
|
349 | m_mapper->setSeries(m_series); | |
|
350 | m_mapper->setModel(m_model); | |||
|
351 | m_mapper->setXColumn(0); | |||
|
352 | m_mapper->setYColumn(1); | |||
|
353 | m_mapper->setFirst(0); | |||
|
354 | m_mapper->setCount(-1); | |||
|
355 | ||||
|
356 | m_chart->addSeries(m_series); | |||
|
357 | seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | |||
|
358 | m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000)); | |||
331 |
|
359 | |||
332 | // // series 2 |
|
360 | // // series 2 | |
333 | // m_series = new QScatterSeries; |
|
361 | // m_series = new QScatterSeries; | |
@@ -348,9 +376,7 void TableWidget::updateChartType(bool toggle) | |||||
348 | // m_chart->addSeries(m_series); |
|
376 | // m_chart->addSeries(m_series); | |
349 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
377 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | |
350 | // m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000)); |
|
378 | // m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000)); | |
351 | // } |
|
379 | } else if (m_pieRadioButton->isChecked()) { | |
352 | else if (m_pieRadioButton->isChecked()) |
|
|||
353 | { |
|
|||
354 | m_chart->setAnimationOptions(QChart::SeriesAnimations); |
|
380 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
355 |
|
381 | |||
356 | // pie 1 |
|
382 | // pie 1 | |
@@ -381,12 +407,12 void TableWidget::updateChartType(bool toggle) | |||||
381 | // pie 2 |
|
407 | // pie 2 | |
382 | m_pieSeries2 = new QPieSeries; |
|
408 | m_pieSeries2 = new QPieSeries; | |
383 |
|
409 | |||
384 | m_pieMapper = new QVPieModelMapper; |
|
410 | m_pieMapper2 = new QVPieModelMapper; | |
385 | m_pieMapper->setValuesColumn(0); |
|
411 | m_pieMapper2->setValuesColumn(0); | |
386 | m_pieMapper->setLabelsColumn(7); |
|
412 | m_pieMapper2->setLabelsColumn(7); | |
387 | m_pieMapper->setModel(m_model); |
|
413 | m_pieMapper2->setModel(m_model); | |
388 | m_pieMapper->setSeries(m_pieSeries2); |
|
414 | m_pieMapper2->setSeries(m_pieSeries2); | |
389 | m_pieMapper->setFirst(2); |
|
415 | m_pieMapper2->setFirst(2); | |
390 |
|
416 | |||
391 | m_pieSeries2->setLabelsVisible(true); |
|
417 | m_pieSeries2->setLabelsVisible(true); | |
392 | m_pieSeries2->setPieSize(0.35); |
|
418 | m_pieSeries2->setPieSize(0.35); | |
@@ -441,25 +467,31 void TableWidget::updateChartType(bool toggle) | |||||
441 | // } |
|
467 | // } | |
442 | else if (m_barRadioButton->isChecked()) |
|
468 | else if (m_barRadioButton->isChecked()) | |
443 | { |
|
469 | { | |
444 |
|
|
470 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
445 |
|
471 | |||
446 |
|
|
472 | QGroupedBarSeries* barSeries = new QGroupedBarSeries(); | |
447 |
|
|
473 | // barSeries->setCategories(QStringList()); | |
448 |
|
|
474 | // barSeries->setModel(m_model); | |
449 |
|
|
475 | // barSeries->setModelMappingRange(2, 5); | |
450 |
|
|
476 | // barSeries->setModelMapping(5, 2, 4, Qt::Vertical); | |
451 |
|
477 | |||
452 | // QBarModelMapper *mapper = new QBarModelMapper; |
|
478 | int first = 3; | |
453 | // mapper->setMapCategories(5); |
|
479 | int count = 4; | |
454 | // mapper->setMapBarBottom(2); |
|
480 | QVBarModelMapper *mapper = new QVBarModelMapper; | |
455 | // mapper->setMapBarTop(4); |
|
481 | mapper->setCategoriesSection(5); | |
|
482 | mapper->setFirstBarSection(2); | |||
|
483 | mapper->setLastBarSection(4); | |||
|
484 | mapper->setFirst(first); | |||
|
485 | mapper->setCount(count); | |||
|
486 | mapper->setSeries(barSeries); | |||
|
487 | mapper->setModel(m_model); | |||
456 |
|
|
488 | // barSeries->setModelMapper(mapper); | |
457 |
|
|
489 | m_chart->addSeries(barSeries); | |
458 |
|
|
490 | QList<QBarSet*> barsets = barSeries->barSets(); | |
459 |
|
|
491 | for (int i = 0; i < barsets.count(); i++) { | |
460 |
|
|
492 | seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); | |
461 |
|
|
493 | m_model->addMapping(seriesColorHex, QRect(2 + i, first, 1, count)); | |
462 | // } |
|
494 | } | |
463 | } |
|
495 | } | |
464 |
|
496 | |||
465 |
|
497 |
@@ -27,6 +27,7 | |||||
27 | //#include "qxyseries.h" |
|
27 | //#include "qxyseries.h" | |
28 | #include <QPieSeries> |
|
28 | #include <QPieSeries> | |
29 | #include <QVPieModelMapper> |
|
29 | #include <QVPieModelMapper> | |
|
30 | #include <QVXYModelMapper> | |||
30 |
|
31 | |||
31 | class CustomTableModel; |
|
32 | class CustomTableModel; | |
32 | class QTableView; |
|
33 | class QTableView; | |
@@ -61,6 +62,7 public: | |||||
61 | QChartView* m_chartView; |
|
62 | QChartView* m_chartView; | |
62 | QChart* m_chart; |
|
63 | QChart* m_chart; | |
63 | QXYSeries* m_series; |
|
64 | QXYSeries* m_series; | |
|
65 | QVXYModelMapper *m_mapper; | |||
64 | CustomTableModel* m_model; |
|
66 | CustomTableModel* m_model; | |
65 | QTableView* m_tableView; |
|
67 | QTableView* m_tableView; | |
66 | QRadioButton* m_lineRadioButton; |
|
68 | QRadioButton* m_lineRadioButton; |
General Comments 0
You need to be logged in to leave comments.
Login now