From e98d5f6bcbb912b119c935a79c3093f2603f02ba 2012-02-28 11:29:04 From: Marek Rosa Date: 2012-02-28 11:29:04 Subject: [PATCH] Doc update --- diff --git a/doc/src/examples.qdoc b/doc/src/examples.qdoc index 828356a..b222770 100644 --- a/doc/src/examples.qdoc +++ b/doc/src/examples.qdoc @@ -16,6 +16,7 @@
  • Bar Chart example
  • Line Chart example
  • Pie Chart example
  • +
  • GDP Chart example
  • diff --git a/example/gdpbarchart/widget.cpp b/example/gdpbarchart/widget.cpp index 20b5c74..97afda2 100644 --- a/example/gdpbarchart/widget.cpp +++ b/example/gdpbarchart/widget.cpp @@ -35,6 +35,7 @@ Widget::Widget(QWidget *parent) countrieslist = new QListWidget; countrieslist->setSelectionMode(QAbstractItemView::MultiSelection); + //list of years widget yearslist = new QListWidget; yearslist->setSelectionMode(QAbstractItemView::ExtendedSelection); for (int i = 1990; i < 2011; i++) @@ -101,7 +102,7 @@ Widget::~Widget() */ void Widget::refreshChart() { - chartArea->removeAllSeries(); + chartArea->removeAllSeries(); // selected countries items list is not sorted. copy the values to QStringlist and sort them. QStringList selectedCountriesStrings; @@ -111,7 +112,7 @@ void Widget::refreshChart() selectedCountriesStrings.sort(); QSqlQuery query; - // selected years items list is not sorted. copy the values to QList and sort them. + // selected years items list is not sorted. copy the values to QList and sort them. QList selectedYearsInts; QList selectedYearsItems = yearslist->selectedItems(); for (int i = 0; i < selectedYearsItems.size(); i++) @@ -119,12 +120,12 @@ void Widget::refreshChart() qSort(selectedYearsInts.begin(), selectedYearsInts.end(), qGreater()); if (barChartRadioButton->isChecked()) - { + { // use the sorted selected coutries list to initialize BarCategory QBarCategory* category = new QBarCategory; for (int i = 0; i < selectedCountriesStrings.size(); i++) *category << selectedCountriesStrings[i]; - series0 = new QBarChartSeries(category); + QBarChartSeries* series0 = new QBarChartSeries(category); // prepare the selected counries SQL query QString countriesQuery = "country IN ("; @@ -162,14 +163,13 @@ void Widget::refreshChart() { // data missing, put 0 *barSet << 0.0f; - qDebug() << "Putting 0 for Bosnia" << " : " << QString("%1").arg(selectedYearsInts[i]); + qDebug() << "Putting 0 for the missing data" << " : " << QString("%1").arg(selectedYearsInts[i]); } } series0->addBarSet(barSet); } // add the serie to the chart chartArea->addSeries(series0); - } else if (scatterChartRadioButton->isChecked()) { @@ -183,7 +183,7 @@ void Widget::refreshChart() yearsQuery.append(")"); } - // perform a query for each selected year + // perform a query for each selected country for (int i = 0; i < selectedCountriesStrings.size(); i++) { query.exec("SELECT year,gdpvalue FROM gdp2 where country='" + selectedCountriesStrings[i] + "' AND " + yearsQuery); @@ -203,7 +203,7 @@ void Widget::refreshChart() { // data missing, put 0 *series << QPointF(selectedYearsInts[k] , 0.0f); - qDebug() << "Putting 0 for Bosnia" << " : " << QString("%1").arg(selectedYearsInts[i]) << " " << query.value(0).toInt(); + qDebug() << "Putting 0 for the missing data" << " : " << QString("%1").arg(selectedYearsInts[i]) << " " << query.value(0).toInt(); } } // chartArea->axisX()->setRange(selectedYearsInts[selectedYearsInts.size() - 1] + 1, selectedYearsInts[0] - 1); diff --git a/example/gdpbarchart/widget.h b/example/gdpbarchart/widget.h index 4debddb..6bb1f76 100644 --- a/example/gdpbarchart/widget.h +++ b/example/gdpbarchart/widget.h @@ -28,7 +28,7 @@ private: QListWidget* countrieslist; QListWidget* yearslist; QSqlDatabase db; - QBarChartSeries* series0; +// QBarChartSeries* series0; QRadioButton* barChartRadioButton; QRadioButton* scatterChartRadioButton; };