##// END OF EJS Templates
Fixed compilation of example apps with QBarSets
Tero Ahola -
r284:f36371057e0a
parent child
Show More
@@ -141,7 +141,7 void Widget::refreshChart()
141 for (int i = 0; i < selectedYearsInts.size(); i++)
141 for (int i = 0; i < selectedYearsInts.size(); i++)
142 {
142 {
143 query.exec("SELECT country,gdpvalue FROM gdp2 where year=" + QString("%1").arg(selectedYearsInts[i]) + " AND " + countriesQuery);
143 query.exec("SELECT country,gdpvalue FROM gdp2 where year=" + QString("%1").arg(selectedYearsInts[i]) + " AND " + countriesQuery);
144 QBarSet* barSet = new QBarSet;
144 QBarSet* barSet = new QBarSet("Barset" + QString::number(i));
145 // while (query.next()) {
145 // while (query.next()) {
146 // qDebug() << query.value(0).toString() << " : " << query.value(1).toString();
146 // qDebug() << query.value(0).toString() << " : " << query.value(1).toString();
147 // }
147 // }
@@ -247,51 +247,25 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS
247 m_chartWidget->addSeries(series);
247 m_chartWidget->addSeries(series);
248 setCurrentSeries(series);
248 setCurrentSeries(series);
249 }
249 }
250 } else if (seriesName == "Bar") {
250 } else if (seriesName == "Bar"
251 || seriesName == "Stacked bar"
252 || seriesName == "Percent bar") {
251 // TODO: replace QBarCategory with QStringList?
253 // TODO: replace QBarCategory with QStringList?
252 QBarCategory *category = new QBarCategory;
254 QBarCategory *category = new QBarCategory;
253 QStringList labels = generateLabels(rowCount);
255 QStringList labels = generateLabels(rowCount);
254 foreach(QString label, labels)
256 foreach(QString label, labels)
255 *category << label;
257 *category << label;
256 QBarChartSeries* series = new QBarChartSeries(category, this);
258 QBarChartSeries* series = 0;
259 if (seriesName == "Bar")
260 series = new QBarChartSeries(category, this);
261 else if (seriesName == "Stacked bar")
262 series = new QStackedBarChartSeries(category, this);
263 else
264 series = new QPercentBarChartSeries(category, this);
257
265
258 for (int j(0); j < data.count(); j++) {
266 for (int j(0); j < data.count(); j++) {
259 QList<qreal> column = data.at(j);
267 QList<qreal> column = data.at(j);
260 QBarSet *set = new QBarSet;
268 QBarSet *set = new QBarSet("set" + QString::number(j));
261 for (int i(0); i < column.count(); i++) {
262 *set << column.at(i);
263 }
264 series->addBarSet(set);
265 }
266 m_chartWidget->addSeries(series);
267 setCurrentSeries(series);
268 } else if (seriesName == "Stacked bar") {
269 QBarCategory *category = new QBarCategory;
270 QStringList labels = generateLabels(rowCount);
271 foreach(QString label, labels)
272 *category << label;
273 QStackedBarChartSeries* series = new QStackedBarChartSeries(category, this);
274
275 for (int j(0); j < data.count(); j++) {
276 QList<qreal> column = data.at(j);
277 QBarSet *set = new QBarSet;
278 for (int i(0); i < column.count(); i++) {
279 *set << column.at(i);
280 }
281 series->addBarSet(set);
282 }
283 m_chartWidget->addSeries(series);
284 setCurrentSeries(series);
285 } else if (seriesName == "Percent bar") {
286 QBarCategory *category = new QBarCategory;
287 QStringList labels = generateLabels(rowCount);
288 foreach(QString label, labels)
289 *category << label;
290 QPercentBarChartSeries* series = new QPercentBarChartSeries(category, this);
291
292 for (int j(0); j < data.count(); j++) {
293 QList<qreal> column = data.at(j);
294 QBarSet *set = new QBarSet;
295 for (int i(0); i < column.count(); i++) {
269 for (int i(0); i < column.count(); i++) {
296 *set << column.at(i);
270 *set << column.at(i);
297 }
271 }
General Comments 0
You need to be logged in to leave comments. Login now