@@ -93,7 +93,7 void BarChartItem::handleDataStructureChanged() | |||
|
93 | 93 | } |
|
94 | 94 | |
|
95 | 95 | // TODO: Is this the right place to call it? |
|
96 |
|
|
|
96 | presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series)); | |
|
97 | 97 | handleLayoutChanged(); |
|
98 | 98 | } |
|
99 | 99 |
@@ -262,10 +262,10 QBarSet* QBarModelMapperPrivate::barSet(QModelIndex index) | |||
|
262 | 262 | |
|
263 | 263 | if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) { |
|
264 | 264 | if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) { |
|
265 | // if (m_model->index(index.row(), m_valuesSection).isValid() && m_model->index(index.row(), m_labelsSection).isValid()) | |
|
266 |
|
|
|
267 | // else | |
|
268 | // return 0; | |
|
265 | // if (m_model->index(index.row(), m_valuesSection).isValid() && m_model->index(index.row(), m_labelsSection).isValid()) | |
|
266 | return m_series->barSets().at(index.column() - m_firstBarSetSection); | |
|
267 | // else | |
|
268 | // return 0; | |
|
269 | 269 | } |
|
270 | 270 | } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) { |
|
271 | 271 | if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count)) |
@@ -461,13 +461,18 void QBarModelMapperPrivate::initializeBarFromModel() | |||
|
461 | 461 | for (int i = m_firstBarSetSection; i <= m_lastBarSetSection; i++) { |
|
462 | 462 | int posInBar = 0; |
|
463 | 463 | QModelIndex barIndex = barModelIndex(i, posInBar); |
|
464 | QBarSet *barSet = new QBarSet(m_model->headerData(i, Qt::Horizontal).toString()); | |
|
465 |
|
|
|
466 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); | |
|
467 | posInBar++; | |
|
468 | barIndex = barModelIndex(i, posInBar); | |
|
464 | // check if there is such model index | |
|
465 | if (barIndex.isValid()) { | |
|
466 | QBarSet *barSet = new QBarSet(m_model->headerData(i, Qt::Horizontal).toString()); | |
|
467 | while (barIndex.isValid()) { | |
|
468 | barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble()); | |
|
469 | posInBar++; | |
|
470 | barIndex = barModelIndex(i, posInBar); | |
|
471 | } | |
|
472 | m_series->append(barSet); | |
|
473 | } else { | |
|
474 | break; | |
|
469 | 475 | } |
|
470 | m_series->append(barSet); | |
|
471 | 476 | } |
|
472 | 477 | blockSeriesSignals(false); |
|
473 | 478 | } |
@@ -178,10 +178,13 bool QBarSeries::remove(QList<QBarSet* > sets) | |||
|
178 | 178 | return success; |
|
179 | 179 | } |
|
180 | 180 | |
|
181 | /*! | |
|
182 | Removes all of the bar sets from the series | |
|
183 | */ | |
|
181 | 184 | void QBarSeries::clear() |
|
182 | 185 | { |
|
183 | 186 | Q_D(QBarSeries); |
|
184 |
d-> |
|
|
187 | d->remove(barSets()); | |
|
185 | 188 | } |
|
186 | 189 | |
|
187 | 190 | /*! |
@@ -50,7 +50,9 TableWidget::TableWidget(QWidget *parent) | |||
|
50 | 50 | m_mapper(0), |
|
51 | 51 | m_model(0), |
|
52 | 52 | m_pieMapper(0), |
|
53 | m_pieMapper2(0) | |
|
53 | m_pieMapper2(0), | |
|
54 | m_barSeries(0), | |
|
55 | m_barMapper(0) | |
|
54 | 56 | // specialPie(0) |
|
55 | 57 | { |
|
56 | 58 | setGeometry(1900, 100, 1000, 600); |
@@ -476,28 +478,29 void TableWidget::updateChartType(bool toggle) | |||
|
476 | 478 | // } |
|
477 | 479 | else if (m_barRadioButton->isChecked()) |
|
478 | 480 | { |
|
479 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
|
481 | // m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
|
482 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
|
480 | 483 | |
|
481 |
|
|
|
484 | m_barSeries = new QGroupedBarSeries(); | |
|
482 | 485 | |
|
483 | 486 | int first = 3; |
|
484 | 487 | int count = 6; |
|
485 |
|
|
|
486 | mapper->setFirstBarSetColumn(2); | |
|
487 | mapper->setLastBarSetColumn(4); | |
|
488 | mapper->setFirst(first); | |
|
489 | mapper->setCount(count); | |
|
490 | mapper->setSeries(barSeries); | |
|
491 | mapper->setModel(m_model); | |
|
488 | m_barMapper = new QVBarModelMapper; | |
|
489 | m_barMapper->setFirstBarSetColumn(2); | |
|
490 | m_barMapper->setLastBarSetColumn(4); | |
|
491 | m_barMapper->setFirst(first); | |
|
492 | m_barMapper->setCount(count); | |
|
493 | m_barMapper->setSeries(m_barSeries); | |
|
494 | m_barMapper->setModel(m_model); | |
|
492 | 495 | // barSeries->setModelMapper(mapper); |
|
493 | m_chart->addSeries(barSeries); | |
|
496 | m_chart->addSeries(m_barSeries); | |
|
494 | 497 | |
|
495 | 498 | QStringList categories; |
|
496 | 499 | categories << "June" << "July" << "August" << "September" << "October" << "November"; |
|
497 | 500 | |
|
498 | 501 | m_chart->axisX()->categories()->insert(categories); |
|
499 | 502 | |
|
500 | QList<QBarSet*> barsets = barSeries->barSets(); | |
|
503 | QList<QBarSet*> barsets = m_barSeries->barSets(); | |
|
501 | 504 | for (int i = 0; i < barsets.count(); i++) { |
|
502 | 505 | seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); |
|
503 | 506 | m_model->addMapping(seriesColorHex, QRect(2 + i, first, 1, barsets.at(i)->count())); |
@@ -570,13 +573,15 void TableWidget::testPie3() | |||
|
570 | 573 | |
|
571 | 574 | void TableWidget::testXY() |
|
572 | 575 | { |
|
576 | if (m_barMapper) | |
|
577 | m_barMapper->setLastBarSetColumn(m_barMapper->lastBarSetColumn() + 1); | |
|
573 | 578 | // if (m_series->type() != QAbstractSeries::SeriesTypeLine) { |
|
574 | 579 | // m_series->append(QPointF(150, 75)); |
|
575 | 580 | // } |
|
576 | 581 | |
|
577 | if (m_series->count() > 0) { | |
|
578 | m_series->remove(m_series->points().last()); | |
|
579 | } | |
|
582 | // if (m_series->count() > 0) { | |
|
583 | // m_series->remove(m_series->points().last()); | |
|
584 | // } | |
|
580 | 585 | } |
|
581 | 586 | |
|
582 | 587 | TableWidget::~TableWidget() |
@@ -29,6 +29,8 | |||
|
29 | 29 | #include <QVPieModelMapper> |
|
30 | 30 | #include <QVXYModelMapper> |
|
31 | 31 | #include <QHXYModelMapper> |
|
32 | #include <QGroupedBarSeries> | |
|
33 | #include <QVBarModelMapper> | |
|
32 | 34 | |
|
33 | 35 | class CustomTableModel; |
|
34 | 36 | class QTableView; |
@@ -66,6 +68,7 public: | |||
|
66 | 68 | QVXYModelMapper *m_mapper; |
|
67 | 69 | CustomTableModel* m_model; |
|
68 | 70 | QTableView* m_tableView; |
|
71 | ||
|
69 | 72 | QRadioButton* m_lineRadioButton; |
|
70 | 73 | QRadioButton* m_splineRadioButton; |
|
71 | 74 | QRadioButton* m_scatterRadioButton; |
@@ -73,10 +76,14 public: | |||
|
73 | 76 | QRadioButton* m_areaRadioButton; |
|
74 | 77 | QRadioButton* m_barRadioButton; |
|
75 | 78 | QSpinBox* m_linesCountSpinBox; |
|
79 | ||
|
76 | 80 | QVPieModelMapper *m_pieMapper; |
|
77 | 81 | QPieSeries* m_pieSeries; |
|
78 | 82 | QVPieModelMapper *m_pieMapper2; |
|
79 | 83 | QPieSeries* m_pieSeries2; |
|
84 | ||
|
85 | QGroupedBarSeries* m_barSeries; | |
|
86 | QVBarModelMapper* m_barMapper; | |
|
80 | 87 | // QPieSeries* specialPie; |
|
81 | 88 | }; |
|
82 | 89 |
General Comments 0
You need to be logged in to leave comments.
Login now