@@ -50,40 +50,19 void DeclarativeSeries::initSeries() | |||
|
50 | 50 | Q_ASSERT(chart); |
|
51 | 51 | |
|
52 | 52 | switch (m_seriesType) { |
|
53 | case SeriesTypeLine: { | |
|
54 | m_series = new QLineChartSeries(this); | |
|
55 | for (qreal i(0.0); i < 100.0; i += 1.0) | |
|
56 | ((QLineChartSeries *)m_series)->add(i, i); | |
|
57 | chart->addSeries(m_series); | |
|
58 | break; | |
|
59 | } | |
|
60 | case SeriesTypeBar: | |
|
61 | // fallthrough; bar and scatter use the same test data | |
|
62 | case SeriesTypeScatter: { | |
|
63 | m_series = new QScatterSeries(); | |
|
64 | chart->addSeries(m_series); | |
|
65 | QScatterSeries *scatter = qobject_cast<QScatterSeries *>(m_series); | |
|
66 | Q_ASSERT(scatter); | |
|
67 | for (qreal i = 0; i < 100; i += 0.1) | |
|
68 | scatter->addData(QPointF(i + (rand() % 5), | |
|
69 | abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5))); | |
|
70 | break; | |
|
71 | } | |
|
72 | case SeriesTypeStackedBar: | |
|
73 | break; | |
|
74 | case SeriesTypePercentBar: | |
|
75 | break; | |
|
76 | 53 | case SeriesTypePie: { |
|
77 |
|
|
|
78 |
chart->addSeries( |
|
|
54 | QPieSeries *pieSeries = new QPieSeries(); | |
|
55 | chart->addSeries(pieSeries); | |
|
79 | 56 | QList<qreal> data; |
|
80 | 57 | data << 1.0; |
|
81 | 58 | data << 12.0; |
|
82 | 59 | data << 4.0; |
|
83 |
Q_ASSERT( |
|
|
60 | Q_ASSERT(pieSeries->setData(data)); | |
|
61 | m_series = pieSeries; | |
|
84 | 62 | break; |
|
85 | 63 | } |
|
86 | 64 | default: |
|
65 | Q_ASSERT(false); | |
|
87 | 66 | break; |
|
88 | 67 | } |
|
89 | 68 | } |
@@ -16,8 +16,8 class DeclarativeSeries : public QDeclarativeItem | |||
|
16 | 16 | public: |
|
17 | 17 | // TODO: how to re-use the existing enum from QChart? |
|
18 | 18 | enum SeriesType { |
|
19 |
SeriesTypeInvalid = |
|
|
20 | SeriesTypeLine, | |
|
19 | SeriesTypeInvalid = -1, | |
|
20 | SeriesTypeLine = QChartSeries::SeriesTypeLine, | |
|
21 | 21 | // SeriesTypeArea, |
|
22 | 22 | SeriesTypeBar, |
|
23 | 23 | SeriesTypeStackedBar, |
General Comments 0
You need to be logged in to leave comments.
Login now