##// END OF EJS Templates
Line and area series in chartwidgettest
Tero Ahola -
r468:baa18f282b3d
parent child
Show More
@@ -1,9 +1,10
1 1 #include "mainwidget.h"
2 2 #include "dataseriedialog.h"
3 #include "qpieseries.h"
4 #include "qscatterseries.h"
3 #include <qpieseries.h>
4 #include <qscatterseries.h>
5 5 #include <qlineseries.h>
6 #include "qsplineseries.h"
6 #include <qareaseries.h>
7 #include <qsplineseries.h>
7 8 #include <qbarset.h>
8 9 #include <qbarseries.h>
9 10 #include <qstackedbarseries.h>
@@ -201,7 +202,7 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS
201 202 QList<RealList> data = generateTestData(columnCount, rowCount, dataCharacteristics);
202 203
203 204 // Line series and scatter series use similar data
204 if (seriesName.contains("qline", Qt::CaseInsensitive)) {
205 if (seriesName == "Line") {
205 206 for (int j(0); j < data.count(); j ++) {
206 207 QList<qreal> column = data.at(j);
207 208 QLineSeries *series = new QLineSeries();
@@ -211,7 +212,19 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS
211 212 m_chartView->addSeries(series);
212 213 setCurrentSeries(series);
213 214 }
214 } else if (seriesName.contains("scatter", Qt::CaseInsensitive)) {
215 } if (seriesName == "Area") {
216 // TODO: lower series for the area?
217 for (int j(0); j < data.count(); j ++) {
218 QList<qreal> column = data.at(j);
219 QLineSeries *lineSeries = new QLineSeries();
220 for (int i(0); i < column.count(); i++) {
221 lineSeries->add(i, column.at(i));
222 }
223 QAreaSeries *areaSeries = new QAreaSeries(lineSeries);
224 m_chartView->addSeries(areaSeries);
225 setCurrentSeries(areaSeries);
226 }
227 } else if (seriesName == "Scatter") {
215 228 for (int j(0); j < data.count(); j++) {
216 229 QList<qreal> column = data.at(j);
217 230 QScatterSeries *series = new QScatterSeries();
@@ -221,7 +234,7 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS
221 234 m_chartView->addSeries(series);
222 235 setCurrentSeries(series);
223 236 }
224 } else if (seriesName.contains("pie", Qt::CaseInsensitive)) {
237 } else if (seriesName == "Pie") {
225 238 QStringList labels = generateLabels(rowCount);
226 239 for (int j(0); j < data.count(); j++) {
227 240 QPieSeries *series = new QPieSeries();
@@ -262,8 +275,7 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS
262 275 series->setSeparatorsEnabled(false);
263 276 m_chartView->addSeries(series);
264 277 setCurrentSeries(series);
265 }
266 else if (seriesName.contains("spline", Qt::CaseInsensitive)) {
278 } else if (seriesName == "Spline") {
267 279 for (int j(0); j < data.count(); j ++) {
268 280 QList<qreal> column = data.at(j);
269 281 QSplineSeries *series = new QSplineSeries();
General Comments 0
You need to be logged in to leave comments. Login now