##// END OF EJS Templates
Marek Rosa -
r329:930e4124fe9e merge
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -3,7 +3,7 include(qt-html-default-styles.qdocconf)
3 3 HTML.postheader = \
4 4 "<div class=\"header\" id=\"qtdocheader\">\n" \
5 5 " <div class=\"content\"> \n" \
6 " <a href=\"index.html\" class=\"qtref\"><span>Qt Reference Documentation</span></a>\n" \
6 " <a href=\"index.html\" class=\"qtref\"><span>QChart Reference Documentation</span></a>\n" \
7 7 " </div>\n" \
8 8 " <div class=\"breadcrumb toolblock\">\n" \
9 9 " <ul>\n" \
@@ -23,23 +23,18 HTML.footer = \
23 23 "</div> \n" \
24 24 "<div class=\"footer\">\n" \
25 25 " <p>\n" \
26 " <acronym title=\"Copyright\">&copy;</acronym> 2008-2011 Nokia Corporation and/or its\n" \
27 " subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation \n" \
26 " <acronym title=\"Copyright\">&copy;</acronym> 2012 Digia ." \
27 " Qt and Qt logos are trademarks of of Nokia Corporation \n" \
28 28 " in Finland and/or other countries worldwide.</p>\n" \
29 29 " <p>\n" \
30 " All other trademarks are property of their respective owners. <a title=\"Privacy Policy\"\n" \
31 " href=\"http://qt.nokia.com/about/privacy-policy\">Privacy Policy</a></p>\n" \
30 " All other trademarks are property of their respective owners.</p>\n" \
32 31 " <br />\n" \
33 32 " <p>\n" \
34 33 " Licensees holding valid Qt Commercial licenses may use this document in accordance with the" \
35 34 " Qt Commercial License Agreement provided with the Software or, alternatively, in accordance" \
36 " with the terms contained in a written agreement between you and Nokia.</p>\n" \
37 " <p>\n" \
38 " Alternatively, this document may be used under the terms of the <a href=\"http://www.gnu.org/licenses/fdl.html\">GNU\n" \
39 " Free Documentation License version 1.3</a>\n" \
40 " as published by the Free Software Foundation.</p>\n" \
35 " with the terms contained in a written agreement between you and Digia.</p>\n" \
41 36 "</div>\n" \
42
37
43 38 # Files not referenced in any qdoc file.
44 39 # See also extraimages.HTML
45 40 qhp.QDoc.extraFiles = index.html \
@@ -1,13 +1,33
1 1 /*!
2 2 \page index.html
3 \title All Classes
3 \title QtCommercial Charts
4 4 \keyword All Classes
5 5
6 TODO: restructure the document
7
8 QtCommercial Charts introduction...
9 For example, to create a chart with line series using a widget based application:
10 \snippet ../example/chartview/main.cpp 1
11 \image chartview_example.jpg
12
13 Showing a few more series:
14 \snippet ../example/chartview/main.cpp 3
15 \image chartview_example_pie.jpg
16 \snippet ../example/chartview/main.cpp 4
17 \image chartview_example_scatter.jpg
18 \snippet ../example/chartview/main.cpp 5
19 \image chartview_example_bar.jpg
20
21 If you need to give a more professional touch to your chart you can switch to one of the
22 pre-defined themes:
23 \snippet ../example/chartview/main.cpp 2
24 \image chartview_example_theme.jpg
25
6 26 \raw HTML
7 27 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
8 28 <tr>
9 29 <th class="titleheader" width="33%">
10 TODO: QtCommercial Chart modules list
30 List of classes
11 31 </th>
12 32 </tr>
13 33 <tr>
@@ -15,9 +35,17
15 35 <ul>
16 36 <li><a href="qchart.html">QChart</a></li>
17 37 <li><a href="qchartview.html">QChartView</a></li>
38 <li><a href="qchartseries.html">QChartSeries</a></li>
39 <li><a href="qlinechartseries.html">QLineChartSeries</a></li>
40 <li><a href="qpieseries.html">QPieSeries</a></li>
41 <li><a href="qbarchartseries.html">QBarChartSeries</a></li>
42 <li><a href="qstackedbarchartseries.html">QStackedBarChartSeries</a></li>
43 <li><a href="qpercentbarchartseries.html">QPercentBarChartSeries</a></li>
44 <li><a href="qscatterseries.html">QScatterSeries</a></li>
18 45 </ul>
19 46 </td>
20 47 </tr>
21 48 </table>
22 49 \endraw
50
23 51 */
@@ -12,41 +12,56 int main(int argc, char *argv[])
12 12 QApplication a(argc, argv);
13 13 QMainWindow window;
14 14
15 //! [1]
16 // Create category
15 17 QBarCategory *category = new QBarCategory;
16 18 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
19 //! [1]
17 20
18 QBarChartSeries* series= new QBarChartSeries(category);
21 //! [2]
22 // Create some test sets for chat
19 23
20 // We use custom set, which connects some signals. Could use QBarSet here if we don't need signals
21 24 QBarSet *set0 = new QBarSet("Bub");
22 25 QBarSet *set1 = new QBarSet("Bob");
23 26 QBarSet *set2 = new QBarSet("Guybrush");
24 27 QBarSet *set3 = new QBarSet("Larry");
25 28 QBarSet *set4 = new QBarSet("Zak");
26 29
27 // Create some test data to chart
28 30 *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 31 *set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 32 *set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 33 *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 34 *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
35 //! [2]
36
37 //! [3]
38 // Create series and add sets to it
39 QBarChartSeries* series= new QBarChartSeries(category);
33 40
34 41 series->addBarSet(set0);
35 42 series->addBarSet(set1);
36 43 series->addBarSet(set2);
37 44 series->addBarSet(set3);
38 45 series->addBarSet(set4);
46 //! [3]
47
48 //! [4]
49 // Enable some features
50 series->enableToolTip();
51 series->enableFloatingValues();
52 //! [4]
39 53
40 series->enableToolTip(true);
41 series->enableFloatingValues(true);
54 //! [5]
55 // Create view for chart and add series to it. Apply theme.
42 56
43 57 QChartView* chartView = new QChartView(&window);
44 58 chartView->addSeries(series);
45 59 chartView->setChartTitle("simple stacked barchart");
46 60 chartView->setChartTheme(QChart::ChartThemeIcy);
61 //! [5]
47 62
48 63 window.setCentralWidget(chartView);
49 window.resize(400, 300);
64 window.resize(600, 300);
50 65 window.show();
51 66
52 67 return a.exec();
@@ -3,6 +3,11
3 3 #include <qchartglobal.h>
4 4 #include <qchartview.h>
5 5 #include <qlinechartseries.h>
6 #include <qscatterseries.h>
7 #include <qbarchartseries.h>
8 #include <qbarset.h>
9 #include <qbarcategory.h>
10 #include <qpieseries.h>
6 11
7 12 QTCOMMERCIALCHART_USE_NAMESPACE
8 13
@@ -13,26 +18,54 int main(int argc, char *argv[])
13 18 //! [1]
14 19 // Create chart view
15 20 QChartView *chartView = new QChartView();
16 chartView->setChartTheme(QChart::ChartThemeIcy);
21 // Add series to the chart
22 QLineChartSeries *line = new QLineChartSeries();
23 line->add(0.0, 0.8);
24 line->add(1.1, 1.1);
25 line->add(2.0, 2.5);
26 chartView->addSeries(line);
17 27 //! [1]
18 28
19 29 //! [2]
20 // Add series to the chart
21 QLineChartSeries *series = new QLineChartSeries();
22 series->add(0.0, 0.8);
23 series->add(1.1, 1.1);
24 series->add(1.6, 1.8);
25 series->add(2.0, 2.5);
26 chartView->addSeries(series);
30 // Change theme
31 chartView->setChartTheme(QChart::ChartThemeScientific);
27 32 //! [2]
28 33
29 34 //! [3]
30 // Change theme
31 chartView->setChartTheme(QChart::ChartThemeScientific);
35 // Add pie series
36 QPieSeries *pie = new QPieSeries();
37 pie->add(3.4, "slice1");
38 pie->add(6.7, "slice2");
39 chartView->addSeries(pie);
32 40 //! [3]
33 41
42 //! [4]
43 // Add scatter series
44 QScatterSeries *scatter = new QScatterSeries();
45 for (qreal x(0); x < 100; x += 0.5) {
46 qreal y = rand() % 100;
47 *(scatter) << QPointF(x, y);
48 }
49 chartView->addSeries(scatter);
50 //! [4]
51
52 //! [5]
53 // Add bar series
54 QBarCategory *barCategory = new QBarCategory();
55 *barCategory << "Jan"
56 << "Feb"
57 << "Mar";
58 QBarChartSeries *bar = new QBarChartSeries(barCategory);
59 QBarSet *barSet = new QBarSet("Sales");
60 *barSet << 123.2
61 << 301.3
62 << 285.8;
63 bar->addBarSet(barSet);
64 chartView->addSeries(bar);
65 //! [5]
66
34 67 QMainWindow w;
35 w.resize(640, 480);
68 w.resize(350, 250);
36 69 w.setCentralWidget(chartView);
37 70 w.show();
38 71
@@ -13,37 +13,52 int main(int argc, char *argv[])
13 13 QApplication a(argc, argv);
14 14 QMainWindow window;
15 15
16 //! [1]
17 // Create category
16 18 QBarCategory *category = new QBarCategory;
17 19 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
20 //! [1]
18 21
19 QPercentBarChartSeries* series = new QPercentBarChartSeries(category);
20
22 //! [2]
23 // Create some test sets for chat
21 24 QBarSet *set0 = new QBarSet("Bub");
22 25 QBarSet *set1 = new QBarSet("Bob");
23 26 QBarSet *set2 = new QBarSet("Guybrush");
24 27 QBarSet *set3 = new QBarSet("Larry");
25 28 QBarSet *set4 = new QBarSet("Zak");
26 29
27 // Create some test data to chart
28 30 *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 31 *set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 32 *set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 33 *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 34 *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
35 //! [2]
36
37 //! [3]
38 // Create series and add sets to it
39 QPercentBarChartSeries* series = new QPercentBarChartSeries(category);
33 40
34 41 series->addBarSet(set0);
35 42 series->addBarSet(set1);
36 43 series->addBarSet(set2);
37 44 series->addBarSet(set3);
38 45 series->addBarSet(set4);
46 //! [3]
47
48 //! [4]
49 // Enable features
50 series->enableToolTip();
51 series->enableFloatingValues();
52 //! [4]
39 53
40 series->enableToolTip(true);
41 series->enableFloatingValues(true);
54 //! [5]
55 // Create view for chart and add series to it. Apply theme.
42 56
43 57 QChartView* chartView = new QChartView(&window);
44 58 chartView->addSeries(series);
45 59 chartView->setChartTitle("simple percent barchart");
46 60 chartView->setChartTheme(QChart::ChartThemeIcy);
61 //! [5]
47 62
48 63 window.setCentralWidget(chartView);
49 64 window.resize(400, 300);
@@ -12,37 +12,52 int main(int argc, char *argv[])
12 12 QApplication a(argc, argv);
13 13 QMainWindow window;
14 14
15 //! [1]
16 // Create category
15 17 QBarCategory *category = new QBarCategory;
16 18 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
19 //! [1]
17 20
18 QStackedBarChartSeries* series = new QStackedBarChartSeries(category);
19
21 //! [2]
22 // Create some test sets for chat
20 23 QBarSet *set0 = new QBarSet("Bub");
21 24 QBarSet *set1 = new QBarSet("Bob");
22 25 QBarSet *set2 = new QBarSet("Guybrush");
23 26 QBarSet *set3 = new QBarSet("Larry");
24 27 QBarSet *set4 = new QBarSet("Zak");
25 28
26 // Create some test data to chart
27 29 *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
28 30 *set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
29 31 *set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
30 32 *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
31 33 *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
34 //! [2]
35
36 //! [3]
37 // Create series and add sets to it
38 QStackedBarChartSeries* series = new QStackedBarChartSeries(category);
32 39
33 40 series->addBarSet(set0);
34 41 series->addBarSet(set1);
35 42 series->addBarSet(set2);
36 43 series->addBarSet(set3);
37 44 series->addBarSet(set4);
45 //! [3]
46
47 //! [4]
48 // Enable features
49 series->enableToolTip();
50 series->enableFloatingValues();
51 //! [4]
38 52
39 series->enableToolTip(true);
40 series->enableFloatingValues(true);
53 //! [5]
54 // Create view for chart and add series to it. Apply theme.
41 55
42 56 QChartView* chartView = new QChartView(&window);
43 57 chartView->addSeries(series);
44 58 chartView->setChartTitle("simple stacked barchart");
45 59 chartView->setChartTheme(QChart::ChartThemeIcy);
60 //! [5]
46 61
47 62 window.setCentralWidget(chartView);
48 63 window.resize(400, 300);
@@ -11,6 +11,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11 11 creating a QBarCategory class and appending the labels of categories to it.
12 12 The QBarCategory is then given to bar chart series class.
13 13
14 \mainclass
15
16 Example on how to create a category:
17 \snippet ../example/barchart/main.cpp 1
18
14 19 \sa QBarChartSeries, QStackedBarChartSeries, QPercentBarChartSeries
15 20 */
16 21
@@ -15,6 +15,23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
15 15 QBarSet data sets. QBarChartSeries groups the data from sets to categories, which are defined
16 16 by QBarCategory class.
17 17
18 \mainclass
19
20 Example on how to create category:
21 \snippet ../example/barchart/main.cpp 1
22
23 Example on how to create sets of data:
24 \snippet ../example/barchart/main.cpp 2
25
26 Example on how to add sets to bar chart:
27 \snippet ../example/barchart/main.cpp 3
28
29 Example on how to enable tooltip and floating values:
30 \snippet ../example/barchart/main.cpp 4
31
32 Example on how to create view and apply theme:
33 \snippet ../example/barchart/main.cpp 5
34
18 35 \sa QBarCategory, QBarSet, QStackedBarChartSeries, QPercentBarChartSeries
19 36 */
20 37
@@ -25,28 +42,29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 42 */
26 43 /*!
27 44 \fn void QBarChartSeries::changed(int index)
28 \brief INTERNAL \a index
45 \brief \internal \a index
29 46 */
30 47 /*!
31 48 \fn void QBarChartSeries::floatingValuesEnabled(bool enabled)
32 \brief INTERNAL \a enabled
49 \brief \internal \a enabled
33 50 */
34 51 /*!
35 52 \fn void QBarChartSeries::toolTipEnabled(bool enabled)
36 \brief INTERNAL \a enabled
53 \brief \internal \a enabled
37 54 */
38 55 /*!
39 56 \fn void QBarChartSeries::separatorsEnabled(bool enabled)
40 \brief INTERNAL \a enabled
57 \brief \internal \a enabled
41 58 */
42 59 /*!
43 60 \fn void QBarChartSeries::showToolTip(QPoint pos, QString tip)
44 \brief INTERNAL \a pos \a tip
61 \brief \internal \a pos \a tip
45 62 */
46 63
47 64 /*!
48 65 Constructs empty QBarChartSeries. Parameter \a category defines the categories for chart.
49 QBarChartSeries is QObject which is a child of a\a parent.
66 Takes ownership of \a category.
67 QBarChartSeries is QObject which is a child of a \a parent.
50 68 */
51 69 QBarChartSeries::QBarChartSeries(QBarCategory *category, QObject *parent)
52 70 : QChartSeries(parent)
@@ -79,8 +97,18 int QBarChartSeries::countSets()
79 97 }
80 98
81 99 /*!
100 Returns number of categories in series
101 */
102 int QBarChartSeries::countCategories()
103 {
104 return mModel->countCategories();
105 }
106
107 /*!
82 108 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.
109 Returns first set, if parameter \a getFirst is true.
110 If series is empty, returns 0.
111 Returns 0 after last set.
84 112 */
85 113 QBarSet* QBarChartSeries::nextSet(bool getFirst)
86 114 {
@@ -106,7 +134,7 QList<QString> QBarChartSeries::legend()
106 134 }
107 135
108 136 /*!
109 INTERNAL \a category
137 \internal \a category
110 138 */
111 139 QString QBarChartSeries::label(int category)
112 140 {
@@ -164,15 +192,7 void QBarChartSeries::enableSeparators(bool enabled)
164 192 }
165 193
166 194 /*!
167 INTERNAL
168 */
169 int QBarChartSeries::countCategories()
170 {
171 return mModel->countCategories();
172 }
173
174 /*!
175 INTERNAL
195 \internal
176 196 */
177 197 qreal QBarChartSeries::min()
178 198 {
@@ -180,7 +200,7 qreal QBarChartSeries::min()
180 200 }
181 201
182 202 /*!
183 INTERNAL
203 \internal
184 204 */
185 205 qreal QBarChartSeries::max()
186 206 {
@@ -188,7 +208,7 qreal QBarChartSeries::max()
188 208 }
189 209
190 210 /*!
191 INTERNAL \a set \a category
211 \internal \a set \a category
192 212 */
193 213 qreal QBarChartSeries::valueAt(int set, int category)
194 214 {
@@ -196,7 +216,7 qreal QBarChartSeries::valueAt(int set, int category)
196 216 }
197 217
198 218 /*!
199 INTERNAL \a set \a category
219 \internal \a set \a category
200 220 */
201 221 qreal QBarChartSeries::percentageAt(int set, int category)
202 222 {
@@ -204,7 +224,7 qreal QBarChartSeries::percentageAt(int set, int category)
204 224 }
205 225
206 226 /*!
207 INTERNAL \a category
227 \internal \a category
208 228 */
209 229 qreal QBarChartSeries::categorySum(int category)
210 230 {
@@ -212,7 +232,7 qreal QBarChartSeries::categorySum(int category)
212 232 }
213 233
214 234 /*!
215 INTERNAL
235 \internal
216 236 */
217 237 qreal QBarChartSeries::maxCategorySum()
218 238 {
@@ -220,7 +240,7 qreal QBarChartSeries::maxCategorySum()
220 240 }
221 241
222 242 /*!
223 INTERNAL
243 \internal
224 244 */
225 245 BarChartModel& QBarChartSeries::model()
226 246 {
@@ -21,6 +21,7 public:
21 21 void addBarSet(QBarSet *set); // Takes ownership of set
22 22 void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
23 23 int countSets();
24 int countCategories();
24 25 QBarSet* nextSet(bool getFirst=false); // Returns first set, if called with true
25 26 QBarSet *setAt(int index);
26 27
@@ -31,7 +32,6 public:
31 32 // to private implementation, when we start using it
32 33 // TODO: TO PIMPL --->
33 34 QString label(int category);
34 int countCategories();
35 35 qreal min();
36 36 qreal max();
37 37 qreal valueAt(int set, int category);
@@ -13,6 +13,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
13 13 If set has fewer values than there are categories, then the missing values are assumed to be
14 14 at the end of set. For missing values in middle of a set, numerical value of zero is used.
15 15
16 \mainclass
17
18 Example on how to create sets of data:
19 \snippet ../example/barchart/main.cpp 2
20
16 21 \sa QBarCategory, QBarChartSeries, QStackedBarChartSeries, QPercentBarChartSeries
17 22 */
18 23
@@ -30,11 +35,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 35 */
31 36 /*!
32 37 \fn void QBarSet::toggleFloatingValues()
33 \brief INTERNAL
38 \brief \internal
34 39 */
35 40 /*!
36 41 \fn void QBarSet::showToolTip(QPoint pos, QString tip)
37 \brief INTERNAL \a pos \a tip
42 \brief \internal \a pos \a tip
38 43 */
39 44
40 45
@@ -129,7 +134,7 const QBrush& QBarSet::brush() const
129 134 }
130 135
131 136 /*!
132 INTERNAL
137 \internal
133 138 */
134 139 void QBarSet::barClicked()
135 140 {
@@ -140,7 +145,7 void QBarSet::barClicked()
140 145 }
141 146
142 147 /*!
143 INTERNAL \a pos
148 \internal \a pos
144 149 */
145 150 void QBarSet::barHoverEntered(QPoint pos)
146 151 {
@@ -149,7 +154,7 void QBarSet::barHoverEntered(QPoint pos)
149 154 }
150 155
151 156 /*!
152 INTERNAL
157 \internal
153 158 */
154 159 void QBarSet::barHoverLeaved()
155 160 {
@@ -10,6 +10,23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 10 of all bars in category. One QPercentBarChartSeries can contain multible QBarSet data sets.
11 11 QBarChartSeries groups the data from sets to categories, which are defined by QBarCategory class.
12 12
13 \mainclass
14
15 Example on how to create category:
16 \snippet ../example/barchart/main.cpp 1
17
18 Example on how to create sets of data:
19 \snippet ../example/barchart/main.cpp 2
20
21 Example on how to add sets to bar chart:
22 \snippet ../example/barchart/main.cpp 3
23
24 Example on how to enable tooltip and floating values:
25 \snippet ../example/barchart/main.cpp 4
26
27 Example on how to create view and apply theme:
28 \snippet ../example/barchart/main.cpp 5
29
13 30 \sa QBarCategory, QBarSet, QStackedBarChartSeries, QBarChartSeries
14 31 */
15 32
@@ -21,7 +38,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
21 38
22 39 /*!
23 40 Constructs empty QPercentBarChartSeries. Parameter \a category defines the categories for chart.
24 QPercentBarChartSeries is QObject which is a child of a\a parent.
41 QPercentBarChartSeries is QObject which is a child of a \a parent.
25 42 */
26 43 QPercentBarChartSeries::QPercentBarChartSeries(QBarCategory *category, QObject *parent)
27 44 : QBarChartSeries(category, parent)
@@ -10,6 +10,23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 10 stacked on top of each other. One QStackedBarChartSeries can contain multible QBarSet data sets.
11 11 QStackedBarChartSeries groups the data from sets to categories, which are defined by QBarCategory class.
12 12
13 \mainclass
14
15 Example on how to create category:
16 \snippet ../example/barchart/main.cpp 1
17
18 Example on how to create sets of data:
19 \snippet ../example/barchart/main.cpp 2
20
21 Example on how to add sets to bar chart:
22 \snippet ../example/barchart/main.cpp 3
23
24 Example on how to enable tooltip and floating values:
25 \snippet ../example/barchart/main.cpp 4
26
27 Example on how to create view and apply theme:
28 \snippet ../example/barchart/main.cpp 5
29
13 30 \sa QBarCategory, QBarSet, QPercentBarChartSeries, QBarChartSeries
14 31 */
15 32
@@ -21,7 +38,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
21 38
22 39 /*!
23 40 Constructs empty QStackedBarChartSeries. Parameter \a category defines the categories for chart.
24 QStackedBarChartSeries is QObject which is a child of a\a parent.
41 QStackedBarChartSeries is QObject which is a child of a \a parent.
25 42 */
26 43 QStackedBarChartSeries::QStackedBarChartSeries(QBarCategory *category, QObject *parent)
27 44 : QBarChartSeries(category, parent)
@@ -1,7 +1,7
1 1 #include "charttheme_p.h"
2 2 #include "qchart.h"
3 3 #include "qchartaxis.h"
4
4 #include <QTime>
5 5
6 6 //series
7 7 #include "qbarset.h"
@@ -50,6 +50,8 ChartTheme::ChartTheme(QChart::ChartTheme id)
50 50 m_seriesColor.append(QRgb(0xff707070));
51 51 m_gradientStartColor = QColor(QRgb(0xffffffff));
52 52 m_gradientEndColor = QColor(QRgb(0xffafafaf));
53
54 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
53 55 }
54 56
55 57
@@ -57,7 +59,7 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
57 59 {
58 60 switch(theme) {
59 61 case QChart::ChartThemeDefault:
60 return new ChartTheme();
62 return new ChartThemeIcy();
61 63 case QChart::ChartThemeVanilla:
62 64 return new ChartThemeVanilla();
63 65 case QChart::ChartThemeIcy:
@@ -188,31 +190,63 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/)
188 190 QColor c = m_seriesColor[i++];
189 191 i = i % m_seriesColor.count();
190 192
191 // -1 means achromatic color -> cannot manipulate lightness
192 // TODO: find a better way to randomize lightness
193 if (c.toHsv().hue() == -1)
194 qWarning() << "ChartTheme::decorate() warning: achromatic theme color";
193 // by default use the "raw" theme color
194 if (!colors.contains(c)) {
195 colors << c;
196 continue;
197 }
198 // ...ok we need to generate something that looks like the same color
199 // but different lightness
200
201 int tryCount = 0;
202 while (tryCount++ < 100) {
203
204 // find maximum value we can raise the lightness
205 int lMax = 255;
206 if (lMax > 255 - c.red())
207 lMax = 255 - c.red();
208 if (lMax > 255 - c.green())
209 lMax = 255 - c.green();
210 if (lMax > 255 - c.blue())
211 lMax = 255 - c.blue();
212
213 // find maximum value we can make it darker
214 int dMax = 255;
215 if (dMax > c.red())
216 dMax = c.red();
217 if (dMax > c.green())
218 dMax = c.green();
219 if (dMax > c.blue())
220 dMax = c.blue();
195 221
196 // randomize lightness
197 qreal f = 50 + (qrand() % 100); // 50 is 50% darker, 100 is the same, 150 is 50% lighter
198 c = c.lighter(f);
222 int max = dMax + lMax;
223 if (max == 0) {
224 // no room to make color lighter or darker...
225 qDebug() << "cannot generate a color for pie!";
226 break;
227 }
199 228
200 // find duplicates
201 bool isUnique = true;
202 foreach (QColor color, colors) {
203 if (c == color)
204 isUnique = false;
229 // generate random color
230 int r = c.red() - dMax;
231 int g = c.green() - dMax;
232 int b = c.blue() - dMax;
233 int d = qrand() % max;
234 c.setRgb(r+d, g+d, b+d);
235
236 // found a unique color?
237 if (!colors.contains(c))
238 break;
205 239 }
206 240
207 // add to array if unique
208 //if (isUnique)
209 colors << c;
241 qDebug() << "generated a color for pie" << c;
242 colors << c;
210 243 }
211 244
212 245 // finally update colors
213 246 foreach (QPieSlice* s, series->slices()) {
214 s->setPen(QPen(Qt::black)); // TODO: get from theme
215 s->setBrush(colors.takeFirst());
247 QColor c = colors.takeFirst();
248 s->setPen(c);
249 s->setBrush(c);
216 250 }
217 251 }
218 252
@@ -7,42 +7,46
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10
10 11 /*!
11 \enum QPieSeries::PiePosition
12 \class QPieSeries::ChangeSet
13 \brief Defines the changes in the series.
12 14
13 This enum describes pie position within its bounding rectangle
15 Contains the changes that have occurred in the series. Lists of added, changed and removed slices.
14 16
15 \value PiePositionMaximized
16 \value PiePositionTopLeft
17 \value PiePositionTopRight
18 \value PiePositionBottomLeft
19 \value PiePositionBottomRight
17 \sa QPieSeries::changed()
20 18 */
21 19
22 20 /*!
23 \class QPieSeries
24 \brief QtCommercial charts pie series API.
25
21 \internal
26 22 */
27
28 23 void QPieSeries::ChangeSet::appendAdded(QPieSlice* slice)
29 24 {
30 25 if (!m_added.contains(slice))
31 26 m_added << slice;
32 27 }
33 28
29 /*!
30 \internal
31 */
34 32 void QPieSeries::ChangeSet::appendAdded(QList<QPieSlice*> slices)
35 33 {
36 34 foreach (QPieSlice* s, slices)
37 35 appendAdded(s);
38 36 }
39 37
38 /*!
39 \internal
40 */
40 41 void QPieSeries::ChangeSet::appendChanged(QPieSlice* slice)
41 42 {
42 43 if (!m_changed.contains(slice))
43 44 m_changed << slice;
44 45 }
45 46
47 /*!
48 \internal
49 */
46 50 void QPieSeries::ChangeSet::appendRemoved(QPieSlice* slice)
47 51 {
48 52 if (!m_removed.contains(slice))
@@ -88,6 +92,30 bool QPieSeries::ChangeSet::isEmpty() const
88 92 }
89 93
90 94 /*!
95 \enum QPieSeries::PiePosition
96
97 This enum describes pie position within its bounding rectangle
98
99 \value PiePositionMaximized
100 \value PiePositionTopLeft
101 \value PiePositionTopRight
102 \value PiePositionBottomLeft
103 \value PiePositionBottomRight
104 */
105
106 /*!
107 \class QPieSeries
108 \brief Pie series API for QtCommercial Charts
109
110 The pie series defines a pie chart which consists of pie slices which are QPieSlice objects.
111 The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices.
112 The actual slice size (span) is determined by that relative value.
113
114 By default the pie is defined as full but it can be a partial pie.
115 This can be done by setting a starting angle and angle span to the series.
116 */
117
118 /*!
91 119 Constructs a series object which is a child of \a parent.
92 120 */
93 121 QPieSeries::QPieSeries(QObject *parent) :
@@ -109,7 +137,7 QPieSeries::~QPieSeries()
109 137 }
110 138
111 139 /*!
112 Returns the type of the series which is always QChartSeries::SeriesTypePie.
140 Returns QChartSeries::SeriesTypePie.
113 141 */
114 142 QChartSeries::QChartSeriesType QPieSeries::type() const
115 143 {
@@ -188,6 +216,7 QPieSlice* QPieSeries::add(qreal value, QString name)
188 216
189 217 /*!
190 218 Removes a single \a slice from the series and deletes the slice.
219
191 220 Do not reference this pointer after this call.
192 221 */
193 222 void QPieSeries::remove(QPieSlice* slice)
@@ -292,7 +321,7 QPieSeries::PiePosition QPieSeries::position() const
292 321 /*!
293 322 Sets the \a startAngle and \a angleSpan of this series.
294 323
295 \sa
324 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
296 325 */
297 326 void QPieSeries::setSpan(qreal startAngle, qreal angleSpan)
298 327 {
@@ -9,8 +9,13 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 10 /*!
11 11 \class QPieSlice
12 \brief QtCommercial charts pie series API.
12 \brief Defines a slice a pie series.
13 13
14 Holds all the data of a single slice in a QPieSeries and provides the means
15 to modify slice data and customize the visual appearance of the slice.
16
17 It also provides the means to customize user interaction with the slice by
18 providing signals for clicking and hover events.
14 19 */
15 20
16 21 /*!
@@ -27,7 +32,9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 32
28 33 /*!
29 34 Constructs an empty slice with a \a parent.
35
30 36 Note that QPieSeries takes ownership of the slice when it is set/added.
37
31 38 \sa QPieSeries::set(), QPieSeries::add()
32 39 */
33 40 QPieSlice::QPieSlice(QObject *parent)
@@ -128,6 +135,7 qreal QPieSlice::explodeDistance() const
128 135
129 136 /*!
130 137 Returns the percentage of this slice compared to all slices in the same series.
138
131 139 Updated internally after the slice is added to the series.
132 140 */
133 141 qreal QPieSlice::percentage() const
@@ -137,6 +145,9 qreal QPieSlice::percentage() const
137 145
138 146 /*!
139 147 Returns the starting angle of this slice in the series it belongs to.
148
149 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
150
140 151 Updated internally after the slice is added to the series.
141 152 */
142 153 qreal QPieSlice::angle() const
@@ -146,6 +157,9 qreal QPieSlice::angle() const
146 157
147 158 /*!
148 159 Returns the angle span of this slice in the series it belongs to.
160
161 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
162
149 163 Updated internally after the slice is added to the series.
150 164 */
151 165 qreal QPieSlice::angleSpan() const
@@ -22,20 +22,26
22 22 \class QChartView
23 23 \brief Standalone charting widget.
24 24
25 QChartView is a standalone widget that can display charts. It does not require separate QGraphicsScene to work. It manages the graphical
26 representation of different types of QChartSeries and other chart related objects like
27 QChartAxis and QChartLegend. If you want to display a chart in your existing QGraphicsScene, you can use the QChart class instead.
25 QChartView is a standalone widget that can display charts. It does not require separate
26 QGraphicsScene to work. It manages the graphical representation of different types of
27 QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to
28 display a chart in your existing QGraphicsScene, you can use the QChart class instead.
28 29
29 For example, to create an empty chart in a widget based application:
30 For example, to create a chart with line series using a widget based application:
30 31 \snippet ../example/chartview/main.cpp 1
31 32 \image chartview_example.jpg
32 33
33 To add a line series:
34 \snippet ../example/chartview/main.cpp 2
35 \image chartview_example_series.jpg
36
37 To modify the visual appearance of the chart, you can use the pre-defined themes:
34 Showing a few more series:
38 35 \snippet ../example/chartview/main.cpp 3
36 \image chartview_example_pie.jpg
37 \snippet ../example/chartview/main.cpp 4
38 \image chartview_example_scatter.jpg
39 \snippet ../example/chartview/main.cpp 5
40 \image chartview_example_bar.jpg
41
42 If you need to give a more professional touch to your chart you can switch to one of the
43 pre-defined themes:
44 \snippet ../example/chartview/main.cpp 2
39 45 \image chartview_example_theme.jpg
40 46
41 47 \sa QChart
1 NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now