@@ -176,16 +176,15 QComboBox* ThemeWidget::createLegendBox() const | |||||
176 |
|
176 | |||
177 | QChart* ThemeWidget::createAreaChart() const |
|
177 | QChart* ThemeWidget::createAreaChart() const | |
178 | { |
|
178 | { | |
179 | // area chart |
|
|||
180 | QChart *chart = new QChart(); |
|
179 | QChart *chart = new QChart(); | |
181 | chart->axisX()->setNiceNumbers(true); |
|
180 | chart->axisX()->setNiceNumbers(true); | |
182 | chart->axisY()->setNiceNumbers(true); |
|
181 | chart->axisY()->setNiceNumbers(true); | |
183 | chart->setTitle("Area chart"); |
|
182 | chart->setTitle("Area chart"); | |
184 | QString name("Series "); |
|
|||
185 | int nameIndex = 0; |
|
|||
186 |
|
183 | |||
187 | // The lower series initialized to zero values |
|
184 | // The lower series initialized to zero values | |
188 | QLineSeries *lowerSeries = 0; |
|
185 | QLineSeries *lowerSeries = 0; | |
|
186 | QString name("Series "); | |||
|
187 | int nameIndex = 0; | |||
189 | for (int i(0); i < m_dataTable.count(); i++) { |
|
188 | for (int i(0); i < m_dataTable.count(); i++) { | |
190 | QLineSeries *upperSeries = new QLineSeries(chart); |
|
189 | QLineSeries *upperSeries = new QLineSeries(chart); | |
191 | for (int j(0); j < m_dataTable[i].count(); j++) { |
|
190 | for (int j(0); j < m_dataTable[i].count(); j++) { | |
@@ -201,22 +200,21 QChart* ThemeWidget::createAreaChart() const | |||||
201 | chart->addSeries(area); |
|
200 | chart->addSeries(area); | |
202 | lowerSeries = upperSeries; |
|
201 | lowerSeries = upperSeries; | |
203 | } |
|
202 | } | |
|
203 | ||||
204 | return chart; |
|
204 | return chart; | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | QChart* ThemeWidget::createBarChart(int valueCount) const |
|
207 | QChart* ThemeWidget::createBarChart(int valueCount) const | |
208 | { |
|
208 | { | |
209 | // bar chart |
|
|||
210 | QChart* chart = new QChart(); |
|
209 | QChart* chart = new QChart(); | |
211 | chart->axisX()->setNiceNumbers(true); |
|
210 | chart->axisX()->setNiceNumbers(true); | |
212 | chart->axisY()->setNiceNumbers(true); |
|
211 | chart->axisY()->setNiceNumbers(true); | |
213 | chart->setTitle("Bar chart"); |
|
212 | chart->setTitle("Bar chart"); | |
|
213 | ||||
214 | QBarCategories categories; |
|
214 | QBarCategories categories; | |
215 | // TODO: categories |
|
|||
216 | for (int i(0); i < valueCount; i++) |
|
215 | for (int i(0); i < valueCount; i++) | |
217 | categories << QString::number(i); |
|
216 | categories << QString::number(i); | |
218 | // QBarSeries* series = new QBarSeries(categories, chart); |
|
217 | ||
219 | // QPercentBarSeries* series = new QPercentBarSeries(categories, chart); |
|
|||
220 | QStackedBarSeries* series = new QStackedBarSeries(categories, chart); |
|
218 | QStackedBarSeries* series = new QStackedBarSeries(categories, chart); | |
221 | for (int i(0); i < m_dataTable.count(); i++) { |
|
219 | for (int i(0); i < m_dataTable.count(); i++) { | |
222 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); |
|
220 | QBarSet *set = new QBarSet("Bar set " + QString::number(i)); | |
@@ -225,16 +223,17 QChart* ThemeWidget::createBarChart(int valueCount) const | |||||
225 | series->appendBarSet(set); |
|
223 | series->appendBarSet(set); | |
226 | } |
|
224 | } | |
227 | chart->addSeries(series); |
|
225 | chart->addSeries(series); | |
|
226 | ||||
228 | return chart; |
|
227 | return chart; | |
229 | } |
|
228 | } | |
230 |
|
229 | |||
231 | QChart* ThemeWidget::createLineChart() const |
|
230 | QChart* ThemeWidget::createLineChart() const | |
232 | { |
|
231 | { | |
233 | // line chart |
|
|||
234 | QChart* chart = new QChart(); |
|
232 | QChart* chart = new QChart(); | |
235 | chart->axisX()->setNiceNumbers(true); |
|
233 | chart->axisX()->setNiceNumbers(true); | |
236 | chart->axisY()->setNiceNumbers(true); |
|
234 | chart->axisY()->setNiceNumbers(true); | |
237 | chart->setTitle("Line chart"); |
|
235 | chart->setTitle("Line chart"); | |
|
236 | ||||
238 | QString name("Series "); |
|
237 | QString name("Series "); | |
239 | int nameIndex = 0; |
|
238 | int nameIndex = 0; | |
240 | foreach (DataList list, m_dataTable) { |
|
239 | foreach (DataList list, m_dataTable) { | |
@@ -245,14 +244,15 QChart* ThemeWidget::createLineChart() const | |||||
245 | nameIndex++; |
|
244 | nameIndex++; | |
246 | chart->addSeries(series); |
|
245 | chart->addSeries(series); | |
247 | } |
|
246 | } | |
|
247 | ||||
248 | return chart; |
|
248 | return chart; | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | QChart* ThemeWidget::createPieChart() const |
|
251 | QChart* ThemeWidget::createPieChart() const | |
252 | { |
|
252 | { | |
253 | // pie chart |
|
|||
254 | QChart* chart = new QChart(); |
|
253 | QChart* chart = new QChart(); | |
255 | chart->setTitle("Pie chart"); |
|
254 | chart->setTitle("Pie chart"); | |
|
255 | ||||
256 | qreal pieSize = 1.0 / m_dataTable.count(); |
|
256 | qreal pieSize = 1.0 / m_dataTable.count(); | |
257 | for (int i = 0; i < m_dataTable.count(); i++) { |
|
257 | for (int i = 0; i < m_dataTable.count(); i++) { | |
258 | QPieSeries *series = new QPieSeries(chart); |
|
258 | QPieSeries *series = new QPieSeries(chart); | |
@@ -364,11 +364,11 void ThemeWidget::updateUI() | |||||
364 | foreach (QChartView *chartView, m_charts) { |
|
364 | foreach (QChartView *chartView, m_charts) { | |
365 | chartView->chart()->legend()->hide(); |
|
365 | chartView->chart()->legend()->hide(); | |
366 | } |
|
366 | } | |
367 | } |
|
367 | } else { | |
368 | else |
|
|||
369 | foreach (QChartView *chartView, m_charts) { |
|
368 | foreach (QChartView *chartView, m_charts) { | |
370 | chartView->chart()->legend()->setAlignment(alignment); |
|
369 | chartView->chart()->legend()->setAlignment(alignment); | |
371 | chartView->chart()->legend()->show(); |
|
370 | chartView->chart()->legend()->show(); | |
372 | } |
|
371 | } | |
|
372 | } | |||
373 | } |
|
373 | } | |
374 |
|
374 |
@@ -187,37 +187,6 void QChartView::mouseReleaseEvent(QMouseEvent *event) | |||||
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | /*! |
|
189 | /*! | |
190 | Pressing + and - keys performs zoomIn() and zoomOut() respectivly. |
|
|||
191 | In other \a event is passed to the QGraphicsView::keyPressEvent() implementation |
|
|||
192 | */ |
|
|||
193 | void QChartView::keyPressEvent(QKeyEvent *event) |
|
|||
194 | { |
|
|||
195 | switch (event->key()) { |
|
|||
196 | case Qt::Key_Plus: |
|
|||
197 | d_ptr->m_chart->zoomIn(); |
|
|||
198 | break; |
|
|||
199 | case Qt::Key_Minus: |
|
|||
200 | d_ptr->m_chart->zoomOut(); |
|
|||
201 | break; |
|
|||
202 | case Qt::Key_Left: |
|
|||
203 | d_ptr->m_chart->scrollLeft(); |
|
|||
204 | break; |
|
|||
205 | case Qt::Key_Right: |
|
|||
206 | d_ptr->m_chart->scrollRight(); |
|
|||
207 | break; |
|
|||
208 | case Qt::Key_Up: |
|
|||
209 | d_ptr->m_chart->scrollUp(); |
|
|||
210 | break; |
|
|||
211 | case Qt::Key_Down: |
|
|||
212 | d_ptr->m_chart->scrollDown(); |
|
|||
213 | break; |
|
|||
214 | default: |
|
|||
215 | QGraphicsView::keyPressEvent(event); |
|
|||
216 | break; |
|
|||
217 | } |
|
|||
218 | } |
|
|||
219 |
|
||||
220 | /*! |
|
|||
221 | Resizes and updates the chart area using the \a event data |
|
190 | Resizes and updates the chart area using the \a event data | |
222 | */ |
|
191 | */ | |
223 | void QChartView::resizeEvent(QResizeEvent *event) |
|
192 | void QChartView::resizeEvent(QResizeEvent *event) |
@@ -60,7 +60,6 protected: | |||||
60 | void mousePressEvent(QMouseEvent *event); |
|
60 | void mousePressEvent(QMouseEvent *event); | |
61 | void mouseMoveEvent(QMouseEvent *event); |
|
61 | void mouseMoveEvent(QMouseEvent *event); | |
62 | void mouseReleaseEvent(QMouseEvent *event); |
|
62 | void mouseReleaseEvent(QMouseEvent *event); | |
63 | void keyPressEvent(QKeyEvent *event); |
|
|||
64 |
|
63 | |||
65 | protected: |
|
64 | protected: | |
66 | QScopedPointer<QChartViewPrivate> d_ptr; |
|
65 | QScopedPointer<QChartViewPrivate> d_ptr; |
General Comments 0
You need to be logged in to leave comments.
Login now