@@ -1,66 +1,70 | |||||
1 | #ifndef QBARSERIES_P_H |
|
1 | #ifndef QBARSERIES_P_H | |
2 | #define QBARSERIES_P_H |
|
2 | #define QBARSERIES_P_H | |
3 |
|
3 | |||
4 | #include "qbarseries.h" |
|
4 | #include "qbarseries.h" | |
5 | #include "qabstractseries_p.h" |
|
5 | #include "qabstractseries_p.h" | |
6 | #include <QStringList> |
|
6 | #include <QStringList> | |
7 | #include <QAbstractSeries> |
|
7 | #include <QAbstractSeries> | |
8 |
|
8 | |||
9 | class QModelIndex; |
|
9 | class QModelIndex; | |
10 |
|
10 | |||
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
12 |
|
12 | |||
13 | class QBarModelMapper; |
|
13 | class QBarModelMapper; | |
14 |
|
14 | |||
15 | // Container for series |
|
15 | // Container for series | |
16 | class QBarSeriesPrivate : public QAbstractSeriesPrivate |
|
16 | class QBarSeriesPrivate : public QAbstractSeriesPrivate | |
17 | { |
|
17 | { | |
18 | Q_OBJECT |
|
18 | Q_OBJECT | |
19 | public: |
|
19 | public: | |
20 | QBarSeriesPrivate(QBarSeries *parent); |
|
20 | QBarSeriesPrivate(QBarSeries *parent); | |
21 | void setCategories(QBarCategories categories); |
|
21 | void setCategories(QBarCategories categories); | |
22 | void setBarMargin(qreal margin); |
|
22 | void setBarMargin(qreal margin); | |
23 | qreal barMargin(); |
|
23 | qreal barMargin(); | |
24 |
|
24 | |||
25 | void scaleDomain(Domain& domain); |
|
25 | void scaleDomain(Domain& domain); | |
26 | Chart* createGraphics(ChartPresenter* presenter); |
|
26 | Chart* createGraphics(ChartPresenter* presenter); | |
27 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
27 | QList<LegendMarker*> createLegendMarker(QLegend* legend); | |
28 |
|
28 | |||
29 | void insertCategory(int index, const QString category); |
|
29 | void insertCategory(int index, const QString category); | |
30 | void removeCategory(int index); |
|
30 | void removeCategory(int index); | |
31 |
|
31 | |||
32 | QBarSet* barsetAt(int index); |
|
32 | QBarSet* barsetAt(int index); | |
33 | QString categoryName(int category); |
|
33 | QString categoryName(int category); | |
34 | qreal min(); |
|
34 | qreal min(); | |
35 | qreal max(); |
|
35 | qreal max(); | |
36 | qreal valueAt(int set, int category); |
|
36 | qreal valueAt(int set, int category); | |
37 | qreal percentageAt(int set, int category); |
|
37 | qreal percentageAt(int set, int category); | |
38 | qreal categorySum(int category); |
|
38 | qreal categorySum(int category); | |
39 | qreal absoluteCategorySum(int category); |
|
39 | qreal absoluteCategorySum(int category); | |
40 | qreal maxCategorySum(); |
|
40 | qreal maxCategorySum(); | |
41 |
|
41 | |||
42 | Q_SIGNALS: |
|
42 | Q_SIGNALS: | |
43 | void clicked(QBarSet *barset, QString category); |
|
43 | void clicked(QBarSet *barset, QString category); | |
44 | void updatedBars(); |
|
44 | void updatedBars(); | |
45 | void restructuredBars(); |
|
45 | void restructuredBars(); | |
46 | void categoriesUpdated(); |
|
46 | void categoriesUpdated(); | |
47 |
|
47 | |||
48 | private Q_SLOTS: |
|
48 | private Q_SLOTS: | |
49 | // slots for updating bars when data in model changes |
|
49 | // slots for updating bars when data in model changes | |
50 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
50 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | |
51 | void modelDataAdded(QModelIndex parent, int start, int end); |
|
51 | void modelDataAdded(QModelIndex parent, int start, int end); | |
52 | void modelDataRemoved(QModelIndex parent, int start, int end); |
|
52 | void modelDataRemoved(QModelIndex parent, int start, int end); | |
53 | void initializeDataFromModel(); |
|
53 | void initializeDataFromModel(); | |
54 | void barsetChanged(); |
|
54 | void barsetChanged(); | |
55 |
|
55 | |||
56 | protected: |
|
56 | protected: | |
57 | QList<QBarSet *> m_barSets; |
|
57 | QList<QBarSet *> m_barSets; | |
58 | QBarCategories m_categories; |
|
58 | QBarCategories m_categories; | |
|
59 | qreal m_barMargin; | |||
|
60 | int m_mapCategories; | |||
|
61 | int m_mapBarBottom; | |||
|
62 | int m_mapBarTop; | |||
59 | QBarModelMapper *m_mapper; |
|
63 | QBarModelMapper *m_mapper; | |
60 | private: |
|
64 | private: | |
61 | Q_DECLARE_PUBLIC(QBarSeries) |
|
65 | Q_DECLARE_PUBLIC(QBarSeries) | |
62 | }; |
|
66 | }; | |
63 |
|
67 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
68 | QTCOMMERCIALCHART_END_NAMESPACE | |
65 |
|
69 | |||
66 | #endif // QBARSERIESPRIVATE_P_H |
|
70 | #endif // QBARSERIESPRIVATE_P_H |
@@ -1,467 +1,468 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "tablewidget.h" |
|
21 | #include "tablewidget.h" | |
22 | #include <QGridLayout> |
|
22 | #include <QGridLayout> | |
23 | #include <QTableView> |
|
23 | #include <QTableView> | |
24 | #include <QChart> |
|
24 | #include <QChart> | |
25 | #include <QStyledItemDelegate> |
|
25 | #include <QStyledItemDelegate> | |
26 | #include <QLineSeries> |
|
26 | #include <QLineSeries> | |
27 | #include <QSplineSeries> |
|
27 | #include <QSplineSeries> | |
28 | #include <QScatterSeries> |
|
28 | #include <QScatterSeries> | |
29 | #include <QXYModelMapper> |
|
29 | #include <QXYModelMapper> | |
30 | #include "customtablemodel.h" |
|
30 | #include "customtablemodel.h" | |
31 | #include <QPieSeries> |
|
31 | #include <QPieSeries> | |
32 | #include <QPieModelMapper> |
|
32 | #include <QPieModelMapper> | |
33 | #include <QPieSlice> |
|
33 | #include <QPieSlice> | |
34 | #include <QAreaSeries> |
|
34 | #include <QAreaSeries> | |
35 | #include <QBarSeries> |
|
35 | #include <QBarSeries> | |
|
36 | #include <QGroupedBarSeries> | |||
36 | #include <QBarSet> |
|
37 | #include <QBarSet> | |
37 | #include <QBarModelMapper> |
|
38 | #include <QBarModelMapper> | |
38 | #include <QPushButton> |
|
39 | #include <QPushButton> | |
39 | #include <QRadioButton> |
|
40 | #include <QRadioButton> | |
40 | #include <QLabel> |
|
41 | #include <QLabel> | |
41 | #include <QSpinBox> |
|
42 | #include <QSpinBox> | |
42 | #include <QTime> |
|
43 | #include <QTime> | |
43 | #include <QHeaderView> |
|
44 | #include <QHeaderView> | |
44 |
|
45 | |||
45 | TableWidget::TableWidget(QWidget *parent) |
|
46 | TableWidget::TableWidget(QWidget *parent) | |
46 | : QWidget(parent) |
|
47 | : QWidget(parent) | |
47 | // specialPie(0) |
|
48 | // specialPie(0) | |
48 | { |
|
49 | { | |
49 | setGeometry(1900, 100, 1000, 600); |
|
50 | setGeometry(1900, 100, 1000, 600); | |
50 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); |
|
51 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); | |
51 | // create simple model for storing data |
|
52 | // create simple model for storing data | |
52 | // user's table data model |
|
53 | // user's table data model | |
53 | m_model = new CustomTableModel; |
|
54 | m_model = new CustomTableModel; | |
54 | m_tableView = new QTableView; |
|
55 | m_tableView = new QTableView; | |
55 | m_tableView->setModel(m_model); |
|
56 | m_tableView->setModel(m_model); | |
56 | // m_tableView->setMinimumHeight(300); |
|
57 | // m_tableView->setMinimumHeight(300); | |
57 | m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); |
|
58 | m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); | |
58 | m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch); |
|
59 | m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch); | |
59 |
|
60 | |||
60 | m_chart = new QChart; |
|
61 | m_chart = new QChart; | |
61 | m_chart->legend()->setVisible(true); |
|
62 | m_chart->legend()->setVisible(true); | |
62 | m_chart->setAnimationOptions(QChart::SeriesAnimations); |
|
63 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
63 | m_chartView = new QChartView(m_chart); |
|
64 | m_chartView = new QChartView(m_chart); | |
64 | m_chartView->setRenderHint(QPainter::Antialiasing); |
|
65 | m_chartView->setRenderHint(QPainter::Antialiasing); | |
65 | m_chartView->setMinimumSize(640, 480); |
|
66 | m_chartView->setMinimumSize(640, 480); | |
66 |
|
67 | |||
67 | // add, remove data buttons |
|
68 | // add, remove data buttons | |
68 | QPushButton* addRowAboveButton = new QPushButton("Add row above"); |
|
69 | QPushButton* addRowAboveButton = new QPushButton("Add row above"); | |
69 | connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove())); |
|
70 | connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove())); | |
70 |
|
71 | |||
71 | QPushButton* addRowBelowButton = new QPushButton("Add row below"); |
|
72 | QPushButton* addRowBelowButton = new QPushButton("Add row below"); | |
72 | connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow())); |
|
73 | connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow())); | |
73 |
|
74 | |||
74 | QPushButton* removeRowButton = new QPushButton("Remove row"); |
|
75 | QPushButton* removeRowButton = new QPushButton("Remove row"); | |
75 | connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow())); |
|
76 | connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow())); | |
76 |
|
77 | |||
77 | QPushButton* addColumnRightButton = new QPushButton("Add column to the right"); |
|
78 | QPushButton* addColumnRightButton = new QPushButton("Add column to the right"); | |
78 | connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight())); |
|
79 | connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight())); | |
79 |
|
80 | |||
80 | QPushButton* removeColumnButton = new QPushButton("Remove column"); |
|
81 | QPushButton* removeColumnButton = new QPushButton("Remove column"); | |
81 | connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn())); |
|
82 | connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn())); | |
82 |
|
83 | |||
83 | QPushButton* specialPieButton = new QPushButton("Test pie"); |
|
84 | QPushButton* specialPieButton = new QPushButton("Test pie"); | |
84 | connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie())); |
|
85 | connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie())); | |
85 |
|
86 | |||
86 |
|
87 | |||
87 | // QLabel *spinBoxLabel = new QLabel("Rows affected:"); |
|
88 | // QLabel *spinBoxLabel = new QLabel("Rows affected:"); | |
88 |
|
89 | |||
89 | // spin box for setting number of affected items (add, remove) |
|
90 | // spin box for setting number of affected items (add, remove) | |
90 | m_linesCountSpinBox = new QSpinBox; |
|
91 | m_linesCountSpinBox = new QSpinBox; | |
91 | m_linesCountSpinBox->setRange(1, 10); |
|
92 | m_linesCountSpinBox->setRange(1, 10); | |
92 | m_linesCountSpinBox->setValue(1); |
|
93 | m_linesCountSpinBox->setValue(1); | |
93 |
|
94 | |||
94 | // buttons layout |
|
95 | // buttons layout | |
95 | QVBoxLayout* buttonsLayout = new QVBoxLayout; |
|
96 | QVBoxLayout* buttonsLayout = new QVBoxLayout; | |
96 | // buttonsLayout->addWidget(spinBoxLabel); |
|
97 | // buttonsLayout->addWidget(spinBoxLabel); | |
97 | // buttonsLayout->addWidget(m_linesCountSpinBox); |
|
98 | // buttonsLayout->addWidget(m_linesCountSpinBox); | |
98 | // buttonsLayout->addWidget(addRowAboveButton); |
|
99 | // buttonsLayout->addWidget(addRowAboveButton); | |
99 | buttonsLayout->addWidget(addRowBelowButton); |
|
100 | buttonsLayout->addWidget(addRowBelowButton); | |
100 | buttonsLayout->addWidget(removeRowButton); |
|
101 | buttonsLayout->addWidget(removeRowButton); | |
101 | // buttonsLayout->addWidget(addColumnRightButton); |
|
102 | // buttonsLayout->addWidget(addColumnRightButton); | |
102 | // buttonsLayout->addWidget(removeColumnButton); |
|
103 | // buttonsLayout->addWidget(removeColumnButton); | |
103 | buttonsLayout->addWidget(specialPieButton); |
|
104 | buttonsLayout->addWidget(specialPieButton); | |
104 | buttonsLayout->addStretch(); |
|
105 | buttonsLayout->addStretch(); | |
105 |
|
106 | |||
106 | // chart type radio buttons |
|
107 | // chart type radio buttons | |
107 | m_lineRadioButton = new QRadioButton("Line"); |
|
108 | m_lineRadioButton = new QRadioButton("Line"); | |
108 | m_splineRadioButton = new QRadioButton("Spline"); |
|
109 | m_splineRadioButton = new QRadioButton("Spline"); | |
109 | m_scatterRadioButton = new QRadioButton("Scatter"); |
|
110 | m_scatterRadioButton = new QRadioButton("Scatter"); | |
110 | m_pieRadioButton = new QRadioButton("Pie"); |
|
111 | m_pieRadioButton = new QRadioButton("Pie"); | |
111 | m_areaRadioButton = new QRadioButton("Area"); |
|
112 | m_areaRadioButton = new QRadioButton("Area"); | |
112 | m_barRadioButton = new QRadioButton("Bar"); |
|
113 | m_barRadioButton = new QRadioButton("Bar"); | |
113 |
|
114 | |||
114 | connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
115 | connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | |
115 | connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
116 | connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | |
116 | connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
117 | connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | |
117 | connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
118 | connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | |
118 | connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
119 | connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | |
119 | connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); |
|
120 | connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool))); | |
120 | m_lineRadioButton->setChecked(true); |
|
121 | m_lineRadioButton->setChecked(true); | |
121 |
|
122 | |||
122 | // radio buttons layout |
|
123 | // radio buttons layout | |
123 | QVBoxLayout* radioLayout = new QVBoxLayout; |
|
124 | QVBoxLayout* radioLayout = new QVBoxLayout; | |
124 | radioLayout->addWidget(m_lineRadioButton); |
|
125 | radioLayout->addWidget(m_lineRadioButton); | |
125 | radioLayout->addWidget(m_splineRadioButton); |
|
126 | radioLayout->addWidget(m_splineRadioButton); | |
126 | // radioLayout->addWidget(m_scatterRadioButton); |
|
127 | // radioLayout->addWidget(m_scatterRadioButton); | |
127 | radioLayout->addWidget(m_pieRadioButton); |
|
128 | radioLayout->addWidget(m_pieRadioButton); | |
128 | // radioLayout->addWidget(m_areaRadioButton); |
|
129 | // radioLayout->addWidget(m_areaRadioButton); | |
129 | radioLayout->addWidget(m_barRadioButton); |
|
130 | radioLayout->addWidget(m_barRadioButton); | |
130 | radioLayout->addStretch(); |
|
131 | radioLayout->addStretch(); | |
131 |
|
132 | |||
132 | // create main layout |
|
133 | // create main layout | |
133 | QGridLayout* mainLayout = new QGridLayout; |
|
134 | QGridLayout* mainLayout = new QGridLayout; | |
134 | mainLayout->addLayout(buttonsLayout, 2, 0); |
|
135 | mainLayout->addLayout(buttonsLayout, 2, 0); | |
135 | mainLayout->addLayout(radioLayout, 3, 0); |
|
136 | mainLayout->addLayout(radioLayout, 3, 0); | |
136 | mainLayout->addWidget(m_tableView, 1, 0); |
|
137 | mainLayout->addWidget(m_tableView, 1, 0); | |
137 | mainLayout->addWidget(m_chartView, 1, 1, 2, 1); |
|
138 | mainLayout->addWidget(m_chartView, 1, 1, 2, 1); | |
138 | setLayout(mainLayout); |
|
139 | setLayout(mainLayout); | |
139 | m_lineRadioButton->setFocus(); |
|
140 | m_lineRadioButton->setFocus(); | |
140 | } |
|
141 | } | |
141 |
|
142 | |||
142 | void TableWidget::addRowAbove() |
|
143 | void TableWidget::addRowAbove() | |
143 | { |
|
144 | { | |
144 | m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value()); |
|
145 | m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value()); | |
145 |
|
146 | |||
146 | } |
|
147 | } | |
147 |
|
148 | |||
148 | void TableWidget::addRowBelow() |
|
149 | void TableWidget::addRowBelow() | |
149 | { |
|
150 | { | |
150 | m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value()); |
|
151 | m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value()); | |
151 |
|
152 | |||
152 | } |
|
153 | } | |
153 |
|
154 | |||
154 | void TableWidget::removeRow() |
|
155 | void TableWidget::removeRow() | |
155 | { |
|
156 | { | |
156 | m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value())); |
|
157 | m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value())); | |
157 | } |
|
158 | } | |
158 |
|
159 | |||
159 | void TableWidget::addColumnRight() |
|
160 | void TableWidget::addColumnRight() | |
160 | { |
|
161 | { | |
161 | m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value()); |
|
162 | m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value()); | |
162 | } |
|
163 | } | |
163 |
|
164 | |||
164 | void TableWidget::removeColumn() |
|
165 | void TableWidget::removeColumn() | |
165 | { |
|
166 | { | |
166 | m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value())); |
|
167 | m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value())); | |
167 | } |
|
168 | } | |
168 |
|
169 | |||
169 | void TableWidget::updateChartType(bool toggle) |
|
170 | void TableWidget::updateChartType(bool toggle) | |
170 | { |
|
171 | { | |
171 | // this if is needed, so that the function is only called once. |
|
172 | // this if is needed, so that the function is only called once. | |
172 | // For the radioButton that was enabled. |
|
173 | // For the radioButton that was enabled. | |
173 | if (toggle) { |
|
174 | if (toggle) { | |
174 | // specialPie = 0; |
|
175 | // specialPie = 0; | |
175 | m_chart->removeAllSeries(); |
|
176 | m_chart->removeAllSeries(); | |
176 | m_chart->axisX()->setNiceNumbersEnabled(false); |
|
177 | m_chart->axisX()->setNiceNumbersEnabled(false); | |
177 | m_chart->axisY()->setNiceNumbersEnabled(false); |
|
178 | m_chart->axisY()->setNiceNumbersEnabled(false); | |
178 |
|
179 | |||
179 | // renable axes of the chart (pie hides them) |
|
180 | // renable axes of the chart (pie hides them) | |
180 | // x axis |
|
181 | // x axis | |
181 | QAxis *axis = m_chart->axisX(); |
|
182 | QAxis *axis = m_chart->axisX(); | |
182 | axis->setAxisVisible(true); |
|
183 | axis->setAxisVisible(true); | |
183 | axis->setGridLineVisible(true); |
|
184 | axis->setGridLineVisible(true); | |
184 | axis->setLabelsVisible(true); |
|
185 | axis->setLabelsVisible(true); | |
185 |
|
186 | |||
186 | // y axis |
|
187 | // y axis | |
187 | axis = m_chart->axisY(); |
|
188 | axis = m_chart->axisY(); | |
188 | axis->setAxisVisible(true); |
|
189 | axis->setAxisVisible(true); | |
189 | axis->setGridLineVisible(true); |
|
190 | axis->setGridLineVisible(true); | |
190 | axis->setLabelsVisible(true); |
|
191 | axis->setLabelsVisible(true); | |
191 |
|
192 | |||
192 | m_model->clearMapping(); |
|
193 | m_model->clearMapping(); | |
193 |
|
194 | |||
194 | QString seriesColorHex = "#000000"; |
|
195 | QString seriesColorHex = "#000000"; | |
195 | QPen pen; |
|
196 | QPen pen; | |
196 | pen.setWidth(2); |
|
197 | pen.setWidth(2); | |
197 |
|
198 | |||
198 | if (m_lineRadioButton->isChecked()) |
|
199 | if (m_lineRadioButton->isChecked()) | |
199 | { |
|
200 | { | |
200 | m_chart->setAnimationOptions(QChart::NoAnimation); |
|
201 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
201 |
|
202 | |||
202 | // series 1 |
|
203 | // series 1 | |
203 | m_series = new QLineSeries; |
|
204 | m_series = new QLineSeries; | |
204 | m_series->setModel(m_model); |
|
205 | m_series->setModel(m_model); | |
205 |
|
206 | |||
206 | QXYModelMapper *mapper = new QXYModelMapper; |
|
207 | QXYModelMapper *mapper = new QXYModelMapper; | |
207 | mapper->setMapX(0); |
|
208 | mapper->setMapX(0); | |
208 | mapper->setMapY(1); |
|
209 | mapper->setMapY(1); | |
209 | mapper->setFirst(3); |
|
210 | mapper->setFirst(3); | |
210 | mapper->setCount(4); |
|
211 | mapper->setCount(4); | |
211 | m_series->setModelMapper(mapper); |
|
212 | m_series->setModelMapper(mapper); | |
212 | // m_series->setModelMapping(0,1, Qt::Vertical); |
|
213 | // m_series->setModelMapping(0,1, Qt::Vertical); | |
213 | // m_series->setModelMappingRange(3, 4); |
|
214 | // m_series->setModelMappingRange(3, 4); | |
214 | m_chart->addSeries(m_series); |
|
215 | m_chart->addSeries(m_series); | |
215 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
216 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
216 | m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4)); |
|
217 | m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4)); | |
217 |
|
218 | |||
218 | // series 2 |
|
219 | // series 2 | |
219 | m_series = new QLineSeries; |
|
220 | m_series = new QLineSeries; | |
220 | m_series->setModel(m_model); |
|
221 | m_series->setModel(m_model); | |
221 |
|
222 | |||
222 | mapper = new QXYModelMapper; |
|
223 | mapper = new QXYModelMapper; | |
223 | mapper->setMapX(3); |
|
224 | mapper->setMapX(3); | |
224 | mapper->setMapY(4); |
|
225 | mapper->setMapY(4); | |
225 | // mapper->setFirst(3); |
|
226 | // mapper->setFirst(3); | |
226 | // mapper->setCount(4); |
|
227 | // mapper->setCount(4); | |
227 | m_series->setModelMapper(mapper); |
|
228 | m_series->setModelMapper(mapper); | |
228 | // m_series->setModelMapping(2,3, Qt::Vertical); |
|
229 | // m_series->setModelMapping(2,3, Qt::Vertical); | |
229 | m_chart->addSeries(m_series); |
|
230 | m_chart->addSeries(m_series); | |
230 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
231 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
231 | m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000)); |
|
232 | m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000)); | |
232 |
|
233 | |||
233 | // series 3 |
|
234 | // series 3 | |
234 | m_series = new QLineSeries; |
|
235 | m_series = new QLineSeries; | |
235 | m_series->setModel(m_model); |
|
236 | m_series->setModel(m_model); | |
236 |
|
237 | |||
237 | mapper = new QXYModelMapper; |
|
238 | mapper = new QXYModelMapper; | |
238 | mapper->setMapX(5); |
|
239 | mapper->setMapX(5); | |
239 | mapper->setMapY(6); |
|
240 | mapper->setMapY(6); | |
240 | mapper->setFirst(2); |
|
241 | mapper->setFirst(2); | |
241 | mapper->setCount(-1); |
|
242 | mapper->setCount(-1); | |
242 | m_series->setModelMapper(mapper); |
|
243 | m_series->setModelMapper(mapper); | |
243 | // m_series->setModelMapping(4,5, Qt::Vertical); |
|
244 | // m_series->setModelMapping(4,5, Qt::Vertical); | |
244 | // m_series->setModelMappingRange(2, -1); |
|
245 | // m_series->setModelMappingRange(2, -1); | |
245 | m_chart->addSeries(m_series); |
|
246 | m_chart->addSeries(m_series); | |
246 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
247 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
247 | m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000)); |
|
248 | m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000)); | |
248 | } |
|
249 | } | |
249 | else if (m_splineRadioButton->isChecked()) |
|
250 | else if (m_splineRadioButton->isChecked()) | |
250 | { |
|
251 | { | |
251 | m_chart->setAnimationOptions(QChart::NoAnimation); |
|
252 | m_chart->setAnimationOptions(QChart::NoAnimation); | |
252 |
|
253 | |||
253 | // series 1 |
|
254 | // series 1 | |
254 | m_series = new QSplineSeries; |
|
255 | m_series = new QSplineSeries; | |
255 | m_series->setModel(m_model); |
|
256 | m_series->setModel(m_model); | |
256 |
|
257 | |||
257 | QXYModelMapper *mapper = new QXYModelMapper; |
|
258 | QXYModelMapper *mapper = new QXYModelMapper; | |
258 | mapper->setMapX(0); |
|
259 | mapper->setMapX(0); | |
259 | mapper->setMapY(1); |
|
260 | mapper->setMapY(1); | |
260 | mapper->setFirst(0); |
|
261 | mapper->setFirst(0); | |
261 | mapper->setCount(-1); |
|
262 | mapper->setCount(-1); | |
262 |
|
263 | |||
263 | m_series->setModelMapper(mapper); |
|
264 | m_series->setModelMapper(mapper); | |
264 |
|
265 | |||
265 | m_chart->addSeries(m_series); |
|
266 | m_chart->addSeries(m_series); | |
266 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
267 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
267 | m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000)); |
|
268 | m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000)); | |
268 |
|
269 | |||
269 | // series 2 |
|
270 | // series 2 | |
270 | m_series = new QSplineSeries; |
|
271 | m_series = new QSplineSeries; | |
271 | m_series->setModel(m_model); |
|
272 | m_series->setModel(m_model); | |
272 |
|
273 | |||
273 | mapper = new QXYModelMapper; |
|
274 | mapper = new QXYModelMapper; | |
274 | mapper->setMapX(2); |
|
275 | mapper->setMapX(2); | |
275 | mapper->setMapY(3); |
|
276 | mapper->setMapY(3); | |
276 | mapper->setFirst(2); |
|
277 | mapper->setFirst(2); | |
277 | mapper->setCount(4); |
|
278 | mapper->setCount(4); | |
278 |
|
279 | |||
279 | m_series->setModelMapper(mapper); |
|
280 | m_series->setModelMapper(mapper); | |
280 |
|
281 | |||
281 | m_chart->addSeries(m_series); |
|
282 | m_chart->addSeries(m_series); | |
282 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
283 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
283 | m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4)); |
|
284 | m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4)); | |
284 |
|
285 | |||
285 | // series 3 |
|
286 | // series 3 | |
286 | m_series = new QSplineSeries; |
|
287 | m_series = new QSplineSeries; | |
287 | m_series->setModel(m_model); |
|
288 | m_series->setModel(m_model); | |
288 |
|
289 | |||
289 | mapper = new QXYModelMapper; |
|
290 | mapper = new QXYModelMapper; | |
290 | mapper->setMapX(4); |
|
291 | mapper->setMapX(4); | |
291 | mapper->setMapY(5); |
|
292 | mapper->setMapY(5); | |
292 | mapper->setFirst(2); |
|
293 | mapper->setFirst(2); | |
293 | mapper->setCount(-1); |
|
294 | mapper->setCount(-1); | |
294 |
|
295 | |||
295 | m_series->setModelMapper(mapper); |
|
296 | m_series->setModelMapper(mapper); | |
296 |
|
297 | |||
297 | m_chart->addSeries(m_series); |
|
298 | m_chart->addSeries(m_series); | |
298 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); |
|
299 | seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); | |
299 | m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); |
|
300 | m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000)); | |
300 | } |
|
301 | } | |
301 | // else if (m_scatterRadioButton->isChecked()) |
|
302 | // else if (m_scatterRadioButton->isChecked()) | |
302 | // { |
|
303 | // { | |
303 | // m_chart->setAnimationOptions(QChart::NoAnimation); |
|
304 | // m_chart->setAnimationOptions(QChart::NoAnimation); | |
304 |
|
305 | |||
305 | // // series 1 |
|
306 | // // series 1 | |
306 | // m_series = new QScatterSeries; |
|
307 | // m_series = new QScatterSeries; | |
307 | // m_series->setModel(m_model); |
|
308 | // m_series->setModel(m_model); | |
308 | // m_series->setModelMapping(0,1, Qt::Vertical); |
|
309 | // m_series->setModelMapping(0,1, Qt::Vertical); | |
309 | // // m_series->setModelMappingRange(2, 0); |
|
310 | // // m_series->setModelMappingRange(2, 0); | |
310 | // // series->setModelMapping(0,1, Qt::Horizontal); |
|
311 | // // series->setModelMapping(0,1, Qt::Horizontal); | |
311 | // m_chart->addSeries(m_series); |
|
312 | // m_chart->addSeries(m_series); | |
312 |
|
313 | |||
313 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
314 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | |
314 | // m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000)); |
|
315 | // m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000)); | |
315 |
|
316 | |||
316 | // // series 2 |
|
317 | // // series 2 | |
317 | // m_series = new QScatterSeries; |
|
318 | // m_series = new QScatterSeries; | |
318 | // m_series->setModel(m_model); |
|
319 | // m_series->setModel(m_model); | |
319 | // m_series->setModelMapping(2,3, Qt::Vertical); |
|
320 | // m_series->setModelMapping(2,3, Qt::Vertical); | |
320 | // // m_series->setModelMappingRange(1, 6); |
|
321 | // // m_series->setModelMappingRange(1, 6); | |
321 | // // series->setModelMapping(2,3, Qt::Horizontal); |
|
322 | // // series->setModelMapping(2,3, Qt::Horizontal); | |
322 | // m_chart->addSeries(m_series); |
|
323 | // m_chart->addSeries(m_series); | |
323 |
|
324 | |||
324 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
325 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | |
325 | // m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6)); |
|
326 | // m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6)); | |
326 |
|
327 | |||
327 | // // series 3 |
|
328 | // // series 3 | |
328 | // m_series = new QScatterSeries; |
|
329 | // m_series = new QScatterSeries; | |
329 | // m_series->setModel(m_model); |
|
330 | // m_series->setModel(m_model); | |
330 | // m_series->setModelMapping(4,5, Qt::Vertical); |
|
331 | // m_series->setModelMapping(4,5, Qt::Vertical); | |
331 | // // series->setModelMapping(4,5, Qt::Horizontal); |
|
332 | // // series->setModelMapping(4,5, Qt::Horizontal); | |
332 | // m_chart->addSeries(m_series); |
|
333 | // m_chart->addSeries(m_series); | |
333 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); |
|
334 | // seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper(); | |
334 | // m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000)); |
|
335 | // m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000)); | |
335 | // } |
|
336 | // } | |
336 | else if (m_pieRadioButton->isChecked()) |
|
337 | else if (m_pieRadioButton->isChecked()) | |
337 | { |
|
338 | { | |
338 | m_chart->setAnimationOptions(QChart::SeriesAnimations); |
|
339 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
339 |
|
340 | |||
340 | // pie 1 |
|
341 | // pie 1 | |
341 | QPieSeries* pieSeries = new QPieSeries; |
|
342 | QPieSeries* pieSeries = new QPieSeries; | |
342 | pieSeries->setModel(m_model); |
|
343 | pieSeries->setModel(m_model); | |
343 |
|
344 | |||
344 | QPieModelMapper *mapper = new QPieModelMapper; |
|
345 | QPieModelMapper *mapper = new QPieModelMapper; | |
345 | mapper->setMapValues(1); |
|
346 | mapper->setMapValues(1); | |
346 | mapper->setMapLabels(1); |
|
347 | mapper->setMapLabels(1); | |
347 | mapper->setFirst(2); |
|
348 | mapper->setFirst(2); | |
348 | mapper->setCount(5); |
|
349 | mapper->setCount(5); | |
349 | pieSeries->setModelMapper(mapper); |
|
350 | pieSeries->setModelMapper(mapper); | |
350 |
|
351 | |||
351 | pieSeries->setLabelsVisible(true); |
|
352 | pieSeries->setLabelsVisible(true); | |
352 | pieSeries->setPieSize(0.75); |
|
353 | pieSeries->setPieSize(0.75); | |
353 | // pieSeries->setHorizontalPosition(0.2); |
|
354 | // pieSeries->setHorizontalPosition(0.2); | |
354 | // pieSeries->setVerticalPosition(0.3); |
|
355 | // pieSeries->setVerticalPosition(0.3); | |
355 |
|
356 | |||
356 | m_chart->addSeries(pieSeries); |
|
357 | m_chart->addSeries(pieSeries); | |
357 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
358 | seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); | |
358 | m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 5)); |
|
359 | m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 5)); | |
359 |
|
360 | |||
360 | // // pie 2 |
|
361 | // // pie 2 | |
361 | // pieSeries = new QPieSeries; |
|
362 | // pieSeries = new QPieSeries; | |
362 | // pieSeries->setModel(m_model); |
|
363 | // pieSeries->setModel(m_model); | |
363 |
|
364 | |||
364 | // pieSeries->setModelMapping(1,1, Qt::Vertical); |
|
365 | // pieSeries->setModelMapping(1,1, Qt::Vertical); | |
365 | // pieSeries->setModelMappingRange(2, -1); |
|
366 | // pieSeries->setModelMappingRange(2, -1); | |
366 | // pieSeries->setLabelsVisible(true); |
|
367 | // pieSeries->setLabelsVisible(true); | |
367 | // pieSeries->setPieSize(0.35); |
|
368 | // pieSeries->setPieSize(0.35); | |
368 | // pieSeries->setHorizontalPosition(0.8); |
|
369 | // pieSeries->setHorizontalPosition(0.8); | |
369 | // pieSeries->setVerticalPosition(0.3); |
|
370 | // pieSeries->setVerticalPosition(0.3); | |
370 | // m_chart->addSeries(pieSeries); |
|
371 | // m_chart->addSeries(pieSeries); | |
371 | // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
372 | // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); | |
372 | // m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 1000)); |
|
373 | // m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 1000)); | |
373 |
|
374 | |||
374 | // // pie 3 |
|
375 | // // pie 3 | |
375 | // pieSeries = new QPieSeries; |
|
376 | // pieSeries = new QPieSeries; | |
376 | // pieSeries->setModel(m_model); |
|
377 | // pieSeries->setModel(m_model); | |
377 | // pieSeries->setModelMapping(2,2, Qt::Vertical); |
|
378 | // pieSeries->setModelMapping(2,2, Qt::Vertical); | |
378 | // pieSeries->setLabelsVisible(true); |
|
379 | // pieSeries->setLabelsVisible(true); | |
379 | // pieSeries->setPieSize(0.35); |
|
380 | // pieSeries->setPieSize(0.35); | |
380 | // pieSeries->setHorizontalPosition(0.5); |
|
381 | // pieSeries->setHorizontalPosition(0.5); | |
381 | // pieSeries->setVerticalPosition(0.75); |
|
382 | // pieSeries->setVerticalPosition(0.75); | |
382 | // m_chart->addSeries(pieSeries); |
|
383 | // m_chart->addSeries(pieSeries); | |
383 | // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); |
|
384 | // seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); | |
384 | // m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000)); |
|
385 | // m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000)); | |
385 |
|
386 | |||
386 | // // special pie |
|
387 | // // special pie | |
387 | // specialPie = new QPieSeries; |
|
388 | // specialPie = new QPieSeries; | |
388 | // specialPie->append(17, "1"); |
|
389 | // specialPie->append(17, "1"); | |
389 | // specialPie->append(45, "2"); |
|
390 | // specialPie->append(45, "2"); | |
390 | // specialPie->append(77, "3"); |
|
391 | // specialPie->append(77, "3"); | |
391 | // specialPie->append(37, "4"); |
|
392 | // specialPie->append(37, "4"); | |
392 | // specialPie->append(27, "5"); |
|
393 | // specialPie->append(27, "5"); | |
393 | // specialPie->append(47, "6"); |
|
394 | // specialPie->append(47, "6"); | |
394 | // specialPie->setPieSize(0.35); |
|
395 | // specialPie->setPieSize(0.35); | |
395 | // specialPie->setHorizontalPosition(0.8); |
|
396 | // specialPie->setHorizontalPosition(0.8); | |
396 | // specialPie->setVerticalPosition(0.75); |
|
397 | // specialPie->setVerticalPosition(0.75); | |
397 | // specialPie->setLabelsVisible(true); |
|
398 | // specialPie->setLabelsVisible(true); | |
398 | // m_chart->addSeries(specialPie); |
|
399 | // m_chart->addSeries(specialPie); | |
399 | } |
|
400 | } | |
400 | // else if (m_areaRadioButton->isChecked()) |
|
401 | // else if (m_areaRadioButton->isChecked()) | |
401 | // { |
|
402 | // { | |
402 | // m_chart->setAnimationOptions(QChart::NoAnimation); |
|
403 | // m_chart->setAnimationOptions(QChart::NoAnimation); | |
403 |
|
404 | |||
404 | // QLineSeries* upperLineSeries = new QLineSeries; |
|
405 | // QLineSeries* upperLineSeries = new QLineSeries; | |
405 | // upperLineSeries->setModel(m_model); |
|
406 | // upperLineSeries->setModel(m_model); | |
406 | // upperLineSeries->setModelMapping(0, 1, Qt::Vertical); |
|
407 | // upperLineSeries->setModelMapping(0, 1, Qt::Vertical); | |
407 | // // upperLineSeries->setModelMappingRange(1, 5); |
|
408 | // // upperLineSeries->setModelMappingRange(1, 5); | |
408 | // QLineSeries* lowerLineSeries = new QLineSeries; |
|
409 | // QLineSeries* lowerLineSeries = new QLineSeries; | |
409 | // lowerLineSeries->setModel(m_model); |
|
410 | // lowerLineSeries->setModel(m_model); | |
410 | // lowerLineSeries->setModelMapping(2, 3, Qt::Vertical); |
|
411 | // lowerLineSeries->setModelMapping(2, 3, Qt::Vertical); | |
411 | // QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries); |
|
412 | // QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries); | |
412 | // m_chart->addSeries(areaSeries); |
|
413 | // m_chart->addSeries(areaSeries); | |
413 | // seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper(); |
|
414 | // seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper(); | |
414 | // m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5)); |
|
415 | // m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5)); | |
415 | // m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); |
|
416 | // m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000)); | |
416 | // } |
|
417 | // } | |
417 | else if (m_barRadioButton->isChecked()) |
|
418 | else if (m_barRadioButton->isChecked()) | |
418 | { |
|
419 | { | |
419 | m_chart->setAnimationOptions(QChart::SeriesAnimations); |
|
420 | m_chart->setAnimationOptions(QChart::SeriesAnimations); | |
420 |
|
421 | |||
421 | QBarSeries* barSeries = new QBarSeries(); |
|
422 | QGroupedBarSeries* barSeries = new QGroupedBarSeries(); | |
422 | barSeries->setCategories(QStringList()); |
|
423 | barSeries->setCategories(QStringList()); | |
423 | barSeries->setModel(m_model); |
|
424 | barSeries->setModel(m_model); | |
424 | // barSeries->setModelMappingRange(2, 5); |
|
425 | // barSeries->setModelMappingRange(2, 5); | |
425 | // barSeries->setModelMapping(5, 2, 4, Qt::Vertical); |
|
426 | // barSeries->setModelMapping(5, 2, 4, Qt::Vertical); | |
426 |
|
427 | |||
427 | QBarModelMapper *mapper = new QBarModelMapper; |
|
428 | QBarModelMapper *mapper = new QBarModelMapper; | |
428 | mapper->setMapCategories(5); |
|
429 | mapper->setMapCategories(5); | |
429 | mapper->setMapBarBottom(2); |
|
430 | mapper->setMapBarBottom(2); | |
430 | mapper->setMapBarTop(4); |
|
431 | mapper->setMapBarTop(4); | |
431 | barSeries->setModelMapper(mapper); |
|
432 | barSeries->setModelMapper(mapper); | |
432 | m_chart->addSeries(barSeries); |
|
433 | m_chart->addSeries(barSeries); | |
433 | QList<QBarSet*> barsets = barSeries->barSets(); |
|
434 | QList<QBarSet*> barsets = barSeries->barSets(); | |
434 | for (int i = 0; i < barsets.count(); i++) { |
|
435 | for (int i = 0; i < barsets.count(); i++) { | |
435 | seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); |
|
436 | seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper(); | |
436 | m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000)); |
|
437 | m_model->addMapping(seriesColorHex, QRect(2 + i, 0, 1, 1000)); | |
437 | } |
|
438 | } | |
438 | } |
|
439 | } | |
439 |
|
440 | |||
440 |
|
441 | |||
441 | if (!m_barRadioButton->isChecked()) { |
|
442 | if (!m_barRadioButton->isChecked()) { | |
442 | m_chart->axisX()->setRange(0, 500); |
|
443 | m_chart->axisX()->setRange(0, 500); | |
443 | m_chart->axisY()->setRange(0, 220); |
|
444 | m_chart->axisY()->setRange(0, 220); | |
444 | } |
|
445 | } | |
445 | m_chart->legend()->setVisible(true); |
|
446 | m_chart->legend()->setVisible(true); | |
446 |
|
447 | |||
447 | // repaint table view colors |
|
448 | // repaint table view colors | |
448 | m_tableView->repaint(); |
|
449 | m_tableView->repaint(); | |
449 | m_tableView->setFocus(); |
|
450 | m_tableView->setFocus(); | |
450 | } |
|
451 | } | |
451 | } |
|
452 | } | |
452 |
|
453 | |||
453 | void TableWidget::testPie() |
|
454 | void TableWidget::testPie() | |
454 | { |
|
455 | { | |
455 | m_series->modelMapper()->setMapX(4); |
|
456 | m_series->modelMapper()->setMapX(4); | |
456 | // m_tableView->setColumnWidth(10, 250); |
|
457 | // m_tableView->setColumnWidth(10, 250); | |
457 | // if (specialPie) { |
|
458 | // if (specialPie) { | |
458 | // specialPie->remove(specialPie->slices().at(2)); |
|
459 | // specialPie->remove(specialPie->slices().at(2)); | |
459 | // // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2)); |
|
460 | // // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2)); | |
460 | // specialPie->append(4, "heloo"); |
|
461 | // specialPie->append(4, "heloo"); | |
461 | // } |
|
462 | // } | |
462 | } |
|
463 | } | |
463 |
|
464 | |||
464 | TableWidget::~TableWidget() |
|
465 | TableWidget::~TableWidget() | |
465 | { |
|
466 | { | |
466 |
|
467 | |||
467 | } |
|
468 | } |
General Comments 0
You need to be logged in to leave comments.
Login now