@@ -25,6 +25,227 | |||||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
|
28 | /*! | |||
|
29 | \qmlclass BoxSet QBoxSet | |||
|
30 | ||||
|
31 | BoxSet represents one box-and-whiskers item. It takes five values to create a graphical representation | |||
|
32 | of range and three medians. There are two ways to give the values. The first one is with constructor | |||
|
33 | or with append method. In these the values have to be given in the following order: lower extreme, lower quartile, median, | |||
|
34 | upper quartile and upper extreme. The second method is to create an empty QBoxSet instance and give the values using | |||
|
35 | value specific methods. | |||
|
36 | \sa BoxPlotSeries | |||
|
37 | */ | |||
|
38 | /*! | |||
|
39 | \qmlproperty string BoxSet::values | |||
|
40 | The values on the box-and-whiskers set. | |||
|
41 | */ | |||
|
42 | /*! | |||
|
43 | \qmlproperty string BoxSet::label | |||
|
44 | Defines the label of the box-and-whiskers set. | |||
|
45 | */ | |||
|
46 | /*! | |||
|
47 | \qmlproperty int BoxSet::count | |||
|
48 | The count of values on the box-and-whiskers set | |||
|
49 | */ | |||
|
50 | /*! | |||
|
51 | \qmlmethod void BoxSet::at(int index) | |||
|
52 | Returns the value at \a index position. | |||
|
53 | */ | |||
|
54 | /*! | |||
|
55 | \qmlmethod void BoxSet::append(qreal value) | |||
|
56 | Appends new value \a value to the end of set. | |||
|
57 | */ | |||
|
58 | /*! | |||
|
59 | \qmlmethod void BoxSet::clear() | |||
|
60 | Sets all values on the set to 0. | |||
|
61 | */ | |||
|
62 | /*! | |||
|
63 | \qmlmethod void BoxSet::setValue(int index, qreal value) | |||
|
64 | Sets a new \a value on the \a index position. | |||
|
65 | */ | |||
|
66 | /*! | |||
|
67 | \qmlsignal BoxSet::onClicked() | |||
|
68 | This signal is emitted when the user clicks with a mouse on top of box-and-whiskers item. | |||
|
69 | */ | |||
|
70 | /*! | |||
|
71 | \qmlsignal BoxSet::onHovered(bool status) | |||
|
72 | The signal is emitted if mouse is hovered on top of box-and-whiskers item. | |||
|
73 | Parameter \a status is true, if mouse entered on top of the item, and false if mouse left from top of the item. | |||
|
74 | */ | |||
|
75 | /*! | |||
|
76 | \qmlsignal BoxSet::onPenChanged() | |||
|
77 | This signal is emitted when the pen of the box-and-whiskers item has changed. | |||
|
78 | */ | |||
|
79 | /*! | |||
|
80 | \qmlsignal BoxSet::onBrushChanged() | |||
|
81 | This signal is emitted when the brush of the box-and-whiskers item has changed. | |||
|
82 | */ | |||
|
83 | /*! | |||
|
84 | \qmlsignal BoxSet::onChangedValues() | |||
|
85 | This signal is emitted when multiple values have been changed on the box-and-whiskers item. | |||
|
86 | */ | |||
|
87 | /*! | |||
|
88 | \qmlsignal BoxSet::onChangedValue(int index) | |||
|
89 | This signal is emitted values the value in the box-and-whiskers item has been modified. | |||
|
90 | Parameter \a index indicates the position of the modified value. | |||
|
91 | */ | |||
|
92 | /*! | |||
|
93 | \qmlsignal BoxSet::onCleared() | |||
|
94 | This signal is emitted when all the values on the set are cleared to 0. | |||
|
95 | */ | |||
|
96 | ||||
|
97 | ||||
|
98 | /*! | |||
|
99 | \qmlclass BoxPlotSeries QBoxPlotSeries | |||
|
100 | \inherits QAbstractSeries | |||
|
101 | ||||
|
102 | BoxPlotSeries represents a series of data shown as box-and-whiskers bars. The purpose of this class is to act as | |||
|
103 | a container for single box-and-whiskers items. Each item is drawn to own slot. If chart includes multiple instances of | |||
|
104 | BoxPlotSeries then box-and-whiskers items with the same index are drawn to same slot. | |||
|
105 | ||||
|
106 | The following QML shows how to create a simple box-and-whiskers chart: | |||
|
107 | \code | |||
|
108 | import QtQuick 1.0 | |||
|
109 | import QtCommercial.Chart 1.3 | |||
|
110 | ||||
|
111 | ChartView { | |||
|
112 | title: "Box Plot series" | |||
|
113 | width: 400 | |||
|
114 | height: 300 | |||
|
115 | theme: ChartView.ChartThemeBrownSand | |||
|
116 | legend.alignment: Qt.AlignBottom | |||
|
117 | ||||
|
118 | BoxPlotSeries { | |||
|
119 | id: plotSeries | |||
|
120 | name: "Income" | |||
|
121 | BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } | |||
|
122 | BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] } | |||
|
123 | BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] } | |||
|
124 | BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] } | |||
|
125 | BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] } | |||
|
126 | } | |||
|
127 | } | |||
|
128 | \endcode | |||
|
129 | ||||
|
130 | \beginfloatleft | |||
|
131 | \image examples_qmlboxplot.png | |||
|
132 | \endfloat | |||
|
133 | \clearfloat | |||
|
134 | */ | |||
|
135 | /*! | |||
|
136 | \qmlmethod BoxPlotSeries::append(string label, VariantList values) | |||
|
137 | Appends a new box-and-whiskers set with \a label and \a values to the series. | |||
|
138 | */ | |||
|
139 | /*! | |||
|
140 | \qmlmethod BoxPlotSeries::append(BoxSet box) | |||
|
141 | Appends the \a box to the series. | |||
|
142 | */ | |||
|
143 | /*! | |||
|
144 | \qmlmethod BoxPlotSeries::insert(int index, string label, VariantList values) | |||
|
145 | Inserts a new box-and-whiskers set with \a label and \a values at the \a index position. | |||
|
146 | */ | |||
|
147 | /*! | |||
|
148 | \qmlmethod BoxPlotSeries::remove(QBoxSet boxset) | |||
|
149 | Removes the \a boxset from the series. | |||
|
150 | */ | |||
|
151 | /*! | |||
|
152 | \qmlmethod BoxPlotSeries::clear() | |||
|
153 | Removes all boxsets from the series. Deletes removed sets. | |||
|
154 | */ | |||
|
155 | /*! | |||
|
156 | \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset); | |||
|
157 | Signal is emitted when the user clicks the \a boxset on the chart. | |||
|
158 | */ | |||
|
159 | /*! | |||
|
160 | \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset); | |||
|
161 | Signal is emitted when there is change in hover \a status over \a boxset. | |||
|
162 | */ | |||
|
163 | /*! | |||
|
164 | \qmlsignal BoxPlotSeries::onCountChanged(); | |||
|
165 | Signal is emitted when there is change in count of box-and-whiskers items in the series. | |||
|
166 | */ | |||
|
167 | /*! | |||
|
168 | \qmlsignal BoxPlotSeries::onBoxsetsAdded() | |||
|
169 | Signal is emitted when new box-and-whiskers sets are added to the series. | |||
|
170 | */ | |||
|
171 | /*! | |||
|
172 | \qmlsignal BoxPlotSeries::onBoxsetsRemoved() | |||
|
173 | Signal is emitted when new box-and-whiskers sets are removed from the series. | |||
|
174 | */ | |||
|
175 | /*! | |||
|
176 | \qmlproperty AbstractAxis BoxPlotSeries::axisX | |||
|
177 | The x axis used for the series. If you leave both axisX and axisXTop undefined, a BarCategoriesAxis is created for | |||
|
178 | the series. | |||
|
179 | \sa axisXTop | |||
|
180 | */ | |||
|
181 | /*! | |||
|
182 | \qmlproperty AbstractAxis BoxPlotSeries::axisY | |||
|
183 | The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for | |||
|
184 | the series. | |||
|
185 | \sa axisYRight | |||
|
186 | */ | |||
|
187 | /*! | |||
|
188 | \qmlproperty AbstractAxis BoxPlotSeries::axisXTop | |||
|
189 | The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or | |||
|
190 | axisXTop, but not both. | |||
|
191 | \sa axisX | |||
|
192 | */ | |||
|
193 | /*! | |||
|
194 | \qmlproperty AbstractAxis BoxPlotSeries::axisYRight | |||
|
195 | The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY | |||
|
196 | or axisYRight, but not both. | |||
|
197 | \sa axisY | |||
|
198 | */ | |||
|
199 | /*! | |||
|
200 | \qmlproperty bool BoxPlotSeries::boxOutlineVisible | |||
|
201 | This property configures the visibility of the middle box outline. | |||
|
202 | */ | |||
|
203 | /*! | |||
|
204 | \qmlproperty Pen BoxPlotSeries::pen | |||
|
205 | This property configures the pen of the box-and-whiskers items. | |||
|
206 | */ | |||
|
207 | /*! | |||
|
208 | \qmlproperty Brush BoxPlotSeries::brush | |||
|
209 | This property configures the brush of the box-and-whiskers items. | |||
|
210 | */ | |||
|
211 | /*! | |||
|
212 | \qmlsignal BoxPlotSeries::onBoxOutlineVisibilityChanged() | |||
|
213 | Signal is emitted when the middle box outline visibility is changed. | |||
|
214 | */ | |||
|
215 | /*! | |||
|
216 | \qmlsignal BoxPlotSeries::onPenChanged() | |||
|
217 | Signal is emitted when the pen for box-and-whiskers items has changed. | |||
|
218 | */ | |||
|
219 | /*! | |||
|
220 | \qmlsignal BoxPlotSeries::onBrushChanged() | |||
|
221 | Signal is emitted when the brush for box-and-whiskers items has changed. | |||
|
222 | */ | |||
|
223 | /*! | |||
|
224 | \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset) | |||
|
225 | Signal is emitted when the user clicks the \a boxset on the chart. | |||
|
226 | */ | |||
|
227 | /*! | |||
|
228 | \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset) | |||
|
229 | Signal is emitted when there is change in hover \a status over \a boxset. | |||
|
230 | */ | |||
|
231 | /*! | |||
|
232 | \qmlsignal BoxPlotSeries::onAxisXChanged(AbstractAxis axis) | |||
|
233 | Signal is emitted when there is change in X axis. | |||
|
234 | */ | |||
|
235 | /*! | |||
|
236 | \qmlsignal BoxPlotSeries::onAxisYChanged(AbstractAxis axis) | |||
|
237 | Signal is emitted when there is change in Y axis. | |||
|
238 | */ | |||
|
239 | /*! | |||
|
240 | \qmlsignal BoxPlotSeries::onAxisXTopChanged(AbstractAxis axis) | |||
|
241 | Signal is emitted when there is change in top X axis. | |||
|
242 | */ | |||
|
243 | /*! | |||
|
244 | \qmlsignal BoxPlotSeries::onAxisYRightChanged(AbstractAxis axis) | |||
|
245 | Signal is emitted when there is change in Y right axis. | |||
|
246 | */ | |||
|
247 | ||||
|
248 | ||||
28 | DeclarativeBoxSet::DeclarativeBoxSet(const QString label, QObject *parent) |
|
249 | DeclarativeBoxSet::DeclarativeBoxSet(const QString label, QObject *parent) | |
29 | : QBoxSet(label, parent) |
|
250 | : QBoxSet(label, parent) | |
30 | { |
|
251 | { |
@@ -84,6 +84,7 void BoxPlotChartItem::handleDataStructureChanged() | |||||
84 | // Set the decorative issues for the newly created box |
|
84 | // Set the decorative issues for the newly created box | |
85 | box->setBrush(m_series->brush()); |
|
85 | box->setBrush(m_series->brush()); | |
86 | box->setPen(m_series->pen()); |
|
86 | box->setPen(m_series->pen()); | |
|
87 | box->setBoxOutlined(m_series->boxOutlineVisible()); | |||
87 | } |
|
88 | } | |
88 | updateBoxGeometry(box, s); |
|
89 | updateBoxGeometry(box, s); | |
89 |
|
90 | |||
@@ -101,6 +102,7 void BoxPlotChartItem::handleUpdatedBars() | |||||
101 | foreach (BoxWhiskers *item, m_boxTable.values()) { |
|
102 | foreach (BoxWhiskers *item, m_boxTable.values()) { | |
102 | item->setBrush(m_series->brush()); |
|
103 | item->setBrush(m_series->brush()); | |
103 | item->setPen(m_series->pen()); |
|
104 | item->setPen(m_series->pen()); | |
|
105 | item->setBoxOutlined(m_series->boxOutlineVisible()); | |||
104 | } |
|
106 | } | |
105 | // Override with QBoxSet specific settings |
|
107 | // Override with QBoxSet specific settings | |
106 | foreach (QBoxSet *set, m_boxTable.keys()) { |
|
108 | foreach (QBoxSet *set, m_boxTable.keys()) { |
@@ -58,12 +58,22 void BoxWhiskers::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) | |||||
58 | void BoxWhiskers::setBrush(const QBrush &brush) |
|
58 | void BoxWhiskers::setBrush(const QBrush &brush) | |
59 | { |
|
59 | { | |
60 | m_brush = brush; |
|
60 | m_brush = brush; | |
|
61 | m_outlinePen.setColor(m_brush.color()); | |||
61 | update(); |
|
62 | update(); | |
62 | } |
|
63 | } | |
63 |
|
64 | |||
64 | void BoxWhiskers::setPen(const QPen &pen) |
|
65 | void BoxWhiskers::setPen(const QPen &pen) | |
65 | { |
|
66 | { | |
|
67 | qreal widthDiff = pen.widthF() - m_pen.widthF(); | |||
|
68 | m_boundingRect.adjust(-widthDiff, -widthDiff, widthDiff, widthDiff); | |||
|
69 | ||||
66 | m_pen = pen; |
|
70 | m_pen = pen; | |
|
71 | m_medianPen = pen; | |||
|
72 | m_medianPen.setCapStyle(Qt::FlatCap); | |||
|
73 | m_outlinePen = pen; | |||
|
74 | m_outlinePen.setStyle(Qt::SolidLine); | |||
|
75 | m_outlinePen.setColor(m_brush.color()); | |||
|
76 | ||||
67 | update(); |
|
77 | update(); | |
68 | } |
|
78 | } | |
69 |
|
79 | |||
@@ -98,10 +108,17 void BoxWhiskers::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio | |||||
98 | Q_UNUSED(option) |
|
108 | Q_UNUSED(option) | |
99 | Q_UNUSED(widget) |
|
109 | Q_UNUSED(widget) | |
100 |
|
110 | |||
101 | painter->setPen(m_pen); |
|
|||
102 | painter->setBrush(m_brush); |
|
111 | painter->setBrush(m_brush); | |
103 | painter->setClipRect(parentItem()->boundingRect()); |
|
112 | painter->setClipRect(parentItem()->boundingRect()); | |
|
113 | painter->setPen(m_pen); | |||
104 | painter->drawPath(m_boxPath); |
|
114 | painter->drawPath(m_boxPath); | |
|
115 | if (!m_boxOutlined) | |||
|
116 | painter->setPen(m_outlinePen); | |||
|
117 | painter->drawRect(m_middleBox); | |||
|
118 | painter->setPen(m_medianPen); | |||
|
119 | qreal halfLine = m_pen.widthF() / 2.0; | |||
|
120 | painter->drawLine(QLineF(m_geometryLeft - halfLine, m_geometryMedian, | |||
|
121 | m_geometryRight + halfLine, m_geometryMedian)); | |||
105 | } |
|
122 | } | |
106 |
|
123 | |||
107 | void BoxWhiskers::updateGeometry(AbstractDomain *domain) |
|
124 | void BoxWhiskers::updateGeometry(AbstractDomain *domain) | |
@@ -121,12 +138,12 void BoxWhiskers::updateGeometry(AbstractDomain *domain) | |||||
121 | QPointF geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_upperExtreme), m_validData); |
|
138 | QPointF geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_upperExtreme), m_validData); | |
122 | if (!m_validData) |
|
139 | if (!m_validData) | |
123 | return; |
|
140 | return; | |
124 |
|
|
141 | m_geometryLeft = geometryPoint.x(); | |
125 | qreal geometryUpperExtreme = geometryPoint.y(); |
|
142 | qreal geometryUpperExtreme = geometryPoint.y(); | |
126 | geometryPoint = m_domain->calculateGeometryPoint(QPointF(left + barWidth, m_data.m_upperQuartile), m_validData); |
|
143 | geometryPoint = m_domain->calculateGeometryPoint(QPointF(left + barWidth, m_data.m_upperQuartile), m_validData); | |
127 | if (!m_validData) |
|
144 | if (!m_validData) | |
128 | return; |
|
145 | return; | |
129 |
|
|
146 | m_geometryRight = geometryPoint.x(); | |
130 | qreal geometryUpperQuartile = geometryPoint.y(); |
|
147 | qreal geometryUpperQuartile = geometryPoint.y(); | |
131 | geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_lowerQuartile), m_validData); |
|
148 | geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_lowerQuartile), m_validData); | |
132 | if (!m_validData) |
|
149 | if (!m_validData) | |
@@ -139,33 +156,29 void BoxWhiskers::updateGeometry(AbstractDomain *domain) | |||||
139 | geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_median), m_validData); |
|
156 | geometryPoint = m_domain->calculateGeometryPoint(QPointF(left, m_data.m_median), m_validData); | |
140 | if (!m_validData) |
|
157 | if (!m_validData) | |
141 | return; |
|
158 | return; | |
142 |
|
|
159 | m_geometryMedian = geometryPoint.y(); | |
143 |
|
160 | |||
144 | // Upper whisker |
|
161 | // Upper whisker | |
145 | path.moveTo(geometryLeft, geometryUpperExtreme); |
|
162 | path.moveTo(m_geometryLeft, geometryUpperExtreme); | |
146 | path.lineTo(geometryRight, geometryUpperExtreme); |
|
163 | path.lineTo(m_geometryRight, geometryUpperExtreme); | |
147 | path.moveTo((geometryLeft + geometryRight) / 2.0, geometryUpperExtreme); |
|
164 | path.moveTo((m_geometryLeft + m_geometryRight) / 2.0, geometryUpperExtreme); | |
148 | path.lineTo((geometryLeft + geometryRight) / 2.0, geometryUpperQuartile); |
|
165 | path.lineTo((m_geometryLeft + m_geometryRight) / 2.0, geometryUpperQuartile); | |
149 |
|
166 | |||
150 | // Middle Box |
|
167 | // Middle Box | |
151 |
|
|
168 | m_middleBox.setCoords(m_geometryLeft, geometryUpperQuartile, m_geometryRight, geometryLowerQuartile); | |
152 |
|
||||
153 | // Median line |
|
|||
154 | path.moveTo(geometryLeft, geometryMedian); |
|
|||
155 | path.lineTo(geometryRight, geometryMedian); |
|
|||
156 |
|
169 | |||
157 | // Lower whisker |
|
170 | // Lower whisker | |
158 | path.moveTo(geometryLeft, geometryLowerExtreme); |
|
171 | path.moveTo(m_geometryLeft, geometryLowerExtreme); | |
159 | path.lineTo(geometryRight, geometryLowerExtreme); |
|
172 | path.lineTo(m_geometryRight, geometryLowerExtreme); | |
160 | path.moveTo((geometryLeft + geometryRight) / 2.0, geometryLowerQuartile); |
|
173 | path.moveTo((m_geometryLeft + m_geometryRight) / 2.0, geometryLowerQuartile); | |
161 | path.lineTo((geometryLeft + geometryRight) / 2.0, geometryLowerExtreme); |
|
174 | path.lineTo((m_geometryLeft + m_geometryRight) / 2.0, geometryLowerExtreme); | |
162 |
|
175 | |||
163 | path.closeSubpath(); |
|
176 | path.closeSubpath(); | |
164 |
|
177 | |||
165 | m_boxPath = path; |
|
178 | m_boxPath = path; | |
166 | m_boundingRect = m_boxPath.boundingRect(); |
|
179 | m_boundingRect = m_boxPath.boundingRect(); | |
167 |
|
180 | |||
168 | qreal extra = (m_pen.width() / 2.0); |
|
181 | qreal extra = (m_pen.widthF() / 2.0); | |
169 | m_boundingRect.adjust(-extra, -extra, extra, extra); |
|
182 | m_boundingRect.adjust(-extra, -extra, extra, extra); | |
170 | } |
|
183 | } | |
171 |
|
184 |
@@ -54,6 +54,7 public: | |||||
54 | void setBrush(const QBrush &brush); |
|
54 | void setBrush(const QBrush &brush); | |
55 | void setPen(const QPen &pen); |
|
55 | void setPen(const QPen &pen); | |
56 | void setLayout(const BoxWhiskersData &data); |
|
56 | void setLayout(const BoxWhiskersData &data); | |
|
57 | void setBoxOutlined(const bool outlined) { m_boxOutlined = outlined; } | |||
57 |
|
58 | |||
58 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
59 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |
59 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); |
|
60 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); | |
@@ -83,8 +84,15 private: | |||||
83 | bool m_validData; |
|
84 | bool m_validData; | |
84 | QBrush m_brush; |
|
85 | QBrush m_brush; | |
85 | QPen m_pen; |
|
86 | QPen m_pen; | |
|
87 | QPen m_medianPen; | |||
|
88 | QPen m_outlinePen; | |||
|
89 | bool m_boxOutlined; | |||
86 | BoxWhiskersData m_data; |
|
90 | BoxWhiskersData m_data; | |
87 | QSizeF m_domainSize; |
|
91 | QSizeF m_domainSize; | |
|
92 | QRectF m_middleBox; | |||
|
93 | qreal m_geometryMedian; | |||
|
94 | qreal m_geometryLeft; | |||
|
95 | qreal m_geometryRight; | |||
88 | }; |
|
96 | }; | |
89 |
|
97 | |||
90 | QTCOMMERCIALCHART_END_NAMESPACE |
|
98 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -48,115 +48,59 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
48 |
|
48 | |||
49 | \sa QBoxSet |
|
49 | \sa QBoxSet | |
50 | */ |
|
50 | */ | |
51 |
|
||||
52 | /*! |
|
|||
53 | \qmlclass BoxPlotSeries QBoxPlotSeries |
|
|||
54 | \inherits QAbstractSeries |
|
|||
55 |
|
||||
56 | BoxPlotSeries represents a series of data shown as box-and-whisker bars. The purpose of this class is to act as |
|
|||
57 | a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple instances of |
|
|||
58 | BoxPlotSeries then box-and-whiskers items with the same index are drawn to same slot. |
|
|||
59 |
|
||||
60 | The following QML shows how to create a simple box-and-whiskers chart: |
|
|||
61 | \code |
|
|||
62 | import QtQuick 1.0 |
|
|||
63 | import QtCommercial.Chart 1.1 |
|
|||
64 |
|
||||
65 | ChartView { |
|
|||
66 | title: "Box Plot series" |
|
|||
67 | width: 400 |
|
|||
68 | height: 300 |
|
|||
69 | theme: ChartView.ChartThemeBrownSand |
|
|||
70 | legend.alignment: Qt.AlignBottom |
|
|||
71 |
|
||||
72 | BoxPlotSeries { |
|
|||
73 | id: plotSeries |
|
|||
74 | name: "Income" |
|
|||
75 | BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } |
|
|||
76 | BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] } |
|
|||
77 | BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] } |
|
|||
78 | BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] } |
|
|||
79 | BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] } |
|
|||
80 | } |
|
|||
81 | } |
|
|||
82 | \endcode |
|
|||
83 |
|
||||
84 | \beginfloatleft |
|
|||
85 | \image examples_qmlboxplot.png |
|
|||
86 | \endfloat |
|
|||
87 | \clearfloat |
|
|||
88 | */ |
|
|||
89 |
|
||||
90 | /*! |
|
51 | /*! | |
91 | \fn QBoxPlotSeries::boxsetsAdded(QList<QBoxSet *> sets) |
|
52 | \fn QBoxPlotSeries::boxsetsAdded(QList<QBoxSet *> sets) | |
92 | \brief Signal is emitted when a new \a sets of box-and-whiskers data is added to the series. |
|
53 | \brief Signal is emitted when a new \a sets of box-and-whiskers data is added to the series. | |
93 | */ |
|
54 | */ | |
94 |
|
||||
95 | /*! |
|
55 | /*! | |
96 | \fn QBoxPlotSeries::boxsetsRemoved(QList<QBoxSet *> sets) |
|
56 | \fn QBoxPlotSeries::boxsetsRemoved(QList<QBoxSet *> sets) | |
97 | \brief Signal is emitted when \a sets of box-and-whiskers data is removed from the series. |
|
57 | \brief Signal is emitted when \a sets of box-and-whiskers data is removed from the series. | |
98 | */ |
|
58 | */ | |
99 |
|
||||
100 | /*! |
|
59 | /*! | |
101 | \fn QBoxPlotSeries::clicked(QBoxSet *boxset) |
|
60 | \fn QBoxPlotSeries::clicked(QBoxSet *boxset) | |
102 | \brief Signal is emitted when the user clicks the \a boxset on the chart. |
|
61 | \brief Signal is emitted when the user clicks the \a boxset on the chart. | |
103 | */ |
|
62 | */ | |
104 |
|
||||
105 | /*! |
|
63 | /*! | |
106 | \fn QBoxPlotSeries::hovered(bool status, QBoxSet *boxset) |
|
64 | \fn QBoxPlotSeries::hovered(bool status, QBoxSet *boxset) | |
107 | \brief Signal is emitted when there is change in hover \a status over \a boxset. |
|
65 | \brief Signal is emitted when there is change in hover \a status over \a boxset. | |
108 | */ |
|
66 | */ | |
109 |
|
||||
110 | /*! |
|
67 | /*! | |
111 | \fn QBoxPlotSeries::countChanged() |
|
68 | \fn QBoxPlotSeries::countChanged() | |
112 | \brief Signal is emitted when there is change in count of box-and-whiskers items in the series. |
|
69 | \brief Signal is emitted when there is change in count of box-and-whiskers items in the series. | |
113 | */ |
|
70 | */ | |
114 | /*! |
|
71 | /*! | |
115 | \fn virtual SeriesType QBoxPlotSeries::type() const |
|
72 | \property QBoxPlotSeries::boxOutlineVisible | |
116 | \brief Returns type of series. |
|
73 | \brief This property configures the visibility of the middle box outline. | |
117 | \sa QAbstractSeries, SeriesType |
|
|||
118 | */ |
|
74 | */ | |
119 | /*! |
|
75 | /*! | |
120 | \qmlmethod BoxPlotSeries::append(const QString label, QVariantList values) |
|
76 | \property QBoxPlotSeries::pen | |
121 | Appends a new box-and-whiskers set with \a label and \a values to the series. |
|
77 | \brief This property configures the pen of the box-and-whiskers items. | |
122 | */ |
|
|||
123 | /*! |
|
|||
124 | \qmlmethod BoxPlotSeries::append(BoxSet *box) |
|
|||
125 | Appends the \a box to the series. |
|
|||
126 | */ |
|
78 | */ | |
127 | /*! |
|
79 | /*! | |
128 | \qmlmethod BoxPlotSeries::insert(int index, const QString label, QVariantList values) |
|
80 | \property QBoxPlotSeries::brush | |
129 | Inserts a new box-and-whiskers set with \a label and \a values at the \a index position. |
|
81 | \brief This property configures the brush of the box-and-whiskers items. | |
130 | */ |
|
82 | */ | |
131 | /*! |
|
83 | /*! | |
132 | \qmlmethod BoxPlotSeries::remove(QBoxSet *boxset) |
|
84 | \fn void QBoxPlotSeries::boxOutlineVisibilityChanged() | |
133 | Removes the \a boxset from the series. |
|
85 | Signal is emitted when the middle box outline visibility is changed. | |
134 | */ |
|
86 | */ | |
135 | /*! |
|
87 | /*! | |
136 |
\ |
|
88 | \fn void QBoxPlotSeries::penChanged() | |
137 | Removes all boxsets from the series. Deletes removed sets. |
|
89 | This signal is emitted when the pen of the box-and-whiskers has changed. | |
|
90 | \sa brush | |||
138 | */ |
|
91 | */ | |
139 |
|
||||
140 | /*! |
|
92 | /*! | |
141 | \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset); |
|
93 | \fn void QBoxPlotSeries::brushChanged() | |
142 |
|
|
94 | This signal is emitted when the brush of the box-and-whiskers has changed. | |
143 | */ |
|
95 | \sa brush | |
144 | /*! |
|
|||
145 | \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset); |
|
|||
146 | Signal is emitted when there is change in hover \a status over \a boxset. |
|
|||
147 | */ |
|
96 | */ | |
|
97 | ||||
|
98 | ||||
148 | /*! |
|
99 | /*! | |
149 | \qmlsignal BoxPlotSeries::onCountChanged(); |
|
100 | \fn virtual SeriesType QBoxPlotSeries::type() const | |
150 | Signal is emitted when there is change in count of box-and-whiskers items in the series. |
|
101 | \brief Returns type of series. | |
|
102 | \sa QAbstractSeries, SeriesType | |||
151 | */ |
|
103 | */ | |
152 | /*! |
|
|||
153 | \qmlsignal BoxPlotSeries::onBoxsetsAdded() |
|
|||
154 | Signal is emitted when new box-and-whiskers sets are added to the series. |
|
|||
155 | */ |
|
|||
156 | /*! |
|
|||
157 | \qmlsignal BoxPlotSeries::boxsetsRemoved() |
|
|||
158 | Signal is emitted when new box-and-whiskers sets are removed from the series. |
|
|||
159 | */ |
|
|||
160 |
|
104 | |||
161 | /*! |
|
105 | /*! | |
162 | Constructs empty QBoxPlotSeries. |
|
106 | Constructs empty QBoxPlotSeries. | |
@@ -314,9 +258,24 QAbstractSeries::SeriesType QBoxPlotSeries::type() const | |||||
314 | return QAbstractSeries::SeriesTypeBoxPlot; |
|
258 | return QAbstractSeries::SeriesTypeBoxPlot; | |
315 | } |
|
259 | } | |
316 |
|
260 | |||
317 | /*! |
|
261 | void QBoxPlotSeries::setBoxOutlineVisible(bool visible) | |
318 | Sets brush for the series. Box-and-whiskers items are drawn using \a brush |
|
262 | { | |
319 | */ |
|
263 | Q_D(QBoxPlotSeries); | |
|
264 | ||||
|
265 | if (d->m_boxOutlineVisible != visible) { | |||
|
266 | d->m_boxOutlineVisible = visible; | |||
|
267 | emit d->updated(); | |||
|
268 | emit boxOutlineVisibilityChanged(); | |||
|
269 | } | |||
|
270 | } | |||
|
271 | ||||
|
272 | bool QBoxPlotSeries::boxOutlineVisible() | |||
|
273 | { | |||
|
274 | Q_D(QBoxPlotSeries); | |||
|
275 | ||||
|
276 | return d->m_boxOutlineVisible; | |||
|
277 | } | |||
|
278 | ||||
320 | void QBoxPlotSeries::setBrush(const QBrush &brush) |
|
279 | void QBoxPlotSeries::setBrush(const QBrush &brush) | |
321 | { |
|
280 | { | |
322 | Q_D(QBoxPlotSeries); |
|
281 | Q_D(QBoxPlotSeries); | |
@@ -324,12 +283,10 void QBoxPlotSeries::setBrush(const QBrush &brush) | |||||
324 | if (d->m_brush != brush) { |
|
283 | if (d->m_brush != brush) { | |
325 | d->m_brush = brush; |
|
284 | d->m_brush = brush; | |
326 | emit d->updated(); |
|
285 | emit d->updated(); | |
|
286 | emit brushChanged(); | |||
327 | } |
|
287 | } | |
328 | } |
|
288 | } | |
329 |
|
289 | |||
330 | /*! |
|
|||
331 | Returns brush of the series. |
|
|||
332 | */ |
|
|||
333 | QBrush QBoxPlotSeries::brush() const |
|
290 | QBrush QBoxPlotSeries::brush() const | |
334 | { |
|
291 | { | |
335 | Q_D(const QBoxPlotSeries); |
|
292 | Q_D(const QBoxPlotSeries); | |
@@ -337,9 +294,6 QBrush QBoxPlotSeries::brush() const | |||||
337 | return d->m_brush; |
|
294 | return d->m_brush; | |
338 | } |
|
295 | } | |
339 |
|
296 | |||
340 | /*! |
|
|||
341 | Sets pen for the series. Box-and-whiskers items are drawn using \a pen |
|
|||
342 | */ |
|
|||
343 | void QBoxPlotSeries::setPen(const QPen &pen) |
|
297 | void QBoxPlotSeries::setPen(const QPen &pen) | |
344 | { |
|
298 | { | |
345 | Q_D(QBoxPlotSeries); |
|
299 | Q_D(QBoxPlotSeries); | |
@@ -347,12 +301,10 void QBoxPlotSeries::setPen(const QPen &pen) | |||||
347 | if (d->m_pen != pen) { |
|
301 | if (d->m_pen != pen) { | |
348 | d->m_pen = pen; |
|
302 | d->m_pen = pen; | |
349 | emit d->updated(); |
|
303 | emit d->updated(); | |
|
304 | emit penChanged(); | |||
350 | } |
|
305 | } | |
351 | } |
|
306 | } | |
352 |
|
307 | |||
353 | /*! |
|
|||
354 | Returns the pen of this series. |
|
|||
355 | */ |
|
|||
356 | QPen QBoxPlotSeries::pen() const |
|
308 | QPen QBoxPlotSeries::pen() const | |
357 | { |
|
309 | { | |
358 | Q_D(const QBoxPlotSeries); |
|
310 | Q_D(const QBoxPlotSeries); | |
@@ -365,7 +317,8 QPen QBoxPlotSeries::pen() const | |||||
365 | QBoxPlotSeriesPrivate::QBoxPlotSeriesPrivate(QBoxPlotSeries *q) |
|
317 | QBoxPlotSeriesPrivate::QBoxPlotSeriesPrivate(QBoxPlotSeries *q) | |
366 | : QAbstractSeriesPrivate(q), |
|
318 | : QAbstractSeriesPrivate(q), | |
367 | m_pen(QChartPrivate::defaultPen()), |
|
319 | m_pen(QChartPrivate::defaultPen()), | |
368 | m_brush(QChartPrivate::defaultBrush()) |
|
320 | m_brush(QChartPrivate::defaultBrush()), | |
|
321 | m_boxOutlineVisible(true) | |||
369 | { |
|
322 | { | |
370 | } |
|
323 | } | |
371 |
|
324 |
@@ -32,6 +32,9 class QBoxPlotSeriesPrivate; | |||||
32 | class QTCOMMERCIALCHART_EXPORT QBoxPlotSeries : public QAbstractSeries |
|
32 | class QTCOMMERCIALCHART_EXPORT QBoxPlotSeries : public QAbstractSeries | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
|
35 | Q_PROPERTY(bool boxOutlineVisible READ boxOutlineVisible WRITE setBoxOutlineVisible NOTIFY boxOutlineVisibilityChanged) | |||
|
36 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |||
|
37 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |||
35 | public: |
|
38 | public: | |
36 | explicit QBoxPlotSeries(QObject *parent = 0); |
|
39 | explicit QBoxPlotSeries(QObject *parent = 0); | |
37 | ~QBoxPlotSeries(); |
|
40 | ~QBoxPlotSeries(); | |
@@ -47,6 +50,8 public: | |||||
47 |
|
50 | |||
48 | QAbstractSeries::SeriesType type() const; |
|
51 | QAbstractSeries::SeriesType type() const; | |
49 |
|
52 | |||
|
53 | void setBoxOutlineVisible(bool visible); | |||
|
54 | bool boxOutlineVisible(); | |||
50 | void setBrush(const QBrush &brush); |
|
55 | void setBrush(const QBrush &brush); | |
51 | QBrush brush() const; |
|
56 | QBrush brush() const; | |
52 | void setPen(const QPen &pen); |
|
57 | void setPen(const QPen &pen); | |
@@ -56,6 +61,9 Q_SIGNALS: | |||||
56 | void clicked(QBoxSet *boxset); |
|
61 | void clicked(QBoxSet *boxset); | |
57 | void hovered(bool status, QBoxSet *boxset); |
|
62 | void hovered(bool status, QBoxSet *boxset); | |
58 | void countChanged(); |
|
63 | void countChanged(); | |
|
64 | void penChanged(); | |||
|
65 | void brushChanged(); | |||
|
66 | void boxOutlineVisibilityChanged(); | |||
59 |
|
67 | |||
60 | void boxsetsAdded(QList<QBoxSet *> sets); |
|
68 | void boxsetsAdded(QList<QBoxSet *> sets); | |
61 | void boxsetsRemoved(QList<QBoxSet *> sets); |
|
69 | void boxsetsRemoved(QList<QBoxSet *> sets); |
@@ -86,6 +86,7 protected: | |||||
86 | QList<QBoxSet *> m_boxSets; |
|
86 | QList<QBoxSet *> m_boxSets; | |
87 | QPen m_pen; |
|
87 | QPen m_pen; | |
88 | QBrush m_brush; |
|
88 | QBrush m_brush; | |
|
89 | bool m_boxOutlineVisible; | |||
89 | int m_index; |
|
90 | int m_index; | |
90 | BoxPlotAnimation *m_animation; |
|
91 | BoxPlotAnimation *m_animation; | |
91 |
|
92 |
@@ -39,16 +39,6 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
39 | \sa QBoxPlotSeries |
|
39 | \sa QBoxPlotSeries | |
40 | */ |
|
40 | */ | |
41 | /*! |
|
41 | /*! | |
42 | \qmlclass BoxSet QBoxSet |
|
|||
43 |
|
||||
44 | BoxSet represents one box-and-whiskers item. It takes five values to create a graphical representation |
|
|||
45 | of range and three medians. There are two ways to give the values. The first one is with constructor |
|
|||
46 | or with append method. In these the values have to be given in the following order: lower extreme, lower quartile, median, |
|
|||
47 | upper quartile and upper extre. The second method is to create an empty QBoxSet instance and give the values using |
|
|||
48 | value specific methods. |
|
|||
49 | \sa BoxPlotSeries |
|
|||
50 | */ |
|
|||
51 | /*! |
|
|||
52 | \enum QBoxSet::ValuePositions |
|
42 | \enum QBoxSet::ValuePositions | |
53 |
|
43 | |||
54 | \value LowerExtreme |
|
44 | \value LowerExtreme | |
@@ -57,102 +47,49 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
57 | \value UpperQuartile |
|
47 | \value UpperQuartile | |
58 | \value UpperExtreme |
|
48 | \value UpperExtreme | |
59 | */ |
|
49 | */ | |
60 |
|
||||
61 | /*! |
|
|||
62 | \qmlproperty string BoxSet::label |
|
|||
63 | Defines the label of the boxSet. |
|
|||
64 | */ |
|
|||
65 | /*! |
|
|||
66 | \qmlproperty int BoxSet::count |
|
|||
67 | The count of values on the box-and-whiskers set |
|
|||
68 | */ |
|
|||
69 |
|
||||
70 | /*! |
|
50 | /*! | |
71 | \property QBoxSet::pen |
|
51 | \property QBoxSet::pen | |
72 | \brief Defines the pen used by the box-and-whiskers set. |
|
52 | \brief Defines the pen used by the box-and-whiskers set. | |
73 | */ |
|
53 | */ | |
74 |
|
||||
75 | /*! |
|
54 | /*! | |
76 | \property QBoxSet::brush |
|
55 | \property QBoxSet::brush | |
77 | \brief Defines the brush used by the box-and-whiskers set. |
|
56 | \brief Defines the brush used by the box-and-whiskers set. | |
78 | */ |
|
57 | */ | |
79 |
|
||||
80 | /*! |
|
|||
81 | \qmlmethod void BoxSet::setValue(int index, qreal value) |
|
|||
82 | Sets a new \a value on the \a index position. |
|
|||
83 | */ |
|
|||
84 | /*! |
|
58 | /*! | |
85 | \fn void QBoxSet::clicked() |
|
59 | \fn void QBoxSet::clicked() | |
86 | The signal is emitted if the user clicks with a mouse on top of box-and-whisker item. |
|
60 | The signal is emitted if the user clicks with a mouse on top of box-and-whisker item. | |
87 | */ |
|
61 | */ | |
88 | /*! |
|
62 | /*! | |
89 | \qmlsignal BoxSet::onClicked() |
|
|||
90 | This signal is emitted when the user clicks with a mouse on top of box-and-whisker item. |
|
|||
91 | */ |
|
|||
92 |
|
||||
93 | /*! |
|
|||
94 | \fn void QBoxSet::hovered(bool status) |
|
63 | \fn void QBoxSet::hovered(bool status) | |
95 |
|
64 | |||
96 | The signal is emitted if mouse is hovered on top of box-and-whisker item. |
|
65 | The signal is emitted if mouse is hovered on top of box-and-whisker item. | |
97 | Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item. |
|
66 | Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item. | |
98 | */ |
|
67 | */ | |
99 | /*! |
|
68 | /*! | |
100 | \qmlsignal BoxSet::onHovered(bool status) |
|
|||
101 |
|
||||
102 | The signal is emitted if mouse is hovered on top of box-and-whisker item. |
|
|||
103 | Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item. |
|
|||
104 | */ |
|
|||
105 |
|
||||
106 | /*! |
|
|||
107 | \fn void QBoxSet::penChanged() |
|
69 | \fn void QBoxSet::penChanged() | |
108 | This signal is emitted when the pen of the box-and-whisker item has changed. |
|
70 | This signal is emitted when the pen of the box-and-whisker item has changed. | |
109 | \sa pen |
|
71 | \sa pen | |
110 | */ |
|
72 | */ | |
111 | /*! |
|
73 | /*! | |
112 | \qmlsignal BoxSet::onPenChanged() |
|
|||
113 | This signal is emitted when the pen of the box-and-whisker item has changed. |
|
|||
114 | */ |
|
|||
115 | /*! |
|
|||
116 | \fn void QBoxSet::brushChanged() |
|
74 | \fn void QBoxSet::brushChanged() | |
117 | This signal is emitted when the brush of the box-and-whisker item has changed. |
|
75 | This signal is emitted when the brush of the box-and-whisker item has changed. | |
118 | \sa brush |
|
76 | \sa brush | |
119 | */ |
|
77 | */ | |
120 | /*! |
|
78 | /*! | |
121 | \qmlsignal BoxSet::onBrushChanged() |
|
|||
122 | This signal is emitted when the brush of the box-and-whisker item has changed. |
|
|||
123 | */ |
|
|||
124 |
|
||||
125 | /*! |
|
|||
126 | \fn void QBoxSet::valuesChanged() |
|
79 | \fn void QBoxSet::valuesChanged() | |
127 | This signal is emitted when multiple values have been changed on the box-and-whisker item. |
|
80 | This signal is emitted when multiple values have been changed on the box-and-whisker item. | |
128 | \sa append() |
|
81 | \sa append() | |
129 | */ |
|
82 | */ | |
130 | /*! |
|
83 | /*! | |
131 | \qmlsignal BoxSet::onChangedValues() |
|
|||
132 | This signal is emitted when multiple values have been changed on the box-and-whisker item. |
|
|||
133 | */ |
|
|||
134 |
|
||||
135 | /*! |
|
|||
136 | \fn void QBoxSet::valueChanged(int index) |
|
84 | \fn void QBoxSet::valueChanged(int index) | |
137 | This signal is emitted values the value in the box-and-whisker item has been modified. |
|
85 | This signal is emitted values the value in the box-and-whisker item has been modified. | |
138 | Parameter \a index indicates the position of the modified value. |
|
86 | Parameter \a index indicates the position of the modified value. | |
139 | \sa at() |
|
87 | \sa at() | |
140 | */ |
|
88 | */ | |
141 | /*! |
|
89 | /*! | |
142 | \qmlsignal BoxSet::onChangedValue(int index) |
|
|||
143 | This signal is emitted values the value in the box-and-whisker item has been modified. |
|
|||
144 | Parameter \a index indicates the position of the modified value. |
|
|||
145 | */ |
|
|||
146 |
|
||||
147 | /*! |
|
|||
148 | \fn void QBoxSet::cleared() |
|
90 | \fn void QBoxSet::cleared() | |
149 | This signal is emitted when all the values on the set are cleared to 0. |
|
91 | This signal is emitted when all the values on the set are cleared to 0. | |
150 | */ |
|
92 | */ | |
151 | /*! |
|
|||
152 | \qmlsignal BoxSet::onCleared() |
|
|||
153 | This signal is emitted when all the values on the set are cleared to 0. |
|
|||
154 | */ |
|
|||
155 |
|
||||
156 |
|
93 | |||
157 | /*! |
|
94 | /*! | |
158 | Constructs QBoxSet with optional \a label and parent of \a parent |
|
95 | Constructs QBoxSet with optional \a label and parent of \a parent |
@@ -193,6 +193,10 void MainWidget::initCheckboxes(QGridLayout *grid) | |||||
193 | modelMapperCheckBox->setChecked(false); |
|
193 | modelMapperCheckBox->setChecked(false); | |
194 | grid->addWidget(modelMapperCheckBox, m_rowPos++, 0); |
|
194 | grid->addWidget(modelMapperCheckBox, m_rowPos++, 0); | |
195 |
|
195 | |||
|
196 | m_boxOutlined = new QCheckBox("Box outlined"); | |||
|
197 | connect(m_boxOutlined, SIGNAL(toggled(bool)), this, SLOT(boxOutlineToggled(bool))); | |||
|
198 | m_boxOutlined->setChecked(true); | |||
|
199 | grid->addWidget(m_boxOutlined, m_rowPos++, 0); | |||
196 | } |
|
200 | } | |
197 |
|
201 | |||
198 | void MainWidget::updateAxis(int categoryCount) |
|
202 | void MainWidget::updateAxis(int categoryCount) | |
@@ -244,6 +248,8 void MainWidget::addSeries() | |||||
244 | connect(set1, SIGNAL(clicked()), this, SLOT(singleBoxClicked())); |
|
248 | connect(set1, SIGNAL(clicked()), this, SLOT(singleBoxClicked())); | |
245 | connect(set2, SIGNAL(hovered(bool)), this, SLOT(singleBoxHovered(bool))); |
|
249 | connect(set2, SIGNAL(hovered(bool)), this, SLOT(singleBoxHovered(bool))); | |
246 |
|
250 | |||
|
251 | m_series[m_seriesCount]->setBoxOutlineVisible(m_boxOutlined->checkState()); | |||
|
252 | ||||
247 | m_chart->addSeries(m_series[m_seriesCount]); |
|
253 | m_chart->addSeries(m_series[m_seriesCount]); | |
248 |
|
254 | |||
249 | updateAxis(m_series[0]->count()); |
|
255 | updateAxis(m_series[0]->count()); | |
@@ -383,6 +389,13 void MainWidget::antialiasingToggled(bool enabled) | |||||
383 | m_chartView->setRenderHint(QPainter::Antialiasing, enabled); |
|
389 | m_chartView->setRenderHint(QPainter::Antialiasing, enabled); | |
384 | } |
|
390 | } | |
385 |
|
391 | |||
|
392 | void MainWidget::boxOutlineToggled(bool visible) | |||
|
393 | { | |||
|
394 | qDebug() << "BoxPlotTester::boxOutlineToggled toggled to " << visible; | |||
|
395 | for (int i = 0; i < m_seriesCount; i++) | |||
|
396 | m_series[i]->setBoxOutlineVisible(visible); | |||
|
397 | } | |||
|
398 | ||||
386 | void MainWidget::modelMapperToggled(bool enabled) |
|
399 | void MainWidget::modelMapperToggled(bool enabled) | |
387 | { |
|
400 | { | |
388 | if (enabled) { |
|
401 | if (enabled) { | |
@@ -445,5 +458,4 void MainWidget::changePen() | |||||
445 | qDebug() << "changePen() = " << m_penTool->pen(); |
|
458 | qDebug() << "changePen() = " << m_penTool->pen(); | |
446 | for (int i = 0; i < m_seriesCount; i++) |
|
459 | for (int i = 0; i < m_seriesCount; i++) | |
447 | m_series[i]->setPen(m_penTool->pen()); |
|
460 | m_series[i]->setPen(m_penTool->pen()); | |
448 |
|
||||
449 | } |
|
461 | } |
@@ -30,6 +30,7 | |||||
30 | #include <QBoxPlotSeries> |
|
30 | #include <QBoxPlotSeries> | |
31 | #include <QBarCategoryAxis> |
|
31 | #include <QBarCategoryAxis> | |
32 | #include <QBoxSet> |
|
32 | #include <QBoxSet> | |
|
33 | #include <QCheckBox> | |||
33 |
|
34 | |||
34 | class QGridLayout; |
|
35 | class QGridLayout; | |
35 |
|
36 | |||
@@ -68,6 +69,7 private slots: | |||||
68 | void singleBoxHovered(bool state); |
|
69 | void singleBoxHovered(bool state); | |
69 | void changePen(); |
|
70 | void changePen(); | |
70 | void antialiasingToggled(bool); |
|
71 | void antialiasingToggled(bool); | |
|
72 | void boxOutlineToggled(bool); | |||
71 |
|
73 | |||
72 | private: |
|
74 | private: | |
73 | QChart *m_chart; |
|
75 | QChart *m_chart; | |
@@ -79,6 +81,7 private: | |||||
79 | int m_rowPos; |
|
81 | int m_rowPos; | |
80 | int m_seriesCount; |
|
82 | int m_seriesCount; | |
81 | QBoxPlotSeries *m_series[10]; |
|
83 | QBoxPlotSeries *m_series[10]; | |
|
84 | QCheckBox *m_boxOutlined; | |||
82 | }; |
|
85 | }; | |
83 |
|
86 | |||
84 | #endif // MAINWIDGET_H |
|
87 | #endif // MAINWIDGET_H |
General Comments 0
You need to be logged in to leave comments.
Login now