@@ -103,6 +103,7 QVector<QRectF> BarChartItem::calculateLayout() | |||||
103 | // Use temporary qreals for accurancy |
|
103 | // Use temporary qreals for accurancy | |
104 | qreal categoryCount = m_series->categoryCount(); |
|
104 | qreal categoryCount = m_series->categoryCount(); | |
105 | qreal setCount = m_series->barsetCount(); |
|
105 | qreal setCount = m_series->barsetCount(); | |
|
106 | bool barsVisible = m_series->isVisible(); | |||
106 |
|
107 | |||
107 | // Domain: |
|
108 | // Domain: | |
108 | qreal width = geometry().width(); |
|
109 | qreal width = geometry().width(); | |
@@ -128,6 +129,7 QVector<QRectF> BarChartItem::calculateLayout() | |||||
128 | layout.append(rect); |
|
129 | layout.append(rect); | |
129 | bar->setPen(barSet->pen()); |
|
130 | bar->setPen(barSet->pen()); | |
130 | bar->setBrush(barSet->brush()); |
|
131 | bar->setBrush(barSet->brush()); | |
|
132 | bar->setVisible(barsVisible); | |||
131 |
|
133 | |||
132 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
134 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
133 |
|
135 |
@@ -113,6 +113,12 void QBarSeries::setBarMargin(qreal margin) | |||||
113 | d->setBarMargin(margin); |
|
113 | d->setBarMargin(margin); | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
|
116 | qreal QBarSeries::barMargin() const | |||
|
117 | { | |||
|
118 | Q_D(const QBarSeries); | |||
|
119 | return d->barMargin(); | |||
|
120 | } | |||
|
121 | ||||
116 | /*! |
|
122 | /*! | |
117 | Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. |
|
123 | Adds a set of bars to series. Takes ownership of \a set. If the set is null or is already in series, it won't be appended. | |
118 | Returns true, if appending succeeded. |
|
124 | Returns true, if appending succeeded. | |
@@ -191,6 +197,18 QBarCategories QBarSeries::categories() const | |||||
191 | return d->categories(); |
|
197 | return d->categories(); | |
192 | } |
|
198 | } | |
193 |
|
199 | |||
|
200 | void QBarSeries::setVisible(bool visible) | |||
|
201 | { | |||
|
202 | Q_D(QBarSeries); | |||
|
203 | d->setVisible(visible); | |||
|
204 | } | |||
|
205 | ||||
|
206 | bool QBarSeries::isVisible() const | |||
|
207 | { | |||
|
208 | Q_D(const QBarSeries); | |||
|
209 | return d->isVisible(); | |||
|
210 | } | |||
|
211 | ||||
194 | /*! |
|
212 | /*! | |
195 | Sets the visibility of labels in series to \a visible |
|
213 | Sets the visibility of labels in series to \a visible | |
196 | */ |
|
214 | */ | |
@@ -214,7 +232,8 bool QBarSeries::isLabelsVisible() const | |||||
214 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : |
|
232 | QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : | |
215 | QAbstractSeriesPrivate(q), |
|
233 | QAbstractSeriesPrivate(q), | |
216 | m_barMargin(0.05), // Default value is 5% of category width |
|
234 | m_barMargin(0.05), // Default value is 5% of category width | |
217 | m_labelsVisible(false) |
|
235 | m_labelsVisible(false), | |
|
236 | m_visible(true) | |||
218 | { |
|
237 | { | |
219 | } |
|
238 | } | |
220 |
|
239 | |||
@@ -280,7 +299,7 void QBarSeriesPrivate::setBarMargin(qreal margin) | |||||
280 | emit updatedBars(); |
|
299 | emit updatedBars(); | |
281 | } |
|
300 | } | |
282 |
|
301 | |||
283 | qreal QBarSeriesPrivate::barMargin() |
|
302 | qreal QBarSeriesPrivate::barMargin() const | |
284 | { |
|
303 | { | |
285 | return m_barMargin; |
|
304 | return m_barMargin; | |
286 | } |
|
305 | } | |
@@ -290,6 +309,19 QBarSet* QBarSeriesPrivate::barsetAt(int index) | |||||
290 | return m_barSets.at(index); |
|
309 | return m_barSets.at(index); | |
291 | } |
|
310 | } | |
292 |
|
311 | |||
|
312 | void QBarSeriesPrivate::setVisible(bool visible) | |||
|
313 | { | |||
|
314 | if (m_visible != visible) { | |||
|
315 | m_visible = visible; | |||
|
316 | emit updatedBars(); | |||
|
317 | } | |||
|
318 | } | |||
|
319 | ||||
|
320 | bool QBarSeriesPrivate::isVisible() const | |||
|
321 | { | |||
|
322 | return m_visible; | |||
|
323 | } | |||
|
324 | ||||
293 | QString QBarSeriesPrivate::categoryName(int category) |
|
325 | QString QBarSeriesPrivate::categoryName(int category) | |
294 | { |
|
326 | { | |
295 | if ((category >= 0) && (category < m_categories.count())) { |
|
327 | if ((category >= 0) && (category < m_categories.count())) { |
@@ -44,6 +44,7 public: | |||||
44 | void setCategories(QBarCategories categories); |
|
44 | void setCategories(QBarCategories categories); | |
45 |
|
45 | |||
46 | void setBarMargin(qreal margin); |
|
46 | void setBarMargin(qreal margin); | |
|
47 | qreal barMargin() const; | |||
47 |
|
48 | |||
48 | bool append(QBarSet *set); |
|
49 | bool append(QBarSet *set); | |
49 | bool remove(QBarSet *set); |
|
50 | bool remove(QBarSet *set); | |
@@ -54,6 +55,8 public: | |||||
54 | QList<QBarSet*> barSets() const; |
|
55 | QList<QBarSet*> barSets() const; | |
55 | QBarCategories categories() const; |
|
56 | QBarCategories categories() const; | |
56 |
|
57 | |||
|
58 | void setVisible(bool visible = true); | |||
|
59 | bool isVisible() const; | |||
57 | void setLabelsVisible(bool visible = true); |
|
60 | void setLabelsVisible(bool visible = true); | |
58 | bool isLabelsVisible() const; |
|
61 | bool isLabelsVisible() const; | |
59 |
|
62 |
@@ -51,7 +51,10 public: | |||||
51 | QBarCategories categories() const; |
|
51 | QBarCategories categories() const; | |
52 |
|
52 | |||
53 | void setBarMargin(qreal margin); |
|
53 | void setBarMargin(qreal margin); | |
54 | qreal barMargin(); |
|
54 | qreal barMargin() const; | |
|
55 | ||||
|
56 | void setVisible(bool visible); | |||
|
57 | bool isVisible() const; | |||
55 |
|
58 | |||
56 | void scaleDomain(Domain& domain); |
|
59 | void scaleDomain(Domain& domain); | |
57 | Chart* createGraphics(ChartPresenter* presenter); |
|
60 | Chart* createGraphics(ChartPresenter* presenter); | |
@@ -87,6 +90,7 protected: | |||||
87 | QBarCategories m_categories; |
|
90 | QBarCategories m_categories; | |
88 | qreal m_barMargin; |
|
91 | qreal m_barMargin; | |
89 | bool m_labelsVisible; |
|
92 | bool m_labelsVisible; | |
|
93 | bool m_visible; | |||
90 |
|
94 | |||
91 | private: |
|
95 | private: | |
92 | Q_DECLARE_PUBLIC(QBarSeries) |
|
96 | Q_DECLARE_PUBLIC(QBarSeries) |
General Comments 0
You need to be logged in to leave comments.
Login now