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