diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-01-30 12:26:43 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2014-01-30 12:30:19 +0200 |
commit | 4f1af728749338b08b16246cc8f39cf9c1171b3f (patch) | |
tree | 70c5a60de4efc391d681a143049ad5705f402ea4 /examples/bars/graphmodifier.cpp | |
parent | 84d20142bd8926be2e08e4354635f36bc681f186 (diff) |
Range changing added to bars example
Task-number: QTRD-2804
Change-Id: I118c013907e109fe36a80e319a46ffdaf926246d
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'examples/bars/graphmodifier.cpp')
-rw-r--r-- | examples/bars/graphmodifier.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/examples/bars/graphmodifier.cpp b/examples/bars/graphmodifier.cpp index 06b36b7f..55f52580 100644 --- a/examples/bars/graphmodifier.cpp +++ b/examples/bars/graphmodifier.cpp @@ -60,14 +60,14 @@ GraphModifier::GraphModifier(Q3DBars *bargraph) //! [2] m_months << "January" << "February" << "March" << "April" << "May" << "June" << "July" << "August" << "September" << "October" << "November" << "December"; - m_years << "2006" << "2007" << "2008" << "2009" << "2010" << "2011" << "2012"; + m_years << "2006" << "2007" << "2008" << "2009" << "2010" << "2011" << "2012" << "2013"; //! [3] m_temperatureAxis->setTitle("Average temperature"); m_temperatureAxis->setSegmentCount(m_segments); m_temperatureAxis->setSubSegmentCount(m_subSegments); m_temperatureAxis->setRange(m_minval, m_maxval); - m_temperatureAxis->setLabelFormat(QString(QStringLiteral("%d ") + celsiusString)); + m_temperatureAxis->setLabelFormat(QString(QStringLiteral("%.1f ") + celsiusString)); m_yearAxis->setTitle("Year"); m_monthAxis->setTitle("Month"); @@ -112,24 +112,26 @@ void GraphModifier::resetTemperatureData() { //! [5] // Set up data - static const float tempOulu[7][12] = { + static const float tempOulu[8][12] = { {-6.7f, -11.7f, -9.7f, 3.3f, 9.2f, 14.0f, 16.3f, 17.8f, 10.2f, 2.1f, -2.6f, -0.3f}, // 2006 {-6.8f, -13.3f, 0.2f, 1.5f, 7.9f, 13.4f, 16.1f, 15.5f, 8.2f, 5.4f, -2.6f, -0.8f}, // 2007 {-4.2f, -4.0f, -4.6f, 1.9f, 7.3f, 12.5f, 15.0f, 12.8f, 7.6f, 5.1f, -0.9f, -1.3f}, // 2008 {-7.8f, -8.8f, -4.2f, 0.7f, 9.3f, 13.2f, 15.8f, 15.5f, 11.2f, 0.6f, 0.7f, -8.4f}, // 2009 {-14.4f, -12.1f, -7.0f, 2.3f, 11.0f, 12.6f, 18.8f, 13.8f, 9.4f, 3.9f, -5.6f, -13.0f}, // 2010 {-9.0f, -15.2f, -3.8f, 2.6f, 8.3f, 15.9f, 18.6f, 14.9f, 11.1f, 5.3f, 1.8f, -0.2f}, // 2011 - {-8.7f, -11.3f, -2.3f, 0.4f, 7.5f, 12.2f, 16.4f, 14.1f, 9.2f, 3.1f, 0.3f, -12.1f} // 2012 + {-8.7f, -11.3f, -2.3f, 0.4f, 7.5f, 12.2f, 16.4f, 14.1f, 9.2f, 3.1f, 0.3f, -12.1f}, // 2012 + {-7.9f, -5.3f, -9.1f, 0.8f, 11.6f, 16.6f, 15.9f, 15.5f, 11.2f, 4.0f, 0.1f, -1.9f} // 2013 }; - static const float tempHelsinki[7][12] = { + static const float tempHelsinki[8][12] = { {-3.7f, -7.8f, -5.4f, 3.4f, 10.7f, 15.4f, 18.6f, 18.7f, 14.3f, 8.5f, 2.9f, 4.1f}, // 2006 {-1.2f, -7.5f, 3.1f, 5.5f, 10.3f, 15.9f, 17.4f, 17.9f, 11.2f, 7.3f, 1.1f, 0.5f}, // 2007 {-0.6f, 1.2f, 0.2f, 6.3f, 10.2f, 13.8f, 18.1f, 15.1f, 10.1f, 9.4f, 2.5f, 0.4f}, // 2008 {-2.9f, -3.5f, -0.9f, 4.7f, 10.9f, 14.0f, 17.4f, 16.8f, 13.2f, 4.1f, 2.6f, -2.3f}, // 2009 {-10.2f, -8.0f, -1.9f, 6.6f, 11.3f, 14.5f, 21.0f, 18.8f, 12.6f, 6.1f, -0.5f, -7.3f}, // 2010 {-4.4f, -9.1f, -2.0f, 5.5f, 9.9f, 15.6f, 20.8f, 17.8f, 13.4f, 8.9f, 3.6f, 1.5f}, // 2011 - {-3.5f, -3.2f, -0.7f, 4.0f, 11.1f, 13.4f, 17.3f, 15.8f, 13.1f, 6.4f, 4.1f, -5.1f} // 2012 + {-3.5f, -3.2f, -0.7f, 4.0f, 11.1f, 13.4f, 17.3f, 15.8f, 13.1f, 6.4f, 4.1f, -5.1f}, // 2012 + {-4.8f, -1.8f, -5.0f, 2.9f, 12.8f, 17.2f, 18.0f, 17.1f, 12.5f, 7.5f, 4.5f, 2.3f} // 2013 }; // Create data arrays @@ -159,6 +161,14 @@ void GraphModifier::resetTemperatureData() //! [5] } +void GraphModifier::changeRange(int range) +{ + if (range >= m_years.count()) + m_yearAxis->setRange(0, m_years.count() - 1); + else + m_yearAxis->setRange(range, range); +} + void GraphModifier::changeStyle(int style) { QComboBox *comboBox = qobject_cast<QComboBox *>(sender()); |