@@ -7,10 +7,13 | |||
|
7 | 7 | <img src="images/qt_commercial_logo.png" alt="qtcommercial"/> |
|
8 | 8 | |
|
9 | 9 | <p> |
|
10 |
QCharts is a part of Qt Commercial addons package. It provides a set of |
|
|
11 | It uses Qt Graphics View Framework, therefore charts can be easily integrated 2D modern user interfaces. QCharts can be used as QWidgets, QGraphicsWidget or QML elements. | |
|
12 | Users can easily create impressive graphs by selecting one of the charts themes. | |
|
10 | QCharts is a part of Qt Commercial addons package. It provides a set of easy to use chart | |
|
11 | components which are available for Qt Commercial customers. It uses Qt Graphics View | |
|
12 | Framework, therefore charts can be easily integrated to modern 2D user interfaces. QCharts can | |
|
13 | be used as QWidgets, QGraphicsWidget or QML elements. Users can easily create impressive | |
|
14 | graphs by selecting one of the charts themes. | |
|
13 | 15 | </p> |
|
16 | ||
|
14 | 17 | <table><tr> |
|
15 | 18 | <td><img src="images/linechart.png" alt="linechart" /></td> |
|
16 | 19 | <td><img src="images/chartview_example_bar.jpg " alt="barchart" /></td> |
@@ -27,14 +27,9 int main(int argc, char *argv[]) | |||
|
27 | 27 | chartView->addSeries(scatter); |
|
28 | 28 | //! [1] |
|
29 | 29 | |
|
30 | // Add some more data | |
|
31 | //! [2] | |
|
32 | scatter->addData(QPointF(2.0, 5.5)); | |
|
33 | //! [2] | |
|
34 | ||
|
35 | 30 | // And more |
|
36 | 31 | //! [3] |
|
37 | *scatter << QPointF(2.0, 5.5); | |
|
32 | *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4); | |
|
38 | 33 | //! [3] |
|
39 | 34 | |
|
40 | 35 | // Add another scatter series (re-use the previous pointer) |
@@ -46,14 +41,14 int main(int argc, char *argv[]) | |||
|
46 | 41 | } |
|
47 | 42 | //! [4] |
|
48 | 43 | QBrush brush(QColor(255, 0, 0, 100), Qt::SolidPattern); |
|
49 |
scatter->set |
|
|
44 | scatter->setBrush(brush); | |
|
50 | 45 | //! [4] |
|
51 | 46 | //! [5] |
|
52 | 47 | QPen pen(QColor(0, 255, 0, 80), 3); |
|
53 |
scatter->set |
|
|
48 | scatter->setPen(pen); | |
|
54 | 49 | //! [5] |
|
55 | 50 | //! [6] |
|
56 |
scatter->set |
|
|
51 | scatter->setShape(QScatterSeries::MarkerShapeRectangle); | |
|
57 | 52 | //! [6] |
|
58 | 53 | chartView->addSeries(scatter); |
|
59 | 54 |
@@ -59,7 +59,7 void DeclarativeScatterSeries::appendData(QDeclarativeListProperty<ScatterElemen | |||
|
59 | 59 | if (series) { |
|
60 | 60 | series->m_data.append(element); |
|
61 | 61 | if (series->m_series) |
|
62 |
series->m_series->add |
|
|
62 | series->m_series->add(element->x(), element->y()); | |
|
63 | 63 | } |
|
64 | 64 | } |
|
65 | 65 |
@@ -41,16 +41,6 | |||
|
41 | 41 | */ |
|
42 | 42 | |
|
43 | 43 | /*! |
|
44 | \fn void QScatterSeries::hoverEnter() | |
|
45 | \brief TODO | |
|
46 | */ | |
|
47 | ||
|
48 | /*! | |
|
49 | \fn void QScatterSeries::hoverLeave() | |
|
50 | \brief TODO | |
|
51 | */ | |
|
52 | ||
|
53 | /*! | |
|
54 | 44 | \fn void QScatterSeries::changed() |
|
55 | 45 | \brief TODO |
|
56 | 46 | */ |
@@ -86,11 +76,18 QScatterSeries::~QScatterSeries() | |||
|
86 | 76 | } |
|
87 | 77 | |
|
88 | 78 | /*! |
|
79 | Add single data point with \a x and \a y coordinates to the series. | |
|
80 | */ | |
|
81 | void QScatterSeries::add(qreal x, qreal y) | |
|
82 | { | |
|
83 | d->m_data.append(QPointF(x, y)); | |
|
84 | emit changed(); | |
|
85 | } | |
|
86 | ||
|
87 | /*! | |
|
89 | 88 | Add single data point with \a value to the series. |
|
90 | For example: | |
|
91 | \snippet ../example/scatter/main.cpp 2 | |
|
92 | 89 | */ |
|
93 |
void QScatterSeries::add |
|
|
90 | void QScatterSeries::add(QPointF value) | |
|
94 | 91 | { |
|
95 | 92 | d->m_data.append(value); |
|
96 | 93 | emit changed(); |
@@ -99,7 +96,7 void QScatterSeries::addData(QPointF value) | |||
|
99 | 96 | /*! |
|
100 | 97 | Add list of \a points to the series. |
|
101 | 98 | */ |
|
102 |
void QScatterSeries::add |
|
|
99 | void QScatterSeries::add(QList<QPointF> points) | |
|
103 | 100 | { |
|
104 | 101 | d->m_data.append(points); |
|
105 | 102 | emit changed(); |
@@ -107,7 +104,7 void QScatterSeries::addData(QList<QPointF> points) | |||
|
107 | 104 | |
|
108 | 105 | /*! |
|
109 | 106 | Stream operator for adding a data point with \a value to the series. |
|
110 |
\sa add |
|
|
107 | \sa add() | |
|
111 | 108 | |
|
112 | 109 | For example: |
|
113 | 110 | \snippet ../example/scatter/main.cpp 3 |
@@ -121,7 +118,7 QScatterSeries& QScatterSeries::operator << (const QPointF &value) | |||
|
121 | 118 | |
|
122 | 119 | /*! |
|
123 | 120 | Stream operator for adding a list of points to the series. |
|
124 |
\sa add |
|
|
121 | \sa add() | |
|
125 | 122 | */ |
|
126 | 123 | QScatterSeries& QScatterSeries::operator << (QList<QPointF> value) |
|
127 | 124 | { |
@@ -158,10 +155,10 QList<QPointF> QScatterSeries::data() | |||
|
158 | 155 | beatiful markers defined by the chart's theme: |
|
159 | 156 | \image scatter_example_pen.jpg |
|
160 | 157 | |
|
161 |
\sa set |
|
|
158 | \sa setBrush() | |
|
162 | 159 | \sa QChart::setChartTheme() |
|
163 | 160 | */ |
|
164 |
void QScatterSeries::set |
|
|
161 | void QScatterSeries::setPen(QPen pen) | |
|
165 | 162 | { |
|
166 | 163 | d->m_markerPen = pen; |
|
167 | 164 | } |
@@ -169,7 +166,7 void QScatterSeries::setMarkerPen(QPen pen) | |||
|
169 | 166 | /*! |
|
170 | 167 | Returns the pen used for drawing markers. |
|
171 | 168 | */ |
|
172 |
QPen QScatterSeries:: |
|
|
169 | QPen QScatterSeries::pen() | |
|
173 | 170 | { |
|
174 | 171 | return d->m_markerPen; |
|
175 | 172 | } |
@@ -184,10 +181,10 QPen QScatterSeries::markerPen() | |||
|
184 | 181 | Would fill your scatter markers with an opaque red color: |
|
185 | 182 | \image scatter_example_brush.jpg |
|
186 | 183 | |
|
187 |
\sa set |
|
|
184 | \sa setPen() | |
|
188 | 185 | \sa QChart::setChartTheme() |
|
189 | 186 | */ |
|
190 |
void QScatterSeries::set |
|
|
187 | void QScatterSeries::setBrush(QBrush brush) | |
|
191 | 188 | { |
|
192 | 189 | d->m_markerBrush = brush; |
|
193 | 190 | } |
@@ -195,7 +192,7 void QScatterSeries::setMarkerBrush(QBrush brush) | |||
|
195 | 192 | /*! |
|
196 | 193 | Returns the brush used for drawing markers. |
|
197 | 194 | */ |
|
198 |
QBrush QScatterSeries:: |
|
|
195 | QBrush QScatterSeries::brush() | |
|
199 | 196 | { |
|
200 | 197 | return d->m_markerBrush; |
|
201 | 198 | } |
@@ -210,7 +207,7 QBrush QScatterSeries::markerBrush() | |||
|
210 | 207 | Would make your scatter marker items rectangle: |
|
211 | 208 | \image scatter_example_shape.jpg |
|
212 | 209 | */ |
|
213 |
void QScatterSeries::set |
|
|
210 | void QScatterSeries::setShape(MarkerShape shape) | |
|
214 | 211 | { |
|
215 | 212 | d->m_markerShape = shape; |
|
216 | 213 | } |
@@ -218,7 +215,7 void QScatterSeries::setMarkerShape(MarkerShape shape) | |||
|
218 | 215 | /*! |
|
219 | 216 | Returns the shape used for drawing markers. |
|
220 | 217 | */ |
|
221 |
QScatterSeries::MarkerShape QScatterSeries:: |
|
|
218 | QScatterSeries::MarkerShape QScatterSeries::shape() | |
|
222 | 219 | { |
|
223 | 220 | return (QScatterSeries::MarkerShape) d->m_markerShape; |
|
224 | 221 | } |
@@ -33,28 +33,25 public: // from QChartSeries | |||
|
33 | 33 | QChartSeriesType type() const { return QChartSeries::SeriesTypeScatter; } |
|
34 | 34 | |
|
35 | 35 | public: |
|
36 | void addData(QPointF value); | |
|
37 |
void add |
|
|
36 | void add(qreal x, qreal y); | |
|
37 | void add(QPointF value); | |
|
38 | void add(QList<QPointF> points); | |
|
38 | 39 | void setData(QList<QPointF> points); |
|
39 | 40 | QScatterSeries& operator << (const QPointF &value); |
|
40 | 41 | QScatterSeries& operator << (QList<QPointF> points); |
|
41 | 42 | QList<QPointF> data(); |
|
42 |
//TODO: insert |
|
|
43 | //TODO: insert, replace, remove, clear...? | |
|
43 | 44 | |
|
44 |
QPen |
|
|
45 | QBrush markerBrush(); | |
|
46 | MarkerShape markerShape(); | |
|
45 | QPen pen(); | |
|
46 | void setPen(QPen pen); | |
|
47 | QBrush brush(); | |
|
48 | void setBrush(QBrush brush); | |
|
49 | MarkerShape shape(); | |
|
50 | void setShape(MarkerShape shape); | |
|
47 | 51 | // TODO: marker size? |
|
48 | 52 | |
|
49 | public Q_SLOTS: | |
|
50 | void setMarkerPen(QPen pen); | |
|
51 | void setMarkerBrush(QBrush brush); | |
|
52 | void setMarkerShape(MarkerShape shape); | |
|
53 | ||
|
54 | 53 | Q_SIGNALS: |
|
55 | 54 | void clicked(/* TODO: parameters? */); |
|
56 | void hoverEnter(/* TODO: parameters? */); | |
|
57 | void hoverLeave(/* TODO: parameters? */); | |
|
58 | 55 | // TODO: move to PIMPL for simplicity or does the user ever need changed signals? |
|
59 | 56 | // TODO: more finegrained signaling for performance reasons |
|
60 | 57 | // (check QPieSeries implementation with change sets) |
@@ -25,6 +25,7 ScatterPresenter::ScatterPresenter(QScatterSeries *series, QGraphicsObject *pare | |||
|
25 | 25 | |
|
26 | 26 | QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect(); |
|
27 | 27 | dropShadow->setOffset(2.0); |
|
28 | dropShadow->setBlurRadius(2.0); | |
|
28 | 29 | setGraphicsEffect(dropShadow); |
|
29 | 30 | } |
|
30 | 31 | |
@@ -54,10 +55,10 void ScatterPresenter::paint(QPainter *painter, const QStyleOptionGraphicsItem * | |||
|
54 | 55 | // Paint the shape |
|
55 | 56 | // The custom settings in series override those defined by the theme |
|
56 | 57 | QPen pen = m_markerPen; |
|
57 |
if (m_series-> |
|
|
58 |
pen = m_series-> |
|
|
59 |
if (m_series-> |
|
|
60 |
painter->setBrush(m_series-> |
|
|
58 | if (m_series->pen().color().isValid()) | |
|
59 | pen = m_series->pen(); | |
|
60 | if (m_series->brush().color().isValid()) | |
|
61 | painter->setBrush(m_series->brush()); | |
|
61 | 62 | else |
|
62 | 63 | painter->setBrush(m_markerBrush); |
|
63 | 64 | painter->setPen(pen); |
@@ -82,7 +83,7 void ScatterPresenter::changeGeometry() | |||
|
82 | 83 | qreal scalex = m_boundingRect.width() / m_visibleChartArea.spanX(); |
|
83 | 84 | qreal scaley = m_boundingRect.height() / m_visibleChartArea.spanY(); |
|
84 | 85 | |
|
85 |
int shape = m_series-> |
|
|
86 | int shape = m_series->shape(); | |
|
86 | 87 | m_path = QPainterPath(); |
|
87 | 88 | |
|
88 | 89 | foreach (QPointF point, m_series->data()) { |
@@ -104,14 +105,8 void ScatterPresenter::changeGeometry() | |||
|
104 | 105 | m_path.addRect(x, y, 9, 9); |
|
105 | 106 | break; |
|
106 | 107 | case QScatterSeries::MarkerShapeTiltedRectangle: { |
|
107 | // TODO: | |
|
108 | // static const QPointF points[4] = { | |
|
109 | // QPointF(-1.0 + x, 0.0 + y), | |
|
110 | // QPointF(0.0 + x, 1.0 + y), | |
|
111 | // QPointF(1.0 + x, 0.0 + y), | |
|
112 | // QPointF(0.0 + x, -1.0 + y) | |
|
113 | // }; | |
|
114 | //m_path.addPolygon(QPolygon(4, &points)); | |
|
108 | // TODO: tilt the rectangle | |
|
109 | m_path.addRect(x, y, 9, 9); | |
|
115 | 110 | break; |
|
116 | 111 | } |
|
117 | 112 | default: |
General Comments 0
You need to be logged in to leave comments.
Login now