@@ -1,213 +1,215 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "barchartitem_p.h" |
|
21 | #include "barchartitem_p.h" | |
22 | #include "bar_p.h" |
|
22 | #include "bar_p.h" | |
23 | #include "qbarset.h" |
|
23 | #include "qbarset.h" | |
24 | #include "qbarset_p.h" |
|
24 | #include "qbarset_p.h" | |
25 | #include "qbarseries.h" |
|
25 | #include "qbarseries.h" | |
26 | #include "qbarseries_p.h" |
|
26 | #include "qbarseries_p.h" | |
27 | #include "qchart.h" |
|
27 | #include "qchart.h" | |
28 | #include "chartpresenter_p.h" |
|
28 | #include "chartpresenter_p.h" | |
29 | #include "chartanimator_p.h" |
|
29 | #include "chartanimator_p.h" | |
30 | #include "chartdataset_p.h" |
|
30 | #include "chartdataset_p.h" | |
31 | #include <QPainter> |
|
31 | #include <QPainter> | |
32 |
|
32 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
34 | |||
35 | BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : |
|
35 | BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : | |
36 | ChartItem(presenter), |
|
36 | ChartItem(presenter), | |
37 | m_series(series) |
|
37 | m_series(series) | |
38 | { |
|
38 | { | |
39 | setFlag(ItemClipsChildrenToShape); |
|
39 | setFlag(ItemClipsChildrenToShape); | |
40 | connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); |
|
40 | connect(series->d_func(), SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); | |
41 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleModelChanged())); |
|
41 | connect(series->d_func(), SIGNAL(restructuredBars()), this, SLOT(handleModelChanged())); | |
42 | connect(series->d_func(), SIGNAL(labelsVisibleChanged(bool)), this, SLOT(labelsVisibleChanged(bool))); |
|
42 | connect(series->d_func(), SIGNAL(labelsVisibleChanged(bool)), this, SLOT(labelsVisibleChanged(bool))); | |
43 | setZValue(ChartPresenter::BarSeriesZValue); |
|
43 | setZValue(ChartPresenter::BarSeriesZValue); | |
44 | dataChanged(); |
|
44 | dataChanged(); | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | BarChartItem::~BarChartItem() |
|
47 | BarChartItem::~BarChartItem() | |
48 | { |
|
48 | { | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
51 | void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
52 | { |
|
52 | { | |
53 | Q_UNUSED(painter); |
|
53 | Q_UNUSED(painter); | |
54 | Q_UNUSED(option); |
|
54 | Q_UNUSED(option); | |
55 | Q_UNUSED(widget); |
|
55 | Q_UNUSED(widget); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | QRectF BarChartItem::boundingRect() const |
|
58 | QRectF BarChartItem::boundingRect() const | |
59 | { |
|
59 | { | |
60 | return m_rect; |
|
60 | return m_rect; | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | void BarChartItem::dataChanged() |
|
63 | void BarChartItem::dataChanged() | |
64 | { |
|
64 | { | |
65 | foreach(QGraphicsItem *item, childItems()) { |
|
65 | foreach(QGraphicsItem *item, childItems()) { | |
66 | delete item; |
|
66 | delete item; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | m_bars.clear(); |
|
69 | m_bars.clear(); | |
70 | m_labels.clear(); |
|
70 | m_labels.clear(); | |
71 | m_layout.clear(); |
|
71 | m_layout.clear(); | |
72 |
|
72 | |||
73 | bool labelsVisible = m_series->isLabelsVisible(); |
|
73 | bool labelsVisible = m_series->isLabelsVisible(); | |
74 |
|
74 | |||
75 | // Create new graphic items for bars |
|
75 | // Create new graphic items for bars | |
76 | for (int c = 0; c < m_series->categoryCount(); c++) { |
|
76 | for (int c = 0; c < m_series->categoryCount(); c++) { | |
77 | QString category = m_series->d_func()->categoryName(c); |
|
77 | QString category = m_series->d_func()->categoryName(c); | |
78 | for (int s = 0; s < m_series->barsetCount(); s++) { |
|
78 | for (int s = 0; s < m_series->barsetCount(); s++) { | |
79 | QBarSet *set = m_series->d_func()->barsetAt(s); |
|
79 | QBarSet *set = m_series->d_func()->barsetAt(s); | |
80 |
|
80 | |||
81 | // Bars |
|
81 | // Bars | |
82 | Bar *bar = new Bar(set,category,this); |
|
82 | Bar *bar = new Bar(set,category,this); | |
83 | m_bars.append(bar); |
|
83 | m_bars.append(bar); | |
84 | connect(bar, SIGNAL(clicked(QBarSet*,QString)), m_series, SIGNAL(clicked(QBarSet*,QString))); |
|
84 | connect(bar, SIGNAL(clicked(QBarSet*,QString)), m_series, SIGNAL(clicked(QBarSet*,QString))); | |
85 | connect(bar, SIGNAL(hovered(QBarSet*,bool)), m_series, SIGNAL(hovered(QBarSet*,bool))); |
|
85 | connect(bar, SIGNAL(hovered(QBarSet*,bool)), m_series, SIGNAL(hovered(QBarSet*,bool))); | |
86 | m_layout.append(QRectF(0, 0, 0, 0)); |
|
86 | m_layout.append(QRectF(0, 0, 0, 0)); | |
87 |
|
87 | |||
88 | // Labels |
|
88 | // Labels | |
89 | QGraphicsSimpleTextItem *label = new QGraphicsSimpleTextItem(this); |
|
89 | QGraphicsSimpleTextItem *label = new QGraphicsSimpleTextItem(this); | |
90 | label->setVisible(labelsVisible); |
|
90 | label->setVisible(labelsVisible); | |
91 | m_labels.append(label); |
|
91 | m_labels.append(label); | |
92 | } |
|
92 | } | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | // TODO: Is this the right place to call it? |
|
95 | // TODO: Is this the right place to call it? | |
96 | // presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series)); |
|
96 | // presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series)); | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | QVector<QRectF> BarChartItem::calculateLayout() |
|
99 | QVector<QRectF> BarChartItem::calculateLayout() | |
100 | { |
|
100 | { | |
101 | QVector<QRectF> layout; |
|
101 | QVector<QRectF> layout; | |
102 |
|
102 | |||
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(); | |
109 | qreal height = geometry().height(); |
|
110 | qreal height = geometry().height(); | |
110 | qreal rangeY = m_domainMaxY - m_domainMinY; |
|
111 | qreal rangeY = m_domainMaxY - m_domainMinY; | |
111 | qreal rangeX = m_domainMaxX - m_domainMinX; |
|
112 | qreal rangeX = m_domainMaxX - m_domainMinX; | |
112 | qreal scaleY = (height / rangeY); |
|
113 | qreal scaleY = (height / rangeY); | |
113 | qreal scaleX = (width / rangeX); |
|
114 | qreal scaleX = (width / rangeX); | |
114 | qreal categoryWidth = width / categoryCount; |
|
115 | qreal categoryWidth = width / categoryCount; | |
115 | qreal barWidth = categoryWidth / setCount - categoryWidth * m_series->d_func()->barMargin(); |
|
116 | qreal barWidth = categoryWidth / setCount - categoryWidth * m_series->d_func()->barMargin(); | |
116 |
|
117 | |||
117 | int itemIndex(0); |
|
118 | int itemIndex(0); | |
118 | for (int category = 0; category < categoryCount; category++) { |
|
119 | for (int category = 0; category < categoryCount; category++) { | |
119 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); |
|
120 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); | |
120 | for (int set = 0; set < setCount; set++) { |
|
121 | for (int set = 0; set < setCount; set++) { | |
121 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
122 | QBarSet* barSet = m_series->d_func()->barsetAt(set); | |
122 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; |
|
123 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; | |
123 | qreal barHeight = barSet->at(category).y() * scaleY; |
|
124 | qreal barHeight = barSet->at(category).y() * scaleY; | |
124 |
|
125 | |||
125 | Bar* bar = m_bars.at(itemIndex); |
|
126 | Bar* bar = m_bars.at(itemIndex); | |
126 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); |
|
127 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); | |
127 |
|
128 | |||
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 | |||
134 | if (!qFuzzyIsNull(barSet->at(category).y())) { |
|
136 | if (!qFuzzyIsNull(barSet->at(category).y())) { | |
135 | label->setText(QString::number(barSet->at(category).y())); |
|
137 | label->setText(QString::number(barSet->at(category).y())); | |
136 | } else { |
|
138 | } else { | |
137 | label->setText(QString("")); |
|
139 | label->setText(QString("")); | |
138 | } |
|
140 | } | |
139 |
|
141 | |||
140 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) |
|
142 | label->setPos(xPos + (rect.width()/2 - label->boundingRect().width()/2) | |
141 | ,yPos - barHeight/2 - label->boundingRect().height()/2); |
|
143 | ,yPos - barHeight/2 - label->boundingRect().height()/2); | |
142 | label->setFont(barSet->labelFont()); |
|
144 | label->setFont(barSet->labelFont()); | |
143 |
|
145 | |||
144 | itemIndex++; |
|
146 | itemIndex++; | |
145 | } |
|
147 | } | |
146 | } |
|
148 | } | |
147 |
|
149 | |||
148 | return layout; |
|
150 | return layout; | |
149 | } |
|
151 | } | |
150 |
|
152 | |||
151 | void BarChartItem::applyLayout(const QVector<QRectF> &layout) |
|
153 | void BarChartItem::applyLayout(const QVector<QRectF> &layout) | |
152 | { |
|
154 | { | |
153 | if (animator()) |
|
155 | if (animator()) | |
154 | animator()->updateLayout(this, m_layout, layout); |
|
156 | animator()->updateLayout(this, m_layout, layout); | |
155 | else |
|
157 | else | |
156 | setLayout(layout); |
|
158 | setLayout(layout); | |
157 | } |
|
159 | } | |
158 |
|
160 | |||
159 | void BarChartItem::setLayout(const QVector<QRectF> &layout) |
|
161 | void BarChartItem::setLayout(const QVector<QRectF> &layout) | |
160 | { |
|
162 | { | |
161 | m_layout = layout; |
|
163 | m_layout = layout; | |
162 |
|
164 | |||
163 | for (int i=0; i < m_bars.count(); i++) |
|
165 | for (int i=0; i < m_bars.count(); i++) | |
164 | m_bars.at(i)->setRect(layout.at(i)); |
|
166 | m_bars.at(i)->setRect(layout.at(i)); | |
165 |
|
167 | |||
166 | update(); |
|
168 | update(); | |
167 | } |
|
169 | } | |
168 | //handlers |
|
170 | //handlers | |
169 |
|
171 | |||
170 | void BarChartItem::handleModelChanged() |
|
172 | void BarChartItem::handleModelChanged() | |
171 | { |
|
173 | { | |
172 | // dataChanged(); |
|
174 | // dataChanged(); | |
173 | presenter()->resetAllElements(); |
|
175 | presenter()->resetAllElements(); | |
174 | } |
|
176 | } | |
175 |
|
177 | |||
176 | void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) |
|
178 | void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) | |
177 | { |
|
179 | { | |
178 | m_domainMinX = minX; |
|
180 | m_domainMinX = minX; | |
179 | m_domainMaxX = maxX; |
|
181 | m_domainMaxX = maxX; | |
180 | m_domainMinY = minY; |
|
182 | m_domainMinY = minY; | |
181 | m_domainMaxY = maxY; |
|
183 | m_domainMaxY = maxY; | |
182 | handleLayoutChanged(); |
|
184 | handleLayoutChanged(); | |
183 | } |
|
185 | } | |
184 |
|
186 | |||
185 | void BarChartItem::handleGeometryChanged(const QRectF &rect) |
|
187 | void BarChartItem::handleGeometryChanged(const QRectF &rect) | |
186 | { |
|
188 | { | |
187 | prepareGeometryChange(); |
|
189 | prepareGeometryChange(); | |
188 | m_rect = rect; |
|
190 | m_rect = rect; | |
189 | handleLayoutChanged(); |
|
191 | handleLayoutChanged(); | |
190 | } |
|
192 | } | |
191 |
|
193 | |||
192 | void BarChartItem::handleLayoutChanged() |
|
194 | void BarChartItem::handleLayoutChanged() | |
193 | { |
|
195 | { | |
194 | if ((m_rect.width() <= 0) || (m_rect.height() <= 0)) { |
|
196 | if ((m_rect.width() <= 0) || (m_rect.height() <= 0)) { | |
195 | // rect size zero. |
|
197 | // rect size zero. | |
196 | return; |
|
198 | return; | |
197 | } |
|
199 | } | |
198 | QVector<QRectF> layout = calculateLayout(); |
|
200 | QVector<QRectF> layout = calculateLayout(); | |
199 | applyLayout(layout); |
|
201 | applyLayout(layout); | |
200 | update(); |
|
202 | update(); | |
201 | } |
|
203 | } | |
202 |
|
204 | |||
203 | void BarChartItem::labelsVisibleChanged(bool visible) |
|
205 | void BarChartItem::labelsVisibleChanged(bool visible) | |
204 | { |
|
206 | { | |
205 | foreach (QGraphicsSimpleTextItem* label, m_labels) { |
|
207 | foreach (QGraphicsSimpleTextItem* label, m_labels) { | |
206 | label->setVisible(visible); |
|
208 | label->setVisible(visible); | |
207 | } |
|
209 | } | |
208 | update(); |
|
210 | update(); | |
209 | } |
|
211 | } | |
210 |
|
212 | |||
211 | #include "moc_barchartitem_p.cpp" |
|
213 | #include "moc_barchartitem_p.cpp" | |
212 |
|
214 | |||
213 | QTCOMMERCIALCHART_END_NAMESPACE |
|
215 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,536 +1,568 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qbarseries.h" |
|
21 | #include "qbarseries.h" | |
22 | #include "qbarseries_p.h" |
|
22 | #include "qbarseries_p.h" | |
23 | #include "qbarset.h" |
|
23 | #include "qbarset.h" | |
24 | #include "qbarset_p.h" |
|
24 | #include "qbarset_p.h" | |
25 | #include "domain_p.h" |
|
25 | #include "domain_p.h" | |
26 | #include "legendmarker_p.h" |
|
26 | #include "legendmarker_p.h" | |
27 | #include "chartdataset_p.h" |
|
27 | #include "chartdataset_p.h" | |
28 | #include "charttheme_p.h" |
|
28 | #include "charttheme_p.h" | |
29 | #include "chartanimator_p.h" |
|
29 | #include "chartanimator_p.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \class QBarSeries |
|
34 | \class QBarSeries | |
35 | \brief part of QtCommercial chart API. |
|
35 | \brief part of QtCommercial chart API. | |
36 | \mainclass |
|
36 | \mainclass | |
37 |
|
37 | |||
38 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to |
|
38 | QBarSeries represents a series of data shown as bars. The purpose of this class is to draw bars to | |
39 | the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar |
|
39 | the position defined by data. Single bar is defined by QPointF, where x value is the x-coordinate of the bar | |
40 | and y-value is the height of the bar. The category names are ignored with this series and x-axis |
|
40 | and y-value is the height of the bar. The category names are ignored with this series and x-axis | |
41 | shows the x-values. |
|
41 | shows the x-values. | |
42 |
|
42 | |||
43 | See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart. |
|
43 | See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart. | |
44 | \image examples_barchart.png |
|
44 | \image examples_barchart.png | |
45 |
|
45 | |||
46 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries |
|
46 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \fn void QBarSeries::clicked(QBarSet *barset, QString category) |
|
50 | \fn void QBarSeries::clicked(QBarSet *barset, QString category) | |
51 |
|
51 | |||
52 | The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset of category \a category |
|
52 | The signal is emitted if the user clicks with a mouse on top of QBarSet \a barset of category \a category | |
53 | contained by the series. |
|
53 | contained by the series. | |
54 | */ |
|
54 | */ | |
55 |
|
55 | |||
56 | /*! |
|
56 | /*! | |
57 | \fn void QBarSeries::hovered(QBarSet* barset, bool status) |
|
57 | \fn void QBarSeries::hovered(QBarSet* barset, bool status) | |
58 |
|
58 | |||
59 | The signal is emitted if mouse is hovered on top of series. |
|
59 | The signal is emitted if mouse is hovered on top of series. | |
60 | Parameter \a barset is the pointer of barset, where hover happened. |
|
60 | Parameter \a barset is the pointer of barset, where hover happened. | |
61 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
61 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | Constructs empty QBarSeries. |
|
65 | Constructs empty QBarSeries. | |
66 | QBarSeries is QObject which is a child of a \a parent. |
|
66 | QBarSeries is QObject which is a child of a \a parent. | |
67 | */ |
|
67 | */ | |
68 | QBarSeries::QBarSeries(QObject *parent) : |
|
68 | QBarSeries::QBarSeries(QObject *parent) : | |
69 | QAbstractSeries(*new QBarSeriesPrivate(this),parent) |
|
69 | QAbstractSeries(*new QBarSeriesPrivate(this),parent) | |
70 | { |
|
70 | { | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | Destructs barseries and owned barsets. |
|
74 | Destructs barseries and owned barsets. | |
75 | */ |
|
75 | */ | |
76 | QBarSeries::~QBarSeries() |
|
76 | QBarSeries::~QBarSeries() | |
77 | { |
|
77 | { | |
78 | Q_D(QBarSeries); |
|
78 | Q_D(QBarSeries); | |
79 | if(d->m_dataset){ |
|
79 | if(d->m_dataset){ | |
80 | d->m_dataset->removeSeries(this); |
|
80 | d->m_dataset->removeSeries(this); | |
81 | } |
|
81 | } | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | /*! |
|
84 | /*! | |
85 | \internal |
|
85 | \internal | |
86 | */ |
|
86 | */ | |
87 | QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) : |
|
87 | QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) : | |
88 | QAbstractSeries(d,parent) |
|
88 | QAbstractSeries(d,parent) | |
89 | { |
|
89 | { | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | /*! |
|
92 | /*! | |
93 | Returns the type of series. Derived classes override this. |
|
93 | Returns the type of series. Derived classes override this. | |
94 | */ |
|
94 | */ | |
95 | QAbstractSeries::SeriesType QBarSeries::type() const |
|
95 | QAbstractSeries::SeriesType QBarSeries::type() const | |
96 | { |
|
96 | { | |
97 | return QAbstractSeries::SeriesTypeBar; |
|
97 | return QAbstractSeries::SeriesTypeBar; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | /*! |
|
100 | /*! | |
101 | Sets the \a categories, which are used to to group the data. |
|
101 | Sets the \a categories, which are used to to group the data. | |
102 | */ |
|
102 | */ | |
103 | void QBarSeries::setCategories(QBarCategories categories) |
|
103 | void QBarSeries::setCategories(QBarCategories categories) | |
104 | { |
|
104 | { | |
105 | Q_D(QBarSeries); |
|
105 | Q_D(QBarSeries); | |
106 | d->setCategories(categories); |
|
106 | d->setCategories(categories); | |
107 | emit d->categoriesUpdated(); |
|
107 | emit d->categoriesUpdated(); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | void QBarSeries::setBarMargin(qreal margin) |
|
110 | void QBarSeries::setBarMargin(qreal margin) | |
111 | { |
|
111 | { | |
112 | Q_D(QBarSeries); |
|
112 | Q_D(QBarSeries); | |
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. | |
119 |
|
125 | |||
120 | */ |
|
126 | */ | |
121 | bool QBarSeries::append(QBarSet *set) |
|
127 | bool QBarSeries::append(QBarSet *set) | |
122 | { |
|
128 | { | |
123 | Q_D(QBarSeries); |
|
129 | Q_D(QBarSeries); | |
124 | return d->append(set); |
|
130 | return d->append(set); | |
125 | } |
|
131 | } | |
126 |
|
132 | |||
127 | /*! |
|
133 | /*! | |
128 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. |
|
134 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. | |
129 | Returns true, if set was removed. |
|
135 | Returns true, if set was removed. | |
130 | */ |
|
136 | */ | |
131 | bool QBarSeries::remove(QBarSet *set) |
|
137 | bool QBarSeries::remove(QBarSet *set) | |
132 | { |
|
138 | { | |
133 | Q_D(QBarSeries); |
|
139 | Q_D(QBarSeries); | |
134 | return d->remove(set); |
|
140 | return d->remove(set); | |
135 | } |
|
141 | } | |
136 |
|
142 | |||
137 | /*! |
|
143 | /*! | |
138 | Adds a list of barsets to series. Takes ownership of \a sets. |
|
144 | Adds a list of barsets to series. Takes ownership of \a sets. | |
139 | Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series, |
|
145 | Returns true, if all sets were appended succesfully. If any of the sets is null or is already appended to series, | |
140 | nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended |
|
146 | nothing is appended and function returns false. If any of the sets is in list more than once, nothing is appended | |
141 | and function returns false. |
|
147 | and function returns false. | |
142 | */ |
|
148 | */ | |
143 | bool QBarSeries::append(QList<QBarSet* > sets) |
|
149 | bool QBarSeries::append(QList<QBarSet* > sets) | |
144 | { |
|
150 | { | |
145 | Q_D(QBarSeries); |
|
151 | Q_D(QBarSeries); | |
146 | return d->append(sets); |
|
152 | return d->append(sets); | |
147 | } |
|
153 | } | |
148 |
|
154 | |||
149 | /*! |
|
155 | /*! | |
150 | Removes a list of barsets from series. Releases ownership of \a sets. Doesn't delete \a sets. |
|
156 | Removes a list of barsets from series. Releases ownership of \a sets. Doesn't delete \a sets. | |
151 | */ |
|
157 | */ | |
152 | bool QBarSeries::remove(QList<QBarSet* > sets) |
|
158 | bool QBarSeries::remove(QList<QBarSet* > sets) | |
153 | { |
|
159 | { | |
154 | Q_D(QBarSeries); |
|
160 | Q_D(QBarSeries); | |
155 | return d->remove(sets); |
|
161 | return d->remove(sets); | |
156 | } |
|
162 | } | |
157 |
|
163 | |||
158 | /*! |
|
164 | /*! | |
159 | Returns number of sets in series. |
|
165 | Returns number of sets in series. | |
160 | */ |
|
166 | */ | |
161 | int QBarSeries::barsetCount() const |
|
167 | int QBarSeries::barsetCount() const | |
162 | { |
|
168 | { | |
163 | Q_D(const QBarSeries); |
|
169 | Q_D(const QBarSeries); | |
164 | return d->m_barSets.count(); |
|
170 | return d->m_barSets.count(); | |
165 | } |
|
171 | } | |
166 |
|
172 | |||
167 | /*! |
|
173 | /*! | |
168 | Returns number of categories in series |
|
174 | Returns number of categories in series | |
169 | */ |
|
175 | */ | |
170 | int QBarSeries::categoryCount() const |
|
176 | int QBarSeries::categoryCount() const | |
171 | { |
|
177 | { | |
172 | Q_D(const QBarSeries); |
|
178 | Q_D(const QBarSeries); | |
173 | return d->categoryCount(); |
|
179 | return d->categoryCount(); | |
174 | } |
|
180 | } | |
175 |
|
181 | |||
176 | /*! |
|
182 | /*! | |
177 | Returns a list of sets in series. Keeps ownership of sets. |
|
183 | Returns a list of sets in series. Keeps ownership of sets. | |
178 | */ |
|
184 | */ | |
179 | QList<QBarSet*> QBarSeries::barSets() const |
|
185 | QList<QBarSet*> QBarSeries::barSets() const | |
180 | { |
|
186 | { | |
181 | Q_D(const QBarSeries); |
|
187 | Q_D(const QBarSeries); | |
182 | return d->m_barSets; |
|
188 | return d->m_barSets; | |
183 | } |
|
189 | } | |
184 |
|
190 | |||
185 | /*! |
|
191 | /*! | |
186 | Returns the bar categories of the series. |
|
192 | Returns the bar categories of the series. | |
187 | */ |
|
193 | */ | |
188 | QBarCategories QBarSeries::categories() const |
|
194 | QBarCategories QBarSeries::categories() const | |
189 | { |
|
195 | { | |
190 | Q_D(const QBarSeries); |
|
196 | Q_D(const QBarSeries); | |
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 | */ | |
197 | void QBarSeries::setLabelsVisible(bool visible) |
|
215 | void QBarSeries::setLabelsVisible(bool visible) | |
198 | { |
|
216 | { | |
199 | Q_D(QBarSeries); |
|
217 | Q_D(QBarSeries); | |
200 | if (d->m_labelsVisible != visible) { |
|
218 | if (d->m_labelsVisible != visible) { | |
201 | d->m_labelsVisible = visible; |
|
219 | d->m_labelsVisible = visible; | |
202 | emit d->updatedBars(); |
|
220 | emit d->updatedBars(); | |
203 | } |
|
221 | } | |
204 | } |
|
222 | } | |
205 |
|
223 | |||
206 | bool QBarSeries::isLabelsVisible() const |
|
224 | bool QBarSeries::isLabelsVisible() const | |
207 | { |
|
225 | { | |
208 | Q_D(const QBarSeries); |
|
226 | Q_D(const QBarSeries); | |
209 | return d->m_labelsVisible; |
|
227 | return d->m_labelsVisible; | |
210 | } |
|
228 | } | |
211 |
|
229 | |||
212 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
230 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
213 |
|
231 | |||
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 | |||
221 | void QBarSeriesPrivate::setCategories(QBarCategories categories) |
|
240 | void QBarSeriesPrivate::setCategories(QBarCategories categories) | |
222 | { |
|
241 | { | |
223 | m_categories = categories; |
|
242 | m_categories = categories; | |
224 | } |
|
243 | } | |
225 |
|
244 | |||
226 | void QBarSeriesPrivate::insertCategory(int index, const QString category) |
|
245 | void QBarSeriesPrivate::insertCategory(int index, const QString category) | |
227 | { |
|
246 | { | |
228 | m_categories.insert(index, category); |
|
247 | m_categories.insert(index, category); | |
229 | emit categoriesUpdated(); |
|
248 | emit categoriesUpdated(); | |
230 | } |
|
249 | } | |
231 |
|
250 | |||
232 | void QBarSeriesPrivate::removeCategory(int index) |
|
251 | void QBarSeriesPrivate::removeCategory(int index) | |
233 | { |
|
252 | { | |
234 | m_categories.removeAt(index); |
|
253 | m_categories.removeAt(index); | |
235 | emit categoriesUpdated(); |
|
254 | emit categoriesUpdated(); | |
236 | } |
|
255 | } | |
237 |
|
256 | |||
238 | int QBarSeriesPrivate::categoryCount() const |
|
257 | int QBarSeriesPrivate::categoryCount() const | |
239 | { |
|
258 | { | |
240 | if (m_categories.count() > 0) { |
|
259 | if (m_categories.count() > 0) { | |
241 | return m_categories.count(); |
|
260 | return m_categories.count(); | |
242 | } |
|
261 | } | |
243 |
|
262 | |||
244 | // No categories defined. return count of longest set. |
|
263 | // No categories defined. return count of longest set. | |
245 | int count = 0; |
|
264 | int count = 0; | |
246 | for (int i=0; i<m_barSets.count(); i++) { |
|
265 | for (int i=0; i<m_barSets.count(); i++) { | |
247 | if (m_barSets.at(i)->count() > count) { |
|
266 | if (m_barSets.at(i)->count() > count) { | |
248 | count = m_barSets.at(i)->count(); |
|
267 | count = m_barSets.at(i)->count(); | |
249 | } |
|
268 | } | |
250 | } |
|
269 | } | |
251 |
|
270 | |||
252 | return count; |
|
271 | return count; | |
253 | } |
|
272 | } | |
254 |
|
273 | |||
255 | QBarCategories QBarSeriesPrivate::categories() const |
|
274 | QBarCategories QBarSeriesPrivate::categories() const | |
256 | { |
|
275 | { | |
257 | if (m_categories.count() > 0) { |
|
276 | if (m_categories.count() > 0) { | |
258 | return m_categories; |
|
277 | return m_categories; | |
259 | } |
|
278 | } | |
260 |
|
279 | |||
261 | // No categories defined. retun list of indices. |
|
280 | // No categories defined. retun list of indices. | |
262 | QBarCategories categories; |
|
281 | QBarCategories categories; | |
263 |
|
282 | |||
264 | int count = categoryCount(); |
|
283 | int count = categoryCount(); | |
265 | for (int i = 0; i < count; i++) { |
|
284 | for (int i = 0; i < count; i++) { | |
266 | categories.append(QString::number(i)); |
|
285 | categories.append(QString::number(i)); | |
267 | } |
|
286 | } | |
268 | return categories; |
|
287 | return categories; | |
269 | } |
|
288 | } | |
270 |
|
289 | |||
271 | void QBarSeriesPrivate::setBarMargin(qreal margin) |
|
290 | void QBarSeriesPrivate::setBarMargin(qreal margin) | |
272 | { |
|
291 | { | |
273 | if (margin > 1.0) { |
|
292 | if (margin > 1.0) { | |
274 | margin = 1.0; |
|
293 | margin = 1.0; | |
275 | } else if (margin < 0.0) { |
|
294 | } else if (margin < 0.0) { | |
276 | margin = 0.0; |
|
295 | margin = 0.0; | |
277 | } |
|
296 | } | |
278 |
|
297 | |||
279 | m_barMargin = margin; |
|
298 | m_barMargin = 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 | } | |
287 |
|
306 | |||
288 | QBarSet* QBarSeriesPrivate::barsetAt(int index) |
|
307 | QBarSet* QBarSeriesPrivate::barsetAt(int index) | |
289 | { |
|
308 | { | |
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())) { | |
296 | return m_categories.at(category); |
|
328 | return m_categories.at(category); | |
297 | } |
|
329 | } | |
298 |
|
330 | |||
299 | return QString::number(category); |
|
331 | return QString::number(category); | |
300 | } |
|
332 | } | |
301 |
|
333 | |||
302 | qreal QBarSeriesPrivate::min() |
|
334 | qreal QBarSeriesPrivate::min() | |
303 | { |
|
335 | { | |
304 | if (m_barSets.count() <= 0) { |
|
336 | if (m_barSets.count() <= 0) { | |
305 | return 0; |
|
337 | return 0; | |
306 | } |
|
338 | } | |
307 | qreal min = INT_MAX; |
|
339 | qreal min = INT_MAX; | |
308 |
|
340 | |||
309 | for (int i = 0; i < m_barSets.count(); i++) { |
|
341 | for (int i = 0; i < m_barSets.count(); i++) { | |
310 | int categoryCount = m_barSets.at(i)->count(); |
|
342 | int categoryCount = m_barSets.at(i)->count(); | |
311 | for (int j = 0; j < categoryCount; j++) { |
|
343 | for (int j = 0; j < categoryCount; j++) { | |
312 | qreal temp = m_barSets.at(i)->at(j).y(); |
|
344 | qreal temp = m_barSets.at(i)->at(j).y(); | |
313 | if (temp < min) |
|
345 | if (temp < min) | |
314 | min = temp; |
|
346 | min = temp; | |
315 | } |
|
347 | } | |
316 | } |
|
348 | } | |
317 | return min; |
|
349 | return min; | |
318 | } |
|
350 | } | |
319 |
|
351 | |||
320 | qreal QBarSeriesPrivate::max() |
|
352 | qreal QBarSeriesPrivate::max() | |
321 | { |
|
353 | { | |
322 | if (m_barSets.count() <= 0) { |
|
354 | if (m_barSets.count() <= 0) { | |
323 | return 0; |
|
355 | return 0; | |
324 | } |
|
356 | } | |
325 | qreal max = INT_MIN; |
|
357 | qreal max = INT_MIN; | |
326 |
|
358 | |||
327 | for (int i = 0; i < m_barSets.count(); i++) { |
|
359 | for (int i = 0; i < m_barSets.count(); i++) { | |
328 | int categoryCount = m_barSets.at(i)->count(); |
|
360 | int categoryCount = m_barSets.at(i)->count(); | |
329 | for (int j = 0; j < categoryCount; j++) { |
|
361 | for (int j = 0; j < categoryCount; j++) { | |
330 | qreal temp = m_barSets.at(i)->at(j).y(); |
|
362 | qreal temp = m_barSets.at(i)->at(j).y(); | |
331 | if (temp > max) |
|
363 | if (temp > max) | |
332 | max = temp; |
|
364 | max = temp; | |
333 | } |
|
365 | } | |
334 | } |
|
366 | } | |
335 |
|
367 | |||
336 | return max; |
|
368 | return max; | |
337 | } |
|
369 | } | |
338 |
|
370 | |||
339 | qreal QBarSeriesPrivate::valueAt(int set, int category) |
|
371 | qreal QBarSeriesPrivate::valueAt(int set, int category) | |
340 | { |
|
372 | { | |
341 | if ((set < 0) || (set >= m_barSets.count())) { |
|
373 | if ((set < 0) || (set >= m_barSets.count())) { | |
342 | // No set, no value. |
|
374 | // No set, no value. | |
343 | return 0; |
|
375 | return 0; | |
344 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
376 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { | |
345 | // No category, no value. |
|
377 | // No category, no value. | |
346 | return 0; |
|
378 | return 0; | |
347 | } |
|
379 | } | |
348 |
|
380 | |||
349 | return m_barSets.at(set)->at(category).y(); |
|
381 | return m_barSets.at(set)->at(category).y(); | |
350 | } |
|
382 | } | |
351 |
|
383 | |||
352 | qreal QBarSeriesPrivate::percentageAt(int set, int category) |
|
384 | qreal QBarSeriesPrivate::percentageAt(int set, int category) | |
353 | { |
|
385 | { | |
354 | if ((set < 0) || (set >= m_barSets.count())) { |
|
386 | if ((set < 0) || (set >= m_barSets.count())) { | |
355 | // No set, no value. |
|
387 | // No set, no value. | |
356 | return 0; |
|
388 | return 0; | |
357 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { |
|
389 | } else if ((category < 0) || (category >= m_barSets.at(set)->count())) { | |
358 | // No category, no value. |
|
390 | // No category, no value. | |
359 | return 0; |
|
391 | return 0; | |
360 | } |
|
392 | } | |
361 |
|
393 | |||
362 | qreal value = m_barSets.at(set)->at(category).y(); |
|
394 | qreal value = m_barSets.at(set)->at(category).y(); | |
363 | qreal sum = categorySum(category); |
|
395 | qreal sum = categorySum(category); | |
364 | if ( qFuzzyIsNull(sum) ) { |
|
396 | if ( qFuzzyIsNull(sum) ) { | |
365 | return 0; |
|
397 | return 0; | |
366 | } |
|
398 | } | |
367 |
|
399 | |||
368 | return value / sum; |
|
400 | return value / sum; | |
369 | } |
|
401 | } | |
370 |
|
402 | |||
371 | qreal QBarSeriesPrivate::categorySum(int category) |
|
403 | qreal QBarSeriesPrivate::categorySum(int category) | |
372 | { |
|
404 | { | |
373 | qreal sum(0); |
|
405 | qreal sum(0); | |
374 | int count = m_barSets.count(); // Count sets |
|
406 | int count = m_barSets.count(); // Count sets | |
375 | for (int set = 0; set < count; set++) { |
|
407 | for (int set = 0; set < count; set++) { | |
376 | if (category < m_barSets.at(set)->count()) |
|
408 | if (category < m_barSets.at(set)->count()) | |
377 | sum += m_barSets.at(set)->at(category).y(); |
|
409 | sum += m_barSets.at(set)->at(category).y(); | |
378 | } |
|
410 | } | |
379 | return sum; |
|
411 | return sum; | |
380 | } |
|
412 | } | |
381 |
|
413 | |||
382 | qreal QBarSeriesPrivate::absoluteCategorySum(int category) |
|
414 | qreal QBarSeriesPrivate::absoluteCategorySum(int category) | |
383 | { |
|
415 | { | |
384 | qreal sum(0); |
|
416 | qreal sum(0); | |
385 | int count = m_barSets.count(); // Count sets |
|
417 | int count = m_barSets.count(); // Count sets | |
386 | for (int set = 0; set < count; set++) { |
|
418 | for (int set = 0; set < count; set++) { | |
387 | if (category < m_barSets.at(set)->count()) |
|
419 | if (category < m_barSets.at(set)->count()) | |
388 | sum += qAbs(m_barSets.at(set)->at(category).y()); |
|
420 | sum += qAbs(m_barSets.at(set)->at(category).y()); | |
389 | } |
|
421 | } | |
390 | return sum; |
|
422 | return sum; | |
391 | } |
|
423 | } | |
392 |
|
424 | |||
393 | qreal QBarSeriesPrivate::maxCategorySum() |
|
425 | qreal QBarSeriesPrivate::maxCategorySum() | |
394 | { |
|
426 | { | |
395 | qreal max = INT_MIN; |
|
427 | qreal max = INT_MIN; | |
396 | int count = categoryCount(); |
|
428 | int count = categoryCount(); | |
397 | for (int i = 0; i < count; i++) { |
|
429 | for (int i = 0; i < count; i++) { | |
398 | qreal sum = categorySum(i); |
|
430 | qreal sum = categorySum(i); | |
399 | if (sum > max) |
|
431 | if (sum > max) | |
400 | max = sum; |
|
432 | max = sum; | |
401 | } |
|
433 | } | |
402 | return max; |
|
434 | return max; | |
403 | } |
|
435 | } | |
404 |
|
436 | |||
405 | void QBarSeriesPrivate::barsetChanged() |
|
437 | void QBarSeriesPrivate::barsetChanged() | |
406 | { |
|
438 | { | |
407 | emit updatedBars(); |
|
439 | emit updatedBars(); | |
408 | } |
|
440 | } | |
409 |
|
441 | |||
410 | void QBarSeriesPrivate::scaleDomain(Domain& domain) |
|
442 | void QBarSeriesPrivate::scaleDomain(Domain& domain) | |
411 | { |
|
443 | { | |
412 | qreal minX(domain.minX()); |
|
444 | qreal minX(domain.minX()); | |
413 | qreal minY(domain.minY()); |
|
445 | qreal minY(domain.minY()); | |
414 | qreal maxX(domain.maxX()); |
|
446 | qreal maxX(domain.maxX()); | |
415 | qreal maxY(domain.maxY()); |
|
447 | qreal maxY(domain.maxY()); | |
416 | int tickXCount(domain.tickXCount()); |
|
448 | int tickXCount(domain.tickXCount()); | |
417 | int tickYCount(domain.tickYCount()); |
|
449 | int tickYCount(domain.tickYCount()); | |
418 |
|
450 | |||
419 | qreal x = categoryCount(); |
|
451 | qreal x = categoryCount(); | |
420 | qreal y = max(); |
|
452 | qreal y = max(); | |
421 | minX = qMin(minX, x) - 0.5; |
|
453 | minX = qMin(minX, x) - 0.5; | |
422 | minY = qMin(minY, y); |
|
454 | minY = qMin(minY, y); | |
423 | maxX = qMax(maxX, x) - 0.5; |
|
455 | maxX = qMax(maxX, x) - 0.5; | |
424 | maxY = qMax(maxY, y); |
|
456 | maxY = qMax(maxY, y); | |
425 | tickXCount = x+1; |
|
457 | tickXCount = x+1; | |
426 |
|
458 | |||
427 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
459 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
428 | } |
|
460 | } | |
429 |
|
461 | |||
430 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
462 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
431 | { |
|
463 | { | |
432 | Q_Q(QBarSeries); |
|
464 | Q_Q(QBarSeries); | |
433 |
|
465 | |||
434 | BarChartItem* bar = new BarChartItem(q,presenter); |
|
466 | BarChartItem* bar = new BarChartItem(q,presenter); | |
435 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
467 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
436 | presenter->animator()->addAnimation(bar); |
|
468 | presenter->animator()->addAnimation(bar); | |
437 | } |
|
469 | } | |
438 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
470 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
439 | return bar; |
|
471 | return bar; | |
440 |
|
472 | |||
441 | } |
|
473 | } | |
442 |
|
474 | |||
443 | QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) |
|
475 | QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) | |
444 | { |
|
476 | { | |
445 | Q_Q(QBarSeries); |
|
477 | Q_Q(QBarSeries); | |
446 | QList<LegendMarker*> markers; |
|
478 | QList<LegendMarker*> markers; | |
447 | foreach(QBarSet* set, q->barSets()) { |
|
479 | foreach(QBarSet* set, q->barSets()) { | |
448 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); |
|
480 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); | |
449 | markers << marker; |
|
481 | markers << marker; | |
450 | } |
|
482 | } | |
451 |
|
483 | |||
452 | return markers; |
|
484 | return markers; | |
453 | } |
|
485 | } | |
454 |
|
486 | |||
455 | bool QBarSeriesPrivate::append(QBarSet *set) |
|
487 | bool QBarSeriesPrivate::append(QBarSet *set) | |
456 | { |
|
488 | { | |
457 | Q_Q(QBarSeries); |
|
489 | Q_Q(QBarSeries); | |
458 | if ((m_barSets.contains(set)) || (set == 0)) { |
|
490 | if ((m_barSets.contains(set)) || (set == 0)) { | |
459 | // Fail if set is already in list or set is null. |
|
491 | // Fail if set is already in list or set is null. | |
460 | return false; |
|
492 | return false; | |
461 | } |
|
493 | } | |
462 | m_barSets.append(set); |
|
494 | m_barSets.append(set); | |
463 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(barsetChanged())); |
|
495 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(barsetChanged())); | |
464 | if (m_dataset) { |
|
496 | if (m_dataset) { | |
465 | m_dataset->updateSeries(q); // this notifies legend |
|
497 | m_dataset->updateSeries(q); // this notifies legend | |
466 | } |
|
498 | } | |
467 | emit restructuredBars(); // this notifies barchartitem |
|
499 | emit restructuredBars(); // this notifies barchartitem | |
468 | return true; |
|
500 | return true; | |
469 | } |
|
501 | } | |
470 |
|
502 | |||
471 | bool QBarSeriesPrivate::remove(QBarSet *set) |
|
503 | bool QBarSeriesPrivate::remove(QBarSet *set) | |
472 | { |
|
504 | { | |
473 | Q_Q(QBarSeries); |
|
505 | Q_Q(QBarSeries); | |
474 | if (!m_barSets.contains(set)) { |
|
506 | if (!m_barSets.contains(set)) { | |
475 | // Fail if set is not in list |
|
507 | // Fail if set is not in list | |
476 | return false; |
|
508 | return false; | |
477 | } |
|
509 | } | |
478 | m_barSets.removeOne(set); |
|
510 | m_barSets.removeOne(set); | |
479 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(barsetChanged())); |
|
511 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(barsetChanged())); | |
480 | if (m_dataset) { |
|
512 | if (m_dataset) { | |
481 | m_dataset->updateSeries(q); // this notifies legend |
|
513 | m_dataset->updateSeries(q); // this notifies legend | |
482 | } |
|
514 | } | |
483 | emit restructuredBars(); // this notifies barchartitem |
|
515 | emit restructuredBars(); // this notifies barchartitem | |
484 | return true; |
|
516 | return true; | |
485 | } |
|
517 | } | |
486 |
|
518 | |||
487 | bool QBarSeriesPrivate::append(QList<QBarSet* > sets) |
|
519 | bool QBarSeriesPrivate::append(QList<QBarSet* > sets) | |
488 | { |
|
520 | { | |
489 | Q_Q(QBarSeries); |
|
521 | Q_Q(QBarSeries); | |
490 | foreach (QBarSet* set, sets) { |
|
522 | foreach (QBarSet* set, sets) { | |
491 | if ((set == 0) || (m_barSets.contains(set))) { |
|
523 | if ((set == 0) || (m_barSets.contains(set))) { | |
492 | // Fail if any of the sets is null or is already appended. |
|
524 | // Fail if any of the sets is null or is already appended. | |
493 | return false; |
|
525 | return false; | |
494 | } |
|
526 | } | |
495 | if (sets.count(set) != 1) { |
|
527 | if (sets.count(set) != 1) { | |
496 | // Also fail if same set is more than once in given list. |
|
528 | // Also fail if same set is more than once in given list. | |
497 | return false; |
|
529 | return false; | |
498 | } |
|
530 | } | |
499 | } |
|
531 | } | |
500 |
|
532 | |||
501 | foreach (QBarSet* set, sets) { |
|
533 | foreach (QBarSet* set, sets) { | |
502 | m_barSets.append(set); |
|
534 | m_barSets.append(set); | |
503 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(barsetChanged())); |
|
535 | QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(barsetChanged())); | |
504 | } |
|
536 | } | |
505 | if (m_dataset) { |
|
537 | if (m_dataset) { | |
506 | m_dataset->updateSeries(q); // this notifies legend |
|
538 | m_dataset->updateSeries(q); // this notifies legend | |
507 | } |
|
539 | } | |
508 | emit restructuredBars(); // this notifies barchartitem |
|
540 | emit restructuredBars(); // this notifies barchartitem | |
509 | return true; |
|
541 | return true; | |
510 | } |
|
542 | } | |
511 |
|
543 | |||
512 | bool QBarSeriesPrivate::remove(QList<QBarSet* > sets) |
|
544 | bool QBarSeriesPrivate::remove(QList<QBarSet* > sets) | |
513 | { |
|
545 | { | |
514 | Q_Q(QBarSeries); |
|
546 | Q_Q(QBarSeries); | |
515 | bool setsRemoved = false; |
|
547 | bool setsRemoved = false; | |
516 | foreach (QBarSet* set, sets) { |
|
548 | foreach (QBarSet* set, sets) { | |
517 | if (m_barSets.contains(set)) { |
|
549 | if (m_barSets.contains(set)) { | |
518 | m_barSets.removeOne(set); |
|
550 | m_barSets.removeOne(set); | |
519 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(barsetChanged())); |
|
551 | QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), this, SLOT(barsetChanged())); | |
520 | setsRemoved = true; |
|
552 | setsRemoved = true; | |
521 | } |
|
553 | } | |
522 | } |
|
554 | } | |
523 |
|
555 | |||
524 | if (setsRemoved) { |
|
556 | if (setsRemoved) { | |
525 | if (m_dataset) { |
|
557 | if (m_dataset) { | |
526 | m_dataset->updateSeries(q); // this notifies legend |
|
558 | m_dataset->updateSeries(q); // this notifies legend | |
527 | } |
|
559 | } | |
528 | emit restructuredBars(); // this notifies barchartitem |
|
560 | emit restructuredBars(); // this notifies barchartitem | |
529 | } |
|
561 | } | |
530 | return setsRemoved; |
|
562 | return setsRemoved; | |
531 | } |
|
563 | } | |
532 |
|
564 | |||
533 | #include "moc_qbarseries.cpp" |
|
565 | #include "moc_qbarseries.cpp" | |
534 | #include "moc_qbarseries_p.cpp" |
|
566 | #include "moc_qbarseries_p.cpp" | |
535 |
|
567 | |||
536 | QTCOMMERCIALCHART_END_NAMESPACE |
|
568 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,77 +1,80 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef BARSERIES_H |
|
21 | #ifndef BARSERIES_H | |
22 | #define BARSERIES_H |
|
22 | #define BARSERIES_H | |
23 |
|
23 | |||
24 | #include <qabstractseries.h> |
|
24 | #include <qabstractseries.h> | |
25 | #include <QStringList> |
|
25 | #include <QStringList> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | typedef QStringList QBarCategories; |
|
29 | typedef QStringList QBarCategories; | |
30 |
|
30 | |||
31 | class QBarSet; |
|
31 | class QBarSet; | |
32 | class BarCategory; |
|
32 | class BarCategory; | |
33 | class QBarSeriesPrivate; |
|
33 | class QBarSeriesPrivate; | |
34 |
|
34 | |||
35 | // Container for series |
|
35 | // Container for series | |
36 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries |
|
36 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 | public: |
|
39 | public: | |
40 | explicit QBarSeries(QObject *parent = 0); |
|
40 | explicit QBarSeries(QObject *parent = 0); | |
41 | virtual ~QBarSeries(); |
|
41 | virtual ~QBarSeries(); | |
42 |
|
42 | |||
43 | QAbstractSeries::SeriesType type() const; |
|
43 | QAbstractSeries::SeriesType type() const; | |
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); | |
50 | bool append(QList<QBarSet* > sets); |
|
51 | bool append(QList<QBarSet* > sets); | |
51 | bool remove(QList<QBarSet* > sets); |
|
52 | bool remove(QList<QBarSet* > sets); | |
52 | int barsetCount() const; |
|
53 | int barsetCount() const; | |
53 | int categoryCount() const; |
|
54 | int categoryCount() const; | |
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 | |||
60 | protected: |
|
63 | protected: | |
61 | explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0); |
|
64 | explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0); | |
62 |
|
65 | |||
63 | Q_SIGNALS: |
|
66 | Q_SIGNALS: | |
64 | void clicked(QBarSet *barset, QString category); |
|
67 | void clicked(QBarSet *barset, QString category); | |
65 | void hovered(QBarSet* barset, bool status); |
|
68 | void hovered(QBarSet* barset, bool status); | |
66 |
|
69 | |||
67 | protected: |
|
70 | protected: | |
68 | Q_DECLARE_PRIVATE(QBarSeries) |
|
71 | Q_DECLARE_PRIVATE(QBarSeries) | |
69 | friend class BarChartItem; |
|
72 | friend class BarChartItem; | |
70 | friend class PercentBarChartItem; |
|
73 | friend class PercentBarChartItem; | |
71 | friend class StackedBarChartItem; |
|
74 | friend class StackedBarChartItem; | |
72 | friend class GroupedBarChartItem; |
|
75 | friend class GroupedBarChartItem; | |
73 | }; |
|
76 | }; | |
74 |
|
77 | |||
75 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE | |
76 |
|
79 | |||
77 | #endif // BARSERIES_H |
|
80 | #endif // BARSERIES_H |
@@ -1,97 +1,101 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QBARSERIES_P_H |
|
30 | #ifndef QBARSERIES_P_H | |
31 | #define QBARSERIES_P_H |
|
31 | #define QBARSERIES_P_H | |
32 |
|
32 | |||
33 | #include "qbarseries.h" |
|
33 | #include "qbarseries.h" | |
34 | #include "qabstractseries_p.h" |
|
34 | #include "qabstractseries_p.h" | |
35 | #include <QStringList> |
|
35 | #include <QStringList> | |
36 | #include <QAbstractSeries> |
|
36 | #include <QAbstractSeries> | |
37 |
|
37 | |||
38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
39 |
|
39 | |||
40 | class QBarModelMapper; |
|
40 | class QBarModelMapper; | |
41 |
|
41 | |||
42 | class QBarSeriesPrivate : public QAbstractSeriesPrivate |
|
42 | class QBarSeriesPrivate : public QAbstractSeriesPrivate | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 | public: |
|
45 | public: | |
46 | QBarSeriesPrivate(QBarSeries *parent); |
|
46 | QBarSeriesPrivate(QBarSeries *parent); | |
47 | void setCategories(QBarCategories categories); |
|
47 | void setCategories(QBarCategories categories); | |
48 | void insertCategory(int index, const QString category); |
|
48 | void insertCategory(int index, const QString category); | |
49 | void removeCategory(int index); |
|
49 | void removeCategory(int index); | |
50 | int categoryCount() const; |
|
50 | int categoryCount() const; | |
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); | |
58 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
61 | QList<LegendMarker*> createLegendMarker(QLegend* legend); | |
59 |
|
62 | |||
60 | bool append(QBarSet *set); |
|
63 | bool append(QBarSet *set); | |
61 | bool remove(QBarSet *set); |
|
64 | bool remove(QBarSet *set); | |
62 | bool append(QList<QBarSet* > sets); |
|
65 | bool append(QList<QBarSet* > sets); | |
63 | bool remove(QList<QBarSet* > sets); |
|
66 | bool remove(QList<QBarSet* > sets); | |
64 |
|
67 | |||
65 | QBarSet* barsetAt(int index); |
|
68 | QBarSet* barsetAt(int index); | |
66 | QString categoryName(int category); |
|
69 | QString categoryName(int category); | |
67 | qreal min(); |
|
70 | qreal min(); | |
68 | qreal max(); |
|
71 | qreal max(); | |
69 | qreal valueAt(int set, int category); |
|
72 | qreal valueAt(int set, int category); | |
70 | qreal percentageAt(int set, int category); |
|
73 | qreal percentageAt(int set, int category); | |
71 | qreal categorySum(int category); |
|
74 | qreal categorySum(int category); | |
72 | qreal absoluteCategorySum(int category); |
|
75 | qreal absoluteCategorySum(int category); | |
73 | qreal maxCategorySum(); |
|
76 | qreal maxCategorySum(); | |
74 |
|
77 | |||
75 | Q_SIGNALS: |
|
78 | Q_SIGNALS: | |
76 | void clicked(QBarSet *barset, QString category); |
|
79 | void clicked(QBarSet *barset, QString category); | |
77 | void updatedBars(); |
|
80 | void updatedBars(); | |
78 | void restructuredBars(); |
|
81 | void restructuredBars(); | |
79 | void categoriesUpdated(); |
|
82 | void categoriesUpdated(); | |
80 | void labelsVisibleChanged(bool visible); |
|
83 | void labelsVisibleChanged(bool visible); | |
81 |
|
84 | |||
82 | private Q_SLOTS: |
|
85 | private Q_SLOTS: | |
83 | void barsetChanged(); |
|
86 | void barsetChanged(); | |
84 |
|
87 | |||
85 | protected: |
|
88 | protected: | |
86 | QList<QBarSet *> m_barSets; |
|
89 | QList<QBarSet *> m_barSets; | |
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) | |
93 | }; |
|
97 | }; | |
94 |
|
98 | |||
95 | QTCOMMERCIALCHART_END_NAMESPACE |
|
99 | QTCOMMERCIALCHART_END_NAMESPACE | |
96 |
|
100 | |||
97 | #endif // QBARSERIESPRIVATE_P_H |
|
101 | #endif // QBARSERIESPRIVATE_P_H |
General Comments 0
You need to be logged in to leave comments.
Login now