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