|
@@
-1,573
+1,582
|
|
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 <QVXYModelMapper>
|
|
29
|
#include <QVXYModelMapper>
|
|
|
|
|
30
|
#include <QHXYModelMapper>
|
|
30
|
#include "customtablemodel.h"
|
|
31
|
#include "customtablemodel.h"
|
|
31
|
#include <QPieSeries>
|
|
32
|
#include <QPieSeries>
|
|
32
|
#include <QVPieModelMapper>
|
|
33
|
#include <QVPieModelMapper>
|
|
33
|
#include <QPieSlice>
|
|
34
|
#include <QPieSlice>
|
|
34
|
#include <QAreaSeries>
|
|
35
|
#include <QAreaSeries>
|
|
35
|
#include <QBarSeries>
|
|
36
|
#include <QBarSeries>
|
|
36
|
#include <QGroupedBarSeries>
|
|
37
|
#include <QGroupedBarSeries>
|
|
37
|
#include <QBarSet>
|
|
38
|
#include <QBarSet>
|
|
38
|
#include <QVBarModelMapper>
|
|
39
|
#include <QVBarModelMapper>
|
|
39
|
#include <QPushButton>
|
|
40
|
#include <QPushButton>
|
|
40
|
#include <QRadioButton>
|
|
41
|
#include <QRadioButton>
|
|
41
|
#include <QLabel>
|
|
42
|
#include <QLabel>
|
|
42
|
#include <QSpinBox>
|
|
43
|
#include <QSpinBox>
|
|
43
|
#include <QTime>
|
|
44
|
#include <QTime>
|
|
44
|
#include <QHeaderView>
|
|
45
|
#include <QHeaderView>
|
|
45
|
|
|
46
|
|
|
46
|
TableWidget::TableWidget(QWidget *parent)
|
|
47
|
TableWidget::TableWidget(QWidget *parent)
|
|
47
|
: QWidget(parent),
|
|
48
|
: QWidget(parent),
|
|
48
|
m_series(0),
|
|
49
|
m_series(0),
|
|
49
|
m_mapper(0),
|
|
50
|
m_mapper(0),
|
|
50
|
m_model(0),
|
|
51
|
m_model(0),
|
|
51
|
m_pieMapper(0),
|
|
52
|
m_pieMapper(0),
|
|
52
|
m_pieMapper2(0)
|
|
53
|
m_pieMapper2(0)
|
|
53
|
// specialPie(0)
|
|
54
|
// specialPie(0)
|
|
54
|
{
|
|
55
|
{
|
|
55
|
setGeometry(1900, 100, 1000, 600);
|
|
56
|
setGeometry(1900, 100, 1000, 600);
|
|
56
|
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
57
|
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
57
|
// create simple model for storing data
|
|
58
|
// create simple model for storing data
|
|
58
|
// user's table data model
|
|
59
|
// user's table data model
|
|
59
|
m_model = new CustomTableModel;
|
|
60
|
m_model = new CustomTableModel;
|
|
60
|
m_tableView = new QTableView;
|
|
61
|
m_tableView = new QTableView;
|
|
61
|
m_tableView->setModel(m_model);
|
|
62
|
m_tableView->setModel(m_model);
|
|
62
|
// m_tableView->setMinimumHeight(300);
|
|
63
|
// m_tableView->setMinimumHeight(300);
|
|
63
|
m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
|
64
|
m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
|
64
|
m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
|
|
65
|
m_tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
|
|
65
|
|
|
66
|
|
|
66
|
m_chart = new QChart;
|
|
67
|
m_chart = new QChart;
|
|
67
|
m_chart->legend()->setVisible(true);
|
|
68
|
m_chart->legend()->setVisible(true);
|
|
68
|
m_chart->setAnimationOptions(QChart::SeriesAnimations);
|
|
69
|
m_chart->setAnimationOptions(QChart::SeriesAnimations);
|
|
69
|
m_chartView = new QChartView(m_chart);
|
|
70
|
m_chartView = new QChartView(m_chart);
|
|
70
|
m_chartView->setRenderHint(QPainter::Antialiasing);
|
|
71
|
m_chartView->setRenderHint(QPainter::Antialiasing);
|
|
71
|
m_chartView->setMinimumSize(640, 480);
|
|
72
|
m_chartView->setMinimumSize(640, 480);
|
|
72
|
|
|
73
|
|
|
73
|
// add, remove data buttons
|
|
74
|
// add, remove data buttons
|
|
74
|
QPushButton* addRowAboveButton = new QPushButton("Add row above");
|
|
75
|
QPushButton* addRowAboveButton = new QPushButton("Add row above");
|
|
75
|
connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove()));
|
|
76
|
connect(addRowAboveButton, SIGNAL(clicked()), this, SLOT(addRowAbove()));
|
|
76
|
|
|
77
|
|
|
77
|
QPushButton* addRowBelowButton = new QPushButton("Add row below");
|
|
78
|
QPushButton* addRowBelowButton = new QPushButton("Add row below");
|
|
78
|
connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow()));
|
|
79
|
connect(addRowBelowButton, SIGNAL(clicked()), this, SLOT(addRowBelow()));
|
|
79
|
|
|
80
|
|
|
80
|
QPushButton* removeRowButton = new QPushButton("Remove row");
|
|
81
|
QPushButton* removeRowButton = new QPushButton("Remove row");
|
|
81
|
connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
|
|
82
|
connect(removeRowButton, SIGNAL(clicked()), this, SLOT(removeRow()));
|
|
82
|
|
|
83
|
|
|
83
|
QPushButton* addColumnRightButton = new QPushButton("Add column to the right");
|
|
84
|
QPushButton* addColumnRightButton = new QPushButton("Add column to the right");
|
|
84
|
connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight()));
|
|
85
|
connect(addColumnRightButton, SIGNAL(clicked()), this, SLOT(addColumnRight()));
|
|
85
|
|
|
86
|
|
|
86
|
QPushButton* removeColumnButton = new QPushButton("Remove column");
|
|
87
|
QPushButton* removeColumnButton = new QPushButton("Remove column");
|
|
87
|
connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn()));
|
|
88
|
connect(removeColumnButton, SIGNAL(clicked()), this, SLOT(removeColumn()));
|
|
88
|
|
|
89
|
|
|
89
|
QPushButton* specialPieButton = new QPushButton("Add slices using series API");
|
|
90
|
QPushButton* specialPieButton = new QPushButton("Add slices using series API");
|
|
90
|
connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie()));
|
|
91
|
connect(specialPieButton, SIGNAL(clicked()), this, SLOT(testPie()));
|
|
91
|
|
|
92
|
|
|
92
|
QPushButton* specialPieButton2 = new QPushButton("Remove slices using series API");
|
|
93
|
QPushButton* specialPieButton2 = new QPushButton("Remove slices using series API");
|
|
93
|
connect(specialPieButton2, SIGNAL(clicked()), this, SLOT(testPie2()));
|
|
94
|
connect(specialPieButton2, SIGNAL(clicked()), this, SLOT(testPie2()));
|
|
94
|
|
|
95
|
|
|
95
|
QPushButton* specialPieButton3 = new QPushButton("Modify slices using series API");
|
|
96
|
QPushButton* specialPieButton3 = new QPushButton("Modify slices using series API");
|
|
96
|
connect(specialPieButton3, SIGNAL(clicked()), this, SLOT(testPie3()));
|
|
97
|
connect(specialPieButton3, SIGNAL(clicked()), this, SLOT(testPie3()));
|
|
97
|
|
|
98
|
|
|
98
|
QPushButton* xyTestButton = new QPushButton("Append XY point");
|
|
99
|
QPushButton* xyTestButton = new QPushButton("Append XY point");
|
|
99
|
connect(xyTestButton, SIGNAL(clicked()), this, SLOT(testXY()));
|
|
100
|
connect(xyTestButton, SIGNAL(clicked()), this, SLOT(testXY()));
|
|
100
|
|
|
101
|
|
|
101
|
|
|
102
|
|
|
102
|
QLabel *spinBoxLabel = new QLabel("Rows affected:");
|
|
103
|
QLabel *spinBoxLabel = new QLabel("Rows affected:");
|
|
103
|
|
|
104
|
|
|
104
|
// spin box for setting number of affected items (add, remove)
|
|
105
|
// spin box for setting number of affected items (add, remove)
|
|
105
|
m_linesCountSpinBox = new QSpinBox;
|
|
106
|
m_linesCountSpinBox = new QSpinBox;
|
|
106
|
m_linesCountSpinBox->setRange(1, 10);
|
|
107
|
m_linesCountSpinBox->setRange(1, 10);
|
|
107
|
m_linesCountSpinBox->setValue(1);
|
|
108
|
m_linesCountSpinBox->setValue(1);
|
|
108
|
|
|
109
|
|
|
109
|
// buttons layout
|
|
110
|
// buttons layout
|
|
110
|
QVBoxLayout* buttonsLayout = new QVBoxLayout;
|
|
111
|
QVBoxLayout* buttonsLayout = new QVBoxLayout;
|
|
111
|
buttonsLayout->addWidget(spinBoxLabel);
|
|
112
|
buttonsLayout->addWidget(spinBoxLabel);
|
|
112
|
buttonsLayout->addWidget(m_linesCountSpinBox);
|
|
113
|
buttonsLayout->addWidget(m_linesCountSpinBox);
|
|
113
|
// buttonsLayout->addWidget(addRowAboveButton);
|
|
114
|
// buttonsLayout->addWidget(addRowAboveButton);
|
|
114
|
buttonsLayout->addWidget(addRowBelowButton);
|
|
115
|
buttonsLayout->addWidget(addRowBelowButton);
|
|
115
|
buttonsLayout->addWidget(removeRowButton);
|
|
116
|
buttonsLayout->addWidget(removeRowButton);
|
|
116
|
// buttonsLayout->addWidget(addColumnRightButton);
|
|
117
|
// buttonsLayout->addWidget(addColumnRightButton);
|
|
117
|
// buttonsLayout->addWidget(removeColumnButton);
|
|
118
|
// buttonsLayout->addWidget(removeColumnButton);
|
|
118
|
buttonsLayout->addWidget(specialPieButton);
|
|
119
|
buttonsLayout->addWidget(specialPieButton);
|
|
119
|
buttonsLayout->addWidget(specialPieButton2);
|
|
120
|
buttonsLayout->addWidget(specialPieButton2);
|
|
120
|
buttonsLayout->addWidget(specialPieButton3);
|
|
121
|
buttonsLayout->addWidget(specialPieButton3);
|
|
121
|
buttonsLayout->addWidget(xyTestButton);
|
|
122
|
buttonsLayout->addWidget(xyTestButton);
|
|
122
|
buttonsLayout->addStretch();
|
|
123
|
buttonsLayout->addStretch();
|
|
123
|
|
|
124
|
|
|
124
|
// chart type radio buttons
|
|
125
|
// chart type radio buttons
|
|
125
|
m_lineRadioButton = new QRadioButton("Line");
|
|
126
|
m_lineRadioButton = new QRadioButton("Line");
|
|
126
|
m_splineRadioButton = new QRadioButton("Spline");
|
|
127
|
m_splineRadioButton = new QRadioButton("Spline");
|
|
127
|
m_scatterRadioButton = new QRadioButton("Scatter");
|
|
128
|
m_scatterRadioButton = new QRadioButton("Scatter");
|
|
128
|
m_pieRadioButton = new QRadioButton("Pie");
|
|
129
|
m_pieRadioButton = new QRadioButton("Pie");
|
|
129
|
m_areaRadioButton = new QRadioButton("Area");
|
|
130
|
m_areaRadioButton = new QRadioButton("Area");
|
|
130
|
m_barRadioButton = new QRadioButton("Bar");
|
|
131
|
m_barRadioButton = new QRadioButton("Bar");
|
|
131
|
|
|
132
|
|
|
132
|
connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
133
|
connect(m_lineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
133
|
connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
134
|
connect(m_splineRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
134
|
connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
135
|
connect(m_scatterRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
135
|
connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
136
|
connect(m_pieRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
136
|
connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
137
|
connect(m_areaRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
137
|
connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
138
|
connect(m_barRadioButton, SIGNAL(toggled(bool)), this, SLOT(updateChartType(bool)));
|
|
138
|
m_barRadioButton->setChecked(true);
|
|
139
|
m_lineRadioButton->setChecked(true);
|
|
139
|
|
|
140
|
|
|
140
|
// radio buttons layout
|
|
141
|
// radio buttons layout
|
|
141
|
QVBoxLayout* radioLayout = new QVBoxLayout;
|
|
142
|
QVBoxLayout* radioLayout = new QVBoxLayout;
|
|
142
|
radioLayout->addWidget(m_lineRadioButton);
|
|
143
|
radioLayout->addWidget(m_lineRadioButton);
|
|
143
|
radioLayout->addWidget(m_splineRadioButton);
|
|
144
|
radioLayout->addWidget(m_splineRadioButton);
|
|
144
|
radioLayout->addWidget(m_scatterRadioButton);
|
|
145
|
radioLayout->addWidget(m_scatterRadioButton);
|
|
145
|
radioLayout->addWidget(m_pieRadioButton);
|
|
146
|
radioLayout->addWidget(m_pieRadioButton);
|
|
146
|
// radioLayout->addWidget(m_areaRadioButton);
|
|
147
|
// radioLayout->addWidget(m_areaRadioButton);
|
|
147
|
radioLayout->addWidget(m_barRadioButton);
|
|
148
|
radioLayout->addWidget(m_barRadioButton);
|
|
148
|
radioLayout->addStretch();
|
|
149
|
radioLayout->addStretch();
|
|
149
|
|
|
150
|
|
|
150
|
// create main layout
|
|
151
|
// create main layout
|
|
151
|
QGridLayout* mainLayout = new QGridLayout;
|
|
152
|
QGridLayout* mainLayout = new QGridLayout;
|
|
152
|
mainLayout->addLayout(buttonsLayout, 2, 0);
|
|
153
|
mainLayout->addLayout(buttonsLayout, 2, 0);
|
|
153
|
mainLayout->addLayout(radioLayout, 3, 0);
|
|
154
|
mainLayout->addLayout(radioLayout, 3, 0);
|
|
154
|
mainLayout->addWidget(m_tableView, 1, 0);
|
|
155
|
mainLayout->addWidget(m_tableView, 1, 0);
|
|
155
|
mainLayout->addWidget(m_chartView, 1, 1, 2, 1);
|
|
156
|
mainLayout->addWidget(m_chartView, 1, 1, 2, 1);
|
|
156
|
setLayout(mainLayout);
|
|
157
|
setLayout(mainLayout);
|
|
157
|
m_lineRadioButton->setFocus();
|
|
158
|
m_lineRadioButton->setFocus();
|
|
158
|
}
|
|
159
|
}
|
|
159
|
|
|
160
|
|
|
160
|
void TableWidget::addRowAbove()
|
|
161
|
void TableWidget::addRowAbove()
|
|
161
|
{
|
|
162
|
{
|
|
162
|
m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value());
|
|
163
|
m_model->insertRows(m_tableView->currentIndex().row(), m_linesCountSpinBox->value());
|
|
163
|
|
|
164
|
|
|
164
|
}
|
|
165
|
}
|
|
165
|
|
|
166
|
|
|
166
|
void TableWidget::addRowBelow()
|
|
167
|
void TableWidget::addRowBelow()
|
|
167
|
{
|
|
168
|
{
|
|
168
|
m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value());
|
|
169
|
m_model->insertRows(m_tableView->currentIndex().row() + 1, m_linesCountSpinBox->value());
|
|
169
|
|
|
170
|
|
|
170
|
}
|
|
171
|
}
|
|
171
|
|
|
172
|
|
|
172
|
void TableWidget::removeRow()
|
|
173
|
void TableWidget::removeRow()
|
|
173
|
{
|
|
174
|
{
|
|
174
|
m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value()));
|
|
175
|
m_model->removeRows(m_tableView->currentIndex().row(), qMin(m_model->rowCount() - m_tableView->currentIndex().row(), m_linesCountSpinBox->value()));
|
|
175
|
}
|
|
176
|
}
|
|
176
|
|
|
177
|
|
|
177
|
void TableWidget::addColumnRight()
|
|
178
|
void TableWidget::addColumnRight()
|
|
178
|
{
|
|
179
|
{
|
|
179
|
m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value());
|
|
180
|
m_model->insertColumns(m_tableView->currentIndex().column() + 1, m_linesCountSpinBox->value());
|
|
180
|
}
|
|
181
|
}
|
|
181
|
|
|
182
|
|
|
182
|
void TableWidget::removeColumn()
|
|
183
|
void TableWidget::removeColumn()
|
|
183
|
{
|
|
184
|
{
|
|
184
|
m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value()));
|
|
185
|
m_model->removeColumns(m_tableView->currentIndex().column(), qMin(m_model->columnCount() - m_tableView->currentIndex().column(), m_linesCountSpinBox->value()));
|
|
185
|
}
|
|
186
|
}
|
|
186
|
|
|
187
|
|
|
187
|
void TableWidget::updateChartType(bool toggle)
|
|
188
|
void TableWidget::updateChartType(bool toggle)
|
|
188
|
{
|
|
189
|
{
|
|
189
|
// this if is needed, so that the function is only called once.
|
|
190
|
// this if is needed, so that the function is only called once.
|
|
190
|
// For the radioButton that was enabled.
|
|
191
|
// For the radioButton that was enabled.
|
|
191
|
if (toggle) {
|
|
192
|
if (toggle) {
|
|
192
|
// specialPie = 0;
|
|
193
|
// specialPie = 0;
|
|
193
|
m_chart->removeAllSeries();
|
|
194
|
m_chart->removeAllSeries();
|
|
194
|
m_series = 0;
|
|
195
|
m_series = 0;
|
|
195
|
// m_chart->axisX()->setNiceNumbersEnabled(false);
|
|
196
|
// m_chart->axisX()->setNiceNumbersEnabled(false);
|
|
196
|
// m_chart->axisY()->setNiceNumbersEnabled(false);
|
|
197
|
// m_chart->axisY()->setNiceNumbersEnabled(false);
|
|
197
|
if (m_mapper) {
|
|
198
|
if (m_mapper) {
|
|
198
|
m_mapper->deleteLater();
|
|
199
|
m_mapper->deleteLater();
|
|
199
|
m_mapper = 0;
|
|
200
|
m_mapper = 0;
|
|
200
|
}
|
|
201
|
}
|
|
201
|
|
|
202
|
|
|
202
|
if (m_pieMapper) {
|
|
203
|
if (m_pieMapper) {
|
|
203
|
m_pieMapper->deleteLater();
|
|
204
|
m_pieMapper->deleteLater();
|
|
204
|
m_pieMapper = 0;
|
|
205
|
m_pieMapper = 0;
|
|
205
|
}
|
|
206
|
}
|
|
206
|
|
|
207
|
|
|
207
|
if (m_pieMapper2) {
|
|
208
|
if (m_pieMapper2) {
|
|
208
|
m_pieMapper2->deleteLater();
|
|
209
|
m_pieMapper2->deleteLater();
|
|
209
|
m_pieMapper2 = 0;
|
|
210
|
m_pieMapper2 = 0;
|
|
210
|
}
|
|
211
|
}
|
|
211
|
|
|
212
|
|
|
212
|
// if (m_series) {
|
|
213
|
// if (m_series) {
|
|
213
|
// delete m_series;
|
|
214
|
// delete m_series;
|
|
214
|
// m_series = 0;
|
|
215
|
// m_series = 0;
|
|
215
|
// }
|
|
216
|
// }
|
|
216
|
|
|
217
|
|
|
217
|
// renable axes of the chart (pie hides them)
|
|
218
|
// renable axes of the chart (pie hides them)
|
|
218
|
// x axis
|
|
219
|
// x axis
|
|
219
|
QAxis *axis = m_chart->axisX();
|
|
220
|
QAxis *axis = m_chart->axisX();
|
|
220
|
axis->setAxisVisible(true);
|
|
221
|
axis->setAxisVisible(true);
|
|
221
|
axis->setGridLineVisible(true);
|
|
222
|
axis->setGridLineVisible(true);
|
|
222
|
axis->setLabelsVisible(true);
|
|
223
|
axis->setLabelsVisible(true);
|
|
223
|
|
|
224
|
|
|
224
|
// y axis
|
|
225
|
// y axis
|
|
225
|
axis = m_chart->axisY();
|
|
226
|
axis = m_chart->axisY();
|
|
226
|
axis->setAxisVisible(true);
|
|
227
|
axis->setAxisVisible(true);
|
|
227
|
axis->setGridLineVisible(true);
|
|
228
|
axis->setGridLineVisible(true);
|
|
228
|
axis->setLabelsVisible(true);
|
|
229
|
axis->setLabelsVisible(true);
|
|
229
|
|
|
230
|
|
|
230
|
m_model->clearMapping();
|
|
231
|
m_model->clearMapping();
|
|
231
|
|
|
232
|
|
|
232
|
QString seriesColorHex = "#000000";
|
|
233
|
QString seriesColorHex = "#000000";
|
|
233
|
// QPen pen;
|
|
234
|
// QPen pen;
|
|
234
|
// pen.setWidth(2);
|
|
235
|
// pen.setWidth(2);
|
|
235
|
|
|
236
|
|
|
236
|
if (m_lineRadioButton->isChecked())
|
|
237
|
if (m_lineRadioButton->isChecked())
|
|
237
|
{
|
|
238
|
{
|
|
238
|
m_chart->setAnimationOptions(QChart::NoAnimation);
|
|
239
|
m_chart->setAnimationOptions(QChart::NoAnimation);
|
|
239
|
|
|
240
|
|
|
240
|
// series 1
|
|
241
|
// series 1
|
|
241
|
m_series = new QLineSeries;
|
|
242
|
m_series = new QLineSeries;
|
|
242
|
|
|
243
|
|
|
243
|
m_mapper = new QVXYModelMapper;
|
|
244
|
m_mapper = new QHXYModelMapper;
|
|
244
|
m_mapper->setModel(m_model);
|
|
245
|
m_mapper->setModel(m_model);
|
|
245
|
m_mapper->setSeries(m_series);
|
|
246
|
m_mapper->setSeries(m_series);
|
|
246
|
m_mapper->setXColumn(0);
|
|
247
|
m_mapper->setXRow(0);
|
|
247
|
m_mapper->setYColumn(1);
|
|
248
|
m_mapper->setYRow(1);
|
|
248
|
m_mapper->setFirst(3);
|
|
249
|
m_mapper->setFirst(3);
|
|
249
|
m_mapper->setCount(4);
|
|
250
|
m_mapper->setCount(4);
|
|
250
|
|
|
251
|
|
|
|
|
|
252
|
// m_mapper = new QVXYModelMapper;
|
|
|
|
|
253
|
// m_mapper->setModel(m_model);
|
|
|
|
|
254
|
// m_mapper->setSeries(m_series);
|
|
|
|
|
255
|
// m_mapper->setXColumn(0);
|
|
|
|
|
256
|
// m_mapper->setYColumn(1);
|
|
|
|
|
257
|
// m_mapper->setFirst(3);
|
|
|
|
|
258
|
// m_mapper->setCount(4);
|
|
|
|
|
259
|
|
|
251
|
// m_series->setModelMapping(0,1, Qt::Vertical);
|
|
260
|
// m_series->setModelMapping(0,1, Qt::Vertical);
|
|
252
|
// m_series->setModelMappingRange(3, 4);
|
|
261
|
// m_series->setModelMappingRange(3, 4);
|
|
253
|
m_chart->addSeries(m_series);
|
|
262
|
m_chart->addSeries(m_series);
|
|
254
|
seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
263
|
seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
255
|
m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4));
|
|
264
|
m_model->addMapping(seriesColorHex, QRect(0, 3, 2, 4));
|
|
256
|
|
|
265
|
|
|
257
|
// // series 2
|
|
266
|
// // series 2
|
|
258
|
// m_series = new QLineSeries;
|
|
267
|
// m_series = new QLineSeries;
|
|
259
|
// m_series->setModel(m_model);
|
|
268
|
// m_series->setModel(m_model);
|
|
260
|
|
|
269
|
|
|
261
|
// mapper = new QXYModelMapper;
|
|
270
|
// mapper = new QXYModelMapper;
|
|
262
|
// mapper->setMapX(3);
|
|
271
|
// mapper->setMapX(3);
|
|
263
|
// mapper->setMapY(4);
|
|
272
|
// mapper->setMapY(4);
|
|
264
|
// // mapper->setFirst(3);
|
|
273
|
// // mapper->setFirst(3);
|
|
265
|
// // mapper->setCount(4);
|
|
274
|
// // mapper->setCount(4);
|
|
266
|
// m_series->setModelMapper(mapper);
|
|
275
|
// m_series->setModelMapper(mapper);
|
|
267
|
// // m_series->setModelMapping(2,3, Qt::Vertical);
|
|
276
|
// // m_series->setModelMapping(2,3, Qt::Vertical);
|
|
268
|
// m_chart->addSeries(m_series);
|
|
277
|
// m_chart->addSeries(m_series);
|
|
269
|
// seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
278
|
// seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
270
|
// m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000));
|
|
279
|
// m_model->addMapping(seriesColorHex, QRect(3, 0, 2, 1000));
|
|
271
|
|
|
280
|
|
|
272
|
// // series 3
|
|
281
|
// // series 3
|
|
273
|
// m_series = new QLineSeries;
|
|
282
|
// m_series = new QLineSeries;
|
|
274
|
// m_series->setModel(m_model);
|
|
283
|
// m_series->setModel(m_model);
|
|
275
|
|
|
284
|
|
|
276
|
// mapper = new QXYModelMapper;
|
|
285
|
// mapper = new QXYModelMapper;
|
|
277
|
// mapper->setMapX(5);
|
|
286
|
// mapper->setMapX(5);
|
|
278
|
// mapper->setMapY(6);
|
|
287
|
// mapper->setMapY(6);
|
|
279
|
// mapper->setFirst(2);
|
|
288
|
// mapper->setFirst(2);
|
|
280
|
// mapper->setCount(-1);
|
|
289
|
// mapper->setCount(-1);
|
|
281
|
// m_series->setModelMapper(mapper);
|
|
290
|
// m_series->setModelMapper(mapper);
|
|
282
|
// // m_series->setModelMapping(4,5, Qt::Vertical);
|
|
291
|
// // m_series->setModelMapping(4,5, Qt::Vertical);
|
|
283
|
// // m_series->setModelMappingRange(2, -1);
|
|
292
|
// // m_series->setModelMappingRange(2, -1);
|
|
284
|
// m_chart->addSeries(m_series);
|
|
293
|
// m_chart->addSeries(m_series);
|
|
285
|
// seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
294
|
// seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
286
|
// m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000));
|
|
295
|
// m_model->addMapping(seriesColorHex, QRect(5, 2, 2, 1000));
|
|
287
|
}
|
|
296
|
}
|
|
288
|
else if (m_splineRadioButton->isChecked())
|
|
297
|
else if (m_splineRadioButton->isChecked())
|
|
289
|
{
|
|
298
|
{
|
|
290
|
m_chart->setAnimationOptions(QChart::NoAnimation);
|
|
299
|
m_chart->setAnimationOptions(QChart::NoAnimation);
|
|
291
|
|
|
300
|
|
|
292
|
// series 1
|
|
301
|
// series 1
|
|
293
|
m_series = new QSplineSeries;
|
|
302
|
m_series = new QSplineSeries;
|
|
294
|
// m_series->setModel(m_model);
|
|
303
|
// m_series->setModel(m_model);
|
|
295
|
|
|
304
|
|
|
296
|
m_mapper = new QVXYModelMapper;
|
|
305
|
// m_mapper = new QVXYModelMapper;
|
|
297
|
m_mapper->setSeries(m_series);
|
|
306
|
// m_mapper->setSeries(m_series);
|
|
298
|
m_mapper->setModel(m_model);
|
|
307
|
// m_mapper->setModel(m_model);
|
|
299
|
m_mapper->setXColumn(0);
|
|
308
|
// m_mapper->setXColumn(0);
|
|
300
|
m_mapper->setYColumn(1);
|
|
309
|
// m_mapper->setYColumn(1);
|
|
301
|
m_mapper->setFirst(0);
|
|
310
|
// m_mapper->setFirst(0);
|
|
302
|
m_mapper->setCount(-1);
|
|
311
|
// m_mapper->setCount(-1);
|
|
303
|
|
|
312
|
|
|
304
|
// m_series->setModelMapper(mapper);
|
|
313
|
// m_series->setModelMapper(mapper);
|
|
305
|
|
|
314
|
|
|
306
|
m_chart->addSeries(m_series);
|
|
315
|
m_chart->addSeries(m_series);
|
|
307
|
seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
316
|
seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
308
|
m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000));
|
|
317
|
m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000));
|
|
309
|
|
|
318
|
|
|
310
|
// // series 2
|
|
319
|
// // series 2
|
|
311
|
// m_series = new QSplineSeries;
|
|
320
|
// m_series = new QSplineSeries;
|
|
312
|
// m_series->setModel(m_model);
|
|
321
|
// m_series->setModel(m_model);
|
|
313
|
|
|
322
|
|
|
314
|
// mapper = new QXYModelMapper;
|
|
323
|
// mapper = new QXYModelMapper;
|
|
315
|
// mapper->setMapX(2);
|
|
324
|
// mapper->setMapX(2);
|
|
316
|
// mapper->setMapY(3);
|
|
325
|
// mapper->setMapY(3);
|
|
317
|
// mapper->setFirst(2);
|
|
326
|
// mapper->setFirst(2);
|
|
318
|
// mapper->setCount(4);
|
|
327
|
// mapper->setCount(4);
|
|
319
|
|
|
328
|
|
|
320
|
// m_series->setModelMapper(mapper);
|
|
329
|
// m_series->setModelMapper(mapper);
|
|
321
|
|
|
330
|
|
|
322
|
// m_chart->addSeries(m_series);
|
|
331
|
// m_chart->addSeries(m_series);
|
|
323
|
// seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
332
|
// seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
324
|
// m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4));
|
|
333
|
// m_model->addMapping(seriesColorHex, QRect(2, 2, 2, 4));
|
|
325
|
|
|
334
|
|
|
326
|
// // series 3
|
|
335
|
// // series 3
|
|
327
|
// m_series = new QSplineSeries;
|
|
336
|
// m_series = new QSplineSeries;
|
|
328
|
// m_series->setModel(m_model);
|
|
337
|
// m_series->setModel(m_model);
|
|
329
|
|
|
338
|
|
|
330
|
// mapper = new QXYModelMapper;
|
|
339
|
// mapper = new QXYModelMapper;
|
|
331
|
// mapper->setMapX(4);
|
|
340
|
// mapper->setMapX(4);
|
|
332
|
// mapper->setMapY(5);
|
|
341
|
// mapper->setMapY(5);
|
|
333
|
// mapper->setFirst(2);
|
|
342
|
// mapper->setFirst(2);
|
|
334
|
// mapper->setCount(-1);
|
|
343
|
// mapper->setCount(-1);
|
|
335
|
|
|
344
|
|
|
336
|
// m_series->setModelMapper(mapper);
|
|
345
|
// m_series->setModelMapper(mapper);
|
|
337
|
|
|
346
|
|
|
338
|
// m_chart->addSeries(m_series);
|
|
347
|
// m_chart->addSeries(m_series);
|
|
339
|
// seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
348
|
// seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper();
|
|
340
|
// m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000));
|
|
349
|
// m_model->addMapping(seriesColorHex, QRect(4, 2, 2, 1000));
|
|
341
|
} else if (m_scatterRadioButton->isChecked())
|
|
350
|
} else if (m_scatterRadioButton->isChecked())
|
|
342
|
{
|
|
351
|
{
|
|
343
|
m_chart->setAnimationOptions(QChart::NoAnimation);
|
|
352
|
m_chart->setAnimationOptions(QChart::NoAnimation);
|
|
344
|
|
|
353
|
|
|
345
|
// series 1
|
|
354
|
// series 1
|
|
346
|
m_series = new QScatterSeries;
|
|
355
|
m_series = new QScatterSeries;
|
|
347
|
|
|
356
|
|
|
348
|
m_mapper = new QVXYModelMapper;
|
|
357
|
// m_mapper = new QVXYModelMapper;
|
|
349
|
m_mapper->setSeries(m_series);
|
|
358
|
// m_mapper->setSeries(m_series);
|
|
350
|
m_mapper->setModel(m_model);
|
|
359
|
// m_mapper->setModel(m_model);
|
|
351
|
m_mapper->setXColumn(0);
|
|
360
|
// m_mapper->setXColumn(0);
|
|
352
|
m_mapper->setYColumn(1);
|
|
361
|
// m_mapper->setYColumn(1);
|
|
353
|
m_mapper->setFirst(0);
|
|
362
|
// m_mapper->setFirst(0);
|
|
354
|
m_mapper->setCount(-1);
|
|
363
|
// m_mapper->setCount(-1);
|
|
355
|
|
|
364
|
|
|
356
|
m_chart->addSeries(m_series);
|
|
365
|
m_chart->addSeries(m_series);
|
|
357
|
seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
|
|
366
|
seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
|
|
358
|
m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000));
|
|
367
|
m_model->addMapping(seriesColorHex, QRect(0, 2, 2, 1000));
|
|
359
|
|
|
368
|
|
|
360
|
// // series 2
|
|
369
|
// // series 2
|
|
361
|
// m_series = new QScatterSeries;
|
|
370
|
// m_series = new QScatterSeries;
|
|
362
|
// m_series->setModel(m_model);
|
|
371
|
// m_series->setModel(m_model);
|
|
363
|
// m_series->setModelMapping(2,3, Qt::Vertical);
|
|
372
|
// m_series->setModelMapping(2,3, Qt::Vertical);
|
|
364
|
// // m_series->setModelMappingRange(1, 6);
|
|
373
|
// // m_series->setModelMappingRange(1, 6);
|
|
365
|
// // series->setModelMapping(2,3, Qt::Horizontal);
|
|
374
|
// // series->setModelMapping(2,3, Qt::Horizontal);
|
|
366
|
// m_chart->addSeries(m_series);
|
|
375
|
// m_chart->addSeries(m_series);
|
|
367
|
|
|
376
|
|
|
368
|
// 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();
|
|
369
|
// m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6));
|
|
378
|
// m_model->addMapping(seriesColorHex, QRect(2, 1, 2, 6));
|
|
370
|
|
|
379
|
|
|
371
|
// // series 3
|
|
380
|
// // series 3
|
|
372
|
// m_series = new QScatterSeries;
|
|
381
|
// m_series = new QScatterSeries;
|
|
373
|
// m_series->setModel(m_model);
|
|
382
|
// m_series->setModel(m_model);
|
|
374
|
// m_series->setModelMapping(4,5, Qt::Vertical);
|
|
383
|
// m_series->setModelMapping(4,5, Qt::Vertical);
|
|
375
|
// // series->setModelMapping(4,5, Qt::Horizontal);
|
|
384
|
// // series->setModelMapping(4,5, Qt::Horizontal);
|
|
376
|
// m_chart->addSeries(m_series);
|
|
385
|
// m_chart->addSeries(m_series);
|
|
377
|
// seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
|
|
386
|
// seriesColorHex = "#" + QString::number(m_series->brush().color().rgb(), 16).right(6).toUpper();
|
|
378
|
// m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000));
|
|
387
|
// m_model->addMapping(seriesColorHex, QRect(4, 0, 2, 1000));
|
|
379
|
} else if (m_pieRadioButton->isChecked()) {
|
|
388
|
} else if (m_pieRadioButton->isChecked()) {
|
|
380
|
m_chart->setAnimationOptions(QChart::SeriesAnimations);
|
|
389
|
m_chart->setAnimationOptions(QChart::SeriesAnimations);
|
|
381
|
|
|
390
|
|
|
382
|
// pie 1
|
|
391
|
// pie 1
|
|
383
|
m_pieSeries = new QPieSeries;
|
|
392
|
m_pieSeries = new QPieSeries;
|
|
384
|
|
|
393
|
|
|
385
|
m_pieMapper = new QVPieModelMapper;
|
|
394
|
m_pieMapper = new QVPieModelMapper;
|
|
386
|
m_pieMapper->setValuesColumn(1);
|
|
395
|
m_pieMapper->setValuesColumn(1);
|
|
387
|
m_pieMapper->setLabelsColumn(7);
|
|
396
|
m_pieMapper->setLabelsColumn(7);
|
|
388
|
m_pieMapper->setSeries(m_pieSeries);
|
|
397
|
m_pieMapper->setSeries(m_pieSeries);
|
|
389
|
m_pieMapper->setModel(m_model);
|
|
398
|
m_pieMapper->setModel(m_model);
|
|
390
|
m_pieMapper->setFirst(2);
|
|
399
|
m_pieMapper->setFirst(2);
|
|
391
|
// m_pieMapper->setCount(5);
|
|
400
|
// m_pieMapper->setCount(5);
|
|
392
|
// pieSeries->setModelMapper(mapper);
|
|
401
|
// pieSeries->setModelMapper(mapper);
|
|
393
|
|
|
402
|
|
|
394
|
m_pieSeries->setLabelsVisible(true);
|
|
403
|
m_pieSeries->setLabelsVisible(true);
|
|
395
|
m_pieSeries->setPieSize(0.35);
|
|
404
|
m_pieSeries->setPieSize(0.35);
|
|
396
|
m_pieSeries->setHorizontalPosition(0.25);
|
|
405
|
m_pieSeries->setHorizontalPosition(0.25);
|
|
397
|
m_pieSeries->setVerticalPosition(0.35);
|
|
406
|
m_pieSeries->setVerticalPosition(0.35);
|
|
398
|
|
|
407
|
|
|
399
|
m_chart->addSeries(m_pieSeries);
|
|
408
|
m_chart->addSeries(m_pieSeries);
|
|
400
|
seriesColorHex = "#" + QString::number(m_pieSeries->slices().at(m_pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
|
|
409
|
seriesColorHex = "#" + QString::number(m_pieSeries->slices().at(m_pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
|
|
401
|
m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 50));
|
|
410
|
m_model->addMapping(seriesColorHex, QRect(1, 2, 1, 50));
|
|
402
|
|
|
411
|
|
|
403
|
|
|
412
|
|
|
404
|
// pieSeries->slices().at(0)->setValue(400);
|
|
413
|
// pieSeries->slices().at(0)->setValue(400);
|
|
405
|
// pieSeries->slices().at(0)->setLabel(QString("36"));
|
|
414
|
// pieSeries->slices().at(0)->setLabel(QString("36"));
|
|
406
|
|
|
415
|
|
|
407
|
// pie 2
|
|
416
|
// pie 2
|
|
408
|
m_pieSeries2 = new QPieSeries;
|
|
417
|
m_pieSeries2 = new QPieSeries;
|
|
409
|
|
|
418
|
|
|
410
|
m_pieMapper2 = new QVPieModelMapper;
|
|
419
|
m_pieMapper2 = new QVPieModelMapper;
|
|
411
|
m_pieMapper2->setValuesColumn(0);
|
|
420
|
m_pieMapper2->setValuesColumn(0);
|
|
412
|
m_pieMapper2->setLabelsColumn(7);
|
|
421
|
m_pieMapper2->setLabelsColumn(7);
|
|
413
|
m_pieMapper2->setModel(m_model);
|
|
422
|
m_pieMapper2->setModel(m_model);
|
|
414
|
m_pieMapper2->setSeries(m_pieSeries2);
|
|
423
|
m_pieMapper2->setSeries(m_pieSeries2);
|
|
415
|
m_pieMapper2->setFirst(2);
|
|
424
|
m_pieMapper2->setFirst(2);
|
|
416
|
|
|
425
|
|
|
417
|
m_pieSeries2->setLabelsVisible(true);
|
|
426
|
m_pieSeries2->setLabelsVisible(true);
|
|
418
|
m_pieSeries2->setPieSize(0.35);
|
|
427
|
m_pieSeries2->setPieSize(0.35);
|
|
419
|
m_pieSeries2->setHorizontalPosition(0.75);
|
|
428
|
m_pieSeries2->setHorizontalPosition(0.75);
|
|
420
|
m_pieSeries2->setVerticalPosition(0.65);
|
|
429
|
m_pieSeries2->setVerticalPosition(0.65);
|
|
421
|
m_chart->addSeries(m_pieSeries2);
|
|
430
|
m_chart->addSeries(m_pieSeries2);
|
|
422
|
seriesColorHex = "#" + QString::number(m_pieSeries2->slices().at(m_pieSeries2->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
|
|
431
|
seriesColorHex = "#" + QString::number(m_pieSeries2->slices().at(m_pieSeries2->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
|
|
423
|
m_model->addMapping(seriesColorHex, QRect(0, 2, 1, 1000));
|
|
432
|
m_model->addMapping(seriesColorHex, QRect(0, 2, 1, 1000));
|
|
424
|
|
|
433
|
|
|
425
|
// // pie 3
|
|
434
|
// // pie 3
|
|
426
|
// pieSeries = new QPieSeries;
|
|
435
|
// pieSeries = new QPieSeries;
|
|
427
|
// pieSeries->setModel(m_model);
|
|
436
|
// pieSeries->setModel(m_model);
|
|
428
|
// pieSeries->setModelMapping(2,2, Qt::Vertical);
|
|
437
|
// pieSeries->setModelMapping(2,2, Qt::Vertical);
|
|
429
|
// pieSeries->setLabelsVisible(true);
|
|
438
|
// pieSeries->setLabelsVisible(true);
|
|
430
|
// pieSeries->setPieSize(0.35);
|
|
439
|
// pieSeries->setPieSize(0.35);
|
|
431
|
// pieSeries->setHorizontalPosition(0.5);
|
|
440
|
// pieSeries->setHorizontalPosition(0.5);
|
|
432
|
// pieSeries->setVerticalPosition(0.75);
|
|
441
|
// pieSeries->setVerticalPosition(0.75);
|
|
433
|
// m_chart->addSeries(pieSeries);
|
|
442
|
// m_chart->addSeries(pieSeries);
|
|
434
|
// seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
|
|
443
|
// seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper();
|
|
435
|
// m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000));
|
|
444
|
// m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000));
|
|
436
|
|
|
445
|
|
|
437
|
// // special pie
|
|
446
|
// // special pie
|
|
438
|
// specialPie = new QPieSeries;
|
|
447
|
// specialPie = new QPieSeries;
|
|
439
|
// specialPie->append(17, "1");
|
|
448
|
// specialPie->append(17, "1");
|
|
440
|
// specialPie->append(45, "2");
|
|
449
|
// specialPie->append(45, "2");
|
|
441
|
// specialPie->append(77, "3");
|
|
450
|
// specialPie->append(77, "3");
|
|
442
|
// specialPie->append(37, "4");
|
|
451
|
// specialPie->append(37, "4");
|
|
443
|
// specialPie->append(27, "5");
|
|
452
|
// specialPie->append(27, "5");
|
|
444
|
// specialPie->append(47, "6");
|
|
453
|
// specialPie->append(47, "6");
|
|
445
|
// specialPie->setPieSize(0.35);
|
|
454
|
// specialPie->setPieSize(0.35);
|
|
446
|
// specialPie->setHorizontalPosition(0.8);
|
|
455
|
// specialPie->setHorizontalPosition(0.8);
|
|
447
|
// specialPie->setVerticalPosition(0.75);
|
|
456
|
// specialPie->setVerticalPosition(0.75);
|
|
448
|
// specialPie->setLabelsVisible(true);
|
|
457
|
// specialPie->setLabelsVisible(true);
|
|
449
|
// m_chart->addSeries(specialPie);
|
|
458
|
// m_chart->addSeries(specialPie);
|
|
450
|
}
|
|
459
|
}
|
|
451
|
// else if (m_areaRadioButton->isChecked())
|
|
460
|
// else if (m_areaRadioButton->isChecked())
|
|
452
|
// {
|
|
461
|
// {
|
|
453
|
// m_chart->setAnimationOptions(QChart::NoAnimation);
|
|
462
|
// m_chart->setAnimationOptions(QChart::NoAnimation);
|
|
454
|
|
|
463
|
|
|
455
|
// QLineSeries* upperLineSeries = new QLineSeries;
|
|
464
|
// QLineSeries* upperLineSeries = new QLineSeries;
|
|
456
|
// upperLineSeries->setModel(m_model);
|
|
465
|
// upperLineSeries->setModel(m_model);
|
|
457
|
// upperLineSeries->setModelMapping(0, 1, Qt::Vertical);
|
|
466
|
// upperLineSeries->setModelMapping(0, 1, Qt::Vertical);
|
|
458
|
// // upperLineSeries->setModelMappingRange(1, 5);
|
|
467
|
// // upperLineSeries->setModelMappingRange(1, 5);
|
|
459
|
// QLineSeries* lowerLineSeries = new QLineSeries;
|
|
468
|
// QLineSeries* lowerLineSeries = new QLineSeries;
|
|
460
|
// lowerLineSeries->setModel(m_model);
|
|
469
|
// lowerLineSeries->setModel(m_model);
|
|
461
|
// lowerLineSeries->setModelMapping(2, 3, Qt::Vertical);
|
|
470
|
// lowerLineSeries->setModelMapping(2, 3, Qt::Vertical);
|
|
462
|
// QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries);
|
|
471
|
// QAreaSeries* areaSeries = new QAreaSeries(upperLineSeries, lowerLineSeries);
|
|
463
|
// m_chart->addSeries(areaSeries);
|
|
472
|
// m_chart->addSeries(areaSeries);
|
|
464
|
// seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper();
|
|
473
|
// seriesColorHex = "#" + QString::number(areaSeries->brush().color().rgb(), 16).right(6).toUpper();
|
|
465
|
// m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5));
|
|
474
|
// m_model->addMapping(seriesColorHex, QRect(0, 1, 2, 5));
|
|
466
|
// m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000));
|
|
475
|
// m_model->addMapping(seriesColorHex, QRect(2, 0, 2, 1000));
|
|
467
|
// }
|
|
476
|
// }
|
|
468
|
else if (m_barRadioButton->isChecked())
|
|
477
|
else if (m_barRadioButton->isChecked())
|
|
469
|
{
|
|
478
|
{
|
|
470
|
m_chart->setAnimationOptions(QChart::SeriesAnimations);
|
|
479
|
m_chart->setAnimationOptions(QChart::SeriesAnimations);
|
|
471
|
|
|
480
|
|
|
472
|
QGroupedBarSeries* barSeries = new QGroupedBarSeries();
|
|
481
|
QGroupedBarSeries* barSeries = new QGroupedBarSeries();
|
|
473
|
// barSeries->setCategories(QStringList());
|
|
482
|
// barSeries->setCategories(QStringList());
|
|
474
|
// barSeries->setModel(m_model);
|
|
483
|
// barSeries->setModel(m_model);
|
|
475
|
// barSeries->setModelMappingRange(2, 5);
|
|
484
|
// barSeries->setModelMappingRange(2, 5);
|
|
476
|
// barSeries->setModelMapping(5, 2, 4, Qt::Vertical);
|
|
485
|
// barSeries->setModelMapping(5, 2, 4, Qt::Vertical);
|
|
477
|
|
|
486
|
|
|
478
|
int first = 3;
|
|
487
|
int first = 3;
|
|
479
|
// int count = 4;
|
|
488
|
// int count = 4;
|
|
480
|
QVBarModelMapper *mapper = new QVBarModelMapper;
|
|
489
|
QVBarModelMapper *mapper = new QVBarModelMapper;
|
|
481
|
mapper->setCategoriesSection(5);
|
|
490
|
mapper->setCategoriesSection(5);
|
|
482
|
mapper->setFirstBarSection(2);
|
|
491
|
mapper->setFirstBarSection(2);
|
|
483
|
mapper->setLastBarSection(4);
|
|
492
|
mapper->setLastBarSection(4);
|
|
484
|
mapper->setFirst(first);
|
|
493
|
mapper->setFirst(first);
|
|
485
|
// mapper->setCount(count);
|
|
494
|
// mapper->setCount(count);
|
|
486
|
mapper->setSeries(barSeries);
|
|
495
|
mapper->setSeries(barSeries);
|
|
487
|
mapper->setModel(m_model);
|
|
496
|
mapper->setModel(m_model);
|
|
488
|
// barSeries->setModelMapper(mapper);
|
|
497
|
// barSeries->setModelMapper(mapper);
|
|
489
|
m_chart->addSeries(barSeries);
|
|
498
|
m_chart->addSeries(barSeries);
|
|
490
|
QList<QBarSet*> barsets = barSeries->barSets();
|
|
499
|
QList<QBarSet*> barsets = barSeries->barSets();
|
|
491
|
for (int i = 0; i < barsets.count(); i++) {
|
|
500
|
for (int i = 0; i < barsets.count(); i++) {
|
|
492
|
seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper();
|
|
501
|
seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper();
|
|
493
|
m_model->addMapping(seriesColorHex, QRect(2 + i, first, 1, barsets.at(i)->count()));
|
|
502
|
m_model->addMapping(seriesColorHex, QRect(2 + i, first, 1, barsets.at(i)->count()));
|
|
494
|
}
|
|
503
|
}
|
|
495
|
}
|
|
504
|
}
|
|
496
|
|
|
505
|
|
|
497
|
|
|
506
|
|
|
498
|
if (!m_barRadioButton->isChecked()) {
|
|
507
|
if (!m_barRadioButton->isChecked()) {
|
|
499
|
m_chart->axisX()->setRange(0, 500);
|
|
508
|
m_chart->axisX()->setRange(0, 500);
|
|
500
|
m_chart->axisY()->setRange(0, 220);
|
|
509
|
m_chart->axisY()->setRange(0, 220);
|
|
501
|
}
|
|
510
|
}
|
|
502
|
m_chart->legend()->setVisible(true);
|
|
511
|
m_chart->legend()->setVisible(true);
|
|
503
|
|
|
512
|
|
|
504
|
// repaint table view colors
|
|
513
|
// repaint table view colors
|
|
505
|
m_tableView->repaint();
|
|
514
|
m_tableView->repaint();
|
|
506
|
m_tableView->setFocus();
|
|
515
|
m_tableView->setFocus();
|
|
507
|
}
|
|
516
|
}
|
|
508
|
}
|
|
517
|
}
|
|
509
|
|
|
518
|
|
|
510
|
void TableWidget::testPie()
|
|
519
|
void TableWidget::testPie()
|
|
511
|
{
|
|
520
|
{
|
|
512
|
// m_pieMapper->setCount(-1);
|
|
521
|
// m_pieMapper->setCount(-1);
|
|
513
|
QPieSlice *slice = new QPieSlice("Hehe", 145);
|
|
522
|
QPieSlice *slice = new QPieSlice("Hehe", 145);
|
|
514
|
slice->setLabelVisible();
|
|
523
|
slice->setLabelVisible();
|
|
515
|
m_pieSeries->append(slice);
|
|
524
|
m_pieSeries->append(slice);
|
|
516
|
|
|
525
|
|
|
517
|
slice = new QPieSlice("Hoho", 34);
|
|
526
|
slice = new QPieSlice("Hoho", 34);
|
|
518
|
slice->setLabelVisible();
|
|
527
|
slice->setLabelVisible();
|
|
519
|
m_pieSeries->append(slice);
|
|
528
|
m_pieSeries->append(slice);
|
|
520
|
// m_series->modelMapper()->setMapX(4);
|
|
529
|
// m_series->modelMapper()->setMapX(4);
|
|
521
|
// m_tableView->setColumnWidth(10, 250);
|
|
530
|
// m_tableView->setColumnWidth(10, 250);
|
|
522
|
// if (specialPie) {
|
|
531
|
// if (specialPie) {
|
|
523
|
// specialPie->remove(specialPie->slices().at(2));
|
|
532
|
// specialPie->remove(specialPie->slices().at(2));
|
|
524
|
// // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2));
|
|
533
|
// // specialPie->insert(4, new QPieSlice(45, "Hello"));//specialPie->slices.at(2));
|
|
525
|
// specialPie->append(4, "heloo");
|
|
534
|
// specialPie->append(4, "heloo");
|
|
526
|
// }
|
|
535
|
// }
|
|
527
|
}
|
|
536
|
}
|
|
528
|
|
|
537
|
|
|
529
|
void TableWidget::testPie2()
|
|
538
|
void TableWidget::testPie2()
|
|
530
|
{
|
|
539
|
{
|
|
531
|
QPieSlice *slice;
|
|
540
|
QPieSlice *slice;
|
|
532
|
if (m_pieSeries->count() > 0) {
|
|
541
|
if (m_pieSeries->count() > 0) {
|
|
533
|
slice = m_pieSeries->slices().last();
|
|
542
|
slice = m_pieSeries->slices().last();
|
|
534
|
m_pieSeries->remove(slice);
|
|
543
|
m_pieSeries->remove(slice);
|
|
535
|
}
|
|
544
|
}
|
|
536
|
|
|
545
|
|
|
537
|
if (m_pieSeries->count() > 0) {
|
|
546
|
if (m_pieSeries->count() > 0) {
|
|
538
|
slice = m_pieSeries->slices().first();
|
|
547
|
slice = m_pieSeries->slices().first();
|
|
539
|
m_pieSeries->remove(slice);
|
|
548
|
m_pieSeries->remove(slice);
|
|
540
|
}
|
|
549
|
}
|
|
541
|
}
|
|
550
|
}
|
|
542
|
|
|
551
|
|
|
543
|
void TableWidget::testPie3()
|
|
552
|
void TableWidget::testPie3()
|
|
544
|
{
|
|
553
|
{
|
|
545
|
QPieSlice *slice;
|
|
554
|
QPieSlice *slice;
|
|
546
|
if (m_pieSeries->count() > 0) {
|
|
555
|
if (m_pieSeries->count() > 0) {
|
|
547
|
slice = m_pieSeries->slices().last();
|
|
556
|
slice = m_pieSeries->slices().last();
|
|
548
|
slice->setLabel("Dalej");
|
|
557
|
slice->setLabel("Dalej");
|
|
549
|
slice->setValue(222);
|
|
558
|
slice->setValue(222);
|
|
550
|
}
|
|
559
|
}
|
|
551
|
|
|
560
|
|
|
552
|
if (m_pieSeries->count() > 0) {
|
|
561
|
if (m_pieSeries->count() > 0) {
|
|
553
|
slice = m_pieSeries->slices().first();
|
|
562
|
slice = m_pieSeries->slices().first();
|
|
554
|
slice->setLabel("Prawie");
|
|
563
|
slice->setLabel("Prawie");
|
|
555
|
slice->setValue(111);
|
|
564
|
slice->setValue(111);
|
|
556
|
}
|
|
565
|
}
|
|
557
|
}
|
|
566
|
}
|
|
558
|
|
|
567
|
|
|
559
|
void TableWidget::testXY()
|
|
568
|
void TableWidget::testXY()
|
|
560
|
{
|
|
569
|
{
|
|
561
|
// if (m_series->type() != QAbstractSeries::SeriesTypeLine) {
|
|
570
|
// if (m_series->type() != QAbstractSeries::SeriesTypeLine) {
|
|
562
|
// m_series->append(QPointF(150, 75));
|
|
571
|
// m_series->append(QPointF(150, 75));
|
|
563
|
// }
|
|
572
|
// }
|
|
564
|
|
|
573
|
|
|
565
|
if (m_series->count() > 0) {
|
|
574
|
if (m_series->count() > 0) {
|
|
566
|
m_series->remove(m_series->points().last());
|
|
575
|
m_series->remove(m_series->points().last());
|
|
567
|
}
|
|
576
|
}
|
|
568
|
}
|
|
577
|
}
|
|
569
|
|
|
578
|
|
|
570
|
TableWidget::~TableWidget()
|
|
579
|
TableWidget::~TableWidget()
|
|
571
|
{
|
|
580
|
{
|
|
572
|
|
|
581
|
|
|
573
|
}
|
|
582
|
}
|