##// END OF EJS Templates
Documenting QChartSeries continues
Tero Ahola -
r310:a8ed8052414f
parent child
Show More
@@ -50,40 +50,19 void DeclarativeSeries::initSeries()
50 Q_ASSERT(chart);
50 Q_ASSERT(chart);
51
51
52 switch (m_seriesType) {
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 case SeriesTypePie: {
53 case SeriesTypePie: {
77 m_series = new QPieSeries();
54 QPieSeries *pieSeries = new QPieSeries();
78 chart->addSeries(m_series);
55 chart->addSeries(pieSeries);
79 QList<qreal> data;
56 QList<qreal> data;
80 data << 1.0;
57 data << 1.0;
81 data << 12.0;
58 data << 12.0;
82 data << 4.0;
59 data << 4.0;
83 Q_ASSERT(m_series->setData(data));
60 Q_ASSERT(pieSeries->setData(data));
61 m_series = pieSeries;
84 break;
62 break;
85 }
63 }
86 default:
64 default:
65 Q_ASSERT(false);
87 break;
66 break;
88 }
67 }
89 }
68 }
@@ -16,8 +16,8 class DeclarativeSeries : public QDeclarativeItem
16 public:
16 public:
17 // TODO: how to re-use the existing enum from QChart?
17 // TODO: how to re-use the existing enum from QChart?
18 enum SeriesType {
18 enum SeriesType {
19 SeriesTypeInvalid = QChartSeries::SeriesTypeInvalid,
19 SeriesTypeInvalid = -1,
20 SeriesTypeLine,
20 SeriesTypeLine = QChartSeries::SeriesTypeLine,
21 // SeriesTypeArea,
21 // SeriesTypeArea,
22 SeriesTypeBar,
22 SeriesTypeBar,
23 SeriesTypeStackedBar,
23 SeriesTypeStackedBar,
@@ -4,6 +4,9
4 \class QChartSeries
4 \class QChartSeries
5 \brief Base class for all QtCommercial Chart series.
5 \brief Base class for all QtCommercial Chart series.
6 \mainclass
6 \mainclass
7
8 Usually you use the series type specific inherited classes instead of the base class.
9 \sa QScatterSeries
7 */
10 */
8
11
9 /*!
12 /*!
General Comments 0
You need to be logged in to leave comments. Login now