##// END OF EJS Templates
Marek Rosa -
r337:1f21d3bffe32 merge
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,51
1 /*!
2 \page classes.html
3 \title QtCommercial Charts API
4 \keyword All Classes
5
6 \raw HTML
7 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
8 <tr>
9 <th class="titleheader" width="33%">
10 List of classes
11 </th>
12 </tr>
13 <tr>
14 <td valign="top">
15 <ul>
16 <li><a href="qbarcategory.html">QBarCategory</a></li>
17 <li><a href="qbarchartseries.html">QBarChartSeries</a></li>
18 <li><a href="qbarset.html">QBarSet</a></li>
19 <li><a href="qchart.html">QChart</a></li>
20 <li><a href="qchartaxis.html">QChartAxis</a></li>
21 <li><a href="qchartseries.html">QChartSeries</a></li>
22 <li><a href="qchartview.html">QChartView</a></li>
23 <li><a href="qlinechartseries.html">QLineChartSeries</a></li>
24 <li><a href="qpercentbarchartseries.html">QPercentBarChartSeries</a></li>
25 <li><a href="qpieseries.html">QPieSeries</a></li>
26 <li><a href="qpieslice.html">QPieSlice</a></li>
27 <li><a href="qscatterseries.html">QScatterSeries</a></li>
28 <li><a href="qstackedbarchartseries.html">QStackedBarChartSeries</a></li>
29 </ul>
30 </td>
31 </tr>
32 </table>
33
34 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
35 <tr>
36 <th class="titleheader" width="33%">
37 Other files:
38 </th>
39 </tr>
40 <tr>
41 <td valign="top">
42 <ul>
43 <li><a href="qchartglobal.html">QChartGlobal</a></li>
44 </ul>
45 </td>
46 </tr>
47 </table>
48
49 \endraw
50
51 */
@@ -0,0 +1,9
1 /*!
2 \example example/barchart
3 \title LineChart Example
4 \subtitle
5
6 The example shows how to create simple bar chart.
7
8 ...
9 */ No newline at end of file
@@ -0,0 +1,9
1 /*!
2 \example example/linechart
3 \title LineChart Example
4 \subtitle
5
6 The example shows how to create simple line chart.
7
8 ...
9 */ No newline at end of file
@@ -0,0 +1,9
1 /*!
2 \example example/piechart
3 \title LineChart Example
4 \subtitle
5
6 The example shows how to create simple pie chart.
7
8 ...
9 */ No newline at end of file
@@ -0,0 +1,24
1 /*!
2 \page examples.html
3 \title Examples
4 \keyword Examples
5
6 \raw HTML
7 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
8 <tr>
9 <th class="titleheader" width="33%">
10 List of examples
11 </th>
12 </tr>
13 <tr>
14 <td valign="top">
15 <ul>
16 <li><a href="example-barchart.html">Bar Chart example</a></li>
17 <li><a href="example-linechart.html">Line Chart example</a></li>
18 <li><a href="example-piechart.html">Pie Chart example</a></li>
19 </ul>
20 </td>
21 </tr>
22 </table>
23 \endraw
24 */
@@ -0,0 +1,26
1 /*!
2 \page tutorials.html
3 \title Tutorials
4 \keyword Tutorials
5
6 For example, to create a chart with line series using a widget based application:
7 \snippet ../example/chartview/main.cpp 1
8 \image chartview_example.jpg
9
10 To replace the line series with a pie series you use the dedicated QPieSeries class:
11 \snippet ../example/chartview/main.cpp 3
12 \image chartview_example_pie.jpg
13
14 To use a scatter series you use QScatterSeries class:
15 \snippet ../example/chartview/main.cpp 4
16 \image chartview_example_scatter.jpg
17
18 And to show a bar series you use one of the bar series classes, for example QBarChartSeries:
19 \snippet ../example/chartview/main.cpp 5
20 \image chartview_example_bar.jpg
21
22 If you need to give a more professional touch to your chart you can switch from the default
23 theme to one of the other themes:
24 \snippet ../example/chartview/main.cpp 2
25 \image chartview_example_theme.jpg
26 */
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,49 +1,57
1 include(qt-html-default-styles.qdocconf)
1 include(qchart-html.qdocconf)
2
2
3 HTML.postheader = \
3 HTML.postheader = \
4 "<div class=\"header\" id=\"qtdocheader\">\n" \
4 "<div class=\"header\" id=\"qtdocheader\">\n" \
5 " <div class=\"content\"> \n" \
5 " <div class=\"content\"> \n" \
6 " <a href=\"index.html\" class=\"qtref\"><span>QChart Reference Documentation</span></a>\n" \
6 " <img src=\"images/qcharts.png\" alt=\"qcharts\"/>\n" \
7 " <p class=\"qtref\"> \n" \
8 " <span>Reference Documentation</span>\n" \
9 " </p>\n" \
7 " </div>\n" \
10 " </div>\n" \
8 " <div class=\"breadcrumb toolblock\">\n" \
11 " <div class=\"breadcrumb toolblock\">\n" \
9 " <ul>\n" \
12 " <ul>\n" \
10 " <li class=\"first\"><a href=\"index.html\">Home</a></li>\n" \
13 " <li class=\"first\"><a href=\"index.html\">About</a></li>\n" \
14 " <li><a href=\"classes.html\">API Classes</a></li>\n" \
15 " <li><a href=\"tutorials.html\">Tutorials</a></li>\n" \
16 " <li><a href=\"examples.html\">Examples</a></li>\n" \
11 " <!-- Breadcrumbs go here -->\n"
17 " <!-- Breadcrumbs go here -->\n"
12
18
13 HTML.postpostheader = \
19 HTML.postpostheader = \
14 " </ul>\n" \
20 " </ul>\n" \
15 " </div>\n" \
21 " </div>\n" \
16 "</div>\n" \
22 "</div>\n" \
17 "<div class=\"content mainContent\">\n"
23 "<div class=\"content mainContent\">\n"
18
24
19 HTML.footer = \
25 HTML.footer = \
20 " <div class=\"ft\">\n" \
26 " <div class=\"ft\">\n" \
21 " <span></span>\n" \
27 " <span></span>\n" \
22 " </div>\n" \
28 " </div>\n" \
23 "</div> \n" \
29 "</div> \n" \
24 "<div class=\"footer\">\n" \
30 "<div class=\"footer\">\n" \
25 " <p>\n" \
31 " <p>\n" \
26 " <acronym title=\"Copyright\">&copy;</acronym> 2012 Digia ." \
32 " <acronym title=\"Copyright\">&copy;</acronym> 2012 Digia ." \
27 " Qt and Qt logos are trademarks of of Nokia Corporation \n" \
33 " Qt and Qt logos are trademarks of of Nokia Corporation \n" \
28 " in Finland and/or other countries worldwide.</p>\n" \
34 " in Finland and/or other countries worldwide.</p>\n" \
29 " <p>\n" \
35 " <p>\n" \
30 " All other trademarks are property of their respective owners.</p>\n" \
36 " All other trademarks are property of their respective owners.</p>\n" \
31 " <br />\n" \
37 " <br />\n" \
32 " <p>\n" \
38 " <p>\n" \
33 " Licensees holding valid Qt Commercial licenses may use this document in accordance with the" \
39 " Licensees holding valid Qt Commercial licenses may use this document in accordance with the" \
34 " Qt Commercial License Agreement provided with the Software or, alternatively, in accordance" \
40 " Qt Commercial License Agreement provided with the Software or, alternatively, in accordance" \
35 " with the terms contained in a written agreement between you and Digia.</p>\n" \
41 " with the terms contained in a written agreement between you and Digia.</p>\n" \
42 " <p>\n" \
43 " <img src=\"images/digia_logo.png\" alt=\"digia\" /></p>\n" \
36 "</div>\n" \
44 "</div>\n" \
37
45
38 # Files not referenced in any qdoc file.
46 # Files not referenced in any qdoc file.
39 # See also extraimages.HTML
47 # See also extraimages.HTML
40 qhp.QDoc.extraFiles = index.html \
48 qhp.QDoc.extraFiles = index.html \
41 images/arrow_down.png \
49 images/arrow_down.png \
42 images/breadcrumb.png \
50 images/breadcrumb.png \
43 images/bullet_gt.png \
51 images/bullet_gt.png \
44 images/bullet_dn.png \
52 images/bullet_dn.png \
45 images/bullet_sq.png \
53 images/bullet_sq.png \
46 images/bullet_up.png \
54 images/bullet_up.png \
47 images/horBar.png \
55 images/horBar.png \
48 images/sprites-combined.png \
56 images/qcharts.png \
49 style/offline.css
57 style/offline.css
@@ -1,34 +1,41
1 # Define the location of the templates to use. Style sheets and scripts are
1 # Define the location of the templates to use. Style sheets and scripts are
2 # specified relative to the template directory and will be copied into
2 # specified relative to the template directory and will be copied into
3 # subdirectories of the output directory.
3 # subdirectories of the output directory.
4
4
5 HTML.templatedir = .
5 HTML.templatedir = .
6
6
7 HTML.stylesheets = style/offline.css
7 HTML.stylesheets = style/offline.css
8
8
9 HTML.scripts =
9 HTML.scripts =
10
10
11 # Files not referenced in any qdoc file, many needed by style sheets.
11 # Files not referenced in any qdoc file, many needed by style sheets.
12 # These also need to be listed in qhp.Qt.extraFiles with the correct
12 # These also need to be listed in qhp.Qt.extraFiles with the correct
13 # directory prefixes.
13 # directory prefixes.
14
14
15 extraimages.HTML = qt-logo.png \
15 extraimages.HTML = qt_commercial_logo.png \
16 digia_logo.png \
17 qcharts.png \
16 arrow_down.png \
18 arrow_down.png \
17 breadcrumb.png \
19 breadcrumb.png \
18 bullet_gt.png \
20 bullet_gt.png \
19 bullet_dn.png \
21 bullet_dn.png \
20 bullet_sq.png \
22 bullet_sq.png \
21 bullet_up.png \
23 bullet_up.png \
22 horBar.png \
24 horBar.png \
23 sprites-combined.png
25 bg.png
26
27
28
24
29
25 # Include the style sheets and scripts used.
30 # Include the style sheets and scripts used.
26
31
27 HTML.headerstyles = \
32 HTML.headerstyles = \
28 " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n"
33 " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n"
29
34
30 HTML.headerscripts =
35 HTML.headerscripts =
31
36
32 HTML.endheader = \
37 HTML.endheader = \
33 "</head>\n" \
38 "</head>\n" \
34 "<body>\n"
39 "<body>\n"
40
41 HTML.nobreadcrumbs = true No newline at end of file
@@ -1,48 +1,46
1 include(compat.qdocconf)
1 include(compat.qdocconf)
2 include(macros.qdocconf)
2 include(macros.qdocconf)
3 include(qt-html-templates.qdocconf)
3 include(qchart-html-template.qdocconf)
4
4
5 project = QtCommercialCharts
5 project = QtCommercialCharts
6 description = Library for creating charts
6 description = Library for creating charts
7
7
8 sourcedirs = ../src \
8 sourcedirs = ../src \
9 ../example \
9 ../example \
10 ./src
10 ./src
11 headerdirs = ../src \
11 headerdirs = ../src \
12 ../example
12 ../example
13 exampledirs = ../src \
13 exampledirs = ../ \
14 ../example
14 ../src \
15
15 ../example
16 HTML.templatedir = .
16
17 HTML.stylesheets = style/offline.css
17 excludefiles += ../example/linechart/linechart.pro
18 HTML.headerstyles= "<link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n"
19 HTML.nobreadcrumbs = true
20
18
21 sources.fileextensions = *.cpp *.qdoc *.mm *.qml
19 sources.fileextensions = *.cpp *.qdoc *.mm *.qml
22 headers.fileextensions = *.h *.ch *.h++ *.hh *.hpp *.hxx
20 headers.fileextensions = *.h *.ch *.h++ *.hh *.hpp *.hxx
23 examples.fileextensions = *.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml
21 examples.fileextensions = *.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml
24 examples.imageextensions = *.png *.jpeg *.jpg *.gif *.mng
22 examples.imageextensions = *.png *.jpeg *.jpg *.gif *.mng
25
23
26 imagedirs = ./images
24 imagedirs = ./images
27 outputdir = ./html
25 outputdir = ./html
28
26
29
27
30 Cpp.ignoretokens = QTCOMMERCIALCHART_EXPORT \
28 Cpp.ignoretokens = QTCOMMERCIALCHART_EXPORT \
31 QTCOMMERCIALCHART_END_NAMESPACE \
29 QTCOMMERCIALCHART_END_NAMESPACE \
32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 Cpp.ignoredirectives = Q_DECLARE_HANDLE \
31 Cpp.ignoredirectives = Q_DECLARE_HANDLE \
34 Q_DECLARE_INTERFACE \
32 Q_DECLARE_INTERFACE \
35 Q_DECLARE_METATYPE \
33 Q_DECLARE_METATYPE \
36 Q_DECLARE_OPERATORS_FOR_FLAGS \
34 Q_DECLARE_OPERATORS_FOR_FLAGS \
37 Q_DECLARE_PRIVATE \
35 Q_DECLARE_PRIVATE \
38 Q_DECLARE_PUBLIC \
36 Q_DECLARE_PUBLIC \
39 Q_DECLARE_SHARED \
37 Q_DECLARE_SHARED \
40 Q_DECLARE_TR_FUNCTIONS \
38 Q_DECLARE_TR_FUNCTIONS \
41 Q_DECLARE_TYPEINFO \
39 Q_DECLARE_TYPEINFO \
42 Q_DISABLE_COPY \
40 Q_DISABLE_COPY \
43 QT_FORWARD_DECLARE_CLASS \
41 QT_FORWARD_DECLARE_CLASS \
44 Q_DUMMY_COMPARISON_OPERATOR \
42 Q_DUMMY_COMPARISON_OPERATOR \
45 Q_ENUMS \
43 Q_ENUMS \
46 Q_FLAGS \
44 Q_FLAGS \
47 Q_INTERFACES \
45 Q_INTERFACES \
48 __attribute__ No newline at end of file
46 __attribute__
@@ -1,51 +1,29
1 /*!
1 /*!
2 \page index.html
2 \page index.html
3 \title QtCommercial Charts
3 \keyword About
4 \keyword All Classes
5
4
6 TODO: restructure the document
5 \raw HTML
7
6 <div class="qchart">
8 QtCommercial Charts introduction...
7 <img src="images/qt_commercial_logo.png" alt="qtcommercial"/>
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
26 \raw HTML
27 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
28 <tr>
29 <th class="titleheader" width="33%">
30 List of classes
31 </th>
32 </tr>
33 <tr>
34 <td valign="top">
35 <ul>
36 <li><a href="qchart.html">QChart</a></li>
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>
45 </ul>
46 </td>
47 </tr>
48 </table>
49 \endraw
50
8
9 <p>
10 QCharts is a part of Qt Commercial addons package. It provides a set of simple chart components which are available for Qt Commercial customers.
11 It uses Qt Graphics View Framework, therefore charts can be easily integrated 2D modern user interfaces. QCharts can be used as QWidgets, QGraphicsWidget or QML elements.
12 Users can easily create impressive graphs by selecting one of the charts themes.
13 </p>
14 <table><tr>
15 <td><img src="images/linechart.png" alt="linechart" /></td>
16 <td><img src="images/chartview_example_bar.jpg " alt="barchart" /></td>
17 <td><img src="images/chartview_example_pie.jpg " alt="piechart" /></td>
18 </tr>
19 <tr>
20 <td><img src="images/chartview_example.jpg " alt="linechart" /></td>
21 <td><img src="images/chartview_example_scatter.jpg " alt="scatterchart" /></td>
22 <td><img src="images/chartview_example_theme.jpg " alt="themechart" /></td>
23 </tr>
24 </table>
25 </div>
26 \endraw
27
28
51 */
29 */
@@ -1,673 +1,708
1 @media screen
1 @media screen
2 {
2 {
3
3
4 .qchart
5 {
6 width: 80%;
7 margin-left: auto;
8 margin-right: auto;
9 margin-top: 50px;
10 }
11
12 .qchart img
13 {
14 float:left;
15 }
16
17 .qchart table
18 {
19 margin-top: 50px;
20 }
21
4 /* basic elements */
22 /* basic elements */
5 html
23 html
6 {
24 {
7 color: #000000;
25 color: #000000;
8 background: #FFFFFF;
26 background: #FFFFFF;
9 }
27 }
10 table
28 table
11 {
29 {
12 border-collapse: collapse;
30 border-collapse: collapse;
13 border-spacing: 0;
31 border-spacing: 0;
14 }
32 }
15 fieldset, img
33 fieldset, img
16 {
34 {
17 border: 0;
35 border: 0;
18 max-width:100%;
36 max-width:100%;
19 }
37 }
20 address, caption, cite, code, dfn, em, strong, th, var, optgroup
38 address, caption, cite, code, dfn, em, strong, th, var, optgroup
21 {
39 {
22 font-style: inherit;
40 font-style: inherit;
23 font-weight: inherit;
41 font-weight: inherit;
24 }
42 }
25 del, ins
43 del, ins
26 {
44 {
27 text-decoration: none;
45 text-decoration: none;
28 }
46 }
29 li
47 li
30 {
48 {
31 list-style: none;
49 list-style: none;
32 }
50 }
33 ol li
51 ol li
34 {
52 {
35 list-style: decimal;
53 list-style: decimal;
36 }
54 }
37 caption, th
55 caption, th
38 {
56 {
39 text-align: left;
57 text-align: left;
40 }
58 }
41 h1, h2, h3, h4, h5, h6
59 h1, h2, h3, h4, h5, h6
42 {
60 {
43 font-size: 100%;
61 font-size: 100%;
44 }
62 }
45 q:before, q:after
63 q:before, q:after
46 {
64 {
47 content: '';
65 content: '';
48 }
66 }
49 abbr, acronym
67 abbr, acronym
50 {
68 {
51 border: 0;
69 border: 0;
52 font-variant: normal;
70 font-variant: normal;
53 }
71 }
54 sup, sub
72 sup, sub
55 {
73 {
56 vertical-align: baseline;
74 vertical-align: baseline;
57 }
75 }
58 tt, .qmlreadonly span, .qmldefault span
76 tt, .qmlreadonly span, .qmldefault span
59 {
77 {
60 word-spacing:0.5em;
78 word-spacing:0.5em;
61 }
79 }
62 legend
80 legend
63 {
81 {
64 color: #000000;
82 color: #000000;
65 }
83 }
66 strong
84 strong
67 {
85 {
68 font-weight: bold;
86 font-weight: bold;
69 }
87 }
70 em
88 em
71 {
89 {
72 font-style: italic;
90 font-style: italic;
73 }
91 }
74
92
75 body
93 body
76 {
94 {
77 margin-left: 0.5em;
95 margin-left: 0.5em;
78 margin-right: 0.5em;
96 margin-right: 0.5em;
79 }
97 }
80 a
98 a
81 {
99 {
82 color: #00732F;
100 color: #00732F;
83 text-decoration: none;
101 text-decoration: none;
84 }
102 }
85 hr
103 hr
86 {
104 {
87 background-color: #E6E6E6;
105 background-color: #E6E6E6;
88 border: 1px solid #E6E6E6;
106 border: 1px solid #E6E6E6;
89 height: 1px;
107 height: 1px;
90 width: 100%;
108 width: 100%;
91 text-align: left;
109 text-align: left;
92 margin: 1.5em 0 1.5em 0;
110 margin: 1.5em 0 1.5em 0;
93 }
111 }
94
112
95 pre
113 pre
96 {
114 {
97 border: 1px solid #DDDDDD;
115 border: 1px solid #DDDDDD;
98 -moz-border-radius: 0.7em 0.7em 0.7em 0.7em;
116 -moz-border-radius: 0.7em 0.7em 0.7em 0.7em;
99 -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em;
117 -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em;
100 border-radius: 0.7em 0.7em 0.7em 0.7em;
118 border-radius: 0.7em 0.7em 0.7em 0.7em;
101 margin: 0 1.5em 1em 1em;
119 margin: 0 1.5em 1em 1em;
102 padding: 1em 1em 1em 1em;
120 padding: 1em 1em 1em 1em;
103 overflow-x: auto;
121 overflow-x: auto;
104 }
122 }
105 table, pre
123 table, pre
106 {
124 {
107 -moz-border-radius: 0.7em 0.7em 0.7em 0.7em;
125 -moz-border-radius: 0.7em 0.7em 0.7em 0.7em;
108 -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em;
126 -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em;
109 border-radius: 0.7em 0.7em 0.7em 0.7em;
127 border-radius: 0.7em 0.7em 0.7em 0.7em;
110 background-color: #F6F6F6;
128 background-color: #F6F6F6;
111 border: 1px solid #E6E6E6;
129 border: 1px solid #E6E6E6;
112 border-collapse: separate;
130 border-collapse: separate;
113 margin-bottom: 2.5em;
131 margin-bottom: 2.5em;
114 }
132 }
115 pre {
133 pre {
116 font-size: 90%;
134 font-size: 90%;
117 display: block;
135 display: block;
118 overflow:hidden;
136 overflow:hidden;
119 }
137 }
120 thead
138 thead
121 {
139 {
122 margin-top: 0.5em;
140 margin-top: 0.5em;
123 font-weight: bold
141 font-weight: bold
124 }
142 }
125 th
143 th
126 {
144 {
127 padding: 0.5em 1.5em 0.5em 1.5em;
145 padding: 0.5em 1.5em 0.5em 1.5em;
128 background-color: #E1E1E1;
146 background-color: #E1E1E1;
129 border-left: 1px solid #E6E6E6;
147 border-left: 1px solid #E6E6E6;
130 }
148 }
131 td
149 td
132 {
150 {
133 padding: 0.25em 1.5em 0.25em 2em;
151 padding: 0.25em 1.5em 0.25em 2em;
134 }
152 }
135
153
136 td.rightAlign
154 td.rightAlign
137 {
155 {
138 padding: 0.25em 0.5em 0.25em 1em;
156 padding: 0.25em 0.5em 0.25em 1em;
139 }
157 }
140 table tr.odd
158 table tr.odd
141 {
159 {
142 border-left: 1px solid #E6E6E6;
160 border-left: 1px solid #E6E6E6;
143 background-color: #F6F6F6;
161 background-color: #F6F6F6;
144 color: #66666E;
162 color: #66666E;
145 }
163 }
146 table tr.even
164 table tr.even
147 {
165 {
148 border-left: 1px solid #E6E6E6;
166 border-left: 1px solid #E6E6E6;
149 background-color: #ffffff;
167 background-color: #ffffff;
150 color: #66666E;
168 color: #66666E;
151 }
169 }
152
170
153 div.float-left
171 div.float-left
154 {
172 {
155 float: left; margin-right: 2em
173 float: left; margin-right: 2em
156 }
174 }
157 div.float-right
175 div.float-right
158 {
176 {
159 float: right; margin-left: 2em
177 float: right; margin-left: 2em
160 }
178 }
161
179
162 span.comment
180 span.comment
163 {
181 {
164 color: #008B00;
182 color: #008B00;
165 font-style: italic
183 font-style: italic
166 }
184 }
167 span.string, span.char
185 span.string, span.char
168 {
186 {
169 color: #000084;
187 color: #000084;
170 }
188 }
171 span.number
189 span.number
172 {
190 {
173 color: #a46200;
191 color: #a46200;
174 }
192 }
175 span.operator
193 span.operator
176 {
194 {
177 color: #202020;
195 color: #202020;
178 }
196 }
179 span.keyword
197 span.keyword
180 {
198 {
181 color: #840000;
199 color: #840000;
182 }
200 }
183 span.name
201 span.name
184 {
202 {
185 color: black
203 color: black
186 }
204 }
187 span.type
205 span.type
188 {
206 {
189 font-weight: bold
207 font-weight: bold
190 }
208 }
191 span.type a:visited
209 span.type a:visited
192 {
210 {
193 color: #0F5300;
211 color: #0F5300;
194 }
212 }
195 span.preprocessor
213 span.preprocessor
196 {
214 {
197 color: #404040
215 color: #404040
198 }
216 }
199 /* end basic elements */
217 /* end basic elements */
200
218
201 /* font style elements */
219 /* font style elements */
202 .heading
220 .heading
203 {
221 {
204 font-weight: bold;
222 font-weight: bold;
205 font-size: 125%;
223 font-size: 125%;
206 }
224 }
207 .subtitle
225 .subtitle
208 {
226 {
209 font-size: 110%
227 font-size: 110%
210 }
228 }
211 .small-subtitle
229 .small-subtitle
212 {
230 {
213 font-size: 100%
231 font-size: 100%
214 }
232 }
215 .red
233 .red
216 {
234 {
217 color:red;
235 color:red;
218 }
236 }
219 /* end font style elements */
237 /* end font style elements */
220
238
221 /* global settings*/
239 /* global settings*/
222 .header, .footer
240 .header, .footer
223 {
241 {
224 display: block;
242 display: block;
225 clear: both;
243 clear: both;
226 overflow: hidden;
244 overflow: hidden;
227 }
245 }
228 /* end global settings*/
246 /* end global settings*/
229
247
230 /* header elements */
248 /* header elements */
231 .header .qtref
249 .header .qtref
232 {
250 {
233 color: #00732F;
251 color: #00732F;
234 font-weight: bold;
252 font-weight: bold;
235 font-size: 130%;
253 font-size: 100%;
254 text-align: center;
236 }
255 }
237
256
238 .header .content
257 .header .content
239 {
258 {
240 margin-bottom: 0.5em
259 /* margin-bottom: 0.5em*/
241 }
260 }
242
261
262 .header .content img
263 {
264 display: block;
265 margin-left: auto;
266 margin-right: auto;
267 width: 100px;
268 }
269
243 .naviNextPrevious
270 .naviNextPrevious
244 {
271 {
245 display: none
272 display: none
246 }
273 }
247 .header .breadcrumb
274 .header .breadcrumb
248 {
275 {
249 font-size: 90%;
276 font-size: 100%;
250 padding: 0.5em 0 0.5em 1em;
277 padding: 0.5em 0 0.5em 1em;
251 margin: 0;
278 margin: 0;
252 background-color: #fafafa;
279 /*background-color: #393735;*/
253 height: 1.35em;
280 font-weight: bold;
281 background: #ffffff url(../images/bg.png) repeat-x;
282 height: 20px;
254 border-bottom: 1px solid #d1d1d1;
283 border-bottom: 1px solid #d1d1d1;
255 }
284 }
256
285
257 .header .breadcrumb ul
286 .header .breadcrumb ul
258 {
287 {
259 margin: 0;
288 margin: 0;
260 padding: 0;
289 padding: 0;
261 }
290 }
262
291
263 .header .content
292 .header .content
264 {
293 {
265 word-wrap: break-word;
294 word-wrap: break-word;
266 }
295 }
267
296
268 .header .breadcrumb ul li
297 .header .breadcrumb ul li
269 {
298 {
270 float: left;
299 float: left;
271 background: url(../images/breadcrumb.png) no-repeat 0 3px;
300 /*background: url(../images/breadcrumb.png) no-repeat 0 3px;*/
272 padding-left: 1.5em;
301 padding-left: 1.5em;
273 margin-left: 1.5em;
302 margin-left: 1.5em;
274 }
303 }
275
304
276 .header .breadcrumb ul li.last
305 .header .breadcrumb ul li.last
277 {
306 {
278 font-weight: normal;
307 font-weight: normal;
279 }
308 }
280
309
281 .header .breadcrumb ul li a
310 .header .breadcrumb ul li a
282 {
311 {
283 color: #00732F;
312 color: #ffffff;
284 }
313 }
285
314
315 .header .breadcrumb ul li a:hover
316 {
317 color: #00732F;
318 text-decoration: none;
319 }
320
286 .header .breadcrumb ul li.first
321 .header .breadcrumb ul li.first
287 {
322 {
288 background-image: none;
323 background-image: none;
289 padding-left: 0;
324 padding-left: 0;
290 margin-left: 0;
325 margin-left: 0;
291 }
326 }
292
327
293 .header .content ol li {
328 .header .content ol li {
294 background: none;
329 background: none;
295 margin-bottom: 1.0em;
330 margin-bottom: 1.0em;
296 margin-left: 1.2em;
331 margin-left: 1.2em;
297 padding-left: 0
332 padding-left: 0
298 }
333 }
299
334
300 .header .content li
335 .header .content li
301 {
336 {
302 background: url(../images/bullet_sq.png) no-repeat 0 5px;
337 background: url(../images/bullet_sq.png) no-repeat 0 5px;
303 margin-bottom: 1em;
338 margin-bottom: 1em;
304 padding-left: 1.2em;
339 padding-left: 1.2em;
305 }
340 }
306
341
307 /* end header elements */
342 /* end header elements */
308
343
309 /* content elements */
344 /* content elements */
310 .content h1
345 .content h1
311 {
346 {
312 font-weight: bold;
347 font-weight: bold;
313 font-size: 150%
348 font-size: 150%
314 }
349 }
315
350
316 .content h2
351 .content h2
317 {
352 {
318 font-weight: bold;
353 font-weight: bold;
319 font-size: 135%;
354 font-size: 135%;
320 width: 100%;
355 width: 100%;
321 }
356 }
322 .content h3
357 .content h3
323 {
358 {
324 font-weight: bold;
359 font-weight: bold;
325 font-size: 120%;
360 font-size: 120%;
326 width: 100%;
361 width: 100%;
327 }
362 }
328 .content table p
363 .content table p
329 {
364 {
330 margin: 0
365 margin: 0
331 }
366 }
332 .content ul
367 .content ul
333 {
368 {
334 padding-left: 2.5em;
369 padding-left: 2.5em;
335 }
370 }
336 .content li
371 .content li
337 {
372 {
338 padding-top: 0.25em;
373 padding-top: 0.25em;
339 padding-bottom: 0.25em;
374 padding-bottom: 0.25em;
340 }
375 }
341 .content ul img {
376 .content ul img {
342 vertical-align: middle;
377 vertical-align: middle;
343 }
378 }
344
379
345 .content a:visited
380 .content a:visited
346 {
381 {
347 color: #4c0033;
382 color: #4c0033;
348 text-decoration: none;
383 text-decoration: none;
349 }
384 }
350
385
351 .content a:visited:hover
386 .content a:visited:hover
352 {
387 {
353 color: #4c0033;
388 color: #4c0033;
354 text-decoration: underline;
389 text-decoration: underline;
355 }
390 }
356
391
357 a:hover
392 a:hover
358 {
393 {
359 color: #4c0033;
394 color: #4c0033;
360 text-decoration: underline;
395 text-decoration: underline;
361 }
396 }
362 descr p a
397 descr p a
363 {
398 {
364 text-decoration: underline;
399 text-decoration: underline;
365 }
400 }
366
401
367 .descr p a:visited
402 .descr p a:visited
368 {
403 {
369 text-decoration: underline;
404 text-decoration: underline;
370 }
405 }
371
406
372 .alphaChar{
407 .alphaChar{
373 width:95%;
408 width:95%;
374 background-color:#F6F6F6;
409 background-color:#F6F6F6;
375 border:1px solid #E6E6E6;
410 border:1px solid #E6E6E6;
376 -moz-border-radius: 7px 7px 7px 7px;
411 -moz-border-radius: 7px 7px 7px 7px;
377 border-radius: 7px 7px 7px 7px;
412 border-radius: 7px 7px 7px 7px;
378 -webkit-border-radius: 7px 7px 7px 7px;
413 -webkit-border-radius: 7px 7px 7px 7px;
379 font-size:12pt;
414 font-size:12pt;
380 padding-left:10px;
415 padding-left:10px;
381 margin-top:10px;
416 margin-top:10px;
382 margin-bottom:10px;
417 margin-bottom:10px;
383 }
418 }
384 .flowList{
419 .flowList{
385 /*vertical-align:top;*/
420 /*vertical-align:top;*/
386 /*margin:20px auto;*/
421 /*margin:20px auto;*/
387
422
388 column-count:3;
423 column-count:3;
389 -webkit-column-count:3;
424 -webkit-column-count:3;
390 -moz-column-count:3;
425 -moz-column-count:3;
391 /*
426 /*
392 column-width:100%;
427 column-width:100%;
393 -webkit-column-width:200px;
428 -webkit-column-width:200px;
394 -col-column-width:200px;
429 -col-column-width:200px;
395 */
430 */
396 column-gap:41px;
431 column-gap:41px;
397 -webkit-column-gap:41px;
432 -webkit-column-gap:41px;
398 -moz-column-gap:41px;
433 -moz-column-gap:41px;
399
434
400 column-rule: 1px dashed #ccc;
435 column-rule: 1px dashed #ccc;
401 -webkit-column-rule: 1px dashed #ccc;
436 -webkit-column-rule: 1px dashed #ccc;
402 -moz-column-rule: 1px dashed #ccc;
437 -moz-column-rule: 1px dashed #ccc;
403 }
438 }
404
439
405 .flowList dl{
440 .flowList dl{
406 }
441 }
407 .flowList dd{
442 .flowList dd{
408 /*display:inline-block;*/
443 /*display:inline-block;*/
409 margin-left:10px;
444 margin-left:10px;
410 min-width:250px;
445 min-width:250px;
411 line-height: 1.5;
446 line-height: 1.5;
412 min-width:100%;
447 min-width:100%;
413 min-height:15px;
448 min-height:15px;
414 }
449 }
415
450
416 .flowList dd a{
451 .flowList dd a{
417 }
452 }
418
453
419 .content .flowList p{
454 .content .flowList p{
420 padding:0px;
455 padding:0px;
421 }
456 }
422
457
423 .content .alignedsummary
458 .content .alignedsummary
424 {
459 {
425 margin: 15px;
460 margin: 15px;
426 }
461 }
427
462
428
463
429 .qmltype
464 .qmltype
430 {
465 {
431 text-align: center;
466 text-align: center;
432 font-size: 120%;
467 font-size: 120%;
433 }
468 }
434 .qmlreadonly
469 .qmlreadonly
435 {
470 {
436 padding-left: 5px;
471 padding-left: 5px;
437 float: right;
472 float: right;
438 color: #254117;
473 color: #254117;
439 }
474 }
440
475
441 .qmldefault
476 .qmldefault
442 {
477 {
443 padding-left: 5px;
478 padding-left: 5px;
444 float: right;
479 float: right;
445 color: red;
480 color: red;
446 }
481 }
447
482
448 .qmldoc
483 .qmldoc
449 {
484 {
450 }
485 }
451
486
452 .generic .alphaChar{
487 .generic .alphaChar{
453 margin-top:5px;
488 margin-top:5px;
454 }
489 }
455
490
456 .generic .odd .alphaChar{
491 .generic .odd .alphaChar{
457 background-color: #F6F6F6;
492 background-color: #F6F6F6;
458 }
493 }
459
494
460 .generic .even .alphaChar{
495 .generic .even .alphaChar{
461 background-color: #FFFFFF;
496 background-color: #FFFFFF;
462 }
497 }
463
498
464 .memItemRight{
499 .memItemRight{
465 padding: 0.25em 1.5em 0.25em 0;
500 padding: 0.25em 1.5em 0.25em 0;
466 }
501 }
467 .highlightedCode
502 .highlightedCode
468 {
503 {
469 margin: 1.0em;
504 margin: 1.0em;
470 }
505 }
471 .annotated td {
506 .annotated td {
472 padding: 0.25em 0.5em 0.25em 0.5em;
507 padding: 0.25em 0.5em 0.25em 0.5em;
473 }
508 }
474
509
475 .header .content .toc ul
510 .header .content .toc ul
476 {
511 {
477 padding-left: 0px;
512 padding-left: 0px;
478 }
513 }
479
514
480 .content .toc h3 {
515 .content .toc h3 {
481 border-bottom: 0px;
516 border-bottom: 0px;
482 margin-top: 0px;
517 margin-top: 10px;
483 }
518 }
484
519
485 .content .toc h3 a:hover {
520 .content .toc h3 a:hover {
486 color: #00732F;
521 color: #00732F;
487 text-decoration: none;
522 text-decoration: none;
488 }
523 }
489
524
490 .content .toc .level2
525 .content .toc .level2
491 {
526 {
492 margin-left: 1.5em;
527 margin-left: 1.5em;
493 }
528 }
494
529
495 .content .toc .level3
530 .content .toc .level3
496 {
531 {
497 margin-left: 3.0em;
532 margin-left: 3.0em;
498 }
533 }
499
534
500 .content ul li
535 .content ul li
501 {
536 {
502 background: url(../images/bullet_sq.png) no-repeat 0 0.7em;
537 background: url(../images/bullet_sq.png) no-repeat 0 0.7em;
503 padding-left: 1em
538 padding-left: 1em
504 }
539 }
505
540
506 .content .toc li
541 .content .toc li
507 {
542 {
508 background: url(../images/bullet_dn.png) no-repeat 0 5px;
543 background: url(../images/bullet_dn.png) no-repeat 0 5px;
509 padding-left: 1em
544 padding-left: 1em
510 }
545 }
511
546
512 .relpage
547 .relpage
513 {
548 {
514 -moz-border-radius: 7px 7px 7px 7px;
549 -moz-border-radius: 7px 7px 7px 7px;
515 -webkit-border-radius: 7px 7px 7px 7px;
550 -webkit-border-radius: 7px 7px 7px 7px;
516 border-radius: 7px 7px 7px 7px;
551 border-radius: 7px 7px 7px 7px;
517 border: 1px solid #DDDDDD;
552 border: 1px solid #DDDDDD;
518 padding: 25px 25px;
553 padding: 25px 25px;
519 clear: both;
554 clear: both;
520 }
555 }
521 .relpage ul
556 .relpage ul
522 {
557 {
523 float: none;
558 float: none;
524 padding: 1.5em;
559 padding: 1.5em;
525 }
560 }
526
561
527 h3.fn, span.fn
562 h3.fn, span.fn
528 {
563 {
529 -moz-border-radius:7px 7px 7px 7px;
564 -moz-border-radius:7px 7px 7px 7px;
530 -webkit-border-radius:7px 7px 7px 7px;
565 -webkit-border-radius:7px 7px 7px 7px;
531 border-radius:7px 7px 7px 7px;
566 border-radius:7px 7px 7px 7px;
532 background-color: #F6F6F6;
567 background-color: #F6F6F6;
533 border-width: 1px;
568 border-width: 1px;
534 border-style: solid;
569 border-style: solid;
535 border-color: #E6E6E6;
570 border-color: #E6E6E6;
536 font-weight: bold;
571 font-weight: bold;
537 word-spacing:3px;
572 word-spacing:3px;
538 padding:3px 5px;
573 padding:3px 5px;
539 }
574 }
540
575
541 .functionIndex {
576 .functionIndex {
542 font-size:12pt;
577 font-size:12pt;
543 word-spacing:10px;
578 word-spacing:10px;
544 margin-bottom:10px;
579 margin-bottom:10px;
545 background-color: #F6F6F6;
580 background-color: #F6F6F6;
546 border-width: 1px;
581 border-width: 1px;
547 border-style: solid;
582 border-style: solid;
548 border-color: #E6E6E6;
583 border-color: #E6E6E6;
549 -moz-border-radius: 7px 7px 7px 7px;
584 -moz-border-radius: 7px 7px 7px 7px;
550 -webkit-border-radius: 7px 7px 7px 7px;
585 -webkit-border-radius: 7px 7px 7px 7px;
551 border-radius: 7px 7px 7px 7px;
586 border-radius: 7px 7px 7px 7px;
552 width:100%;
587 width:100%;
553 }
588 }
554
589
555 .centerAlign
590 .centerAlign
556 {
591 {
557 text-align:center;
592 text-align:center;
558 }
593 }
559
594
560 .rightAlign
595 .rightAlign
561 {
596 {
562 text-align:right;
597 text-align:right;
563 }
598 }
564
599
565 .leftAlign
600 .leftAlign
566 {
601 {
567 text-align:left;
602 text-align:left;
568 }
603 }
569
604
570 .topAlign{
605 .topAlign{
571 vertical-align:top
606 vertical-align:top
572 }
607 }
573
608
574 .functionIndex a{
609 .functionIndex a{
575 display:inline-block;
610 display:inline-block;
576 }
611 }
577
612
578 /* end content elements */
613 /* end content elements */
579 /* footer elements */
614 /* footer elements */
580
615
581 .footer
616 .footer
582 {
617 {
583 color: #393735;
618 color: #393735;
584 font-size: 0.75em;
619 font-size: 0.75em;
585 text-align: center;
620 text-align: center;
586 padding-top: 1.5em;
621 padding-top: 1.5em;
587 padding-bottom: 1em;
622 padding-bottom: 1em;
588 background-color: #E6E7E8;
623 background-color: #E6E7E8;
589 margin: 0;
624 margin: 0;
590 }
625 }
591 .footer p
626 .footer p
592 {
627 {
593 margin: 0.25em
628 margin: 0.25em
594 }
629 }
595 .small
630 .small
596 {
631 {
597 font-size: 0.5em;
632 font-size: 0.5em;
598 }
633 }
599 /* end footer elements */
634 /* end footer elements */
600
635
601 .item {
636 .item {
602 float: left;
637 float: left;
603 position: relative;
638 position: relative;
604 width: 100%;
639 width: 100%;
605 overflow: hidden;
640 overflow: hidden;
606 }
641 }
607
642
608
643
609 .item .primary {
644 .item .primary {
610 margin-right: 220px;
645 margin-right: 220px;
611 position: relative;
646 position: relative;
612 }
647 }
613
648
614 .item hr {
649 .item hr {
615 margin-left: -220px;
650 margin-left: -220px;
616 }
651 }
617
652
618 .item .secondary {
653 .item .secondary {
619 float: right;
654 float: right;
620 width: 200px;
655 width: 200px;
621 position: relative;
656 position: relative;
622 }
657 }
623
658
624 .item .cols {
659 .item .cols {
625 clear: both;
660 clear: both;
626 display: block;
661 display: block;
627 }
662 }
628
663
629 .item .cols .col {
664 .item .cols .col {
630 float: left;
665 float: left;
631 margin-left: 1.5%;
666 margin-left: 1.5%;
632 }
667 }
633
668
634 .item .cols .col.first {
669 .item .cols .col.first {
635 margin-left: 0;
670 margin-left: 0;
636 }
671 }
637
672
638 .item .cols.two .col {
673 .item .cols.two .col {
639 width: 45%;
674 width: 45%;
640 }
675 }
641
676
642 .item .box {
677 .item .box {
643 margin: 0 0 10px 0;
678 margin: 0 0 10px 0;
644 }
679 }
645
680
646 .item .box h3 {
681 .item .box h3 {
647 margin: 0 0 10px 0;
682 margin: 0 0 10px 0;
648 }
683 }
649
684
650 .cols.unclear {
685 .cols.unclear {
651 clear:none;
686 clear:none;
652 }
687 }
653 }
688 }
654
689
655 /* end of screen media */
690 /* end of screen media */
656
691
657 /* start of print media */
692 /* start of print media */
658
693
659 @media print
694 @media print
660 {
695 {
661 input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft, #feedbackBox, #blurpage, .toc, .breadcrumb, .toolbar, .floatingResult
696 input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft, #feedbackBox, #blurpage, .toc, .breadcrumb, .toolbar, .floatingResult
662 {
697 {
663 display: none;
698 display: none;
664 background: none;
699 background: none;
665 }
700 }
666 .content
701 .content
667 {
702 {
668 background: none;
703 background: none;
669 display: block;
704 display: block;
670 width: 100%; margin: 0; float: none;
705 width: 100%; margin: 0; float: none;
671 }
706 }
672 }
707 }
673 /* end of print media */
708 /* end of print media */
@@ -1,73 +1,77
1 #include <QtGui/QApplication>
1 #include <QtGui/QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartglobal.h>
3 #include <qchartglobal.h>
4 #include <qchartview.h>
4 #include <qchartview.h>
5 #include <qlinechartseries.h>
5 #include <qlinechartseries.h>
6 #include <qscatterseries.h>
6 #include <qscatterseries.h>
7 #include <qbarchartseries.h>
7 #include <qbarchartseries.h>
8 #include <qbarset.h>
8 #include <qbarset.h>
9 #include <qbarcategory.h>
9 #include <qbarcategory.h>
10 #include <qpieseries.h>
10 #include <qpieseries.h>
11
11
12 QTCOMMERCIALCHART_USE_NAMESPACE
12 QTCOMMERCIALCHART_USE_NAMESPACE
13
13
14 int main(int argc, char *argv[])
14 int main(int argc, char *argv[])
15 {
15 {
16 QApplication a(argc, argv);
16 QApplication a(argc, argv);
17
17
18 //! [1]
18 //! [1]
19 // Create chart view
19 // Create chart view
20 QChartView *chartView = new QChartView();
20 QChartView *chartView = new QChartView();
21 chartView->setRenderHint(QPainter::Antialiasing);
21 // Add series to the chart
22 // Add series to the chart
22 QLineChartSeries *line = new QLineChartSeries();
23 QLineChartSeries *line = new QLineChartSeries();
23 line->add(0.0, 0.8);
24 line->add(0.0, 0.8);
24 line->add(1.1, 1.1);
25 line->add(1.1, 1.1);
25 line->add(2.0, 2.5);
26 line->add(2.0, 2.5);
26 chartView->addSeries(line);
27 chartView->addSeries(line);
27 //! [1]
28 //! [1]
28
29
29 //! [2]
30 //! [2]
30 // Change theme
31 // Change theme
31 chartView->setChartTheme(QChart::ChartThemeScientific);
32 chartView->setChartTheme(QChart::ChartThemeScientific);
32 //! [2]
33 //! [2]
33
34
34 //! [3]
35 //! [3]
35 // Add pie series
36 // Add pie series
37 // ...
36 QPieSeries *pie = new QPieSeries();
38 QPieSeries *pie = new QPieSeries();
37 pie->add(3.4, "slice1");
39 pie->add(3.4, "slice1");
38 pie->add(6.7, "slice2");
40 pie->add(6.7, "slice2");
39 chartView->addSeries(pie);
41 chartView->addSeries(pie);
40 //! [3]
42 //! [3]
41
43
42 //! [4]
44 //! [4]
43 // Add scatter series
45 // Add scatter series
46 // ...
44 QScatterSeries *scatter = new QScatterSeries();
47 QScatterSeries *scatter = new QScatterSeries();
45 for (qreal x(0); x < 100; x += 0.5) {
48 for (qreal x(0); x < 100; x += 0.5) {
46 qreal y = rand() % 100;
49 qreal y = rand() % 100;
47 *(scatter) << QPointF(x, y);
50 *(scatter) << QPointF(x, y);
48 }
51 }
49 chartView->addSeries(scatter);
52 chartView->addSeries(scatter);
50 //! [4]
53 //! [4]
51
54
52 //! [5]
55 //! [5]
56 // ...
53 // Add bar series
57 // Add bar series
54 QBarCategory *barCategory = new QBarCategory();
58 QBarCategory *barCategory = new QBarCategory();
55 *barCategory << "Jan"
59 *barCategory << "Jan"
56 << "Feb"
60 << "Feb"
57 << "Mar";
61 << "Mar";
58 QBarChartSeries *bar = new QBarChartSeries(barCategory);
62 QBarChartSeries *bar = new QBarChartSeries(barCategory);
59 QBarSet *barSet = new QBarSet("Sales");
63 QBarSet *barSet = new QBarSet("Sales");
60 *barSet << 123.2
64 *barSet << 123.2
61 << 301.3
65 << 301.3
62 << 285.8;
66 << 285.8;
63 bar->addBarSet(barSet);
67 bar->addBarSet(barSet);
64 chartView->addSeries(bar);
68 chartView->addSeries(bar);
65 //! [5]
69 //! [5]
66
70
67 QMainWindow w;
71 QMainWindow w;
68 w.resize(350, 250);
72 w.resize(380, 250);
69 w.setCentralWidget(chartView);
73 w.setCentralWidget(chartView);
70 w.show();
74 w.show();
71
75
72 return a.exec();
76 return a.exec();
73 }
77 }
@@ -1,46 +1,56
1 #include <QApplication>
1 #include <QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartview.h>
3 #include <qchartview.h>
4 #include <qlinechartseries.h>
4 #include <qlinechartseries.h>
5 #include <qchart.h>
5 #include <qchart.h>
6 #include <cmath>
6 #include <cmath>
7
7
8 QTCOMMERCIALCHART_USE_NAMESPACE
8 QTCOMMERCIALCHART_USE_NAMESPACE
9
9
10 #define PI 3.14159265358979
11
12 int main(int argc, char *argv[])
10 int main(int argc, char *argv[])
13 {
11 {
14 QApplication a(argc, argv);
12 QApplication a(argc, argv);
15
13
16 QMainWindow window;
14 QMainWindow window;
17
15
16 //![1]
17
18 QLineChartSeries* series0 = new QLineChartSeries();
18 QLineChartSeries* series0 = new QLineChartSeries();
19 QPen blue(Qt::blue);
19 QPen blue(Qt::blue);
20 blue.setWidth(3);
20 blue.setWidth(3);
21 series0->setPen(blue);
21 series0->setPen(blue);
22
22 QLineChartSeries* series1 = new QLineChartSeries();
23 QLineChartSeries* series1 = new QLineChartSeries();
23 QPen red(Qt::red);
24 QPen red(Qt::red);
24 red.setWidth(3);
25 red.setWidth(3);
25 series1->setPen(red);
26 series1->setPen(red);
26
27 //![1]
27 int numPoints = 100;
28
28
29 //![2]
29 for (int x = 0; x <= numPoints; ++x) {
30 series0->add(0, 6);
30 series0->add(x, fabs(sin(PI/50*x)*100));
31 series0->add(2, 4);
31 series1->add(x, fabs(cos(PI/50*x)*100));
32 series0->add(3, 8);
32 }
33 series0->add(7, 4);
33
34 series0->add(10,5);
35
36 series1->add(1, 1);
37 series1->add(3, 3);
38 series1->add(7, 6);
39 series1->add(8, 3);
40 series1->add(10,2);
41 //![2]
42 //![3]
34 QChartView* chartView = new QChartView(&window);
43 QChartView* chartView = new QChartView(&window);
35
44
36 chartView->setRenderHint(QPainter::Antialiasing);
45 chartView->setRenderHint(QPainter::Antialiasing);
37 chartView->setChartTitle("Basic line chart example");
46 chartView->setChartTitle("Basic line chart example");
38 chartView->addSeries(series0);
47 chartView->addSeries(series0);
39 chartView->addSeries(series1);
48 chartView->addSeries(series1);
49 //![3]
40
50
41 window.setCentralWidget(chartView);
51 window.setCentralWidget(chartView);
42 window.resize(400, 300);
52 window.resize(400, 300);
43 window.show();
53 window.show();
44
54
45 return a.exec();
55 return a.exec();
46 }
56 }
@@ -1,335 +1,335
1 #include "axisitem_p.h"
1 #include "axisitem_p.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 #include "chartpresenter_p.h"
3 #include "chartpresenter_p.h"
4 #include <QPainter>
4 #include <QPainter>
5 #include <QDebug>
5 #include <QDebug>
6
6
7 static int label_padding = 5;
7 static int label_padding = 5;
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 AxisItem::AxisItem(AxisType type,QGraphicsItem* parent) :
11 AxisItem::AxisItem(AxisType type,QGraphicsItem* parent) :
12 ChartItem(parent),
12 ChartItem(parent),
13 m_type(type),
13 m_type(type),
14 m_labelsAngle(0),
14 m_labelsAngle(0),
15 m_grid(parent),
15 m_grid(parent),
16 m_shades(parent),
16 m_shades(parent),
17 m_labels(parent),
17 m_labels(parent),
18 m_axis(parent)
18 m_axis(parent)
19 {
19 {
20 //initial initialization
20 //initial initialization
21 m_axis.setZValue(ChartPresenter::AxisZValue);
21 m_axis.setZValue(ChartPresenter::AxisZValue);
22 m_shades.setZValue(ChartPresenter::ShadesZValue);
22 m_shades.setZValue(ChartPresenter::ShadesZValue);
23 m_grid.setZValue(ChartPresenter::GridZValue);
23 m_grid.setZValue(ChartPresenter::GridZValue);
24 setFlags(QGraphicsItem::ItemHasNoContents);
24 setFlags(QGraphicsItem::ItemHasNoContents);
25 }
25 }
26
26
27 AxisItem::~AxisItem()
27 AxisItem::~AxisItem()
28 {
28 {
29 }
29 }
30
30
31 QRectF AxisItem::boundingRect() const
31 QRectF AxisItem::boundingRect() const
32 {
32 {
33 return QRectF();
33 return QRectF();
34 }
34 }
35
35
36 void AxisItem::createItems(int count)
36 void AxisItem::createItems(int count)
37 {
37 {
38 if(m_axis.children().size()==0)
38 if(m_axis.children().size()==0)
39 m_axis.addToGroup(new QGraphicsLineItem());
39 m_axis.addToGroup(new QGraphicsLineItem());
40 for (int i = 0; i < count; ++i) {
40 for (int i = 0; i < count; ++i) {
41 m_grid.addToGroup(new QGraphicsLineItem());
41 m_grid.addToGroup(new QGraphicsLineItem());
42 m_labels.addToGroup(new QGraphicsSimpleTextItem());
42 m_labels.addToGroup(new QGraphicsSimpleTextItem());
43 if(m_grid.childItems().size()%2) m_shades.addToGroup(new QGraphicsRectItem());
43 if(m_grid.childItems().size()%2) m_shades.addToGroup(new QGraphicsRectItem());
44 m_axis.addToGroup(new QGraphicsLineItem());
44 m_axis.addToGroup(new QGraphicsLineItem());
45 }
45 }
46 }
46 }
47
47
48 void AxisItem::clear(int count)
48 void AxisItem::clear(int count)
49 {
49 {
50 QList<QGraphicsItem *> lines = m_grid.childItems();
50 QList<QGraphicsItem *> lines = m_grid.childItems();
51 QList<QGraphicsItem *> labels = m_labels.childItems();
51 QList<QGraphicsItem *> labels = m_labels.childItems();
52 QList<QGraphicsItem *> shades = m_shades.childItems();
52 QList<QGraphicsItem *> shades = m_shades.childItems();
53 QList<QGraphicsItem *> axis = m_axis.childItems();
53 QList<QGraphicsItem *> axis = m_axis.childItems();
54
54
55 for (int i = 0; i < count; ++i) {
55 for (int i = 0; i < count; ++i) {
56 delete(lines.takeLast());
56 delete(lines.takeLast());
57 delete(labels.takeLast());
57 delete(labels.takeLast());
58 if(lines.size()%2) delete(shades.takeLast());
58 if(lines.size()%2) delete(shades.takeLast());
59 delete(axis.takeLast());
59 delete(axis.takeLast());
60 }
60 }
61
61
62 m_thicksList.clear();
62 m_thicksList.clear();
63
63
64 }
64 }
65
65
66 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
66 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
67 {
67 {
68 Q_UNUSED(painter);
68 Q_UNUSED(painter);
69 Q_UNUSED(option);
69 Q_UNUSED(option);
70 Q_UNUSED(widget);
70 Q_UNUSED(widget);
71 }
71 }
72
72
73 void AxisItem::updateItems(QVector<qreal>& vector)
73 void AxisItem::updateItems(QVector<qreal>& vector)
74 {
74 {
75 calculateLayout(vector);
75 calculateLayout(vector);
76 if(vector.count()==0) return;
76 if(vector.count()==0) return;
77 applyLayout(vector);
77 applyLayout(vector);
78 }
78 }
79
79
80 void AxisItem::handleAxisUpdate(QChartAxis* axis)
80 void AxisItem::handleAxisUpdate(QChartAxis* axis)
81 {
81 {
82 if(m_layoutVector.count()==0) return;
82 if(m_layoutVector.count()==0) return;
83
83
84 if(axis->isAxisVisible()) {
84 if(axis->isAxisVisible()) {
85 setAxisOpacity(100);
85 setAxisOpacity(100);
86 }
86 }
87 else {
87 else {
88 setAxisOpacity(0);
88 setAxisOpacity(0);
89 }
89 }
90
90
91 if(axis->isGridVisible()) {
91 if(axis->isGridVisible()) {
92 setGridOpacity(100);
92 setGridOpacity(100);
93 }
93 }
94 else {
94 else {
95 setGridOpacity(0);
95 setGridOpacity(0);
96 }
96 }
97
97
98 if(axis->isLabelsVisible())
98 if(axis->isLabelsVisible())
99 {
99 {
100 setLabelsOpacity(100);
100 setLabelsOpacity(100);
101 }
101 }
102 else {
102 else {
103 setLabelsOpacity(0);
103 setLabelsOpacity(0);
104 }
104 }
105
105
106 if(axis->isShadesVisible()) {
106 if(axis->isShadesVisible()) {
107 setShadesOpacity(axis->shadesOpacity());
107 setShadesOpacity(axis->shadesOpacity());
108 }
108 }
109 else {
109 else {
110 setShadesOpacity(0);
110 setShadesOpacity(0);
111 }
111 }
112
112
113 setLabelsAngle(axis->labelsAngle());
113 setLabelsAngle(axis->labelsAngle());
114 setAxisPen(axis->axisPen());
114 setAxisPen(axis->axisPen());
115 setLabelsPen(axis->labelsPen());
115 setLabelsPen(axis->labelsPen());
116 setLabelsBrush(axis->labelsBrush());
116 setLabelsBrush(axis->labelsBrush());
117 setLabelsFont(axis->labelFont());
117 setLabelsFont(axis->labelsFont());
118 setGridPen(axis->gridPen());
118 setGridPen(axis->gridPen());
119 setShadesPen(axis->shadesPen());
119 setShadesPen(axis->shadesPen());
120 setShadesBrush(axis->shadesBrush());
120 setShadesBrush(axis->shadesBrush());
121 }
121 }
122
122
123 void AxisItem::handleLabelsChanged(QChartAxis* axis,const QStringList& labels)
123 void AxisItem::handleLabelsChanged(QChartAxis* axis,const QStringList& labels)
124 {
124 {
125 int diff = m_thicksList.size() - labels.size();
125 int diff = m_thicksList.size() - labels.size();
126
126
127 if(diff>0){
127 if(diff>0){
128 clear(diff);
128 clear(diff);
129 }else if(diff<0){
129 }else if(diff<0){
130 createItems(-diff);
130 createItems(-diff);
131 }
131 }
132 m_thicksList=labels;
132 m_thicksList=labels;
133 m_layoutVector.resize(m_thicksList.size());
133 m_layoutVector.resize(m_thicksList.size());
134 updateItems(m_layoutVector);
134 updateItems(m_layoutVector);
135 if(diff!=0) handleAxisUpdate(axis);
135 if(diff!=0) handleAxisUpdate(axis);
136 }
136 }
137
137
138 void AxisItem::handleGeometryChanged(const QRectF& rect)
138 void AxisItem::handleGeometryChanged(const QRectF& rect)
139 {
139 {
140 m_rect = rect;
140 m_rect = rect;
141 updateItems(m_layoutVector);
141 updateItems(m_layoutVector);
142 }
142 }
143
143
144 void AxisItem::setAxisOpacity(qreal opacity)
144 void AxisItem::setAxisOpacity(qreal opacity)
145 {
145 {
146 m_axis.setOpacity(opacity);
146 m_axis.setOpacity(opacity);
147 }
147 }
148
148
149 qreal AxisItem::axisOpacity() const
149 qreal AxisItem::axisOpacity() const
150 {
150 {
151 return m_axis.opacity();
151 return m_axis.opacity();
152 }
152 }
153
153
154 void AxisItem::setGridOpacity(qreal opacity)
154 void AxisItem::setGridOpacity(qreal opacity)
155 {
155 {
156 m_grid.setOpacity(opacity);
156 m_grid.setOpacity(opacity);
157 }
157 }
158
158
159 qreal AxisItem::gridOpacity() const
159 qreal AxisItem::gridOpacity() const
160 {
160 {
161 return m_grid.opacity();
161 return m_grid.opacity();
162 }
162 }
163
163
164 void AxisItem::setLabelsOpacity(qreal opacity)
164 void AxisItem::setLabelsOpacity(qreal opacity)
165 {
165 {
166 m_labels.setOpacity(opacity);
166 m_labels.setOpacity(opacity);
167 }
167 }
168
168
169 qreal AxisItem::labelsOpacity() const
169 qreal AxisItem::labelsOpacity() const
170 {
170 {
171 return m_labels.opacity();
171 return m_labels.opacity();
172 }
172 }
173
173
174 void AxisItem::setShadesOpacity(qreal opacity)
174 void AxisItem::setShadesOpacity(qreal opacity)
175 {
175 {
176 m_shades.setOpacity(opacity);
176 m_shades.setOpacity(opacity);
177 }
177 }
178
178
179 qreal AxisItem::shadesOpacity() const
179 qreal AxisItem::shadesOpacity() const
180 {
180 {
181 return m_shades.opacity();
181 return m_shades.opacity();
182 }
182 }
183
183
184 void AxisItem::setLabelsAngle(int angle)
184 void AxisItem::setLabelsAngle(int angle)
185 {
185 {
186 foreach(QGraphicsItem* item , m_labels.childItems()) {
186 foreach(QGraphicsItem* item , m_labels.childItems()) {
187 QPointF center = item->boundingRect().center();
187 QPointF center = item->boundingRect().center();
188 item->setRotation(angle);
188 item->setRotation(angle);
189 }
189 }
190
190
191 m_labelsAngle=angle;
191 m_labelsAngle=angle;
192 }
192 }
193
193
194 void AxisItem::setLabelsPen(const QPen& pen)
194 void AxisItem::setLabelsPen(const QPen& pen)
195 {
195 {
196 foreach(QGraphicsItem* item , m_labels.childItems()) {
196 foreach(QGraphicsItem* item , m_labels.childItems()) {
197 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
197 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
198 }
198 }
199 }
199 }
200
200
201 void AxisItem::setLabelsBrush(const QBrush& brush)
201 void AxisItem::setLabelsBrush(const QBrush& brush)
202 {
202 {
203 foreach(QGraphicsItem* item , m_labels.childItems()) {
203 foreach(QGraphicsItem* item , m_labels.childItems()) {
204 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
204 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
205 }
205 }
206 }
206 }
207
207
208 void AxisItem::setLabelsFont(const QFont& font)
208 void AxisItem::setLabelsFont(const QFont& font)
209 {
209 {
210 foreach(QGraphicsItem* item , m_labels.childItems()) {
210 foreach(QGraphicsItem* item , m_labels.childItems()) {
211 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
211 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
212 }
212 }
213 }
213 }
214
214
215 void AxisItem::setShadesBrush(const QBrush& brush)
215 void AxisItem::setShadesBrush(const QBrush& brush)
216 {
216 {
217 foreach(QGraphicsItem* item , m_shades.childItems()) {
217 foreach(QGraphicsItem* item , m_shades.childItems()) {
218 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
218 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
219 }
219 }
220 }
220 }
221
221
222 void AxisItem::setShadesPen(const QPen& pen)
222 void AxisItem::setShadesPen(const QPen& pen)
223 {
223 {
224 foreach(QGraphicsItem* item , m_shades.childItems()) {
224 foreach(QGraphicsItem* item , m_shades.childItems()) {
225 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
225 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
226 }
226 }
227 }
227 }
228
228
229 void AxisItem::setAxisPen(const QPen& pen)
229 void AxisItem::setAxisPen(const QPen& pen)
230 {
230 {
231 foreach(QGraphicsItem* item , m_axis.childItems()) {
231 foreach(QGraphicsItem* item , m_axis.childItems()) {
232 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
232 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
233 }
233 }
234 }
234 }
235
235
236 void AxisItem::setGridPen(const QPen& pen)
236 void AxisItem::setGridPen(const QPen& pen)
237 {
237 {
238 foreach(QGraphicsItem* item , m_grid.childItems()) {
238 foreach(QGraphicsItem* item , m_grid.childItems()) {
239 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
239 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
240 }
240 }
241 }
241 }
242
242
243 void AxisItem::calculateLayout(QVector<qreal>& points)
243 void AxisItem::calculateLayout(QVector<qreal>& points)
244 {
244 {
245 switch (m_type)
245 switch (m_type)
246 {
246 {
247 case X_AXIS:
247 case X_AXIS:
248 {
248 {
249 const qreal deltaX = m_rect.width()/(m_thicksList.size()-1);
249 const qreal deltaX = m_rect.width()/(m_thicksList.size()-1);
250 for (int i = 0; i < m_thicksList.size(); ++i) {
250 for (int i = 0; i < m_thicksList.size(); ++i) {
251 int x = i * deltaX + m_rect.left();
251 int x = i * deltaX + m_rect.left();
252 points[i]=x;
252 points[i]=x;
253 }
253 }
254 }
254 }
255 break;
255 break;
256 case Y_AXIS:
256 case Y_AXIS:
257 {
257 {
258 const qreal deltaY = m_rect.height()/(m_thicksList.size()-1);
258 const qreal deltaY = m_rect.height()/(m_thicksList.size()-1);
259 for (int i = 0; i < m_thicksList.size(); ++i) {
259 for (int i = 0; i < m_thicksList.size(); ++i) {
260 int y = i * -deltaY + m_rect.bottom();
260 int y = i * -deltaY + m_rect.bottom();
261 points[i]=y;
261 points[i]=y;
262 }
262 }
263 }
263 }
264 break;
264 break;
265 }
265 }
266 }
266 }
267
267
268 void AxisItem::applyLayout(const QVector<qreal>& points)
268 void AxisItem::applyLayout(const QVector<qreal>& points)
269 {
269 {
270 Q_ASSERT(points.size() == m_thicksList.size());
270 Q_ASSERT(points.size() == m_thicksList.size());
271
271
272 QList<QGraphicsItem *> lines = m_grid.childItems();
272 QList<QGraphicsItem *> lines = m_grid.childItems();
273 QList<QGraphicsItem *> labels = m_labels.childItems();
273 QList<QGraphicsItem *> labels = m_labels.childItems();
274 QList<QGraphicsItem *> shades = m_shades.childItems();
274 QList<QGraphicsItem *> shades = m_shades.childItems();
275 QList<QGraphicsItem *> axis = m_axis.childItems();
275 QList<QGraphicsItem *> axis = m_axis.childItems();
276
276
277 Q_ASSERT(labels.size() == m_thicksList.size());
277 Q_ASSERT(labels.size() == m_thicksList.size());
278
278
279 switch (m_type)
279 switch (m_type)
280 {
280 {
281 case X_AXIS:
281 case X_AXIS:
282 {
282 {
283 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0));
283 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0));
284 lineItem->setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom());
284 lineItem->setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom());
285
285
286 for (int i = 0; i < points.size(); ++i) {
286 for (int i = 0; i < points.size(); ++i) {
287 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
287 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
288 lineItem->setLine(points[i], m_rect.top(), points[i], m_rect.bottom());
288 lineItem->setLine(points[i], m_rect.top(), points[i], m_rect.bottom());
289 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
289 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
290 labelItem->setText(m_thicksList.at(i));
290 labelItem->setText(m_thicksList.at(i));
291 QPointF center = labelItem->boundingRect().center();
291 QPointF center = labelItem->boundingRect().center();
292 labelItem->setTransformOriginPoint(center.x(), center.y());
292 labelItem->setTransformOriginPoint(center.x(), center.y());
293 labelItem->setPos(points[i] - center.x(), m_rect.bottom() + label_padding);
293 labelItem->setPos(points[i] - center.x(), m_rect.bottom() + label_padding);
294 if(i%2){
294 if(i%2){
295 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
295 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
296 rectItem->setRect(points[i],m_rect.top(),points[i+1]-points[i],m_rect.height());
296 rectItem->setRect(points[i],m_rect.top(),points[i+1]-points[i],m_rect.height());
297 }
297 }
298 lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1));
298 lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1));
299 lineItem->setLine(points[i],m_rect.bottom(),points[i],m_rect.bottom()+5);
299 lineItem->setLine(points[i],m_rect.bottom(),points[i],m_rect.bottom()+5);
300 }
300 }
301 }
301 }
302 break;
302 break;
303
303
304 case Y_AXIS:
304 case Y_AXIS:
305 {
305 {
306 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0));
306 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(axis.at(0));
307 lineItem->setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
307 lineItem->setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
308
308
309 for (int i = 0; i < points.size(); ++i) {
309 for (int i = 0; i < points.size(); ++i) {
310 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
310 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
311 lineItem->setLine(m_rect.left() , points[i], m_rect.right(), points[i]);
311 lineItem->setLine(m_rect.left() , points[i], m_rect.right(), points[i]);
312 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
312 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
313 labelItem->setText(m_thicksList.at(i));
313 labelItem->setText(m_thicksList.at(i));
314 QPointF center = labelItem->boundingRect().center();
314 QPointF center = labelItem->boundingRect().center();
315 labelItem->setTransformOriginPoint(center.x(), center.y());
315 labelItem->setTransformOriginPoint(center.x(), center.y());
316 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , points[i]-center.y());
316 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , points[i]-center.y());
317 if(i%2){
317 if(i%2){
318 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
318 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
319 rectItem->setRect(m_rect.left(),points[i],m_rect.width(),points[i]-points[i+1]);
319 rectItem->setRect(m_rect.left(),points[i],m_rect.width(),points[i]-points[i+1]);
320 }
320 }
321 lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1));
321 lineItem = static_cast<QGraphicsLineItem*>(axis.at(i+1));
322 lineItem->setLine(m_rect.left()-5,points[i],m_rect.left(),points[i]);
322 lineItem->setLine(m_rect.left()-5,points[i],m_rect.left(),points[i]);
323 }
323 }
324 }
324 }
325 break;
325 break;
326 default:
326 default:
327 qDebug()<<"Unknown axis type";
327 qDebug()<<"Unknown axis type";
328 break;
328 break;
329 }
329 }
330 }
330 }
331
331
332 //TODO "nice numbers algorithm"
332 //TODO "nice numbers algorithm"
333 #include "moc_axisitem_p.cpp"
333 #include "moc_axisitem_p.cpp"
334
334
335 QTCOMMERCIALCHART_END_NAMESPACE
335 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,75 +1,182
1 #include "qlinechartseries.h"
1 #include "qlinechartseries.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 /*!
6 \class QLineChartSeries
7 \brief The QLineChartSeries class is used for making line charts.
8
9 \mainclass
10
11 A line chart is used to show information as a series of data points
12 connected by straight lines.
13
14 \image linechart.png
15
16 To create line charts, users need to first QLineChartSeries object.
17
18 \snippet ../example/linechart/main.cpp 1
19
20 Populate with the data
21
22 \snippet ../example/linechart/main.cpp 2
23
24 Add created series objects to QChartView or QChart instance.
25
26 \snippet ../example/linechart/main.cpp 3
27
28 */
29
30 /*!
31 \fn virtual QChartSeriesType QLineChartSeries::type() const
32 \brief Returns type of series.
33 \sa QChartSeries, QChartSeriesType
34 */
35
36 /*!
37 \fn QPen QLineChartSeries::pen() const
38 \brief Returns the pen used to draw line for this series.
39 \sa setPen()
40 */
41
42 /*!
43 \fn bool QLineChartSeries::isPointsVisible() const
44 \brief Returns if the points are drawn for this series.
45 \sa setPointsVisible()
46 */
47
48
49 /*!
50 \fn void QLineChartSeries::changed(int index)
51 \brief \internal \a index
52 */
53
54 /*!
55 Constructs empty series object which is a child of \a parent.
56 When series object is added to QChartView or QChart instance ownerships is transfered.
57 */
5 QLineChartSeries::QLineChartSeries(QObject* parent):QChartSeries(parent),
58 QLineChartSeries::QLineChartSeries(QObject* parent):QChartSeries(parent),
6 m_pointsVisible(false)
59 m_pointsVisible(false)
7 {
60 {
8 }
61 }
9
62 /*!
63 Destroys the object. Series added to QChartView or QChart instances are owned by those,
64 and are deleted when mentioned object are destroyed.
65 */
10 QLineChartSeries::~QLineChartSeries()
66 QLineChartSeries::~QLineChartSeries()
11 {
67 {
12 }
68 }
13
69
70 /*!
71 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
72 Function returns index, which can be used to modify data.
73 */
14 int QLineChartSeries::add(qreal x,qreal y)
74 int QLineChartSeries::add(qreal x,qreal y)
15 {
75 {
16 m_x<<x;
76 m_x<<x;
17 m_y<<y;
77 m_y<<y;
18 return m_x.size()-1;
78 return m_x.size()-1;
19 }
79 }
20
80
81 /*!
82 This is an overloaded function.
83 Adds data \a point to the series. Points are connected with lines on the chart.
84 Function returns index, which can be used to modify data.
85 */
86 int QLineChartSeries::add(const QPointF& point)
87 {
88 m_x<<point.x();
89 m_y<<point.y();
90 return m_x.size()-1;
91 }
92
93 /*!
94 Modifies data within \a index, sets new \a x and \a y values.
95 */
21 void QLineChartSeries::set(int index,qreal x,qreal y)
96 void QLineChartSeries::set(int index,qreal x,qreal y)
22 {
97 {
23 m_x[index]=x;
98 m_x[index]=x;
24 m_y[index]=y;
99 m_y[index]=y;
25 emit changed(index);
100 emit changed(index);
26 }
101 }
27
102
103 /*!
104 This is an overloaded function.
105 Modifies data within \a index, sets new \a point value.
106 */
107 void QLineChartSeries::set(int index,const QPointF& point)
108 {
109 m_x[index]=point.x();
110 m_y[index]=point.y();
111 emit changed(index);
112 }
113
114
115 /*!
116 Clears all the data.
117 */
28 void QLineChartSeries::clear()
118 void QLineChartSeries::clear()
29 {
119 {
30 m_x.clear();
120 m_x.clear();
31 m_y.clear();
121 m_y.clear();
32 }
122 }
33
123
124 /*!
125 \internal \a pos
126 */
34 qreal QLineChartSeries::x(int pos) const
127 qreal QLineChartSeries::x(int pos) const
35 {
128 {
36 return m_x.at(pos);
129 return m_x.at(pos);
37 }
130 }
38
131
132 /*!
133 \internal \a pos
134 */
39 qreal QLineChartSeries::y(int pos) const
135 qreal QLineChartSeries::y(int pos) const
40 {
136 {
41 return m_y.at(pos);
137 return m_y.at(pos);
42 }
138 }
43
139
140 /*!
141 Returns number of data points within series.
142 */
44 int QLineChartSeries::count() const
143 int QLineChartSeries::count() const
45 {
144 {
46 Q_ASSERT(m_x.size() == m_y.size());
145 Q_ASSERT(m_x.size() == m_y.size());
47
146
48 return m_x.size();
147 return m_x.size();
49
148
50 }
149 }
51
150
151 /*!
152 Sets \a pen used for drawing given series..
153 */
52 void QLineChartSeries::setPen(const QPen& pen)
154 void QLineChartSeries::setPen(const QPen& pen)
53 {
155 {
54 m_pen=pen;
156 m_pen=pen;
55 }
157 }
56
158
159 /*!
160 Sets if data points are \a visible and should be drawn on line.
161 */
162 void QLineChartSeries::setPointsVisible(bool visible)
163 {
164 m_pointsVisible=visible;
165 }
166
57 QDebug operator<< (QDebug debug, const QLineChartSeries series)
167 QDebug operator<< (QDebug debug, const QLineChartSeries series)
58 {
168 {
59 Q_ASSERT(series.m_x.size() == series.m_y.size());
169 Q_ASSERT(series.m_x.size() == series.m_y.size());
60
170
61 int size = series.m_x.size();
171 int size = series.m_x.size();
62
172
63 for (int i=0;i<size;i++) {
173 for (int i=0;i<size;i++) {
64 debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") ";
174 debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") ";
65 }
175 }
66 return debug.space();
176 return debug.space();
67 }
177 }
68
178
69 void QLineChartSeries::setPointsVisible(bool visible)
179
70 {
71 m_pointsVisible=visible;
72 }
73 #include "moc_qlinechartseries.cpp"
180 #include "moc_qlinechartseries.cpp"
74
181
75 QTCOMMERCIALCHART_END_NAMESPACE
182 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,48 +1,50
1 #ifndef QLINECHARTSERIES_H_
1 #ifndef QLINECHARTSERIES_H_
2 #define QLINECHARTSERIES_H_
2 #define QLINECHARTSERIES_H_
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qchartseries.h"
5 #include "qchartseries.h"
6 #include <QDebug>
6 #include <QDebug>
7 #include <QPen>
7 #include <QPen>
8 #include <QBrush>
8 #include <QBrush>
9
9
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11
11
12 class QTCOMMERCIALCHART_EXPORT QLineChartSeries : public QChartSeries
12 class QTCOMMERCIALCHART_EXPORT QLineChartSeries : public QChartSeries
13 {
13 {
14 Q_OBJECT
14 Q_OBJECT
15 public:
15 public:
16 QLineChartSeries(QObject* parent=0);
16 QLineChartSeries(QObject* parent=0);
17 virtual ~QLineChartSeries();
17 virtual ~QLineChartSeries();
18
18
19 public: // from QChartSeries
19 public: // from QChartSeries
20 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;}
20 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;}
21 int add(qreal x, qreal y);
21 int add(qreal x, qreal y);
22 int add(const QPointF& point);
22 void set(int index,qreal x,qreal y);
23 void set(int index,qreal x,qreal y);
24 void set(int index,const QPointF& point);
23 void clear();
25 void clear();
24
26
25 void setPen(const QPen& pen);
27 void setPen(const QPen& pen);
26 const QPen& pen() const { return m_pen;}
28 QPen pen() const { return m_pen;}
27
29
28 void setPointsVisible(bool visible);
30 void setPointsVisible(bool visible);
29 bool isPointsVisible() const {return m_pointsVisible;}
31 bool isPointsVisible() const {return m_pointsVisible;}
30
32
31 int count() const;
33 int count() const;
32 qreal x(int pos) const;
34 qreal x(int pos) const;
33 qreal y(int pos) const;
35 qreal y(int pos) const;
34 friend QDebug operator<< (QDebug d, const QLineChartSeries series);
36 friend QDebug operator<< (QDebug d, const QLineChartSeries series);
35
37
36 signals:
38 signals:
37 void changed(int index);
39 void changed(int index);
38
40
39 private:
41 private:
40 QVector<qreal> m_x;
42 QVector<qreal> m_x;
41 QVector<qreal> m_y;
43 QVector<qreal> m_y;
42 QPen m_pen;
44 QPen m_pen;
43 bool m_pointsVisible;
45 bool m_pointsVisible;
44 };
46 };
45
47
46 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
47
49
48 #endif
50 #endif
@@ -1,154 +1,353
1 #include "qchartaxis.h"
1 #include "qchartaxis.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 /*!
6 \class QChartAxis
7 \brief The QChartAxis class is used for manipulating chart's axis
8 and for adding optional axes to the chart.
9 \mainclass
10
11 There is only one x Axis, however there can be multiple y axes.
12 Each chart series can be bound to exactly one Y axis and the share common X axis.
13 Axis can be setup to show axis line with ticks, gird lines and shades.
14
15 */
16
17 /*!
18 \fn bool QChartAxis::isAxisVisible() const
19 \brief Returns if axis is visible
20 \sa setAxisVisible()
21 */
22
23 /*!
24 \fn QPen QChartAxis::axisPen() const
25 \brief Returns pen used to draw axis and ticks.
26 \sa setAxisPen()
27 */
28
29
30 /*!
31 \fn bool QChartAxis::isGridVisible() const
32 \brief Returns if grid is visible
33 \sa setGridVisible()
34 */
35
36 /*!
37 \fn QPen QChartAxis::gridPen() const
38 \brief Returns pen used to draw grid.
39 \sa setGridPen()
40 */
41
42 /*!
43 \fn bool QChartAxis::isLabelsVisible() const
44 \brief Returns if grid is visible
45 \sa setLabelsVisible()
46 */
47
48 /*!
49 \fn QPen QChartAxis::labelsPen() const
50 \brief Returns the pen used to labels.
51 \sa setLabelsPen()
52 */
53
54 /*!
55 \fn QBrush QChartAxis::labelsBrush() const
56 \brief Returns brush used to draw labels.
57 \sa setLabelsBrush()
58 */
59
60 /*!
61 \fn QFont QChartAxis::labelsFont() const
62 \brief Returns font used to draw labels.
63 \sa setLabelsFont()
64 */
65
66 /*!
67 \fn QFont QChartAxis::labelsAngle() const
68 \brief Returns angle used to draw labels.
69 \sa setLabelsAngle()
70 */
71
72 /*!
73 \fn bool QChartAxis::isShadesVisible() const
74 \brief Returns if shades are visible.
75 \sa setShadesVisible()
76 */
77
78 /*!
79 \fn qreal QChartAxis::shadesOpacity() const
80 \brief Returns opacity of shades.
81 */
82
83 /*!
84 \fn QPen QChartAxis::shadesPen() const
85 \brief Returns pen used to draw shades.
86 \sa setShadesPen()
87 */
88
89 /*!
90 \fn QBrush QChartAxis::shadesBrush() const
91 \brief Returns brush used to draw shades.
92 \sa setShadesBrush()
93 */
94
95 /*!
96 \fn qreal QChartAxis::min() const
97 \brief Returns minimum value on the axis.
98 \sa setMin()
99 */
100
101 /*!
102 \fn qreal QChartAxis::max() const
103 \brief Returns maximim value on the axis.
104 \sa setMax()
105 */
106
107 /*!
108 \fn void QChartAxis::minChanged(qreal min)
109 \brief Axis emits signal when \a min of axis has changed.
110 */
111
112 /*!
113 \fn void QChartAxis::maxChanged(qreal max)
114 \brief Axis emits signal when \a max of axis has changed.
115 */
116 /*!
117 \fn int QChartAxis::ticksCount() const
118 \brief Return number of ticks on the axis
119 \sa setTicksCount()
120 */
121
122 /*!
123 \fn void QChartAxis::update(QChartAxis*)
124 \brief \internal
125 */
126
127 /*!
128 \fn void QChartAxis::ticksChanged(QChartAxis*)
129 \brief \internal
130 */
131
132 /*!
133 Constructs new axis object which is a child of \a parent. Ownership is taken by
134 QChatView or QChart when axis added.
135 */
136
5 QChartAxis::QChartAxis(QObject* parent):QObject(parent),
137 QChartAxis::QChartAxis(QObject* parent):QObject(parent),
6 m_axisVisible(true),
138 m_axisVisible(true),
7 m_gridVisible(true),
139 m_gridVisible(true),
8 m_labelsVisible(true),
140 m_labelsVisible(true),
9 m_labelsAngle(0),
141 m_labelsAngle(0),
10 m_shadesVisible(true),
142 m_shadesVisible(true),
11 m_shadesOpacity(1.0),
143 m_shadesOpacity(1.0),
12 m_min(0),
144 m_min(0),
13 m_max(0),
145 m_max(0),
14 m_ticksCount(5)
146 m_ticksCount(5)
15 {
147 {
16
148
17 }
149 }
18
150
151 /*!
152 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
153 */
154
19 QChartAxis::~QChartAxis()
155 QChartAxis::~QChartAxis()
20 {
156 {
21 }
157 }
22
158
159 /*!
160 Sets \a pen used to draw axis line and ticks.
161 */
23 void QChartAxis::setAxisPen(const QPen& pen)
162 void QChartAxis::setAxisPen(const QPen& pen)
24 {
163 {
25 m_axisPen=pen;
164 m_axisPen=pen;
26 emit update(this);
165 emit update(this);
27 }
166 }
28
167
168 /*!
169 Sets if axis and ticks are \a visible.
170 */
29 void QChartAxis::setAxisVisible(bool visible)
171 void QChartAxis::setAxisVisible(bool visible)
30 {
172 {
31 m_axisVisible=visible;
173 m_axisVisible=visible;
32 emit update(this);
174 emit update(this);
33 }
175 }
34
176
177 /*!
178 Sets if grid is \a visible.
179 */
35 void QChartAxis::setGridVisible(bool visible)
180 void QChartAxis::setGridVisible(bool visible)
36 {
181 {
37 m_gridVisible=visible;
182 m_gridVisible=visible;
38 emit update(this);
183 emit update(this);
39 }
184 }
40
185
186 /*!
187 Sets \a pen used to draw grid.
188 */
41 void QChartAxis::setGridPen(const QPen& pen)
189 void QChartAxis::setGridPen(const QPen& pen)
42 {
190 {
43 m_gridPen=pen;
191 m_gridPen=pen;
44 emit update(this);
192 emit update(this);
45 }
193 }
46
194
195 /*!
196 Sets if axis' labels are \a visible.
197 */
47 void QChartAxis::setLabelsVisible(bool visible)
198 void QChartAxis::setLabelsVisible(bool visible)
48 {
199 {
49 m_labelsVisible=visible;
200 m_labelsVisible=visible;
50 emit update(this);
201 emit update(this);
51 }
202 }
52
203
204 /*!
205 Sets \a pen used to draw labels.
206 */
53 void QChartAxis::setLabelsPen(const QPen& pen)
207 void QChartAxis::setLabelsPen(const QPen& pen)
54 {
208 {
55 m_labelsPen=pen;
209 m_labelsPen=pen;
56 emit update(this);
210 emit update(this);
57 }
211 }
58
212
213 /*!
214 Sets \a brush used to draw labels.
215 */
59 void QChartAxis::setLabelsBrush(const QBrush& brush)
216 void QChartAxis::setLabelsBrush(const QBrush& brush)
60 {
217 {
61 m_labelsBrush=brush;
218 m_labelsBrush=brush;
62 emit update(this);
219 emit update(this);
63 }
220 }
64
221
222 /*!
223 Sets \a font used to draw labels.
224 */
65 void QChartAxis::setLabelsFont(const QFont& font)
225 void QChartAxis::setLabelsFont(const QFont& font)
66 {
226 {
67 m_labelsFont=font;
227 m_labelsFont=font;
68 emit update(this);
228 emit update(this);
69 }
229 }
70
230
231 /*!
232 Sets \a angle for all the labels on given axis.
233 */
71 void QChartAxis::setLabelsAngle(int angle)
234 void QChartAxis::setLabelsAngle(int angle)
72 {
235 {
73 m_labelsAngle=angle;
236 m_labelsAngle=angle;
74 emit update(this);
237 emit update(this);
75 }
238 }
76
239
240 /*!
241 Sets if shades are \a visible.
242 */
77 void QChartAxis::setShadesVisible(bool visible)
243 void QChartAxis::setShadesVisible(bool visible)
78 {
244 {
79 m_shadesVisible=visible;
245 m_shadesVisible=visible;
80 emit update(this);
246 emit update(this);
81 }
247 }
82
248
249 /*!
250 Sets \a pen used to draw shades.
251 */
83 void QChartAxis::setShadesPen(const QPen& pen)
252 void QChartAxis::setShadesPen(const QPen& pen)
84 {
253 {
85 m_shadesPen=pen;
254 m_shadesPen=pen;
86 emit update(this);
255 emit update(this);
87 }
256 }
88
257
258 /*!
259 Sets \a brush used to draw shades.
260 */
89 void QChartAxis::setShadesBrush(const QBrush& brush)
261 void QChartAxis::setShadesBrush(const QBrush& brush)
90 {
262 {
91 m_shadesBrush=brush;
263 m_shadesBrush=brush;
92 emit update(this);
264 emit update(this);
93 }
265 }
94
266
267 /*!
268 Sets \a opacity of the shades.
269 */
95 void QChartAxis::setShadesOpacity(qreal opacity)
270 void QChartAxis::setShadesOpacity(qreal opacity)
96 {
271 {
97 m_shadesOpacity=opacity;
272 m_shadesOpacity=opacity;
98 emit update(this);
273 emit update(this);
99 }
274 }
100
275
276 /*!
277 Sets \a min value on the axis.
278 */
101 void QChartAxis::setMin(qreal min)
279 void QChartAxis::setMin(qreal min)
102 {
280 {
103 if(m_min!=min){
281 if(m_min!=min){
104 m_min=min;
282 m_min=min;
105 emit minChanged(m_min);
283 emit minChanged(m_min);
106 }
284 }
107 }
285 }
108
286
287 /*!
288 Sets \a max value on the axis.
289 */
109 void QChartAxis::setMax(qreal max)
290 void QChartAxis::setMax(qreal max)
110 {
291 {
111 if(m_max!=max){
292 if(m_max!=max){
112 m_max=max;
293 m_max=max;
113 emit maxChanged(m_max);
294 emit maxChanged(m_max);
114 }
295 }
115 }
296 }
116
297
298 /*!
299 Sets range from \a min to \a max on the axis.
300 */
117 void QChartAxis::setRange(qreal min, qreal max)
301 void QChartAxis::setRange(qreal min, qreal max)
118 {
302 {
119 setMin(min);
303 setMin(min);
120 setMax(max);
304 setMax(max);
121 }
305 }
122
306
307 /*!
308 Sets \a count for ticks on the axis.
309 */
123 void QChartAxis::setTicksCount(int count)
310 void QChartAxis::setTicksCount(int count)
124 {
311 {
125 m_ticksCount=count;
312 m_ticksCount=count;
126 emit ticksChanged(this);
313 emit ticksChanged(this);
127 }
314 }
128
315
316 /*!
317 TODO: refactor me. Sets string \a label for \a value on the axis.
318 */
129 void QChartAxis::addAxisTickLabel(qreal value,const QString& label)
319 void QChartAxis::addAxisTickLabel(qreal value,const QString& label)
130 {
320 {
131 m_ticks.insert(value,label);
321 m_ticks.insert(value,label);
132 emit ticksChanged(this);
322 emit ticksChanged(this);
133 }
323 }
134
324
325 /*!
326 TODO: refactor me. Removes label for \a value on the axis.
327 */
135 void QChartAxis::removeAxisTickLabel(qreal value)
328 void QChartAxis::removeAxisTickLabel(qreal value)
136 {
329 {
137 m_ticks.remove(value);
330 m_ticks.remove(value);
138 emit ticksChanged(this);
331 emit ticksChanged(this);
139 }
332 }
140
333
334 /*!
335 TODO: refactor me. Returns label for \a value on the axis.
336 */
141 QString QChartAxis::axisTickLabel(qreal value) const
337 QString QChartAxis::axisTickLabel(qreal value) const
142 {
338 {
143 return m_ticks.value(value);
339 return m_ticks.value(value);
144 }
340 }
145
341
342 /*!
343 TODO: refactor me. Removes all the string labels for on the axis.
344 */
146 void QChartAxis::clearAxisTickLabels()
345 void QChartAxis::clearAxisTickLabels()
147 {
346 {
148 m_ticks.clear();
347 m_ticks.clear();
149 emit ticksChanged(this);
348 emit ticksChanged(this);
150 }
349 }
151
350
152 #include "moc_qchartaxis.cpp"
351 #include "moc_qchartaxis.cpp"
153
352
154 QTCOMMERCIALCHART_END_NAMESPACE
353 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,103 +1,101
1 #ifndef QCHARTAXIS_H_
1 #ifndef QCHARTAXIS_H_
2 #define QCHARTAXIS_H_
2 #define QCHARTAXIS_H_
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <QPen>
5 #include <QPen>
6 #include <QFont>
6 #include <QFont>
7
7
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject
11 class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject
12 {
12 {
13 Q_OBJECT
13 Q_OBJECT
14 public:
14 public:
15 QChartAxis(QObject* parent =0);
15 QChartAxis(QObject* parent =0);
16 ~QChartAxis();
16 ~QChartAxis();
17
17
18 //axis handling
18 //axis handling
19 bool isAxisVisible() const { return m_axisVisible;};
19 bool isAxisVisible() const { return m_axisVisible;};
20 void setAxisVisible(bool visible);
20 void setAxisVisible(bool visible);
21 void setAxisPen(const QPen& pen);
21 void setAxisPen(const QPen& pen);
22 QPen axisPen() const { return m_axisPen;};
22 QPen axisPen() const { return m_axisPen;};
23 void setAxisBrush(const QBrush& brush);
24 QBrush axisBrush() const { return m_axisBrush;};
25
23
26 //grid handling
24 //grid handling
27 bool isGridVisible() const { return m_gridVisible;};
25 bool isGridVisible() const { return m_gridVisible;};
28 void setGridVisible(bool visible);
26 void setGridVisible(bool visible);
29 void setGridPen(const QPen& pen);
27 void setGridPen(const QPen& pen);
30 QPen gridPen() const {return m_gridPen;}
28 QPen gridPen() const {return m_gridPen;}
31
29
32 //labels handling
30 //labels handling
33 bool isLabelsVisible() const { return m_labelsVisible;};
31 bool isLabelsVisible() const { return m_labelsVisible;};
34 void setLabelsVisible(bool visible);
32 void setLabelsVisible(bool visible);
35 void setLabelsPen(const QPen& pen);
33 void setLabelsPen(const QPen& pen);
36 QPen labelsPen() const { return m_labelsPen;}
34 QPen labelsPen() const { return m_labelsPen;}
37 void setLabelsBrush(const QBrush& brush);
35 void setLabelsBrush(const QBrush& brush);
38 QBrush labelsBrush() const { return m_labelsBrush;}
36 QBrush labelsBrush() const { return m_labelsBrush;}
39 void setLabelsFont(const QFont& font);
37 void setLabelsFont(const QFont& font);
40 QFont labelFont() const { return m_labelsFont;}
38 QFont labelsFont() const { return m_labelsFont;}
41 void setLabelsAngle(int angle);
39 void setLabelsAngle(int angle);
42 int labelsAngle() const { return m_labelsAngle;};
40 int labelsAngle() const { return m_labelsAngle;};
43
41
44 //shades handling
42 //shades handling
45 bool isShadesVisible() const { return m_shadesVisible;};
43 bool isShadesVisible() const { return m_shadesVisible;};
46 void setShadesVisible(bool visible);
44 void setShadesVisible(bool visible);
47 void setShadesPen(const QPen& pen);
45 void setShadesPen(const QPen& pen);
48 QPen shadesPen() const { return m_shadesPen;}
46 QPen shadesPen() const { return m_shadesPen;}
49 void setShadesBrush(const QBrush& brush);
47 void setShadesBrush(const QBrush& brush);
50 QBrush shadesBrush() const { return m_shadesBrush;}
48 QBrush shadesBrush() const { return m_shadesBrush;}
51 void setShadesOpacity(qreal opacity);
49 void setShadesOpacity(qreal opacity);
52 qreal shadesOpacity() const { return m_shadesOpacity;}
50 qreal shadesOpacity() const { return m_shadesOpacity;}
53
51
54 //range handling
52 //range handling
55 void setMin(qreal min);
53 void setMin(qreal min);
56 qreal min() const { return m_min;};
54 qreal min() const { return m_min;};
57 void setMax(qreal max);
55 void setMax(qreal max);
58 qreal max() const { return m_max;};
56 qreal max() const { return m_max;};
59 void setRange(qreal min, qreal max);
57 void setRange(qreal min, qreal max);
60
58
61 //ticks handling
59 //ticks handling
62 void setTicksCount(int count);
60 void setTicksCount(int count);
63 int ticksCount() const { return m_ticksCount;}
61 int ticksCount() const { return m_ticksCount;}
64 void addAxisTickLabel(qreal value,const QString& label);
62 void addAxisTickLabel(qreal value,const QString& label);
65 void removeAxisTickLabel(qreal value);
63 void removeAxisTickLabel(qreal value);
66 QString axisTickLabel(qreal value) const ;
64 QString axisTickLabel(qreal value) const ;
67 void clearAxisTickLabels();
65 void clearAxisTickLabels();
68
66
69 signals:
67 signals:
70 void minChanged(qreal min);
68 void minChanged(qreal min);
71 void maxChanged(qreal max);
69 void maxChanged(qreal max);
72 //private signal
70 //private signal
73 void update(QChartAxis*);
71 void update(QChartAxis*);
74 void ticksChanged(QChartAxis*);
72 void ticksChanged(QChartAxis*);
75
73
76 private:
74 private:
77 bool m_axisVisible;
75 bool m_axisVisible;
78 QPen m_axisPen;
76 QPen m_axisPen;
79 QBrush m_axisBrush;
77 QBrush m_axisBrush;
80
78
81 bool m_gridVisible;
79 bool m_gridVisible;
82 QPen m_gridPen;
80 QPen m_gridPen;
83
81
84 bool m_labelsVisible;
82 bool m_labelsVisible;
85 QPen m_labelsPen;
83 QPen m_labelsPen;
86 QBrush m_labelsBrush;
84 QBrush m_labelsBrush;
87 QFont m_labelsFont;
85 QFont m_labelsFont;
88 int m_labelsAngle;
86 int m_labelsAngle;
89
87
90 bool m_shadesVisible;
88 bool m_shadesVisible;
91 QPen m_shadesPen;
89 QPen m_shadesPen;
92 QBrush m_shadesBrush;
90 QBrush m_shadesBrush;
93 qreal m_shadesOpacity;
91 qreal m_shadesOpacity;
94
92
95 qreal m_min;
93 qreal m_min;
96 qreal m_max;
94 qreal m_max;
97
95
98 int m_ticksCount;
96 int m_ticksCount;
99 QMap<qreal, QString> m_ticks;
97 QMap<qreal, QString> m_ticks;
100 };
98 };
101
99
102 QTCOMMERCIALCHART_END_NAMESPACE
100 QTCOMMERCIALCHART_END_NAMESPACE
103 #endif /* QCHARTAXIS_H_ */
101 #endif /* QCHARTAXIS_H_ */
@@ -1,368 +1,351
1 #include "qchartview.h"
1 #include "qchartview.h"
2 #include "qchart.h"
2 #include "qchart.h"
3 #include "qchartaxis.h"
3 #include "qchartaxis.h"
4 #include <QGraphicsView>
4 #include <QGraphicsView>
5 #include <QGraphicsScene>
5 #include <QGraphicsScene>
6 #include <QRubberBand>
6 #include <QRubberBand>
7 #include <QResizeEvent>
7 #include <QResizeEvent>
8 #include <QDebug>
8 #include <QDebug>
9
9
10 /*!
10 /*!
11 \enum QChartView::RubberBandPolicy
11 \enum QChartView::RubberBandPolicy
12
12
13 This enum describes the different types of rubber bands that can be used for zoom rect selection
13 This enum describes the different types of rubber bands that can be used for zoom rect selection
14
14
15 \value NoRubberBand
15 \value NoRubberBand
16 \value VerticalRubberBand
16 \value VerticalRubberBand
17 \value HorizonalRubberBand
17 \value HorizonalRubberBand
18 \value RectangleRubberBand
18 \value RectangleRubberBand
19 */
19 */
20
20
21 /*!
21 /*!
22 \class QChartView
22 \class QChartView
23 \brief Standalone charting widget.
23 \brief Standalone charting widget.
24
24
25 QChartView is a standalone widget that can display charts. It does not require separate
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
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
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 display a chart in your existing QGraphicsScene, you can use the QChart class instead.
29
29
30 For example, to create a chart with line series using a widget based application:
31 \snippet ../example/chartview/main.cpp 1
32 \image chartview_example.jpg
33
34 Showing a few more series:
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
45 \image chartview_example_theme.jpg
46
47 \sa QChart
30 \sa QChart
48 */
31 */
49
32
50 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
51
34
52 /*!
35 /*!
53 Constructs a chartView object which is a child of a\a parent.
36 Constructs a chartView object which is a child of a\a parent.
54 */
37 */
55 QChartView::QChartView(QWidget *parent) :
38 QChartView::QChartView(QWidget *parent) :
56 QGraphicsView(parent),
39 QGraphicsView(parent),
57 m_scene(new QGraphicsScene(this)),
40 m_scene(new QGraphicsScene(this)),
58 m_chart(new QChart()),
41 m_chart(new QChart()),
59 m_rubberBand(0),
42 m_rubberBand(0),
60 m_verticalRubberBand(false),
43 m_verticalRubberBand(false),
61 m_horizonalRubberBand(false)
44 m_horizonalRubberBand(false)
62 {
45 {
63 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
46 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
64 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
47 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
65 setScene(m_scene);
48 setScene(m_scene);
66 m_chart->setMargin(50);
49 m_chart->setMargin(50);
67 m_scene->addItem(m_chart);
50 m_scene->addItem(m_chart);
68 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
51 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
69 }
52 }
70
53
71
54
72 /*!
55 /*!
73 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
56 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
74 */
57 */
75 QChartView::~QChartView()
58 QChartView::~QChartView()
76 {
59 {
77 }
60 }
78
61
79 /*!
62 /*!
80 Resizes and updates the chart area using the \a event data
63 Resizes and updates the chart area using the \a event data
81 */
64 */
82 void QChartView::resizeEvent(QResizeEvent *event)
65 void QChartView::resizeEvent(QResizeEvent *event)
83 {
66 {
84 m_scene->setSceneRect(0,0,size().width(),size().height());
67 m_scene->setSceneRect(0,0,size().width(),size().height());
85 m_chart->resize(size());
68 m_chart->resize(size());
86 QWidget::resizeEvent(event);
69 QWidget::resizeEvent(event);
87 }
70 }
88
71
89 /*!
72 /*!
90 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
73 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
91 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
74 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
92 the y axis).
75 the y axis).
93 \sa removeSeries(), removeAllSeries()
76 \sa removeSeries(), removeAllSeries()
94 */
77 */
95 void QChartView::addSeries(QChartSeries* series,QChartAxis *axisY)
78 void QChartView::addSeries(QChartSeries* series,QChartAxis *axisY)
96 {
79 {
97 m_chart->addSeries(series,axisY);
80 m_chart->addSeries(series,axisY);
98 }
81 }
99
82
100 /*!
83 /*!
101 Removes the \a series specified in a perameter from the QChartView.
84 Removes the \a series specified in a perameter from the QChartView.
102 It releses its ownership of the specified QChartSeries object.
85 It releses its ownership of the specified QChartSeries object.
103 It does not delete the pointed QChartSeries data object
86 It does not delete the pointed QChartSeries data object
104 \sa addSeries(), removeAllSeries()
87 \sa addSeries(), removeAllSeries()
105 */
88 */
106 void QChartView::removeSeries(QChartSeries* series)
89 void QChartView::removeSeries(QChartSeries* series)
107 {
90 {
108 m_chart->removeSeries(series);
91 m_chart->removeSeries(series);
109 }
92 }
110
93
111 /*!
94 /*!
112 Removes all the QChartSeries that have been added to the QChartView
95 Removes all the QChartSeries that have been added to the QChartView
113 It also deletes the pointed QChartSeries data objects
96 It also deletes the pointed QChartSeries data objects
114 \sa addSeries(), removeSeries()
97 \sa addSeries(), removeSeries()
115 */
98 */
116 void QChartView::removeAllSeries()
99 void QChartView::removeAllSeries()
117 {
100 {
118 m_chart->removeAllSeries();
101 m_chart->removeAllSeries();
119 }
102 }
120
103
121 /*!
104 /*!
122 Zooms in the view by a factor of 2
105 Zooms in the view by a factor of 2
123 */
106 */
124 void QChartView::zoomIn()
107 void QChartView::zoomIn()
125 {
108 {
126 m_chart->zoomIn();
109 m_chart->zoomIn();
127 }
110 }
128
111
129 /*!
112 /*!
130 Zooms in the view to a maximum level at which \a rect is still fully visible.
113 Zooms in the view to a maximum level at which \a rect is still fully visible.
131 */
114 */
132 void QChartView::zoomIn(const QRect& rect)
115 void QChartView::zoomIn(const QRect& rect)
133 {
116 {
134 m_chart->zoomIn(rect);
117 m_chart->zoomIn(rect);
135 }
118 }
136
119
137 /*!
120 /*!
138 Restores the view zoom level to the previous one.
121 Restores the view zoom level to the previous one.
139 */
122 */
140 void QChartView::zoomOut()
123 void QChartView::zoomOut()
141 {
124 {
142 m_chart->zoomOut();
125 m_chart->zoomOut();
143 }
126 }
144
127
145 /*!
128 /*!
146 Returns the chart margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
129 Returns the chart margin, which is the distance between the widget edge and the part of the chart where the actual data can be displayed.
147 */
130 */
148 int QChartView::margin() const
131 int QChartView::margin() const
149 {
132 {
150 return m_chart->margin();
133 return m_chart->margin();
151 }
134 }
152
135
153 /*!
136 /*!
154 Sets the chart \a title. A description text that is rendered above the chart.
137 Sets the chart \a title. A description text that is rendered above the chart.
155 */
138 */
156 void QChartView::setChartTitle(const QString& title)
139 void QChartView::setChartTitle(const QString& title)
157 {
140 {
158 m_chart->setChartTitle(title);
141 m_chart->setChartTitle(title);
159 }
142 }
160
143
161 /*!
144 /*!
162 Sets the \a font that is used for rendering the description text that is rendered above the chart.
145 Sets the \a font that is used for rendering the description text that is rendered above the chart.
163 */
146 */
164 void QChartView::setChartTitleFont(const QFont& font)
147 void QChartView::setChartTitleFont(const QFont& font)
165 {
148 {
166 m_chart->setChartTitleFont(font);
149 m_chart->setChartTitleFont(font);
167 }
150 }
168
151
169 /*!
152 /*!
170 Sets the \a brush that is used for painting the background of the chart area of the QChartView widget.
153 Sets the \a brush that is used for painting the background of the chart area of the QChartView widget.
171 */
154 */
172 void QChartView::setChartBackgroundBrush(const QBrush& brush)
155 void QChartView::setChartBackgroundBrush(const QBrush& brush)
173 {
156 {
174 m_chart->setChartBackgroundBrush(brush);
157 m_chart->setChartBackgroundBrush(brush);
175 }
158 }
176
159
177 /*!
160 /*!
178 Sets the \a pen that is used for painting the background of the chart area of the QChartView widget.
161 Sets the \a pen that is used for painting the background of the chart area of the QChartView widget.
179 */
162 */
180 void QChartView::setChartBackgroundPen(const QPen& pen)
163 void QChartView::setChartBackgroundPen(const QPen& pen)
181 {
164 {
182 m_chart->setChartBackgroundPen(pen);
165 m_chart->setChartBackgroundPen(pen);
183 }
166 }
184
167
185 /*!
168 /*!
186 Sets the RubberBandPlicy to \a policy. Selected policy determines the way zooming is performed.
169 Sets the RubberBandPlicy to \a policy. Selected policy determines the way zooming is performed.
187 */
170 */
188 void QChartView::setRubberBandPolicy(const RubberBandPolicy policy)
171 void QChartView::setRubberBandPolicy(const RubberBandPolicy policy)
189 {
172 {
190 switch(policy) {
173 switch(policy) {
191 case VerticalRubberBand:
174 case VerticalRubberBand:
192 m_verticalRubberBand = true;
175 m_verticalRubberBand = true;
193 m_horizonalRubberBand = false;
176 m_horizonalRubberBand = false;
194 break;
177 break;
195 case HorizonalRubberBand:
178 case HorizonalRubberBand:
196 m_verticalRubberBand = false;
179 m_verticalRubberBand = false;
197 m_horizonalRubberBand = true;
180 m_horizonalRubberBand = true;
198 break;
181 break;
199 case RectangleRubberBand:
182 case RectangleRubberBand:
200 m_verticalRubberBand = true;
183 m_verticalRubberBand = true;
201 m_horizonalRubberBand = true;
184 m_horizonalRubberBand = true;
202 break;
185 break;
203 case NoRubberBand:
186 case NoRubberBand:
204 default:
187 default:
205 delete m_rubberBand;
188 delete m_rubberBand;
206 m_rubberBand=0;
189 m_rubberBand=0;
207 m_horizonalRubberBand = false;
190 m_horizonalRubberBand = false;
208 m_verticalRubberBand = false;
191 m_verticalRubberBand = false;
209 return;
192 return;
210 }
193 }
211 if(!m_rubberBand) {
194 if(!m_rubberBand) {
212 m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
195 m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
213 m_rubberBand->setEnabled(true);
196 m_rubberBand->setEnabled(true);
214 }
197 }
215 }
198 }
216
199
217 /*!
200 /*!
218 Returns the RubberBandPolicy that is currently being used by the widget.
201 Returns the RubberBandPolicy that is currently being used by the widget.
219 */
202 */
220 QChartView::RubberBandPolicy QChartView::rubberBandPolicy() const
203 QChartView::RubberBandPolicy QChartView::rubberBandPolicy() const
221 {
204 {
222 if(m_horizonalRubberBand && m_verticalRubberBand) return RectangleRubberBand;
205 if(m_horizonalRubberBand && m_verticalRubberBand) return RectangleRubberBand;
223 if(m_horizonalRubberBand) return HorizonalRubberBand;
206 if(m_horizonalRubberBand) return HorizonalRubberBand;
224 if(m_verticalRubberBand) return VerticalRubberBand;
207 if(m_verticalRubberBand) return VerticalRubberBand;
225 return NoRubberBand;
208 return NoRubberBand;
226 }
209 }
227
210
228 /*!
211 /*!
229 If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area.
212 If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area.
230 If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation.
213 If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation.
231 */
214 */
232 void QChartView::mousePressEvent(QMouseEvent *event)
215 void QChartView::mousePressEvent(QMouseEvent *event)
233 {
216 {
234 if(m_rubberBand && m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
217 if(m_rubberBand && m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
235
218
236 int margin = m_chart->margin();
219 int margin = m_chart->margin();
237 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
220 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
238
221
239 if (rect.contains(event->pos())) {
222 if (rect.contains(event->pos())) {
240 m_rubberBandOrigin = event->pos();
223 m_rubberBandOrigin = event->pos();
241 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin, QSize()));
224 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin, QSize()));
242 m_rubberBand->show();
225 m_rubberBand->show();
243 event->accept();
226 event->accept();
244 }
227 }
245 }
228 }
246 else {
229 else {
247 QGraphicsView::mousePressEvent(event);
230 QGraphicsView::mousePressEvent(event);
248 }
231 }
249 }
232 }
250
233
251 /*!
234 /*!
252 If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry.
235 If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry.
253 In other case the defualt QGraphicsView::mouseMoveEvent implementation is called.
236 In other case the defualt QGraphicsView::mouseMoveEvent implementation is called.
254 */
237 */
255 void QChartView::mouseMoveEvent(QMouseEvent *event)
238 void QChartView::mouseMoveEvent(QMouseEvent *event)
256 {
239 {
257 if(m_rubberBand && m_rubberBand->isVisible()) {
240 if(m_rubberBand && m_rubberBand->isVisible()) {
258 int margin = m_chart->margin();
241 int margin = m_chart->margin();
259 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
242 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
260 int width = event->pos().x() - m_rubberBandOrigin.x();
243 int width = event->pos().x() - m_rubberBandOrigin.x();
261 int height = event->pos().y() - m_rubberBandOrigin.y();
244 int height = event->pos().y() - m_rubberBandOrigin.y();
262 if(!m_verticalRubberBand) {
245 if(!m_verticalRubberBand) {
263 m_rubberBandOrigin.setY(rect.top());
246 m_rubberBandOrigin.setY(rect.top());
264 height = rect.height();
247 height = rect.height();
265 }
248 }
266 if(!m_horizonalRubberBand) {
249 if(!m_horizonalRubberBand) {
267 m_rubberBandOrigin.setX(rect.left());
250 m_rubberBandOrigin.setX(rect.left());
268 width= rect.width();
251 width= rect.width();
269 }
252 }
270 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin.x(),m_rubberBandOrigin.y(), width,height).normalized());
253 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin.x(),m_rubberBandOrigin.y(), width,height).normalized());
271 }
254 }
272 else {
255 else {
273 QGraphicsView::mouseMoveEvent(event);
256 QGraphicsView::mouseMoveEvent(event);
274 }
257 }
275 }
258 }
276
259
277 /*!
260 /*!
278 If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand
261 If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand
279 If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled.
262 If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled.
280 */
263 */
281 void QChartView::mouseReleaseEvent(QMouseEvent *event)
264 void QChartView::mouseReleaseEvent(QMouseEvent *event)
282 {
265 {
283 if(m_rubberBand) {
266 if(m_rubberBand) {
284 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
267 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
285 m_rubberBand->hide();
268 m_rubberBand->hide();
286 QRect rect = m_rubberBand->geometry();
269 QRect rect = m_rubberBand->geometry();
287 m_chart->zoomIn(rect);
270 m_chart->zoomIn(rect);
288 event->accept();
271 event->accept();
289 }
272 }
290
273
291 if(event->button()==Qt::RightButton)
274 if(event->button()==Qt::RightButton)
292 m_chart->zoomReset();
275 m_chart->zoomReset();
293 }
276 }
294 else {
277 else {
295 QGraphicsView::mouseReleaseEvent(event);
278 QGraphicsView::mouseReleaseEvent(event);
296 }
279 }
297 }
280 }
298
281
299 /*!
282 /*!
300 Pressing + and - keys performs zoomIn() and zoomOut() respectivly.
283 Pressing + and - keys performs zoomIn() and zoomOut() respectivly.
301 In other \a event is passed to the QGraphicsView::keyPressEvent() implementation
284 In other \a event is passed to the QGraphicsView::keyPressEvent() implementation
302 */
285 */
303 void QChartView::keyPressEvent(QKeyEvent *event)
286 void QChartView::keyPressEvent(QKeyEvent *event)
304 {
287 {
305 switch (event->key()) {
288 switch (event->key()) {
306 case Qt::Key_Plus:
289 case Qt::Key_Plus:
307 zoomIn();
290 zoomIn();
308 break;
291 break;
309 case Qt::Key_Minus:
292 case Qt::Key_Minus:
310 zoomOut();
293 zoomOut();
311 break;
294 break;
312 default:
295 default:
313 QGraphicsView::keyPressEvent(event);
296 QGraphicsView::keyPressEvent(event);
314 break;
297 break;
315 }
298 }
316 }
299 }
317
300
318 /*!
301 /*!
319 Sets the \a theme used by the chart for rendering the graphical representation of the data
302 Sets the \a theme used by the chart for rendering the graphical representation of the data
320 \sa QChart::ChartTheme, chartTheme()
303 \sa QChart::ChartTheme, chartTheme()
321 */
304 */
322 void QChartView::setChartTheme(QChart::ChartTheme theme)
305 void QChartView::setChartTheme(QChart::ChartTheme theme)
323 {
306 {
324 m_chart->setChartTheme(theme);
307 m_chart->setChartTheme(theme);
325 }
308 }
326
309
327 /*!
310 /*!
328 Returns the theme enum used by the chart.
311 Returns the theme enum used by the chart.
329 \sa setChartTheme()
312 \sa setChartTheme()
330 */
313 */
331 QChart::ChartTheme QChartView::chartTheme() const
314 QChart::ChartTheme QChartView::chartTheme() const
332 {
315 {
333 return m_chart->chartTheme();
316 return m_chart->chartTheme();
334 }
317 }
335
318
336 /*!
319 /*!
337 Returns the pointer to the x axis object of the chart
320 Returns the pointer to the x axis object of the chart
338 */
321 */
339 QChartAxis* QChartView::axisX() const
322 QChartAxis* QChartView::axisX() const
340 {
323 {
341 return m_chart->axisX();
324 return m_chart->axisX();
342 }
325 }
343
326
344 /*!
327 /*!
345 Returns the pointer to the y axis object of the chart
328 Returns the pointer to the y axis object of the chart
346 */
329 */
347 QChartAxis* QChartView::axisY() const
330 QChartAxis* QChartView::axisY() const
348 {
331 {
349 return m_chart->axisY();
332 return m_chart->axisY();
350 }
333 }
351
334
352 /*!
335 /*!
353 Sets animation \a options for the chart
336 Sets animation \a options for the chart
354 */
337 */
355 void QChartView::setAnimationOptions(QChart::AnimationOptions options)
338 void QChartView::setAnimationOptions(QChart::AnimationOptions options)
356 {
339 {
357 m_chart->setAnimationOptions(options);
340 m_chart->setAnimationOptions(options);
358 }
341 }
359
342
360 /*!
343 /*!
361 Returns animation options for the chart
344 Returns animation options for the chart
362 */
345 */
363 QChart::AnimationOptions QChartView::animationOptions() const
346 QChart::AnimationOptions QChartView::animationOptions() const
364 {
347 {
365 return m_chart->animationOptions();
348 return m_chart->animationOptions();
366 }
349 }
367
350
368 QTCOMMERCIALCHART_END_NAMESPACE
351 QTCOMMERCIALCHART_END_NAMESPACE
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now