@@ -29,6 +29,7 | |||
|
29 | 29 | <li><a href="qseries.html">QSeries</a></li> |
|
30 | 30 | <li><a href="qsplineseries.html">QSplineSeries</a></li> |
|
31 | 31 | <li><a href="qstackedbarseries.html">QStackedBarSeries</a></li> |
|
32 | <li><a href="qxyseries.html">QXYSeries</a></li> | |
|
32 | 33 | </ul> |
|
33 | 34 | </td> |
|
34 | 35 | </tr> |
@@ -112,7 +112,7 void QChart::setChartBackgroundPen(const QPen& pen) | |||
|
112 | 112 | } |
|
113 | 113 | |
|
114 | 114 | /*! |
|
115 |
Sets the chart \a title. The description text that is |
|
|
115 | Sets the chart \a title. The description text that is drawn above the chart. | |
|
116 | 116 | */ |
|
117 | 117 | void QChart::setChartTitle(const QString& title) |
|
118 | 118 | { |
@@ -121,7 +121,7 void QChart::setChartTitle(const QString& title) | |||
|
121 | 121 | } |
|
122 | 122 | |
|
123 | 123 | /*! |
|
124 |
|
|
|
124 | Returns the chart title. The description text that is drawn above the chart. | |
|
125 | 125 | */ |
|
126 | 126 | QString QChart::chartTitle() const |
|
127 | 127 | { |
@@ -134,7 +134,7 int QChartView::margin() const | |||
|
134 | 134 | } |
|
135 | 135 | |
|
136 | 136 | /*! |
|
137 |
Sets the chart \a title. A description text that is |
|
|
137 | Sets the chart \a title. A description text that is drawn above the chart. | |
|
138 | 138 | */ |
|
139 | 139 | void QChartView::setChartTitle(const QString& title) |
|
140 | 140 | { |
@@ -142,7 +142,7 void QChartView::setChartTitle(const QString& title) | |||
|
142 | 142 | } |
|
143 | 143 | |
|
144 | 144 | /*! |
|
145 |
Returns the chart's title. A description text that is |
|
|
145 | Returns the chart's title. A description text that is drawn above the chart. | |
|
146 | 146 | */ |
|
147 | 147 | QString QChartView::chartTitle() const |
|
148 | 148 | { |
@@ -3,25 +3,23 | |||
|
3 | 3 | |
|
4 | 4 | /*! |
|
5 | 5 | \class QScatterSeries |
|
6 | \brief QtCommercial Chart series API for showing scatter series. | |
|
6 | \brief The QScatterSeries class is used for making scatter charts. | |
|
7 | 7 | |
|
8 | 8 | \mainclass |
|
9 | 9 | |
|
10 | Example on how to create a chart with scatter series: | |
|
11 | \snippet ../example/scatter/main.cpp 1 | |
|
10 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis | |
|
11 | and the vertical axis. | |
|
12 | 12 | |
|
13 | The example code would result the following: | |
|
13 | \image scatterchart.png | |
|
14 | 14 | |
|
15 | \image scatter_example1.jpg | |
|
16 | ||
|
17 | To customize the graphical representation of the series, you can modify pen, brush, shape and | |
|
18 | size of the marker items. For example: | |
|
19 | ||
|
20 | \snippet ../example/scatter/main.cpp 3 | |
|
21 | ||
|
22 | Would present your scatter markers as big rectangles with opaque, uglyish green outlines and | |
|
23 | opaque red filling instead of the beatiful markers defined by the chart's theme: | |
|
24 | \image scatter_example_custom.jpg | |
|
15 | Creating basic scatter chart is simple: | |
|
16 | \code | |
|
17 | QScatterSeries* series = new QScatterSeries(); | |
|
18 | series->add(0, 6); | |
|
19 | series->add(2, 4); | |
|
20 | ... | |
|
21 | chartView->addSeries(series); | |
|
22 | \endcode | |
|
25 | 23 | */ |
|
26 | 24 | |
|
27 | 25 | /*! |
@@ -41,13 +39,12 | |||
|
41 | 39 | /*! |
|
42 | 40 | \fn QChartSeriesType QScatterSeries::type() const |
|
43 | 41 | \brief Returns QChartSeries::SeriesTypeScatter. |
|
42 | \sa QSeries, QSeriesType | |
|
44 | 43 | */ |
|
45 | 44 | |
|
46 | 45 | /*! |
|
47 |
\fn void QScatterSeries::clicked(QPointF |
|
|
48 | User clicked the scatter series. Note that the \a coordinate is the chart coordinate that the | |
|
49 | click occurred on; not necessarily a data point coordinate. To find the corresponding (closest) | |
|
50 | data point you can use closestPoint(). | |
|
46 | \fn void QScatterSeries::clicked(const QPointF& point) | |
|
47 | \brief Signal is emitted when user clicks the \a point on scatter chart. | |
|
51 | 48 | */ |
|
52 | 49 | |
|
53 | 50 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
@@ -69,101 +66,6 QScatterSeries::~QScatterSeries() | |||
|
69 | 66 | { |
|
70 | 67 | } |
|
71 | 68 | |
|
72 | ||
|
73 | ||
|
74 | /*! | |
|
75 | Stream operator for adding a data point with \a value to the series. | |
|
76 | \sa add() | |
|
77 | ||
|
78 | For example: | |
|
79 | \snippet ../example/scatter/main.cpp 2 | |
|
80 | */ | |
|
81 | ||
|
82 | ||
|
83 | /*! | |
|
84 | Stream operator for adding a list of points to the series. | |
|
85 | \sa add() | |
|
86 | */ | |
|
87 | ||
|
88 | ||
|
89 | /*! | |
|
90 | Replaces the data of the series with the given list of data \a points. | |
|
91 | */ | |
|
92 | ||
|
93 | ||
|
94 | /*! | |
|
95 | Returns the current list of data points of the series. | |
|
96 | */ | |
|
97 | ||
|
98 | /*! | |
|
99 | Replaces the point at \a index with \a newPoint. Returns true if \a index is a valid position | |
|
100 | in the series data, false otherwise. | |
|
101 | */ | |
|
102 | ||
|
103 | ||
|
104 | /*! | |
|
105 | Remove the data point at \a index. Returns true if a point was removed, false if the point | |
|
106 | at \a index does not exist on the series. | |
|
107 | */ | |
|
108 | ||
|
109 | ||
|
110 | /*! | |
|
111 | Remove all occurrences of \a point from the series and returns the number of points removed. | |
|
112 | */ | |
|
113 | ||
|
114 | ||
|
115 | /*! | |
|
116 | Remove all data points from the series. | |
|
117 | */ | |
|
118 | ||
|
119 | /*! | |
|
120 | Returns the index of the data point that is closest to \a coordinate. If several data points | |
|
121 | are at the same distance from the \a coordinate, returns the last one. If no points exist, | |
|
122 | returns -1. | |
|
123 | ||
|
124 | int QScatterSeries::closestPoint(QPointF coordinate) | |
|
125 | { | |
|
126 | qreal distance(-1); | |
|
127 | int pointIndex(-1); | |
|
128 | for (int i(0); i < d->m_data.count(); i++) { | |
|
129 | QPointF dataPoint = d->m_data.at(i); | |
|
130 | QPointF difference = dataPoint - coordinate; | |
|
131 | if (i == 0 || difference.manhattanLength() <= distance) { | |
|
132 | distance = difference.manhattanLength(); | |
|
133 | pointIndex = i; | |
|
134 | } | |
|
135 | } | |
|
136 | return pointIndex; | |
|
137 | } | |
|
138 | */ | |
|
139 | ||
|
140 | /*! | |
|
141 | Returns the pen used for drawing markers. | |
|
142 | */ | |
|
143 | ||
|
144 | ||
|
145 | /*! | |
|
146 | Overrides the default pen used for drawing a marker item with a user defined \a pen. The | |
|
147 | default pen is defined by chart theme setting. | |
|
148 | ||
|
149 | \sa setBrush() | |
|
150 | \sa QChart::setChartTheme() | |
|
151 | */ | |
|
152 | ||
|
153 | ||
|
154 | /*! | |
|
155 | Returns the brush used for drawing markers. | |
|
156 | */ | |
|
157 | ||
|
158 | ||
|
159 | /*! | |
|
160 | Overrides the default brush of the marker items with a user defined \a brush. The default brush | |
|
161 | is defined by chart theme setting. | |
|
162 | ||
|
163 | \sa setPen() | |
|
164 | \sa QChart::setChartTheme() | |
|
165 | */ | |
|
166 | ||
|
167 | 69 | /*! |
|
168 | 70 | Returns the shape used for drawing markers. |
|
169 | 71 | */ |
@@ -34,15 +34,13 public: // from QChartSeries | |||
|
34 | 34 | QSeriesType type() const { return QSeries::SeriesTypeScatter; } |
|
35 | 35 | |
|
36 | 36 | public: |
|
37 | //int closestPoint(QPointF coordinate); | |
|
38 | ||
|
39 | 37 | MarkerShape shape() const; |
|
40 | 38 | void setShape(MarkerShape shape); |
|
41 | 39 | qreal size() const; |
|
42 | 40 | void setSize(qreal size); |
|
43 | 41 | |
|
44 | 42 | signals: |
|
45 |
void clicked(QPointF |
|
|
43 | void clicked(const QPointF& point); | |
|
46 | 44 | |
|
47 | 45 | private: |
|
48 | 46 | MarkerShape m_shape; |
@@ -8,12 +8,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
8 | 8 | */ |
|
9 | 9 | |
|
10 | 10 | /*! |
|
11 | \fn virtual QSeriesType QXYSeries::type() const | |
|
12 | \brief Returns type of series. | |
|
13 | \sa QSeries, QSeriesType | |
|
14 | */ | |
|
15 | ||
|
16 | /*! | |
|
17 | 11 | \fn QPen QXYSeries::pen() const |
|
18 | 12 | \brief Returns pen used to draw points for series. |
|
19 | 13 | \sa setPen() |
@@ -81,6 +75,17 void QXYSeries::add(const QPointF& point) | |||
|
81 | 75 | } |
|
82 | 76 | |
|
83 | 77 | /*! |
|
78 | This is an overloaded function. | |
|
79 | Adds list of data \a points to the series. Points are connected with lines on the chart. | |
|
80 | */ | |
|
81 | void QXYSeries::add(const QList<QPointF> points) | |
|
82 | { | |
|
83 | foreach(const QPointF& point , points) { | |
|
84 | add(point.x(),point.y()); | |
|
85 | } | |
|
86 | } | |
|
87 | ||
|
88 | /*! | |
|
84 | 89 | Modifies \a y value for given \a x a value. |
|
85 | 90 | */ |
|
86 | 91 | void QXYSeries::replace(qreal x,qreal y) |
@@ -120,9 +125,9 void QXYSeries::remove(const QPointF& point) | |||
|
120 | 125 | } |
|
121 | 126 | |
|
122 | 127 | /*! |
|
123 | Clears all the data. | |
|
128 | Removes all data points from the series. | |
|
124 | 129 | */ |
|
125 |
void QXYSeries:: |
|
|
130 | void QXYSeries::removeAll() | |
|
126 | 131 | { |
|
127 | 132 | m_x.clear(); |
|
128 | 133 | m_y.clear(); |
@@ -156,7 +161,9 int QXYSeries::count() const | |||
|
156 | 161 | } |
|
157 | 162 | |
|
158 | 163 | /*! |
|
159 | Sets \a pen used for drawing points on the chart. | |
|
164 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
|
165 | pen from chart theme is used. | |
|
166 | \sa QChart::setChartTheme() | |
|
160 | 167 | */ |
|
161 | 168 | void QXYSeries::setPen(const QPen& pen) |
|
162 | 169 | { |
@@ -167,7 +174,9 void QXYSeries::setPen(const QPen& pen) | |||
|
167 | 174 | } |
|
168 | 175 | |
|
169 | 176 | /*! |
|
170 | Sets \a brush used for drawing points on the chart. | |
|
177 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
|
178 | from chart theme setting is used. | |
|
179 | \sa QChart::setChartTheme() | |
|
171 | 180 | */ |
|
172 | 181 | |
|
173 | 182 | void QXYSeries::setBrush(const QBrush& brush) |
@@ -191,6 +200,18 QXYSeries& QXYSeries::operator<< (const QPointF &point) | |||
|
191 | 200 | } |
|
192 | 201 | |
|
193 | 202 | |
|
203 | /*! | |
|
204 | Stream operator for adding a list of \a points to the series. | |
|
205 | \sa add() | |
|
206 | */ | |
|
207 | ||
|
208 | QXYSeries& QXYSeries::operator<< (const QList<QPointF> points) | |
|
209 | { | |
|
210 | add(points); | |
|
211 | return *this; | |
|
212 | } | |
|
213 | ||
|
214 | ||
|
194 | 215 | #include "moc_qxyseries.cpp" |
|
195 | 216 | |
|
196 | 217 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -19,24 +19,19 protected: | |||
|
19 | 19 | public: |
|
20 | 20 | void add(qreal x, qreal y); |
|
21 | 21 | void add(const QPointF& point); |
|
22 | void add(const QList<QPointF> points); | |
|
22 | 23 | void replace(qreal x,qreal y); |
|
23 | 24 | void replace(const QPointF& point); |
|
24 | 25 | void remove(qreal x); |
|
25 | 26 | void remove(const QPointF& point); |
|
26 |
void |
|
|
27 | void removeAll(); | |
|
27 | 28 | |
|
28 | 29 | int count() const; |
|
29 | 30 | qreal x(int pos) const; |
|
30 | 31 | qreal y(int pos) const; |
|
31 | 32 | |
|
32 | 33 | QXYSeries& operator << (const QPointF &point); |
|
33 | /* | |
|
34 | void add(QList<QPointF> points); | |
|
35 | void setData(QList<QPointF> points); | |
|
36 | QScatterSeries& operator << (const QPointF &value); | |
|
37 | QScatterSeries& operator << (QList<QPointF> points); | |
|
38 | int removeAll(QPointF point); | |
|
39 | */ | |
|
34 | QXYSeries& operator << (const QList<QPointF> points); | |
|
40 | 35 | |
|
41 | 36 | void setPen(const QPen& pen); |
|
42 | 37 | QPen pen() const {return m_pen;} |
General Comments 0
You need to be logged in to leave comments.
Login now