##// END OF EJS Templates
For BarChart labels for legend are now taken from model's headerData (row or column)
Marek Rosa -
r1012:63ded67c2d2b
parent child
Show More
@@ -224,7 +224,6 void QBarSeries::setLabelsVisible(bool visible)
224 QBarSeriesPrivate::QBarSeriesPrivate(QBarCategories categories, QBarSeries *q) :
224 QBarSeriesPrivate::QBarSeriesPrivate(QBarCategories categories, QBarSeries *q) :
225 QAbstractSeriesPrivate(q),
225 QAbstractSeriesPrivate(q),
226 m_categories(categories),
226 m_categories(categories),
227 m_model(0),
228 m_mapCategories(-1),
227 m_mapCategories(-1),
229 m_mapBarBottom(-1),
228 m_mapBarBottom(-1),
230 m_mapBarTop(-1),
229 m_mapBarTop(-1),
@@ -394,7 +393,7 void QBarSeriesPrivate::setModelMapping(int categories, int bottomBoundry, int t
394 }
393 }
395
394
396 for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) {
395 for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) {
397 QBarSet* barSet = new QBarSet(QString("Column: %1").arg(i + 1));
396 QBarSet* barSet = new QBarSet(m_model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
398 for(int m = 0; m < m_model->rowCount(); m++)
397 for(int m = 0; m < m_model->rowCount(); m++)
399 *barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble();
398 *barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble();
400 q->appendBarSet(barSet);
399 q->appendBarSet(barSet);
@@ -405,7 +404,7 void QBarSeriesPrivate::setModelMapping(int categories, int bottomBoundry, int t
405 }
404 }
406
405
407 for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) {
406 for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) {
408 QBarSet* barSet = new QBarSet(QString("Row: %1").arg(i + 1));
407 QBarSet* barSet = new QBarSet(m_model->headerData(i, Qt::Vertical, Qt::DisplayRole).toString());
409 for(int m = 0; m < m_model->columnCount(); m++)
408 for(int m = 0; m < m_model->columnCount(); m++)
410 *barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble();
409 *barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble();
411 q->appendBarSet(barSet);
410 q->appendBarSet(barSet);
@@ -48,7 +48,6 protected:
48 QList<QBarSet *> m_barSets;
48 QList<QBarSet *> m_barSets;
49 QBarCategories m_categories;
49 QBarCategories m_categories;
50
50
51 QAbstractItemModel* m_model;
52 int m_mapCategories;
51 int m_mapCategories;
53 int m_mapBarBottom;
52 int m_mapBarBottom;
54 int m_mapBarTop;
53 int m_mapBarTop;
@@ -51,6 +51,7 TableWidget::TableWidget(QWidget *parent)
51 // tableView->setMinimumSize(340, 480);
51 // tableView->setMinimumSize(340, 480);
52 // tableView->setItemDelegate(new QStyledItemDelegate);
52 // tableView->setItemDelegate(new QStyledItemDelegate);
53 m_chart = new QChart;
53 m_chart = new QChart;
54 m_chart->legend()->setVisible(true);
54 m_chartView = new QChartView(m_chart);
55 m_chartView = new QChartView(m_chart);
55 m_chartView->setRenderHint(QPainter::Antialiasing);
56 m_chartView->setRenderHint(QPainter::Antialiasing);
56 m_chartView->setMinimumSize(640, 480);
57 m_chartView->setMinimumSize(640, 480);
@@ -139,7 +140,9 void TableWidget::updateChartType(bool toggle)
139 // this if is needed, so that the function is only called once.
140 // this if is needed, so that the function is only called once.
140 // For the radioButton that was enabled.
141 // For the radioButton that was enabled.
141 if (toggle) {
142 if (toggle) {
142 m_chart->removeAllSeries();
143 m_chart->removeAllSeries();
144 m_chart->axisX()->setNiceNumbersEnabled(false);
145 m_chart->axisY()->setNiceNumbersEnabled(false);
143
146
144 // renable axes of the chart (pie hides them)
147 // renable axes of the chart (pie hides them)
145 // x axis
148 // x axis
@@ -321,8 +324,10 void TableWidget::updateChartType(bool toggle)
321 }
324 }
322
325
323
326
324 m_chart->axisX()->setRange(0, 500);
327 if (!m_barRadioButton->isChecked())
328 m_chart->axisX()->setRange(0, 500);
325 m_chart->axisY()->setRange(0, 120);
329 m_chart->axisY()->setRange(0, 120);
330 m_chart->legend()->setVisible(true);
326
331
327 // repaint table view colors
332 // repaint table view colors
328 m_tableView->repaint();
333 m_tableView->repaint();
General Comments 0
You need to be logged in to leave comments. Login now