@@ -0,0 +1,38 | |||
|
1 | /*! | |
|
2 | \example examples/boxplotchart | |
|
3 | \title Box and Whiskers Example | |
|
4 | \subtitle | |
|
5 | ||
|
6 | The example shows how to create a box-and-whiskers chart. | |
|
7 | ||
|
8 | \image examples_barchart.png | |
|
9 | ||
|
10 | Introduction here | |
|
11 | ||
|
12 | \snippet ../examples/barchart/main.cpp 1 | |
|
13 | ||
|
14 | Ykk�skohta | |
|
15 | ||
|
16 | \snippet ../examples/barchart/main.cpp 2 | |
|
17 | ||
|
18 | Kakkoskohta | |
|
19 | ||
|
20 | \snippet ../examples/barchart/main.cpp 3 | |
|
21 | ||
|
22 | Kolmoskohta | |
|
23 | ||
|
24 | \snippet ../examples/barchart/main.cpp 4 | |
|
25 | ||
|
26 | Neloskohta | |
|
27 | ||
|
28 | \snippet ../examples/barchart/main.cpp 5 | |
|
29 | ||
|
30 | Tarkista numerointi. Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. | |
|
31 | ||
|
32 | \snippet ../examples/barchart/main.cpp 6 | |
|
33 | ||
|
34 | Tarkista numerointi. Chart is ready to be shown. We set the chart to be central widget of the window. | |
|
35 | We also set the size for the chart window and show it. | |
|
36 | ||
|
37 | \snippet ../examples/barchart/main.cpp 7 | |
|
38 | */ |
@@ -58,7 +58,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
58 | 58 | |
|
59 | 59 | /*! |
|
60 | 60 | \property QVBarModelMapper::series |
|
61 |
\brief Defines the Q |
|
|
61 | \brief Defines the QBarSeries object that is used by the mapper. | |
|
62 | 62 | |
|
63 | 63 | All the data in the series is discarded when it is set to the mapper. |
|
64 | 64 | When new series is specified the old series is disconnected (it preserves its data) |
@@ -82,22 +82,26 void BoxPlotChartItem::handleDataStructureChanged() | |||
|
82 | 82 | for (int s = 0; s < setCount; s++) { |
|
83 | 83 | QBoxSet *set = m_series->d_func()->boxsetAt(s); |
|
84 | 84 | |
|
85 |
BoxWhiskers *box |
|
|
86 |
if (box |
|
|
85 | BoxWhiskers *box = m_boxTable.value(set); | |
|
86 | if (!box) { | |
|
87 | 87 | // Item is not yet created, make a box and add it to hash table |
|
88 |
box |
|
|
89 |
m_boxTable.insert(set, box |
|
|
88 | box = new BoxWhiskers(set, domain(), this); | |
|
89 | m_boxTable.insert(set, box); | |
|
90 | connect(box, SIGNAL(clicked(QBoxSet *)), m_series, SIGNAL(clicked(QBoxSet*))); | |
|
91 | connect(box, SIGNAL(hovered(bool,QBoxSet*)), m_series, SIGNAL(hovered(bool,QBoxSet*))); | |
|
92 | connect(box, SIGNAL(clicked(QBoxSet*)), set, SIGNAL(clicked())); | |
|
93 | connect(box, SIGNAL(hovered(bool,QBoxSet*)), set, SIGNAL(hovered(bool))); | |
|
90 | 94 | |
|
91 | 95 | // Set the decorative issues for the newly created box |
|
92 |
box |
|
|
93 |
box |
|
|
96 | box->setBrush(m_series->brush()); | |
|
97 | box->setPen(m_series->pen()); | |
|
94 | 98 | } |
|
95 |
updateBoxGeometry(box |
|
|
99 | updateBoxGeometry(box, s); | |
|
96 | 100 | |
|
97 |
box |
|
|
101 | box->updateGeometry(); | |
|
98 | 102 | |
|
99 | 103 | if (m_animation) |
|
100 |
m_animation->addBox(box |
|
|
104 | m_animation->addBox(box); | |
|
101 | 105 | } |
|
102 | 106 | |
|
103 | 107 | // |
@@ -20,42 +20,41 | |||
|
20 | 20 | |
|
21 | 21 | #include "boxwhiskers_p.h" |
|
22 | 22 | #include <QPainter> |
|
23 | #include <QDebug> | |
|
24 | 23 | #include <QWidget> |
|
25 | 24 | |
|
25 | #include <QDebug> | |
|
26 | ||
|
26 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | 28 | |
|
28 | BoxWhiskers::BoxWhiskers(AbstractDomain *domain, QGraphicsObject *parent) : | |
|
29 | BoxWhiskers::BoxWhiskers(QBoxSet *set, AbstractDomain *domain, QGraphicsObject *parent) : | |
|
29 | 30 | QGraphicsObject(parent), |
|
31 | m_boxSet(set), | |
|
30 | 32 | m_domain(domain) |
|
31 | 33 | { |
|
32 | //qDebug() << "BoxWhiskers::BoxWhiskers()"; | |
|
34 | setAcceptHoverEvents(true); | |
|
35 | setAcceptedMouseButtons(Qt::MouseButtonMask); | |
|
33 | 36 | } |
|
34 | 37 | |
|
35 | 38 | BoxWhiskers::~BoxWhiskers() |
|
36 | 39 | { |
|
37 | //qDebug() << "BoxWhiskers::~BoxWhiskers()"; | |
|
38 | 40 | } |
|
39 | 41 | |
|
40 | 42 | void BoxWhiskers::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
41 | 43 | { |
|
42 | 44 | Q_UNUSED(event) |
|
43 | ||
|
44 | qDebug() << "BoxWhiskers::mousePressEvent"; | |
|
45 | emit clicked(m_boxSet); | |
|
45 | 46 | } |
|
46 | 47 | |
|
47 | 48 | void BoxWhiskers::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
48 | 49 | { |
|
49 | 50 | Q_UNUSED(event) |
|
50 | ||
|
51 | qDebug() << "BoxWhiskers::hoverEnterEvent"; | |
|
51 | emit hovered(true, m_boxSet); | |
|
52 | 52 | } |
|
53 | 53 | |
|
54 | 54 | void BoxWhiskers::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
55 | 55 | { |
|
56 | 56 | Q_UNUSED(event) |
|
57 | ||
|
58 | qDebug() << "BoxWhiskers::hoverLeaveEvent"; | |
|
57 | emit hovered(false, m_boxSet); | |
|
59 | 58 | } |
|
60 | 59 | |
|
61 | 60 | void BoxWhiskers::setBrush(const QBrush &brush) |
@@ -32,8 +32,8 | |||
|
32 | 32 | |
|
33 | 33 | #include "boxwhiskersdata_p.h" |
|
34 | 34 | #include "qchartglobal.h" |
|
35 | #include "qbarset.h" | |
|
36 | 35 | #include "abstractdomain_p.h" |
|
36 | #include <QBoxSet> | |
|
37 | 37 | #include <QGraphicsRectItem> |
|
38 | 38 | #include <QGraphicsLineItem> |
|
39 | 39 | #include <QGraphicsLayoutItem> |
@@ -48,7 +48,7 class BoxWhiskers : public QGraphicsObject/*, public QGraphicsLayoutItem*/ | |||
|
48 | 48 | Q_OBJECT |
|
49 | 49 | //Q_INTERFACES(QGraphicsLayoutItem) |
|
50 | 50 | public: |
|
51 | BoxWhiskers(AbstractDomain *domain, QGraphicsObject *parent); | |
|
51 | BoxWhiskers(QBoxSet *set, AbstractDomain *domain, QGraphicsObject *parent); | |
|
52 | 52 | ~BoxWhiskers(); |
|
53 | 53 | |
|
54 | 54 | void setBrush(const QBrush &brush); |
@@ -73,13 +73,14 private: | |||
|
73 | 73 | void updateBoundingRect(); |
|
74 | 74 | |
|
75 | 75 | Q_SIGNALS: |
|
76 |
void clicked( |
|
|
77 |
void hovered(bool status, QB |
|
|
76 | void clicked(QBoxSet *boxset); | |
|
77 | void hovered(bool status, QBoxSet *boxset); | |
|
78 | 78 | |
|
79 | 79 | private: |
|
80 | 80 | friend class BoxPlotChartItem; |
|
81 | 81 | friend class BoxPlotAnimation; |
|
82 | 82 | |
|
83 | QBoxSet *m_boxSet; | |
|
83 | 84 | AbstractDomain *m_domain; |
|
84 | 85 | QPainterPath m_boxPath; |
|
85 | 86 | QRectF m_boundingRect; |
@@ -38,25 +38,25 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
38 | 38 | |
|
39 | 39 | /*! |
|
40 | 40 | \class QBoxPlotSeries |
|
41 |
\brief Series for creating s |
|
|
41 | \brief Series for creating box-and-whiskers chart | |
|
42 | 42 | \mainclass |
|
43 | 43 | |
|
44 |
QBoxPlotSeries represents a series of data shown as bars. The purpose of this class is to |
|
|
45 | as stacks, where bars in same category are stacked on top of each other. | |
|
46 | QBoxPlotSeries groups the data from sets to categories, which are defined by QStringList. | |
|
44 | QBoxPlotSeries represents a series of data shown as box-and-whisker bars. The purpose of this class is to act as | |
|
45 | a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple QBoxPlotSeries | |
|
46 | items with the same index are drawn to same slot. | |
|
47 | 47 | |
|
48 |
See the \l {Box |
|
|
48 | See the \l {Box and Whiskers Example} {box-and-whiskers chart example} to learn how to create a box-and-whiskers chart. | |
|
49 | 49 | \image examples_boxplotchart.png |
|
50 | 50 | |
|
51 | \sa QBoxSet, QPercentBarSeries, QAbstractBarSeries | |
|
51 | \sa QBoxSet | |
|
52 | 52 | */ |
|
53 | 53 | |
|
54 | 54 | /*! |
|
55 | 55 | \qmlclass BoxPlotSeries QBoxPlotSeries |
|
56 | 56 | \inherits AbstractBarSeries |
|
57 | 57 | |
|
58 |
The following QML shows how to create a simple s |
|
|
59 |
\snippet ../ |
|
|
58 | The following QML shows how to create a simple box-and-whiskers chart: | |
|
59 | \snippet ../examples/qmlboxplot/qml/qmlboxplot/main.qml 1 | |
|
60 | 60 | \beginfloatleft |
|
61 | 61 | \image demos_qmlchart7.png |
|
62 | 62 | \endfloat |
@@ -64,6 +64,31 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
64 | 64 | */ |
|
65 | 65 | |
|
66 | 66 | /*! |
|
67 | \fn QBoxPlotSeries::boxsetsAdded(QList<QBoxSet *> sets) | |
|
68 | \brief Signal is emitted when a new \a sets of box-and-whiskers data is added to the series. | |
|
69 | */ | |
|
70 | ||
|
71 | /*! | |
|
72 | \fn QBoxPlotSeries::boxsetsRemoved(QList<QBoxSet *> sets) | |
|
73 | \brief Signal is emitted when \a sets of box-and-whiskers data is removed from the series. | |
|
74 | */ | |
|
75 | ||
|
76 | /*! | |
|
77 | \fn QBoxPlotSeries::clicked(QBoxSet *boxset) | |
|
78 | \brief Signal is emitted when the user clicks the \a boxset on the chart. | |
|
79 | */ | |
|
80 | ||
|
81 | /*! | |
|
82 | \fn QBoxPlotSeries::hovered(bool status, QBoxSet *boxset) | |
|
83 | \brief Signal is emitted when there is change in hover \a status over \a boxset. | |
|
84 | */ | |
|
85 | ||
|
86 | /*! | |
|
87 | \fn QBoxPlotSeries::countChanged() | |
|
88 | \brief Signal is emitted when there is change in count of box-and-whiskers items in the series. | |
|
89 | */ | |
|
90 | ||
|
91 | /*! | |
|
67 | 92 | Constructs empty QBoxPlotSeries. |
|
68 | 93 | QBoxPlotSeries is QObject which is a child of a \a parent. |
|
69 | 94 | */ |
@@ -85,7 +110,7 QBoxPlotSeries::~QBoxPlotSeries() | |||
|
85 | 110 | } |
|
86 | 111 | |
|
87 | 112 | /*! |
|
88 |
Adds a single box and whiskers |
|
|
113 | Adds a single box and whiskers set to series. Takes ownership of the \a set. If the set is null or is already in series, it won't be appended. | |
|
89 | 114 | Returns true, if appending succeeded. |
|
90 | 115 | */ |
|
91 | 116 | bool QBoxPlotSeries::append(QBoxSet *set) |
@@ -223,6 +248,9 QAbstractSeries::SeriesType QBoxPlotSeries::type() const | |||
|
223 | 248 | return QAbstractSeries::SeriesTypeBoxPlot; |
|
224 | 249 | } |
|
225 | 250 | |
|
251 | /*! | |
|
252 | Sets brush for the series. Box-and-whiskers items are drawn using \a brush | |
|
253 | */ | |
|
226 | 254 | void QBoxPlotSeries::setBrush(const QBrush &brush) |
|
227 | 255 | { |
|
228 | 256 | Q_D(QBoxPlotSeries); |
@@ -233,6 +261,9 void QBoxPlotSeries::setBrush(const QBrush &brush) | |||
|
233 | 261 | } |
|
234 | 262 | } |
|
235 | 263 | |
|
264 | /*! | |
|
265 | Returns brush of the series. | |
|
266 | */ | |
|
236 | 267 | QBrush QBoxPlotSeries::brush() const |
|
237 | 268 | { |
|
238 | 269 | Q_D(const QBoxPlotSeries); |
@@ -240,6 +271,9 QBrush QBoxPlotSeries::brush() const | |||
|
240 | 271 | return d->m_brush; |
|
241 | 272 | } |
|
242 | 273 | |
|
274 | /*! | |
|
275 | Sets pen for the series. Box-and-whiskers items are drawn using \a pen | |
|
276 | */ | |
|
243 | 277 | void QBoxPlotSeries::setPen(const QPen &pen) |
|
244 | 278 | { |
|
245 | 279 | Q_D(QBoxPlotSeries); |
@@ -250,6 +284,9 void QBoxPlotSeries::setPen(const QPen &pen) | |||
|
250 | 284 | } |
|
251 | 285 | } |
|
252 | 286 | |
|
287 | /*! | |
|
288 | Returns the pen of this series. | |
|
289 | */ | |
|
253 | 290 | QPen QBoxPlotSeries::pen() const |
|
254 | 291 | { |
|
255 | 292 | Q_D(const QBoxPlotSeries); |
@@ -23,13 +23,11 | |||
|
23 | 23 | |
|
24 | 24 | #include <qchartglobal.h> |
|
25 | 25 | #include <qboxset.h> |
|
26 | //#include <qabstractbarseries.h> | |
|
27 | 26 | #include <qabstractseries.h> |
|
28 | 27 | |
|
29 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 29 | |
|
31 | 30 | class QBoxPlotSeriesPrivate; |
|
32 | //class QBarSet; | |
|
33 | 31 | |
|
34 | 32 | class QTCOMMERCIALCHART_EXPORT QBoxPlotSeries : public QAbstractSeries |
|
35 | 33 | { |
@@ -47,9 +45,6 public: | |||
|
47 | 45 | QList<QBoxSet *> boxSets() const; |
|
48 | 46 | void clear(); |
|
49 | 47 | |
|
50 | void setLabelsVisible(bool visible = true); | |
|
51 | bool isLabelsVisible() const; | |
|
52 | ||
|
53 | 48 | QAbstractSeries::SeriesType type() const; |
|
54 | 49 | |
|
55 | 50 | void setBrush(const QBrush &brush); |
@@ -58,10 +53,9 public: | |||
|
58 | 53 | QPen pen() const; |
|
59 | 54 | |
|
60 | 55 | Q_SIGNALS: |
|
61 |
void clicked( |
|
|
56 | void clicked(QBoxSet *boxset); | |
|
62 | 57 | void hovered(bool status, QBoxSet *boxset); |
|
63 | 58 | void countChanged(); |
|
64 | void labelsVisibleChanged(); | |
|
65 | 59 | |
|
66 | 60 | void boxsetsAdded(QList<QBoxSet *> sets); |
|
67 | 61 | void boxsetsRemoved(QList<QBoxSet *> sets); |
@@ -27,7 +27,101 | |||
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | /*! |
|
30 | Constructs QBoxSet with parent of \a parent | |
|
30 | \class QBoxSet | |
|
31 | \brief Building block for box-and-whiskers chart | |
|
32 | ||
|
33 | QBoxSet represents one box-and-whiskers item. It takes fives values to create a graphical representation | |
|
34 | of range and three medians. There's two type of methods to give the values. The first one is with constructor | |
|
35 | or append type of methods (append and operator <<). In these the values have to be given in order lower extreme, | |
|
36 | lower quartile, median, upper quartile and upper extre. Second method is to create an empty QBoxSet instance and | |
|
37 | give the values using own methods. | |
|
38 | ||
|
39 | \mainclass | |
|
40 | ||
|
41 | \sa QBoxPlotSeries | |
|
42 | */ | |
|
43 | /*! | |
|
44 | \qmlclass BoxSet QBoxSet | |
|
45 | ||
|
46 | BoxSet represents one box-and-whiskers item. It takes fives values to create a graphical representation | |
|
47 | of range and three medians. There's two type of methods to give the values. The first one is with constructor | |
|
48 | or append type of methods (append and operator <<). In these the values have to be given in order lower extreme, | |
|
49 | lower quartile, median, upper quartile and upper extre. Second method is to create an empty BoxSet instance and | |
|
50 | give the values using own methods. | |
|
51 | \sa BoxPlotSeries | |
|
52 | */ | |
|
53 | ||
|
54 | /*! | |
|
55 | \property QBoxSet::pen | |
|
56 | \brief Defines the pen used by the box-and-whiskers set. | |
|
57 | */ | |
|
58 | ||
|
59 | /*! | |
|
60 | \property QBoxSet::brush | |
|
61 | \brief Defines the brush used by the box-and-whiskers set. | |
|
62 | */ | |
|
63 | ||
|
64 | /*! | |
|
65 | \property QBoxSet::color | |
|
66 | The fill (brush) color of the box-and-whiskers set. | |
|
67 | */ | |
|
68 | ||
|
69 | /*! | |
|
70 | \property QBoxSet::borderColor | |
|
71 | The line (pen) color of the box-and-whiskers set. | |
|
72 | */ | |
|
73 | ||
|
74 | /*! | |
|
75 | \fn void QBoxSet::clicked() | |
|
76 | The signal is emitted if the user clicks with a mouse on top of box-and-whisker item. | |
|
77 | */ | |
|
78 | ||
|
79 | /*! | |
|
80 | \fn void QBoxSet::hovered(bool status) | |
|
81 | ||
|
82 | The signal is emitted if mouse is hovered on top of box-and-whisker item. | |
|
83 | Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item. | |
|
84 | */ | |
|
85 | ||
|
86 | /*! | |
|
87 | \fn void QBoxSet::penChanged() | |
|
88 | This signal is emitted when the pen of the box-and-whisker item has changed. | |
|
89 | \sa pen | |
|
90 | */ | |
|
91 | ||
|
92 | /*! | |
|
93 | \fn void QBoxSet::brushChanged() | |
|
94 | This signal is emitted when the brush of the box-and-whisker item has changed. | |
|
95 | \sa brush | |
|
96 | */ | |
|
97 | ||
|
98 | /*! | |
|
99 | \fn void QBoxSet::colorChanged(QColor) | |
|
100 | This signal is emitted when the fill (brush) color of the box-and-whisker item has changed to \a color. | |
|
101 | */ | |
|
102 | ||
|
103 | /*! | |
|
104 | \fn void QBoxSet::valuesAdded(int index, int count) | |
|
105 | This signal is emitted when new values have been added to the box-and-whisker item. | |
|
106 | Parameter \a index indicates the position of the first inserted value. | |
|
107 | Parameter \a count is the number of inserted values. | |
|
108 | \sa append(), insert() | |
|
109 | */ | |
|
110 | ||
|
111 | /*! | |
|
112 | \fn void QBoxSet::valueChanged(int index) | |
|
113 | This signal is emitted values the value in the box-and-whisker item has been modified. | |
|
114 | Parameter \a index indicates the position of the modified value. | |
|
115 | \sa at() | |
|
116 | */ | |
|
117 | ||
|
118 | /*! | |
|
119 | \fn void QBoxSet::borderColorChanged(QColor) | |
|
120 | This signal is emitted when the line (pen) color of the box-and-whisker item has changed to \a color. | |
|
121 | */ | |
|
122 | ||
|
123 | /*! | |
|
124 | Constructs QBoxSet with optional \a label and parent of \a parent | |
|
31 | 125 | */ |
|
32 | 126 | QBoxSet::QBoxSet(const QString label, QObject *parent) |
|
33 | 127 | : QObject(parent), |
@@ -35,15 +129,19 QBoxSet::QBoxSet(const QString label, QObject *parent) | |||
|
35 | 129 | { |
|
36 | 130 | } |
|
37 | 131 | |
|
38 | QBoxSet::QBoxSet(qreal value1, qreal value2, qreal value3, qreal value4, qreal value5, const QString label, QObject *parent) | |
|
132 | /*! | |
|
133 | Constructs QBoxSet with given ordered values. \a le for lower extreme, \a lq for lower quartile, \a m for median, | |
|
134 | \a uq for upper quartile and \a ue for upper quartile. \a label and \a parent are optional. | |
|
135 | */ | |
|
136 | QBoxSet::QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label = "", QObject *parent) | |
|
39 | 137 | : QObject(parent), |
|
40 | 138 | d_ptr(new QBoxSetPrivate(label, this)) |
|
41 | 139 | { |
|
42 |
d_ptr->append( |
|
|
43 |
d_ptr->append( |
|
|
44 |
d_ptr->append( |
|
|
45 |
d_ptr->append( |
|
|
46 |
d_ptr->append( |
|
|
140 | d_ptr->append(le); | |
|
141 | d_ptr->append(lq); | |
|
142 | d_ptr->append(m); | |
|
143 | d_ptr->append(uq); | |
|
144 | d_ptr->append(ue); | |
|
47 | 145 | } |
|
48 | 146 | |
|
49 | 147 | /*! |
@@ -39,7 +39,7 class QTCOMMERCIALCHART_EXPORT QBoxSet : public QObject | |||
|
39 | 39 | |
|
40 | 40 | public: |
|
41 | 41 | explicit QBoxSet(const QString label = "", QObject *parent = 0); |
|
42 |
explicit QBoxSet(const qreal |
|
|
42 | explicit QBoxSet(const qreal le, const qreal lq, const qreal m, const qreal uq, const qreal ue, const QString label = "", QObject *parent = 0); | |
|
43 | 43 | virtual ~QBoxSet(); |
|
44 | 44 | |
|
45 | 45 | void append(const qreal value); |
@@ -62,7 +62,6 public: | |||
|
62 | 62 | QBoxSet &operator << (const qreal &value); |
|
63 | 63 | |
|
64 | 64 | void insert(const int index, const qreal value); |
|
65 | void remove(const int index, const int count = 1); | |
|
66 | 65 | void replace(const int index, const qreal value); |
|
67 | 66 | qreal at(const int index) const; |
|
68 | 67 | qreal operator [](const int index) const; |
@@ -82,7 +81,7 public: | |||
|
82 | 81 | |
|
83 | 82 | |
|
84 | 83 | Q_SIGNALS: |
|
85 |
void clicked( |
|
|
84 | void clicked(); | |
|
86 | 85 | void hovered(bool status); |
|
87 | 86 | void penChanged(); |
|
88 | 87 | void brushChanged(); |
@@ -90,7 +89,6 Q_SIGNALS: | |||
|
90 | 89 | void borderColorChanged(QColor color); |
|
91 | 90 | |
|
92 | 91 | void valuesAdded(int index, int count); |
|
93 | void valuesRemoved(int index, int count); | |
|
94 | 92 | void valueChanged(int index); |
|
95 | 93 | |
|
96 | 94 | private: |
@@ -28,21 +28,21 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
28 | 28 | \mainclass |
|
29 | 29 | |
|
30 | 30 | Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. |
|
31 |
Vertical model mapper is used to create a connection between Q |
|
|
31 | Vertical model mapper is used to create a connection between QBoxPlotSeries and QAbstractItemModel derived model object. | |
|
32 | 32 | Model mapper maintains equal size of all the BarSets. |
|
33 | Adding/removing value from the BarSet causes the the same change in the rest of the BarSets added to the same series. | |
|
34 | 33 | Note: used model has to support adding/removing rows/columns and modifying the data of the cells. |
|
35 | 34 | */ |
|
36 | 35 | /*! |
|
37 |
\qmlclass VB |
|
|
36 | \qmlclass VBoxPlotModelMapper | |
|
38 | 37 | \mainclass |
|
39 | 38 | |
|
40 |
VB |
|
|
41 |
for any bar series. It is possible to use both QAbstractItemModel and bar series data API to |
|
|
42 | VBarModelMapper keeps the series and the model in sync. | |
|
39 | VBoxPlotModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source | |
|
40 | for any box-and-whiskers series. It is possible to use both QAbstractItemModel and box-and-whiskers series data API to | |
|
41 | manipulate data. | |
|
42 | VBoxPlotModelMapper keeps the series and the model in sync. | |
|
43 | 43 | |
|
44 |
The following QML example would create a bar series with three b |
|
|
45 |
model has at least four columns). Each b |
|
|
44 | The following QML example would create a box-and-whiskers series with three box sets (assuming the | |
|
45 | model has at least four columns). Each box set would contain data starting from row 1. The name of a set would be | |
|
46 | 46 | defined by the horizontal header (of the column). |
|
47 | 47 | \code |
|
48 | 48 | BarSeries { |
@@ -58,7 +58,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
58 | 58 | |
|
59 | 59 | /*! |
|
60 | 60 | \property QVBoxPlotModelMapper::series |
|
61 |
\brief Defines the Q |
|
|
61 | \brief Defines the QBoxPlotSeries object that is used by the mapper. | |
|
62 | 62 | |
|
63 | 63 | All the data in the series is discarded when it is set to the mapper. |
|
64 | 64 | When new series is specified the old series is disconnected (it preserves its data) |
@@ -81,46 +81,46 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
81 | 81 | */ |
|
82 | 82 | |
|
83 | 83 | /*! |
|
84 |
\property QVBoxPlotModelMapper::firstB |
|
|
85 | \brief Defines which column of the model is used as the data source for the first bar set | |
|
84 | \property QVBoxPlotModelMapper::firstBoxSetColumn | |
|
85 | \brief Defines which column of the model is used as the data source for the first box-and-whiskers set | |
|
86 | 86 | Default value is: -1 (invalid mapping) |
|
87 | 87 | */ |
|
88 | 88 | /*! |
|
89 |
\qmlproperty int VBarModelMapper::firstB |
|
|
90 | Defines which column of the model is used as the data source for the first bar set. Default value | |
|
89 | \qmlproperty int VBarModelMapper::firstBoxSetColumn | |
|
90 | Defines which column of the model is used as the data source for the first box-and-whiskers set. Default value | |
|
91 | 91 | is: -1 (invalid mapping). |
|
92 | 92 | */ |
|
93 | 93 | |
|
94 | 94 | /*! |
|
95 |
\property QVBoxPlotModelMapper::lastB |
|
|
96 | \brief Defines which column of the model is used as the data source for the last bar set | |
|
95 | \property QVBoxPlotModelMapper::lastBoxSetColumn | |
|
96 | \brief Defines which column of the model is used as the data source for the last box-and-whiskers set | |
|
97 | 97 | Default value is: -1 (invalid mapping) |
|
98 | 98 | */ |
|
99 | 99 | /*! |
|
100 |
\qmlproperty int VBarModelMapper::lastB |
|
|
101 | Defines which column of the model is used as the data source for the last bar set. Default | |
|
100 | \qmlproperty int VBarModelMapper::lastBoxSetColumn | |
|
101 | Defines which column of the model is used as the data source for the last box-and-whiskers set. Default | |
|
102 | 102 | value is: -1 (invalid mapping). |
|
103 | 103 | */ |
|
104 | 104 | |
|
105 | 105 | /*! |
|
106 | 106 | \property QVBoxPlotModelMapper::firstRow |
|
107 |
\brief Defines which row of the model contains the first values of the QB |
|
|
107 | \brief Defines which row of the model contains the first values of the QBoxSets in the series. | |
|
108 | 108 | Minimal and default value is: 0 |
|
109 | 109 | */ |
|
110 | 110 | /*! |
|
111 |
\qmlproperty int VB |
|
|
112 |
Defines which row of the model contains the first values of the QB |
|
|
111 | \qmlproperty int VBoxPlotModelMapper::firstRow | |
|
112 | Defines which row of the model contains the first values of the QBoxSets in the series. | |
|
113 | 113 | The default value is 0. |
|
114 | 114 | */ |
|
115 | 115 | |
|
116 | 116 | /*! |
|
117 | 117 | \property QVBoxPlotModelMapper::rowCount |
|
118 |
\brief Defines the number of rows of the model that are mapped as the data for Q |
|
|
118 | \brief Defines the number of rows of the model that are mapped as the data for QBoxPlotSeries | |
|
119 | 119 | Minimal and default value is: -1 (count limited by the number of rows in the model) |
|
120 | 120 | */ |
|
121 | 121 | /*! |
|
122 |
\qmlproperty int VB |
|
|
123 |
Defines the number of rows of the model that are mapped as the data for Q |
|
|
122 | \qmlproperty int VBoxModelMapper::rowCount | |
|
123 | Defines the number of rows of the model that are mapped as the data for QBoxPlotSeries. The default value is | |
|
124 | 124 | -1 (count limited by the number of rows in the model) |
|
125 | 125 | */ |
|
126 | 126 | |
@@ -137,13 +137,13 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
137 | 137 | */ |
|
138 | 138 | |
|
139 | 139 | /*! |
|
140 |
\fn void QVBoxPlotModelMapper::firstB |
|
|
141 |
Emitted when the firstB |
|
|
140 | \fn void QVBoxPlotModelMapper::firstBoxSetColumnChanged() | |
|
141 | Emitted when the firstBoxSetColumn has changed. | |
|
142 | 142 | */ |
|
143 | 143 | |
|
144 | 144 | /*! |
|
145 |
\fn void QVBoxPlotModelMapper::lastB |
|
|
146 |
Emitted when the lastB |
|
|
145 | \fn void QVBoxPlotModelMapper::lastBoxSetColumnChanged() | |
|
146 | Emitted when the lastBoxSetColumn has changed. | |
|
147 | 147 | */ |
|
148 | 148 | |
|
149 | 149 | /*! |
@@ -53,6 +53,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
53 | 53 | \value LegendMarkerTypeBar |
|
54 | 54 | \value LegendMarkerTypePie |
|
55 | 55 | \value LegendMarkerTypeXY |
|
56 | \value LegendMarkerTypeBoxPlot | |
|
56 | 57 | */ |
|
57 | 58 | |
|
58 | 59 | /*! |
@@ -62,6 +62,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
62 | 62 | \value SeriesTypeHorizontalBar |
|
63 | 63 | \value SeriesTypeHorizontalStackedBar |
|
64 | 64 | \value SeriesTypeHorizontalPercentBar |
|
65 | \value SeriesTypeBoxPlot | |
|
65 | 66 | */ |
|
66 | 67 | |
|
67 | 68 | /*! |
@@ -206,6 +206,11 void MainWidget::addSeries() | |||
|
206 | 206 | m_series[nSeries]->append(set5); |
|
207 | 207 | m_series[nSeries]->setName("Box & Whiskers"); |
|
208 | 208 | |
|
209 | connect(m_series[nSeries], SIGNAL(clicked(QBoxSet*)), this, SLOT(boxClicked(QBoxSet*))); | |
|
210 | connect(m_series[nSeries], SIGNAL(hovered(bool, QBoxSet*)), this, SLOT(boxHovered(bool, QBoxSet*))); | |
|
211 | connect(set1, SIGNAL(clicked()), this, SLOT(singleBoxClicked())); | |
|
212 | connect(set2, SIGNAL(hovered(bool)), this, SLOT(singleBoxHovered(bool))); | |
|
213 | ||
|
209 | 214 | m_chart->addSeries(m_series[nSeries]); |
|
210 | 215 | |
|
211 | 216 | if (nSeries == 0) { |
@@ -356,3 +361,29 void MainWidget::changeChartTheme(int themeIndex) | |||
|
356 | 361 | else |
|
357 | 362 | m_chart->setTheme((QChart::ChartTheme) (themeIndex - 1)); |
|
358 | 363 | } |
|
364 | ||
|
365 | void MainWidget::boxClicked(QBoxSet *set) | |
|
366 | { | |
|
367 | qDebug() << "boxClicked, median = " << set->median(); | |
|
368 | } | |
|
369 | ||
|
370 | void MainWidget::boxHovered(bool state, QBoxSet *set) | |
|
371 | { | |
|
372 | if (state) | |
|
373 | qDebug() << "box median " << set->median() << " hover started"; | |
|
374 | else | |
|
375 | qDebug() << "box median " << set->median() << " hover ended"; | |
|
376 | } | |
|
377 | ||
|
378 | void MainWidget::singleBoxClicked() | |
|
379 | { | |
|
380 | qDebug() << "singleBoxClicked"; | |
|
381 | } | |
|
382 | ||
|
383 | void MainWidget::singleBoxHovered(bool state) | |
|
384 | { | |
|
385 | if (state) | |
|
386 | qDebug() << "single box hover started"; | |
|
387 | else | |
|
388 | qDebug() << "single box hover ended"; | |
|
389 | } |
@@ -28,6 +28,7 | |||
|
28 | 28 | #include <QWidget> |
|
29 | 29 | #include <QBoxPlotSeries> |
|
30 | 30 | #include <QBarCategoryAxis> |
|
31 | #include <QBoxSet> | |
|
31 | 32 | |
|
32 | 33 | class QGridLayout; |
|
33 | 34 | |
@@ -58,6 +59,10 private slots: | |||
|
58 | 59 | void titleToggled(bool enabled); |
|
59 | 60 | void modelMapperToggled(bool enabled); |
|
60 | 61 | void changeChartTheme(int themeIndex); |
|
62 | void boxClicked(QBoxSet *set); | |
|
63 | void boxHovered(bool state, QBoxSet *set); | |
|
64 | void singleBoxClicked(); | |
|
65 | void singleBoxHovered(bool state); | |
|
61 | 66 | |
|
62 | 67 | private: |
|
63 | 68 | QChart *m_chart; |
General Comments 0
You need to be logged in to leave comments.
Login now