##// END OF EJS Templates
make gdpbarchart compile again
Jani Honkonen -
r826:851f130d7cc1
parent child
Show More
@@ -6,7 +6,7 SUBDIRS += \
6 6 customchart \
7 7 #dynamiclinechart \
8 8 #ekgchart \
9 #gdpbarchart \
9 gdpbarchart \
10 10 linechart \
11 11 #multichart \
12 12 percentbarchart \
@@ -5,21 +5,22
5 5 */
6 6
7 7 #include "widget.h"
8
9 #include <QChart>
10 #include <QScatterSeries>
11 #include <QChartAxis>
12 #include <QBarset>
13 #include <QBarSeries>
14
8 15 #include <QGridLayout>
9 16 #include <QPushButton>
10 17 #include <QLabel>
11
12 #include <QSqlQuery>
13 #include <qscatterseries.h>
14 #include <qchartview.h>
15 #include <qchartaxis.h>
16 #include <qbarset.h>
17 18 #include <QListWidget>
18 19 #include <QPrinter>
19 20 #include <QPrintDialog>
20 21 #include <QRadioButton>
21 22 #include <QStringList>
22 #include <qbarseries.h>
23 #include <QSqlQuery>
23 24
24 25 QTCOMMERCIALCHART_USE_NAMESPACE
25 26
@@ -58,11 +59,13 Widget::Widget(QWidget *parent)
58 59 rightPanelLayout->setStretch(0, 1);
59 60 rightPanelLayout->setStretch(1, 0);
60 61
62 QChart *chart = new QChart();
63 chart->setTitle("GDP by country");
64
61 65 // main layout
62 chartArea = new QChartView(this);
63 chartArea->setChartTitle("GDP by country");
66 chartView = new QChartView(chart);
64 67 QGridLayout* mainLayout = new QGridLayout;
65 mainLayout->addWidget(chartArea, 0, 0);
68 mainLayout->addWidget(chartView, 0, 0);
66 69 mainLayout->addLayout(rightPanelLayout, 0, 1);
67 70 mainLayout->setColumnStretch(0,1);
68 71 setLayout(mainLayout);
@@ -104,7 +107,7 Widget::~Widget()
104 107 */
105 108 void Widget::refreshChart()
106 109 {
107 chartArea->removeAllSeries();
110 chartView->chart()->removeAllSeries();
108 111
109 112 // selected countries items list is not sorted. copy the values to QStringlist and sort them.
110 113 QStringList selectedCountriesStrings;
@@ -169,10 +172,10 void Widget::refreshChart()
169 172 qDebug() << "Putting 0 for the missing data" << " : " << QString("%1").arg(selectedYearsInts[i]);
170 173 }
171 174 }
172 series0->addBarSet(barSet);
175 series0->appendBarSet(barSet);
173 176 }
174 177 // add the serie to the chart
175 chartArea->addSeries(series0);
178 chartView->chart()->addSeries(series0);
176 179 }
177 180 else if (scatterChartRadioButton->isChecked())
178 181 {
@@ -210,9 +213,9 void Widget::refreshChart()
210 213 }
211 214 }
212 215 // chartArea->axisX()->setRange(selectedYearsInts[selectedYearsInts.size() - 1] + 1, selectedYearsInts[0] - 1);
213 chartArea->addSeries(series);
216 chartView->chart()->addSeries(series);
214 217 }
215 chartArea->axisX()->setRange(selectedYearsInts[selectedYearsInts.size() - 1] - 1, selectedYearsInts[0] + 1);
218 chartView->chart()->axisX()->setRange(selectedYearsInts[selectedYearsInts.size() - 1] - 1, selectedYearsInts[0] + 1);
216 219 }
217 220 }
218 221
@@ -226,5 +229,5 void Widget::printChart()
226 229
227 230 QPainter painter;
228 231 painter.begin(&printer);
229 chartArea->render(&painter);
232 chartView->render(&painter);
230 233 }
@@ -2,7 +2,7
2 2 #define WIDGET_H
3 3
4 4 #include <QtGui/QWidget>
5 #include <qchartview.h>
5 #include <QChartview>
6 6 #include <QSqlDatabase>
7 7
8 8 QTCOMMERCIALCHART_USE_NAMESPACE
@@ -23,7 +23,7 public slots:
23 23 void printChart();
24 24
25 25 private:
26 QChartView* chartArea;
26 QChartView* chartView;
27 27 QListWidget* countrieslist;
28 28 QListWidget* yearslist;
29 29 QSqlDatabase db;
General Comments 0
You need to be logged in to leave comments. Login now