##// END OF EJS Templates
Documentation for bar charts
sauimone -
r313:625c56c7d323
parent child
Show More
@@ -4,12 +4,14 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 /*!
5 /*!
6 \class QBarCategory
6 \class QBarCategory
7 \brief QtCommercial chart API.
7 \brief part of QtCommercial chart API.
8
8
9 QBarCategory is a container for labels of various bar charts. Before the
9 QBarCategory is a container for labels of various bar charts. Before the
10 bar chart can be constructed, the categories must be defined. This is done by
10 bar chart can be constructed, the categories must be defined. This is done by
11 creating a QBarCategory class and appending the labels of categories to it.
11 creating a QBarCategory class and appending the labels of categories to it.
12 The QBarCategory is then given to QBarSeries class.
12 The QBarCategory is then given to bar chart series class.
13
14 \sa QBarChartSeries, QStackedBarChartSeries, QPercentBarChartSeries
13 */
15 */
14
16
15 /*!
17 /*!
@@ -7,47 +7,117
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 /*!
11 \class QBarChartSeries
12 \brief part of QtCommercial chart API.
13
14 QBarChartSeries represents a series of data shown as bars. One QBarChartSeries can contain multible
15 QBarSet data sets. QBarChartSeries groups the data from sets to categories, which are defined
16 by QBarCategory class.
17
18 \sa QBarCategory, QBarSet, QStackedBarChartSeries, QPercentBarChartSeries
19 */
20
21 /*!
22 \fn virtual QChartSeriesType QBarChartSeries::type() const
23 \brief Returns type of series.
24 \sa QChartSeries, QChartSeriesType
25 */
26 /*!
27 \fn void QBarChartSeries::changed(int index)
28 \brief INTERNAL \a index
29 */
30 /*!
31 \fn void QBarChartSeries::floatingValuesEnabled(bool enabled)
32 \brief INTERNAL \a enabled
33 */
34 /*!
35 \fn void QBarChartSeries::toolTipEnabled(bool enabled)
36 \brief INTERNAL \a enabled
37 */
38 /*!
39 \fn void QBarChartSeries::separatorsEnabled(bool enabled)
40 \brief INTERNAL \a enabled
41 */
42 /*!
43 \fn void QBarChartSeries::showToolTip(QPoint pos, QString tip)
44 \brief INTERNAL \a pos \a tip
45 */
46
47 /*!
48 Constructs empty QBarChartSeries. Parameter \a category defines the categories for chart.
49 QBarChartSeries is QObject which is a child of a\a parent.
50 */
10 QBarChartSeries::QBarChartSeries(QBarCategory *category, QObject *parent)
51 QBarChartSeries::QBarChartSeries(QBarCategory *category, QObject *parent)
11 : QChartSeries(parent)
52 : QChartSeries(parent)
12 ,mModel(new BarChartModel(category, this))
53 ,mModel(new BarChartModel(category, this))
13 {
54 {
14 }
55 }
15
56
57 /*!
58 Adds a set of bars to series. Takes ownership of \a set
59 */
16 void QBarChartSeries::addBarSet(QBarSet *set)
60 void QBarChartSeries::addBarSet(QBarSet *set)
17 {
61 {
18 mModel->addBarSet(set);
62 mModel->addBarSet(set);
19 }
63 }
20
64
65 /*!
66 Removes a set of bars from series. Releases ownership of \a set. Doesnt delete \a set.
67 */
21 void QBarChartSeries::removeBarSet(QBarSet *set)
68 void QBarChartSeries::removeBarSet(QBarSet *set)
22 {
69 {
23 mModel->removeBarSet(set);
70 mModel->removeBarSet(set);
24 }
71 }
25
72
73 /*!
74 Returns number of sets in series.
75 */
26 int QBarChartSeries::countSets()
76 int QBarChartSeries::countSets()
27 {
77 {
28 return mModel->countSets();
78 return mModel->countSets();
29 }
79 }
30
80
81 /*!
82 Simple iterator for set. Returns pointer to next set in series.
83 Returns first set, if \a getFirst is true. If series is empty, returns 0.
84 */
31 QBarSet* QBarChartSeries::nextSet(bool getFirst)
85 QBarSet* QBarChartSeries::nextSet(bool getFirst)
32 {
86 {
33 return mModel->nextSet(getFirst);
87 return mModel->nextSet(getFirst);
34 }
88 }
35
89
90 /*!
91 Returns set indexed by \a index. Doesn't check for index bounds.
92 Assumes that \a index is between 0 and number of sets. Use countSets() to get valid index bound.
93 \sa countSets()
94 */
36 QBarSet* QBarChartSeries::setAt(int index)
95 QBarSet* QBarChartSeries::setAt(int index)
37 {
96 {
38 return mModel->setAt(index);
97 return mModel->setAt(index);
39 }
98 }
40
99
100 /*!
101 Returns legend of series. Legend is a list of set names in series.
102 */
41 QList<QString> QBarChartSeries::legend()
103 QList<QString> QBarChartSeries::legend()
42 {
104 {
43 return mModel->legend();
105 return mModel->legend();
44 }
106 }
45
107
108 /*!
109 INTERNAL \a category
110 */
46 QString QBarChartSeries::label(int category)
111 QString QBarChartSeries::label(int category)
47 {
112 {
48 return mModel->label(category);
113 return mModel->label(category);
49 }
114 }
50
115
116 /*!
117 Enables or disables floating values depending on parameter \a enabled.
118 Floating values are bar values, that are displayed on top of each bar.
119 Calling without parameter \a enabled, enables the floating values
120 */
51 void QBarChartSeries::enableFloatingValues(bool enabled)
121 void QBarChartSeries::enableFloatingValues(bool enabled)
52 {
122 {
53 if (enabled) {
123 if (enabled) {
@@ -63,6 +133,11 void QBarChartSeries::enableFloatingValues(bool enabled)
63 }
133 }
64 }
134 }
65
135
136 /*!
137 Enables or disables tooltip depending on parameter \a enabled.
138 Tooltip shows the name of set, when mouse is hovering on top of bar.
139 Calling without parameter \a enabled, enables the tooltip
140 */
66 void QBarChartSeries::enableToolTip(bool enabled)
141 void QBarChartSeries::enableToolTip(bool enabled)
67 {
142 {
68 if (enabled) {
143 if (enabled) {
@@ -78,46 +153,75 void QBarChartSeries::enableToolTip(bool enabled)
78 }
153 }
79 }
154 }
80
155
156 /*!
157 Enables or disables separators depending on parameter \a enabled.
158 Separators are visual elements that are drawn between categories.
159 Calling without parameter \a enabled, enables the separators
160 */
81 void QBarChartSeries::enableSeparators(bool enabled)
161 void QBarChartSeries::enableSeparators(bool enabled)
82 {
162 {
83 emit separatorsEnabled(enabled);
163 emit separatorsEnabled(enabled);
84 }
164 }
85
165
166 /*!
167 INTERNAL
168 */
86 int QBarChartSeries::countCategories()
169 int QBarChartSeries::countCategories()
87 {
170 {
88 return mModel->countCategories();
171 return mModel->countCategories();
89 }
172 }
90
173
174 /*!
175 INTERNAL
176 */
91 qreal QBarChartSeries::min()
177 qreal QBarChartSeries::min()
92 {
178 {
93 return mModel->min();
179 return mModel->min();
94 }
180 }
95
181
182 /*!
183 INTERNAL
184 */
96 qreal QBarChartSeries::max()
185 qreal QBarChartSeries::max()
97 {
186 {
98 return mModel->max();
187 return mModel->max();
99 }
188 }
100
189
190 /*!
191 INTERNAL \a set \a category
192 */
101 qreal QBarChartSeries::valueAt(int set, int category)
193 qreal QBarChartSeries::valueAt(int set, int category)
102 {
194 {
103 return mModel->valueAt(set,category);
195 return mModel->valueAt(set,category);
104 }
196 }
105
197
198 /*!
199 INTERNAL \a set \a category
200 */
106 qreal QBarChartSeries::percentageAt(int set, int category)
201 qreal QBarChartSeries::percentageAt(int set, int category)
107 {
202 {
108 return mModel->percentageAt(set,category);
203 return mModel->percentageAt(set,category);
109 }
204 }
110
205
206 /*!
207 INTERNAL \a category
208 */
111 qreal QBarChartSeries::categorySum(int category)
209 qreal QBarChartSeries::categorySum(int category)
112 {
210 {
113 return mModel->categorySum(category);
211 return mModel->categorySum(category);
114 }
212 }
115
213
214 /*!
215 INTERNAL
216 */
116 qreal QBarChartSeries::maxCategorySum()
217 qreal QBarChartSeries::maxCategorySum()
117 {
218 {
118 return mModel->maxCategorySum();
219 return mModel->maxCategorySum();
119 }
220 }
120
221
222 /*!
223 INTERNAL
224 */
121 BarChartModel& QBarChartSeries::model()
225 BarChartModel& QBarChartSeries::model()
122 {
226 {
123 return *mModel;
227 return *mModel;
@@ -25,12 +25,12 public:
25 QBarSet *setAt(int index);
25 QBarSet *setAt(int index);
26
26
27 QList<QString> legend(); // Returns legend of series (ie. names of all sets in series)
27 QList<QString> legend(); // Returns legend of series (ie. names of all sets in series)
28 QString label(int category);
29
28
30 public:
29 public:
31 // TODO: Functions below this are not part of api and will be moved
30 // TODO: Functions below this are not part of api and will be moved
32 // to private implementation, when we start using it
31 // to private implementation, when we start using it
33 // TODO: TO PIMPL --->
32 // TODO: TO PIMPL --->
33 QString label(int category);
34 int countCategories();
34 int countCategories();
35 qreal min();
35 qreal min();
36 qreal max();
36 qreal max();
@@ -4,62 +4,133
4
4
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6
6
7 /*!
8 \class QBarSet
9 \brief part of QtCommercial chart API.
10
11 QBarSet represents one set of bars. Set of bars contains one data value for each category.
12 First value of set is assumed to belong to first category, second to second category and so on.
13 If set has fewer values than there are categories, then the missing values are assumed to be
14 at the end of set. For missing values in middle of a set, numerical value of zero is used.
15
16 \sa QBarCategory, QBarChartSeries, QStackedBarChartSeries, QPercentBarChartSeries
17 */
18
19 /*!
20 \fn void QBarSet::clicked()
21 \brief signals that set has been clicked
22 */
23 /*!
24 \fn void QBarSet::hoverEnter(QPoint pos)
25 \brief signals that mouse has entered over the set at position \a pos.
26 */
27 /*!
28 \fn void QBarSet::hoverLeave()
29 \brief signals that mouse has left from the set.
30 */
31 /*!
32 \fn void QBarSet::toggleFloatingValues()
33 \brief INTERNAL
34 */
35 /*!
36 \fn void QBarSet::showToolTip(QPoint pos, QString tip)
37 \brief INTERNAL \a pos \a tip
38 */
39
40
41 /*!
42 Constructs QBarSet with a name of \a name and with parent of \a parent
43 */
7 QBarSet::QBarSet(QString name, QObject *parent)
44 QBarSet::QBarSet(QString name, QObject *parent)
8 : QObject(parent)
45 : QObject(parent)
9 ,mName(name)
46 ,mName(name)
10 {
47 {
11 }
48 }
12
49
50 /*!
51 Sets new \a name for set.
52 */
13 void QBarSet::setName(QString name)
53 void QBarSet::setName(QString name)
14 {
54 {
15 mName = name;
55 mName = name;
16 }
56 }
57
58 /*!
59 Returns name of the set.
60 */
17 QString QBarSet::name()
61 QString QBarSet::name()
18 {
62 {
19 return mName;
63 return mName;
20 }
64 }
21
65
66 /*!
67 Appends new value \a value to the end of set.
68 */
22 QBarSet& QBarSet::operator << (const qreal &value)
69 QBarSet& QBarSet::operator << (const qreal &value)
23 {
70 {
24 mValues.append(value);
71 mValues.append(value);
25 return *this;
72 return *this;
26 }
73 }
27
74
75 /*!
76 Returns count of values in set.
77 */
28 int QBarSet::count()
78 int QBarSet::count()
29 {
79 {
30 return mValues.count();
80 return mValues.count();
31 }
81 }
32
82
83 /*!
84 Returns value of set indexed by \a index
85 */
33 qreal QBarSet::valueAt(int index)
86 qreal QBarSet::valueAt(int index)
34 {
87 {
35 return mValues.at(index);
88 return mValues.at(index);
36 }
89 }
37
90
91 /*!
92 Sets a new value \a value to set, indexed by \a index
93 */
38 void QBarSet::setValue(int index, qreal value)
94 void QBarSet::setValue(int index, qreal value)
39 {
95 {
40 mValues.replace(index,value);
96 mValues.replace(index,value);
41 }
97 }
42
98
99 /*!
100 Sets pen for set. Bars of this set are drawn using \a pen
101 */
43 void QBarSet::setPen(const QPen& pen)
102 void QBarSet::setPen(const QPen& pen)
44 {
103 {
45 mPen = pen;
104 mPen = pen;
46 }
105 }
47
106
107 /*!
108 Returns pen of the set.
109 */
48 const QPen& QBarSet::pen() const
110 const QPen& QBarSet::pen() const
49 {
111 {
50 return mPen;
112 return mPen;
51 }
113 }
52
114
115 /*!
116 Sets brush for the set. Bars of this set are drawn using \a brush
117 */
53 void QBarSet::setBrush(const QBrush& brush)
118 void QBarSet::setBrush(const QBrush& brush)
54 {
119 {
55 mBrush = brush;
120 mBrush = brush;
56 }
121 }
57
122
123 /*!
124 Returns brush of the set.
125 */
58 const QBrush& QBarSet::brush() const
126 const QBrush& QBarSet::brush() const
59 {
127 {
60 return mBrush;
128 return mBrush;
61 }
129 }
62
130
131 /*!
132 INTERNAL
133 */
63 void QBarSet::barClicked()
134 void QBarSet::barClicked()
64 {
135 {
65 // qDebug() << "QBarset::barClicked" << this;
136 // qDebug() << "QBarset::barClicked" << this;
@@ -68,12 +139,18 void QBarSet::barClicked()
68 emit clicked(); // Notify that set has been clicked
139 emit clicked(); // Notify that set has been clicked
69 }
140 }
70
141
142 /*!
143 INTERNAL \a pos
144 */
71 void QBarSet::barHoverEntered(QPoint pos)
145 void QBarSet::barHoverEntered(QPoint pos)
72 {
146 {
73 emit showToolTip(pos, mName);
147 emit showToolTip(pos, mName);
74 emit hoverEnter(pos);
148 emit hoverEnter(pos);
75 }
149 }
76
150
151 /*!
152 INTERNAL
153 */
77 void QBarSet::barHoverLeaved()
154 void QBarSet::barHoverLeaved()
78 {
155 {
79 // qDebug() << "QBarset::barHoverLeaved" << this;
156 // qDebug() << "QBarset::barHoverLeaved" << this;
@@ -2,6 +2,27
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 /*!
6 \class QPercentBarChartSeries
7 \brief part of QtCommercial chart API.
8
9 QPercentBarChartSeries represents a series of data shown as bars. Each bar of QBarSet is shown as percentage
10 of all bars in category. One QPercentBarChartSeries can contain multible QBarSet data sets.
11 QBarChartSeries groups the data from sets to categories, which are defined by QBarCategory class.
12
13 \sa QBarCategory, QBarSet, QStackedBarChartSeries, QBarChartSeries
14 */
15
16 /*!
17 \fn virtual QChartSeriesType QPercentBarChartSeries::type() const
18 \brief Returns type of series.
19 \sa QChartSeries, QChartSeriesType
20 */
21
22 /*!
23 Constructs empty QPercentBarChartSeries. Parameter \a category defines the categories for chart.
24 QPercentBarChartSeries is QObject which is a child of a\a parent.
25 */
5 QPercentBarChartSeries::QPercentBarChartSeries(QBarCategory *category, QObject *parent)
26 QPercentBarChartSeries::QPercentBarChartSeries(QBarCategory *category, QObject *parent)
6 : QBarChartSeries(category, parent)
27 : QBarChartSeries(category, parent)
7 {
28 {
@@ -2,6 +2,27
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 /*!
6 \class QStackedBarChartSeries
7 \brief part of QtCommercial chart API.
8
9 QStackedBarChartSeries represents a series of data shown as bars. All bars in same category are
10 stacked on top of each other. One QStackedBarChartSeries can contain multible QBarSet data sets.
11 QStackedBarChartSeries groups the data from sets to categories, which are defined by QBarCategory class.
12
13 \sa QBarCategory, QBarSet, QPercentBarChartSeries, QBarChartSeries
14 */
15
16 /*!
17 \fn virtual QChartSeriesType QStackedBarChartSeries::type() const
18 \brief Returns type of series.
19 \sa QChartSeries, QChartSeriesType
20 */
21
22 /*!
23 Constructs empty QStackedBarChartSeries. Parameter \a category defines the categories for chart.
24 QStackedBarChartSeries is QObject which is a child of a\a parent.
25 */
5 QStackedBarChartSeries::QStackedBarChartSeries(QBarCategory *category, QObject *parent)
26 QStackedBarChartSeries::QStackedBarChartSeries(QBarCategory *category, QObject *parent)
6 : QBarChartSeries(category, parent)
27 : QBarChartSeries(category, parent)
7 {
28 {
General Comments 0
You need to be logged in to leave comments. Login now