@@ -1,102 +1,103 | |||||
1 | /*! |
|
1 | /*! | |
2 | \page qml.html |
|
2 | \page qml.html | |
3 | \title QtCommercial Charts QML API |
|
3 | \title QtCommercial Charts QML API | |
4 | \keyword Charts QML API |
|
4 | \keyword Charts QML API | |
5 |
|
5 | |||
6 | QtCommercial Charts QML API is an intuitive and simple way to show charts in your QML |
|
6 | QtCommercial Charts QML API is an intuitive and simple way to show charts in your QML | |
7 | applications. |
|
7 | applications. | |
8 |
|
8 | |||
9 | \table |
|
9 | \table | |
10 | \row |
|
10 | \row | |
11 | \o \br |
|
11 | \o \br | |
12 | Use the following QML to create a simple pie chart: |
|
12 | Use the following QML to create a simple pie chart: | |
13 | \br |
|
13 | \br | |
14 | \br |
|
14 | \br | |
15 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
15 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
16 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
16 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
17 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
17 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
18 | \o \inlineimage examples_qmlpiechart.png |
|
18 | \o \inlineimage examples_qmlpiechart.png | |
19 | \endtable |
|
19 | \endtable | |
20 |
|
20 | |||
21 | \note Since QtCommercial Charts utilizes Qt Graphics View Framework for drawing, it works best |
|
21 | \note Since QtCommercial Charts utilizes Qt Graphics View Framework for drawing, it works best | |
22 | with QtQuick 1, which is based on the same framework. |
|
22 | with QtQuick 1, which is based on the same framework. | |
23 | As of release 1.3.0, QtCommercial Charts is also usable with QtQuick 2, though the performance |
|
23 | As of release 1.3.0, QtCommercial Charts is also usable with QtQuick 2, though the performance | |
24 | is slightly worse than with QtQuick 1. Also, hovered and clicked signals of series do not work |
|
24 | is slightly worse than with QtQuick 1. Also, hovered and clicked signals of series do not work | |
25 | with QtQuick 2. |
|
25 | with QtQuick 2. | |
26 |
|
26 | |||
27 | \raw HTML |
|
27 | \raw HTML | |
28 | <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable"> |
|
28 | <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable"> | |
29 | <tr> |
|
29 | <tr> | |
30 | <th class="titleheader" width="25%"> ChartView and it's properties </th> |
|
30 | <th class="titleheader" width="25%"> ChartView and it's properties </th> | |
31 | </tr> |
|
31 | </tr> | |
32 | <tr> |
|
32 | <tr> | |
33 | <td valign="top"> |
|
33 | <td valign="top"> | |
34 | <ul> |
|
34 | <ul> | |
35 | <li><a href="qml-chartview.html">ChartView</a></li> |
|
35 | <li><a href="qml-chartview.html">ChartView</a></li> | |
36 | <li><a href="qml-polarchartview.html">PolarChartView</a></li> |
|
36 | <li><a href="qml-polarchartview.html">PolarChartView</a></li> | |
37 | <li><a href="qml-abstractaxis.html">AbstractAxis</a></li> |
|
37 | <li><a href="qml-abstractaxis.html">AbstractAxis</a></li> | |
38 | <li><a href="qml-valueaxis.html">ValueAxis</a></li> |
|
38 | <li><a href="qml-valueaxis.html">ValueAxis</a></li> | |
|
39 | <li><a href="qml-logvaluesaxis.html">LogValueAxis</a></li> | |||
39 | <li><a href="qml-categoryaxis.html">CategoryAxis</a></li> |
|
40 | <li><a href="qml-categoryaxis.html">CategoryAxis</a></li> | |
40 | <li><a href="qml-categoryrange.html">CategoryRange</a></li> |
|
41 | <li><a href="qml-categoryrange.html">CategoryRange</a></li> | |
41 | <li><a href="qml-barcategoryaxis.html">BarCategoryAxis</a></li> |
|
42 | <li><a href="qml-barcategoryaxis.html">BarCategoryAxis</a></li> | |
42 | <li><a href="qml-datetimeaxis.html">DateTimeAxis</a></li> |
|
43 | <li><a href="qml-datetimeaxis.html">DateTimeAxis</a></li> | |
43 | <li><a href="qml-legend.html">Legend</a></li> |
|
44 | <li><a href="qml-legend.html">Legend</a></li> | |
44 | <li><a href="qml-abstractseries.html">AbstractSeries</a></li> |
|
45 | <li><a href="qml-abstractseries.html">AbstractSeries</a></li> | |
45 | </ul> |
|
46 | </ul> | |
46 | </td> |
|
47 | </td> | |
47 | </tr> |
|
48 | </tr> | |
48 | </table> |
|
49 | </table> | |
49 | <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable"> |
|
50 | <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable"> | |
50 | <tr> |
|
51 | <tr> | |
51 | <th class="titleheader" width="25%"> XY chart </th> |
|
52 | <th class="titleheader" width="25%"> XY chart </th> | |
52 | </tr> |
|
53 | </tr> | |
53 | <tr> |
|
54 | <tr> | |
54 | <td valign="top"> |
|
55 | <td valign="top"> | |
55 | <ul> |
|
56 | <ul> | |
56 | <li><a href="qml-xyseries.html">XYSeries</a></li> |
|
57 | <li><a href="qml-xyseries.html">XYSeries</a></li> | |
57 | <li><a href="qml-lineseries.html">LineSeries</a></li> |
|
58 | <li><a href="qml-lineseries.html">LineSeries</a></li> | |
58 | <li><a href="qml-areaseries.html">AreaSeries</a></li> |
|
59 | <li><a href="qml-areaseries.html">AreaSeries</a></li> | |
59 | <li><a href="qml-scatterseries.html">ScatterSeries</a></li> |
|
60 | <li><a href="qml-scatterseries.html">ScatterSeries</a></li> | |
60 | <li><a href="qml-splineseries.html">SplineSeries</a></li> |
|
61 | <li><a href="qml-splineseries.html">SplineSeries</a></li> | |
61 | <li><a href="qml-xypoint.html">XYPoint</a></li> |
|
62 | <li><a href="qml-xypoint.html">XYPoint</a></li> | |
62 | <li><a href="qml-hxymodelmapper.html">HXYModelMapper</a></li> |
|
63 | <li><a href="qml-hxymodelmapper.html">HXYModelMapper</a></li> | |
63 | <li><a href="qml-vxymodelmapper.html">VXYModelMapper</a></li> |
|
64 | <li><a href="qml-vxymodelmapper.html">VXYModelMapper</a></li> | |
64 | </ul> |
|
65 | </ul> | |
65 | </td> |
|
66 | </td> | |
66 | </tr> |
|
67 | </tr> | |
67 | </table> |
|
68 | </table> | |
68 | <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable"> |
|
69 | <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable"> | |
69 | <tr> |
|
70 | <tr> | |
70 | <th class="titleheader" width="25%"> Pie chart </th> |
|
71 | <th class="titleheader" width="25%"> Pie chart </th> | |
71 | <tr> |
|
72 | <tr> | |
72 | <td valign="top"> |
|
73 | <td valign="top"> | |
73 | <ul> |
|
74 | <ul> | |
74 | <li><a href="qml-pieseries.html">PieSeries</a></li> |
|
75 | <li><a href="qml-pieseries.html">PieSeries</a></li> | |
75 | <li><a href="qml-pieslice.html">PieSlice</a></li> |
|
76 | <li><a href="qml-pieslice.html">PieSlice</a></li> | |
76 | <li><a href="qml-hpiemodelmapper.html">HPieModelMapper</a></li> |
|
77 | <li><a href="qml-hpiemodelmapper.html">HPieModelMapper</a></li> | |
77 | <li><a href="qml-vpiemodelmapper.html">VPieModelMapper</a></li> |
|
78 | <li><a href="qml-vpiemodelmapper.html">VPieModelMapper</a></li> | |
78 | </ul> |
|
79 | </ul> | |
79 | </td> |
|
80 | </td> | |
80 | </tr> |
|
81 | </tr> | |
81 | </table> |
|
82 | </table> | |
82 | <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable"> |
|
83 | <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable"> | |
83 | <tr> |
|
84 | <tr> | |
84 | <th class="titleheader" width="25%"> Bar chart </th> |
|
85 | <th class="titleheader" width="25%"> Bar chart </th> | |
85 | <tr> |
|
86 | <tr> | |
86 | <td valign="top"> |
|
87 | <td valign="top"> | |
87 | <ul> |
|
88 | <ul> | |
88 | <li><a href="qml-barseries.html">BarSeries</a></li> |
|
89 | <li><a href="qml-barseries.html">BarSeries</a></li> | |
89 | <li><a href="qml-stackedbarseries.html">StackedBarSeries</a></li> |
|
90 | <li><a href="qml-stackedbarseries.html">StackedBarSeries</a></li> | |
90 | <li><a href="qml-percentbarseries.html">PercentBarSeries</a></li> |
|
91 | <li><a href="qml-percentbarseries.html">PercentBarSeries</a></li> | |
91 | <li><a href="qml-horizontalbarseries.html">HorizontalBarSeries</a></li> |
|
92 | <li><a href="qml-horizontalbarseries.html">HorizontalBarSeries</a></li> | |
92 | <li><a href="qml-horizontalstackedbarseries.html">HorizontalStackedBarSeries</a></li> |
|
93 | <li><a href="qml-horizontalstackedbarseries.html">HorizontalStackedBarSeries</a></li> | |
93 | <li><a href="qml-horizontalpercentbarseries.html">HorizontalPercentBarSeries</a></li> |
|
94 | <li><a href="qml-horizontalpercentbarseries.html">HorizontalPercentBarSeries</a></li> | |
94 | <li><a href="qml-barset.html">BarSet</a></li> |
|
95 | <li><a href="qml-barset.html">BarSet</a></li> | |
95 | <li><a href="qml-hbarmodelmapper.html">HBarModelMapper</a></li> |
|
96 | <li><a href="qml-hbarmodelmapper.html">HBarModelMapper</a></li> | |
96 | <li><a href="qml-vbarmodelmapper.html">VBarModelMapper</a></li> |
|
97 | <li><a href="qml-vbarmodelmapper.html">VBarModelMapper</a></li> | |
97 | </ul> |
|
98 | </ul> | |
98 | </td> |
|
99 | </td> | |
99 | </tr> |
|
100 | </tr> | |
100 | </table> |
|
101 | </table> | |
101 | \endraw |
|
102 | \endraw | |
102 | */ |
|
103 | */ |
@@ -1,817 +1,820 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
23 | #include "declarativelineseries.h" |
|
23 | #include "declarativelineseries.h" | |
24 | #include "declarativeareaseries.h" |
|
24 | #include "declarativeareaseries.h" | |
25 | #include "declarativebarseries.h" |
|
25 | #include "declarativebarseries.h" | |
26 | #include "declarativepieseries.h" |
|
26 | #include "declarativepieseries.h" | |
27 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
29 | #include "qbarcategoryaxis.h" |
|
29 | #include "qbarcategoryaxis.h" | |
30 | #include "qvalueaxis.h" |
|
30 | #include "qvalueaxis.h" | |
|
31 | #include "qlogvalueaxis.h" | |||
31 | #include "qcategoryaxis.h" |
|
32 | #include "qcategoryaxis.h" | |
32 | #include "qabstractseries_p.h" |
|
33 | #include "qabstractseries_p.h" | |
33 | #include "declarativemargins.h" |
|
34 | #include "declarativemargins.h" | |
34 | #include "chartdataset_p.h" |
|
35 | #include "chartdataset_p.h" | |
35 | #include "declarativeaxes.h" |
|
36 | #include "declarativeaxes.h" | |
36 | #include "qchart_p.h" |
|
37 | #include "qchart_p.h" | |
37 | #include "qpolarchart.h" |
|
38 | #include "qpolarchart.h" | |
38 |
|
39 | |||
39 | #ifndef QT_ON_ARM |
|
40 | #ifndef QT_ON_ARM | |
40 | #include "qdatetimeaxis.h" |
|
41 | #include "qdatetimeaxis.h" | |
41 | #endif |
|
42 | #endif | |
42 |
|
43 | |||
43 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
44 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
44 |
|
45 | |||
45 | /*! |
|
46 | /*! | |
46 | \qmlclass ChartView DeclarativeChart |
|
47 | \qmlclass ChartView DeclarativeChart | |
47 |
|
48 | |||
48 | ChartView element is the parent that is responsible for showing different chart series types. |
|
49 | ChartView element is the parent that is responsible for showing different chart series types. | |
49 |
|
50 | |||
50 | The following QML shows how to create a simple chart with one pie series: |
|
51 | The following QML shows how to create a simple chart with one pie series: | |
51 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
52 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
52 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
53 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
53 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
54 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
54 |
|
55 | |||
55 | \beginfloatleft |
|
56 | \beginfloatleft | |
56 | \image examples_qmlpiechart.png |
|
57 | \image examples_qmlpiechart.png | |
57 | \endfloat |
|
58 | \endfloat | |
58 | \clearfloat |
|
59 | \clearfloat | |
59 | */ |
|
60 | */ | |
60 |
|
61 | |||
61 | /*! |
|
62 | /*! | |
62 | \qmlproperty Theme ChartView::theme |
|
63 | \qmlproperty Theme ChartView::theme | |
63 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
64 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
64 | widths and chart background. |
|
65 | widths and chart background. | |
65 | */ |
|
66 | */ | |
66 |
|
67 | |||
67 | /*! |
|
68 | /*! | |
68 | \qmlproperty Animation ChartView::animationOptions |
|
69 | \qmlproperty Animation ChartView::animationOptions | |
69 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
70 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
70 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
71 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
71 | */ |
|
72 | */ | |
72 |
|
73 | |||
73 | /*! |
|
74 | /*! | |
74 | \qmlproperty Font ChartView::titleFont |
|
75 | \qmlproperty Font ChartView::titleFont | |
75 | The title font of the chart |
|
76 | The title font of the chart | |
76 |
|
77 | |||
77 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
78 | See the \l {Font} {QML Font Element} for detailed documentation. | |
78 | */ |
|
79 | */ | |
79 |
|
80 | |||
80 | /*! |
|
81 | /*! | |
81 | \qmlproperty string ChartView::title |
|
82 | \qmlproperty string ChartView::title | |
82 | The title of the chart, shown on top of the chart. |
|
83 | The title of the chart, shown on top of the chart. | |
83 | \sa ChartView::titleColor |
|
84 | \sa ChartView::titleColor | |
84 | */ |
|
85 | */ | |
85 |
|
86 | |||
86 | /*! |
|
87 | /*! | |
87 | \qmlproperty color ChartView::titleColor |
|
88 | \qmlproperty color ChartView::titleColor | |
88 | The color of the title text. |
|
89 | The color of the title text. | |
89 | */ |
|
90 | */ | |
90 |
|
91 | |||
91 | /*! |
|
92 | /*! | |
92 | \qmlproperty Legend ChartView::legend |
|
93 | \qmlproperty Legend ChartView::legend | |
93 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
94 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
94 | */ |
|
95 | */ | |
95 |
|
96 | |||
96 | /*! |
|
97 | /*! | |
97 | \qmlproperty int ChartView::count |
|
98 | \qmlproperty int ChartView::count | |
98 | The count of series added to the chart. |
|
99 | The count of series added to the chart. | |
99 | */ |
|
100 | */ | |
100 |
|
101 | |||
101 | /*! |
|
102 | /*! | |
102 | \qmlproperty color ChartView::backgroundColor |
|
103 | \qmlproperty color ChartView::backgroundColor | |
103 | The color of the chart's background. By default background color is defined by chart theme. |
|
104 | The color of the chart's background. By default background color is defined by chart theme. | |
104 | \sa ChartView::theme |
|
105 | \sa ChartView::theme | |
105 | */ |
|
106 | */ | |
106 |
|
107 | |||
107 | /*! |
|
108 | /*! | |
108 | \qmlproperty bool ChartView::dropShadowEnabled |
|
109 | \qmlproperty bool ChartView::dropShadowEnabled | |
109 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
110 | The chart's border drop shadow. Set to true to enable drop shadow. | |
110 | */ |
|
111 | */ | |
111 |
|
112 | |||
112 | /*! |
|
113 | /*! | |
113 | \qmlproperty real ChartView::topMargin |
|
114 | \qmlproperty real ChartView::topMargin | |
114 | */ |
|
115 | */ | |
115 |
|
116 | |||
116 | /*! |
|
117 | /*! | |
117 | \qmlproperty real ChartView::bottomMargin |
|
118 | \qmlproperty real ChartView::bottomMargin | |
118 | */ |
|
119 | */ | |
119 |
|
120 | |||
120 | /*! |
|
121 | /*! | |
121 | \qmlproperty real ChartView::leftMargin |
|
122 | \qmlproperty real ChartView::leftMargin | |
122 | */ |
|
123 | */ | |
123 |
|
124 | |||
124 | /*! |
|
125 | /*! | |
125 | \qmlproperty real ChartView::rightMargin |
|
126 | \qmlproperty real ChartView::rightMargin | |
126 | */ |
|
127 | */ | |
127 |
|
128 | |||
128 | /*! |
|
129 | /*! | |
129 | \qmlproperty Margins ChartView::minimumMargins |
|
130 | \qmlproperty Margins ChartView::minimumMargins | |
130 | Deprecated; use margins instead. |
|
131 | Deprecated; use margins instead. | |
131 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins |
|
132 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins | |
132 | area of ChartView is used for drawing title, axes and legend. Please note that setting the |
|
133 | area of ChartView is used for drawing title, axes and legend. Please note that setting the | |
133 | properties of minimumMargins may be bigger than the defined value, depending on other ChartView |
|
134 | properties of minimumMargins may be bigger than the defined value, depending on other ChartView | |
134 | properties that affect it's layout. If you need to know the actual plotting area used at any |
|
135 | properties that affect it's layout. If you need to know the actual plotting area used at any | |
135 | given time, you can check ChartView::plotArea instead. |
|
136 | given time, you can check ChartView::plotArea instead. | |
136 | */ |
|
137 | */ | |
137 |
|
138 | |||
138 | /*! |
|
139 | /*! | |
139 | \qmlproperty rect ChartView::plotArea |
|
140 | \qmlproperty rect ChartView::plotArea | |
140 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the |
|
141 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the | |
141 | margins. |
|
142 | margins. | |
142 | \sa ChartView::minimumMargins |
|
143 | \sa ChartView::minimumMargins | |
143 | */ |
|
144 | */ | |
144 |
|
145 | |||
145 | /*! |
|
146 | /*! | |
146 | \qmlproperty Margins ChartView::margins |
|
147 | \qmlproperty Margins ChartView::margins | |
147 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins |
|
148 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins | |
148 | area of ChartView is used for drawing title, axes and legend. |
|
149 | area of ChartView is used for drawing title, axes and legend. | |
149 | */ |
|
150 | */ | |
150 |
|
151 | |||
151 | /*! |
|
152 | /*! | |
152 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
153 | \qmlmethod AbstractSeries ChartView::series(int index) | |
153 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
154 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with | |
154 | the count property of the chart. |
|
155 | the count property of the chart. | |
155 | */ |
|
156 | */ | |
156 |
|
157 | |||
157 | /*! |
|
158 | /*! | |
158 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
159 | \qmlmethod AbstractSeries ChartView::series(string name) | |
159 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
160 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
160 | */ |
|
161 | */ | |
161 |
|
162 | |||
162 | /*! |
|
163 | /*! | |
163 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) |
|
164 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) | |
164 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and |
|
165 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and | |
165 | optional axis \a axisY. For example: |
|
166 | optional axis \a axisY. For example: | |
166 | \code |
|
167 | \code | |
167 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes |
|
168 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes | |
168 | var myAxisX = chartView.axisX(lineSeries); |
|
169 | var myAxisX = chartView.axisX(lineSeries); | |
169 | var myAxisY = chartView.axisY(lineSeries); |
|
170 | var myAxisY = chartView.axisY(lineSeries); | |
170 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); |
|
171 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); | |
171 | \endcode |
|
172 | \endcode | |
172 | */ |
|
173 | */ | |
173 |
|
174 | |||
174 | /*! |
|
175 | /*! | |
175 | \qmlmethod ChartView::removeSeries(AbstractSeries series) |
|
176 | \qmlmethod ChartView::removeSeries(AbstractSeries series) | |
176 | Removes the \a series from the chart. The series object is also destroyed. |
|
177 | Removes the \a series from the chart. The series object is also destroyed. | |
177 | */ |
|
178 | */ | |
178 |
|
179 | |||
179 | /*! |
|
180 | /*! | |
180 | \qmlmethod ChartView::removeAllSeries() |
|
181 | \qmlmethod ChartView::removeAllSeries() | |
181 | Removes all series from the chart. All the series objects are also destroyed. |
|
182 | Removes all series from the chart. All the series objects are also destroyed. | |
182 | */ |
|
183 | */ | |
183 |
|
184 | |||
184 | /*! |
|
185 | /*! | |
185 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) |
|
186 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) | |
186 | The x-axis of the series. |
|
187 | The x-axis of the series. | |
187 | */ |
|
188 | */ | |
188 |
|
189 | |||
189 | /*! |
|
190 | /*! | |
190 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) |
|
191 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) | |
191 | The y-axis of the series. |
|
192 | The y-axis of the series. | |
192 | */ |
|
193 | */ | |
193 |
|
194 | |||
194 | /*! |
|
195 | /*! | |
195 | \qmlmethod ChartView::zoomY(real factor) |
|
196 | \qmlmethod ChartView::zoomY(real factor) | |
196 | Zooms in by \a factor on the center of the chart. |
|
197 | Zooms in by \a factor on the center of the chart. | |
197 | */ |
|
198 | */ | |
198 |
|
199 | |||
199 | /*! |
|
200 | /*! | |
200 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
201 | \qmlmethod ChartView::scrollLeft(real pixels) | |
201 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
202 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
202 | */ |
|
203 | */ | |
203 |
|
204 | |||
204 | /*! |
|
205 | /*! | |
205 | \qmlmethod ChartView::scrollRight(real pixels) |
|
206 | \qmlmethod ChartView::scrollRight(real pixels) | |
206 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
207 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
207 | */ |
|
208 | */ | |
208 |
|
209 | |||
209 | /*! |
|
210 | /*! | |
210 | \qmlmethod ChartView::scrollUp(real pixels) |
|
211 | \qmlmethod ChartView::scrollUp(real pixels) | |
211 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
212 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
212 | */ |
|
213 | */ | |
213 |
|
214 | |||
214 | /*! |
|
215 | /*! | |
215 | \qmlmethod ChartView::scrollDown(real pixels) |
|
216 | \qmlmethod ChartView::scrollDown(real pixels) | |
216 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
217 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
217 | */ |
|
218 | */ | |
218 |
|
219 | |||
219 | /*! |
|
220 | /*! | |
220 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) |
|
221 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) | |
221 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins |
|
222 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins | |
222 | or if you resize the chart, or if you modify font size related properties of the legend or chart |
|
223 | or if you resize the chart, or if you modify font size related properties of the legend or chart | |
223 | title. |
|
224 | title. | |
224 | */ |
|
225 | */ | |
225 |
|
226 | |||
226 | /*! |
|
227 | /*! | |
227 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) |
|
228 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) | |
228 | The \a series has been added to the chart. |
|
229 | The \a series has been added to the chart. | |
229 | */ |
|
230 | */ | |
230 |
|
231 | |||
231 | /*! |
|
232 | /*! | |
232 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) |
|
233 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) | |
233 | The \a series has been removed from the chart. Please note that \a series is no longer a valid |
|
234 | The \a series has been removed from the chart. Please note that \a series is no longer a valid | |
234 | object after the signal handler has completed. |
|
235 | object after the signal handler has completed. | |
235 | */ |
|
236 | */ | |
236 |
|
237 | |||
237 | DeclarativeChart::DeclarativeChart(QDECLARATIVE_ITEM *parent) |
|
238 | DeclarativeChart::DeclarativeChart(QDECLARATIVE_ITEM *parent) | |
238 | : QDECLARATIVE_PAINTED_ITEM(parent) |
|
239 | : QDECLARATIVE_PAINTED_ITEM(parent) | |
239 | { |
|
240 | { | |
240 | initChart(QChart::ChartTypeCartesian); |
|
241 | initChart(QChart::ChartTypeCartesian); | |
241 | } |
|
242 | } | |
242 |
|
243 | |||
243 | DeclarativeChart::DeclarativeChart(QChart::ChartType type, QDECLARATIVE_ITEM *parent) |
|
244 | DeclarativeChart::DeclarativeChart(QChart::ChartType type, QDECLARATIVE_ITEM *parent) | |
244 | : QDECLARATIVE_PAINTED_ITEM(parent) |
|
245 | : QDECLARATIVE_PAINTED_ITEM(parent) | |
245 | { |
|
246 | { | |
246 | initChart(type); |
|
247 | initChart(type); | |
247 | } |
|
248 | } | |
248 |
|
249 | |||
249 | void DeclarativeChart::initChart(QChart::ChartType type) |
|
250 | void DeclarativeChart::initChart(QChart::ChartType type) | |
250 | { |
|
251 | { | |
251 | #ifdef CHARTS_FOR_QUICK2 |
|
252 | #ifdef CHARTS_FOR_QUICK2 | |
252 | if (type == QChart::ChartTypePolar) |
|
253 | if (type == QChart::ChartTypePolar) | |
253 | m_chart = new QPolarChart(); |
|
254 | m_chart = new QPolarChart(); | |
254 | else |
|
255 | else | |
255 | m_chart = new QChart(); |
|
256 | m_chart = new QChart(); | |
256 |
|
257 | |||
257 | m_scene = new QGraphicsScene(this); |
|
258 | m_scene = new QGraphicsScene(this); | |
258 | m_scene->addItem(m_chart); |
|
259 | m_scene->addItem(m_chart); | |
259 |
|
260 | |||
260 | setAntialiasing(QQuickItem::antialiasing()); |
|
261 | setAntialiasing(QQuickItem::antialiasing()); | |
261 | connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(update())); |
|
262 | connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(update())); | |
262 | connect(this, SIGNAL(antialiasingChanged(bool)), this, SLOT(handleAntialiasingChanged(bool))); |
|
263 | connect(this, SIGNAL(antialiasingChanged(bool)), this, SLOT(handleAntialiasingChanged(bool))); | |
263 | #else |
|
264 | #else | |
264 | if (type == QChart::ChartTypePolar) |
|
265 | if (type == QChart::ChartTypePolar) | |
265 | m_chart = new QPolarChart(this); |
|
266 | m_chart = new QPolarChart(this); | |
266 | else |
|
267 | else | |
267 | m_chart = new QChart(this); |
|
268 | m_chart = new QChart(this); | |
268 |
|
269 | |||
269 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
270 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
270 | #endif |
|
271 | #endif | |
271 |
|
272 | |||
272 | m_margins = new DeclarativeMargins(this); |
|
273 | m_margins = new DeclarativeMargins(this); | |
273 | m_margins->setTop(m_chart->margins().top()); |
|
274 | m_margins->setTop(m_chart->margins().top()); | |
274 | m_margins->setLeft(m_chart->margins().left()); |
|
275 | m_margins->setLeft(m_chart->margins().left()); | |
275 | m_margins->setRight(m_chart->margins().right()); |
|
276 | m_margins->setRight(m_chart->margins().right()); | |
276 | m_margins->setBottom(m_chart->margins().bottom()); |
|
277 | m_margins->setBottom(m_chart->margins().bottom()); | |
277 | connect(m_margins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
278 | connect(m_margins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
278 | connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
279 | connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
279 | connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
280 | connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
280 | connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
281 | connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
281 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); |
|
282 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); | |
282 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
283 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
283 | } |
|
284 | } | |
284 |
|
285 | |||
285 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) |
|
286 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) | |
286 | { |
|
287 | { | |
287 | emit seriesAdded(series); |
|
288 | emit seriesAdded(series); | |
288 | } |
|
289 | } | |
289 |
|
290 | |||
290 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) |
|
291 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) | |
291 | { |
|
292 | { | |
292 | m_chart->setMargins(QMargins(left, top, right, bottom)); |
|
293 | m_chart->setMargins(QMargins(left, top, right, bottom)); | |
293 | emit minimumMarginsChanged(); |
|
294 | emit minimumMarginsChanged(); | |
294 | emit plotAreaChanged(m_chart->plotArea()); |
|
295 | emit plotAreaChanged(m_chart->plotArea()); | |
295 | } |
|
296 | } | |
296 |
|
297 | |||
297 | DeclarativeChart::~DeclarativeChart() |
|
298 | DeclarativeChart::~DeclarativeChart() | |
298 | { |
|
299 | { | |
299 | delete m_chart; |
|
300 | delete m_chart; | |
300 | } |
|
301 | } | |
301 |
|
302 | |||
302 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
303 | void DeclarativeChart::childEvent(QChildEvent *event) | |
303 | { |
|
304 | { | |
304 | if (event->type() == QEvent::ChildAdded) { |
|
305 | if (event->type() == QEvent::ChildAdded) { | |
305 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
306 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
306 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
307 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
307 | } |
|
308 | } | |
308 | } |
|
309 | } | |
309 | } |
|
310 | } | |
310 |
|
311 | |||
311 | void DeclarativeChart::componentComplete() |
|
312 | void DeclarativeChart::componentComplete() | |
312 | { |
|
313 | { | |
313 | foreach (QObject *child, children()) { |
|
314 | foreach (QObject *child, children()) { | |
314 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
315 | if (qobject_cast<QAbstractSeries *>(child)) { | |
315 | // Add series to the chart |
|
316 | // Add series to the chart | |
316 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); |
|
317 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); | |
317 | m_chart->addSeries(series); |
|
318 | m_chart->addSeries(series); | |
318 |
|
319 | |||
319 | // Connect to axis changed signals (unless this is a pie series) |
|
320 | // Connect to axis changed signals (unless this is a pie series) | |
320 | if (!qobject_cast<DeclarativePieSeries *>(series)) { |
|
321 | if (!qobject_cast<DeclarativePieSeries *>(series)) { | |
321 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
322 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
322 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
323 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
323 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
324 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
324 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); |
|
325 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); | |
325 | } |
|
326 | } | |
326 |
|
327 | |||
327 | initializeAxes(series); |
|
328 | initializeAxes(series); | |
328 | } |
|
329 | } | |
329 | } |
|
330 | } | |
330 |
|
331 | |||
331 | QDECLARATIVE_ITEM::componentComplete(); |
|
332 | QDECLARATIVE_ITEM::componentComplete(); | |
332 | } |
|
333 | } | |
333 |
|
334 | |||
334 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) |
|
335 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) | |
335 | { |
|
336 | { | |
336 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
337 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
337 | if (axis && s) { |
|
338 | if (axis && s) { | |
338 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) |
|
339 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) | |
339 | m_chart->addAxis(axis, Qt::AlignBottom); |
|
340 | m_chart->addAxis(axis, Qt::AlignBottom); | |
340 | if (!s->attachedAxes().contains(axis)) |
|
341 | if (!s->attachedAxes().contains(axis)) | |
341 | s->attachAxis(axis); |
|
342 | s->attachAxis(axis); | |
342 | } else { |
|
343 | } else { | |
343 | qWarning() << "Trying to set axisX to null."; |
|
344 | qWarning() << "Trying to set axisX to null."; | |
344 | } |
|
345 | } | |
345 | } |
|
346 | } | |
346 |
|
347 | |||
347 | void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis) |
|
348 | void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis) | |
348 | { |
|
349 | { | |
349 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
350 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
350 | if (axis && s) { |
|
351 | if (axis && s) { | |
351 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) |
|
352 | if (!m_chart->axes(Qt::Horizontal).contains(axis)) | |
352 | m_chart->addAxis(axis, Qt::AlignTop); |
|
353 | m_chart->addAxis(axis, Qt::AlignTop); | |
353 | if (!s->attachedAxes().contains(axis)) |
|
354 | if (!s->attachedAxes().contains(axis)) | |
354 | s->attachAxis(axis); |
|
355 | s->attachAxis(axis); | |
355 | } else { |
|
356 | } else { | |
356 | qWarning() << "Trying to set axisXTop to null."; |
|
357 | qWarning() << "Trying to set axisXTop to null."; | |
357 | } |
|
358 | } | |
358 | } |
|
359 | } | |
359 |
|
360 | |||
360 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) |
|
361 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) | |
361 | { |
|
362 | { | |
362 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
363 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
363 | if (axis && s) { |
|
364 | if (axis && s) { | |
364 | if (!m_chart->axes(Qt::Vertical).contains(axis)) |
|
365 | if (!m_chart->axes(Qt::Vertical).contains(axis)) | |
365 | m_chart->addAxis(axis, Qt::AlignLeft); |
|
366 | m_chart->addAxis(axis, Qt::AlignLeft); | |
366 | if (!s->attachedAxes().contains(axis)) |
|
367 | if (!s->attachedAxes().contains(axis)) | |
367 | s->attachAxis(axis); |
|
368 | s->attachAxis(axis); | |
368 | } else { |
|
369 | } else { | |
369 | qWarning() << "Trying to set axisY to null."; |
|
370 | qWarning() << "Trying to set axisY to null."; | |
370 | } |
|
371 | } | |
371 | } |
|
372 | } | |
372 |
|
373 | |||
373 | void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis) |
|
374 | void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis) | |
374 | { |
|
375 | { | |
375 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
376 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); | |
376 | if (axis && s) { |
|
377 | if (axis && s) { | |
377 | if (!m_chart->axes(Qt::Vertical).contains(axis)) |
|
378 | if (!m_chart->axes(Qt::Vertical).contains(axis)) | |
378 | m_chart->addAxis(axis, Qt::AlignRight); |
|
379 | m_chart->addAxis(axis, Qt::AlignRight); | |
379 | if (!s->attachedAxes().contains(axis)) |
|
380 | if (!s->attachedAxes().contains(axis)) | |
380 | s->attachAxis(axis); |
|
381 | s->attachAxis(axis); | |
381 | } else { |
|
382 | } else { | |
382 | qWarning() << "Trying to set axisYRight to null."; |
|
383 | qWarning() << "Trying to set axisYRight to null."; | |
383 | } |
|
384 | } | |
384 | } |
|
385 | } | |
385 |
|
386 | |||
386 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
387 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
387 | { |
|
388 | { | |
388 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
389 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
389 | if (newGeometry.isValid()) { |
|
390 | if (newGeometry.isValid()) { | |
390 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
391 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
391 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
392 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
392 | } |
|
393 | } | |
393 | } |
|
394 | } | |
394 | QDECLARATIVE_ITEM::geometryChanged(newGeometry, oldGeometry); |
|
395 | QDECLARATIVE_ITEM::geometryChanged(newGeometry, oldGeometry); | |
395 |
|
396 | |||
396 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or |
|
397 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or | |
397 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is |
|
398 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is | |
398 | // to implement it here for the QML API purposes. |
|
399 | // to implement it here for the QML API purposes. | |
399 | emit plotAreaChanged(m_chart->plotArea()); |
|
400 | emit plotAreaChanged(m_chart->plotArea()); | |
400 | } |
|
401 | } | |
401 |
|
402 | |||
402 | #ifdef CHARTS_FOR_QUICK2 |
|
403 | #ifdef CHARTS_FOR_QUICK2 | |
403 | void DeclarativeChart::paint(QPainter *painter) |
|
404 | void DeclarativeChart::paint(QPainter *painter) | |
404 | { |
|
405 | { | |
405 | QRectF renderRect(QPointF(0, 0), m_chart->size()); |
|
406 | QRectF renderRect(QPointF(0, 0), m_chart->size()); | |
406 | m_scene->render(painter, renderRect, renderRect); |
|
407 | m_scene->render(painter, renderRect, renderRect); | |
407 | } |
|
408 | } | |
408 |
|
409 | |||
409 | void DeclarativeChart::handleAntialiasingChanged(bool enable) |
|
410 | void DeclarativeChart::handleAntialiasingChanged(bool enable) | |
410 | { |
|
411 | { | |
411 | setAntialiasing(enable); |
|
412 | setAntialiasing(enable); | |
412 | } |
|
413 | } | |
413 | #endif |
|
414 | #endif | |
414 |
|
415 | |||
415 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
416 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
416 | { |
|
417 | { | |
417 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
418 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
418 | if (chartTheme != m_chart->theme()) |
|
419 | if (chartTheme != m_chart->theme()) | |
419 | m_chart->setTheme(chartTheme); |
|
420 | m_chart->setTheme(chartTheme); | |
420 | } |
|
421 | } | |
421 |
|
422 | |||
422 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
423 | DeclarativeChart::Theme DeclarativeChart::theme() | |
423 | { |
|
424 | { | |
424 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
425 | return (DeclarativeChart::Theme) m_chart->theme(); | |
425 | } |
|
426 | } | |
426 |
|
427 | |||
427 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
428 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
428 | { |
|
429 | { | |
429 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
430 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
430 | if (animationOptions != m_chart->animationOptions()) |
|
431 | if (animationOptions != m_chart->animationOptions()) | |
431 | m_chart->setAnimationOptions(animationOptions); |
|
432 | m_chart->setAnimationOptions(animationOptions); | |
432 | } |
|
433 | } | |
433 |
|
434 | |||
434 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
435 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
435 | { |
|
436 | { | |
436 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
437 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
437 | return DeclarativeChart::AllAnimations; |
|
438 | return DeclarativeChart::AllAnimations; | |
438 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
439 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
439 | return DeclarativeChart::GridAxisAnimations; |
|
440 | return DeclarativeChart::GridAxisAnimations; | |
440 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
441 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
441 | return DeclarativeChart::SeriesAnimations; |
|
442 | return DeclarativeChart::SeriesAnimations; | |
442 | else |
|
443 | else | |
443 | return DeclarativeChart::NoAnimation; |
|
444 | return DeclarativeChart::NoAnimation; | |
444 | } |
|
445 | } | |
445 |
|
446 | |||
446 | void DeclarativeChart::setTitle(QString title) |
|
447 | void DeclarativeChart::setTitle(QString title) | |
447 | { |
|
448 | { | |
448 | if (title != m_chart->title()) |
|
449 | if (title != m_chart->title()) | |
449 | m_chart->setTitle(title); |
|
450 | m_chart->setTitle(title); | |
450 | } |
|
451 | } | |
451 | QString DeclarativeChart::title() |
|
452 | QString DeclarativeChart::title() | |
452 | { |
|
453 | { | |
453 | return m_chart->title(); |
|
454 | return m_chart->title(); | |
454 | } |
|
455 | } | |
455 |
|
456 | |||
456 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
457 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) | |
457 | { |
|
458 | { | |
458 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series); |
|
459 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series); | |
459 | if (axes.count()) |
|
460 | if (axes.count()) | |
460 | return axes[0]; |
|
461 | return axes[0]; | |
461 | return 0; |
|
462 | return 0; | |
462 | } |
|
463 | } | |
463 |
|
464 | |||
464 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
465 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
465 | { |
|
466 | { | |
466 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series); |
|
467 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series); | |
467 | if (axes.count()) |
|
468 | if (axes.count()) | |
468 | return axes[0]; |
|
469 | return axes[0]; | |
469 | return 0; |
|
470 | return 0; | |
470 | } |
|
471 | } | |
471 |
|
472 | |||
472 | QLegend *DeclarativeChart::legend() |
|
473 | QLegend *DeclarativeChart::legend() | |
473 | { |
|
474 | { | |
474 | return m_chart->legend(); |
|
475 | return m_chart->legend(); | |
475 | } |
|
476 | } | |
476 |
|
477 | |||
477 | void DeclarativeChart::setTitleColor(QColor color) |
|
478 | void DeclarativeChart::setTitleColor(QColor color) | |
478 | { |
|
479 | { | |
479 | QBrush b = m_chart->titleBrush(); |
|
480 | QBrush b = m_chart->titleBrush(); | |
480 | if (color != b.color()) { |
|
481 | if (color != b.color()) { | |
481 | b.setColor(color); |
|
482 | b.setColor(color); | |
482 | m_chart->setTitleBrush(b); |
|
483 | m_chart->setTitleBrush(b); | |
483 | emit titleColorChanged(color); |
|
484 | emit titleColorChanged(color); | |
484 | } |
|
485 | } | |
485 | } |
|
486 | } | |
486 |
|
487 | |||
487 | QFont DeclarativeChart::titleFont() const |
|
488 | QFont DeclarativeChart::titleFont() const | |
488 | { |
|
489 | { | |
489 | return m_chart->titleFont(); |
|
490 | return m_chart->titleFont(); | |
490 | } |
|
491 | } | |
491 |
|
492 | |||
492 | void DeclarativeChart::setTitleFont(const QFont &font) |
|
493 | void DeclarativeChart::setTitleFont(const QFont &font) | |
493 | { |
|
494 | { | |
494 | m_chart->setTitleFont(font); |
|
495 | m_chart->setTitleFont(font); | |
495 | } |
|
496 | } | |
496 |
|
497 | |||
497 | QColor DeclarativeChart::titleColor() |
|
498 | QColor DeclarativeChart::titleColor() | |
498 | { |
|
499 | { | |
499 | return m_chart->titleBrush().color(); |
|
500 | return m_chart->titleBrush().color(); | |
500 | } |
|
501 | } | |
501 |
|
502 | |||
502 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
503 | void DeclarativeChart::setBackgroundColor(QColor color) | |
503 | { |
|
504 | { | |
504 | QBrush b = m_chart->backgroundBrush(); |
|
505 | QBrush b = m_chart->backgroundBrush(); | |
505 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
506 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
506 | b.setStyle(Qt::SolidPattern); |
|
507 | b.setStyle(Qt::SolidPattern); | |
507 | b.setColor(color); |
|
508 | b.setColor(color); | |
508 | m_chart->setBackgroundBrush(b); |
|
509 | m_chart->setBackgroundBrush(b); | |
509 | emit backgroundColorChanged(); |
|
510 | emit backgroundColorChanged(); | |
510 | } |
|
511 | } | |
511 | } |
|
512 | } | |
512 |
|
513 | |||
513 | QColor DeclarativeChart::backgroundColor() |
|
514 | QColor DeclarativeChart::backgroundColor() | |
514 | { |
|
515 | { | |
515 | return m_chart->backgroundBrush().color(); |
|
516 | return m_chart->backgroundBrush().color(); | |
516 | } |
|
517 | } | |
517 |
|
518 | |||
518 | int DeclarativeChart::count() |
|
519 | int DeclarativeChart::count() | |
519 | { |
|
520 | { | |
520 | return m_chart->series().count(); |
|
521 | return m_chart->series().count(); | |
521 | } |
|
522 | } | |
522 |
|
523 | |||
523 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
524 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
524 | { |
|
525 | { | |
525 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
526 | if (enabled != m_chart->isDropShadowEnabled()) { | |
526 | m_chart->setDropShadowEnabled(enabled); |
|
527 | m_chart->setDropShadowEnabled(enabled); | |
527 | dropShadowEnabledChanged(enabled); |
|
528 | dropShadowEnabledChanged(enabled); | |
528 | } |
|
529 | } | |
529 | } |
|
530 | } | |
530 |
|
531 | |||
531 | bool DeclarativeChart::dropShadowEnabled() |
|
532 | bool DeclarativeChart::dropShadowEnabled() | |
532 | { |
|
533 | { | |
533 | return m_chart->isDropShadowEnabled(); |
|
534 | return m_chart->isDropShadowEnabled(); | |
534 | } |
|
535 | } | |
535 |
|
536 | |||
536 | qreal DeclarativeChart::topMargin() |
|
537 | qreal DeclarativeChart::topMargin() | |
537 | { |
|
538 | { | |
538 | qWarning() << "ChartView.topMargin is deprecated. Use margins instead."; |
|
539 | qWarning() << "ChartView.topMargin is deprecated. Use margins instead."; | |
539 | return m_chart->margins().top(); |
|
540 | return m_chart->margins().top(); | |
540 | } |
|
541 | } | |
541 |
|
542 | |||
542 | qreal DeclarativeChart::bottomMargin() |
|
543 | qreal DeclarativeChart::bottomMargin() | |
543 | { |
|
544 | { | |
544 | qWarning() << "ChartView.bottomMargin is deprecated. Use margins instead."; |
|
545 | qWarning() << "ChartView.bottomMargin is deprecated. Use margins instead."; | |
545 | return m_chart->margins().bottom(); |
|
546 | return m_chart->margins().bottom(); | |
546 | } |
|
547 | } | |
547 |
|
548 | |||
548 | qreal DeclarativeChart::leftMargin() |
|
549 | qreal DeclarativeChart::leftMargin() | |
549 | { |
|
550 | { | |
550 | qWarning() << "ChartView.leftMargin is deprecated. Use margins instead."; |
|
551 | qWarning() << "ChartView.leftMargin is deprecated. Use margins instead."; | |
551 | return m_chart->margins().left(); |
|
552 | return m_chart->margins().left(); | |
552 | } |
|
553 | } | |
553 |
|
554 | |||
554 | qreal DeclarativeChart::rightMargin() |
|
555 | qreal DeclarativeChart::rightMargin() | |
555 | { |
|
556 | { | |
556 | qWarning() << "ChartView.rightMargin is deprecated. Use margins instead."; |
|
557 | qWarning() << "ChartView.rightMargin is deprecated. Use margins instead."; | |
557 | return m_chart->margins().right(); |
|
558 | return m_chart->margins().right(); | |
558 | } |
|
559 | } | |
559 |
|
560 | |||
560 | void DeclarativeChart::zoom(qreal factor) |
|
561 | void DeclarativeChart::zoom(qreal factor) | |
561 | { |
|
562 | { | |
562 | m_chart->zoom(factor); |
|
563 | m_chart->zoom(factor); | |
563 | } |
|
564 | } | |
564 |
|
565 | |||
565 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
566 | void DeclarativeChart::scrollLeft(qreal pixels) | |
566 | { |
|
567 | { | |
567 | m_chart->scroll(-pixels, 0); |
|
568 | m_chart->scroll(-pixels, 0); | |
568 | } |
|
569 | } | |
569 |
|
570 | |||
570 | void DeclarativeChart::scrollRight(qreal pixels) |
|
571 | void DeclarativeChart::scrollRight(qreal pixels) | |
571 | { |
|
572 | { | |
572 | m_chart->scroll(pixels, 0); |
|
573 | m_chart->scroll(pixels, 0); | |
573 | } |
|
574 | } | |
574 |
|
575 | |||
575 | void DeclarativeChart::scrollUp(qreal pixels) |
|
576 | void DeclarativeChart::scrollUp(qreal pixels) | |
576 | { |
|
577 | { | |
577 | m_chart->scroll(0, pixels); |
|
578 | m_chart->scroll(0, pixels); | |
578 | } |
|
579 | } | |
579 |
|
580 | |||
580 | void DeclarativeChart::scrollDown(qreal pixels) |
|
581 | void DeclarativeChart::scrollDown(qreal pixels) | |
581 | { |
|
582 | { | |
582 | m_chart->scroll(0, -pixels); |
|
583 | m_chart->scroll(0, -pixels); | |
583 | } |
|
584 | } | |
584 |
|
585 | |||
585 | QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> DeclarativeChart::axes() |
|
586 | QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> DeclarativeChart::axes() | |
586 | { |
|
587 | { | |
587 | return QDECLARATIVE_LIST_PROPERTY<QAbstractAxis>(this, 0, |
|
588 | return QDECLARATIVE_LIST_PROPERTY<QAbstractAxis>(this, 0, | |
588 | &DeclarativeChart::axesAppendFunc, |
|
589 | &DeclarativeChart::axesAppendFunc, | |
589 | &DeclarativeChart::axesCountFunc, |
|
590 | &DeclarativeChart::axesCountFunc, | |
590 | #ifdef CHARTS_FOR_QUICK2 |
|
591 | #ifdef CHARTS_FOR_QUICK2 | |
591 | &DeclarativeChart::axesAtFunc, |
|
592 | &DeclarativeChart::axesAtFunc, | |
592 | &DeclarativeChart::axesClearFunc); |
|
593 | &DeclarativeChart::axesClearFunc); | |
593 | #else |
|
594 | #else | |
594 | &DeclarativeChart::axesAtFunc); |
|
595 | &DeclarativeChart::axesAtFunc); | |
595 | #endif |
|
596 | #endif | |
596 | } |
|
597 | } | |
597 |
|
598 | |||
598 | void DeclarativeChart::axesAppendFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, QAbstractAxis *element) |
|
599 | void DeclarativeChart::axesAppendFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, QAbstractAxis *element) | |
599 | { |
|
600 | { | |
600 | // Empty implementation |
|
601 | // Empty implementation | |
601 | Q_UNUSED(list); |
|
602 | Q_UNUSED(list); | |
602 | Q_UNUSED(element); |
|
603 | Q_UNUSED(element); | |
603 | } |
|
604 | } | |
604 |
|
605 | |||
605 | int DeclarativeChart::axesCountFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list) |
|
606 | int DeclarativeChart::axesCountFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list) | |
606 | { |
|
607 | { | |
607 | if (qobject_cast<DeclarativeChart *>(list->object)) { |
|
608 | if (qobject_cast<DeclarativeChart *>(list->object)) { | |
608 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); |
|
609 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); | |
609 | return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count(); |
|
610 | return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count(); | |
610 | } |
|
611 | } | |
611 | return 0; |
|
612 | return 0; | |
612 | } |
|
613 | } | |
613 |
|
614 | |||
614 | QAbstractAxis *DeclarativeChart::axesAtFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, int index) |
|
615 | QAbstractAxis *DeclarativeChart::axesAtFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list, int index) | |
615 | { |
|
616 | { | |
616 | if (qobject_cast<DeclarativeChart *>(list->object)) { |
|
617 | if (qobject_cast<DeclarativeChart *>(list->object)) { | |
617 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); |
|
618 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); | |
618 | QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]); |
|
619 | QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]); | |
619 | return axes.at(index); |
|
620 | return axes.at(index); | |
620 | } |
|
621 | } | |
621 | return 0; |
|
622 | return 0; | |
622 | } |
|
623 | } | |
623 |
|
624 | |||
624 | void DeclarativeChart::axesClearFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list) |
|
625 | void DeclarativeChart::axesClearFunc(QDECLARATIVE_LIST_PROPERTY<QAbstractAxis> *list) | |
625 | { |
|
626 | { | |
626 | // Empty implementation |
|
627 | // Empty implementation | |
627 | Q_UNUSED(list); |
|
628 | Q_UNUSED(list); | |
628 | } |
|
629 | } | |
629 |
|
630 | |||
630 |
|
631 | |||
631 | QAbstractSeries *DeclarativeChart::series(int index) |
|
632 | QAbstractSeries *DeclarativeChart::series(int index) | |
632 | { |
|
633 | { | |
633 | if (index < m_chart->series().count()) { |
|
634 | if (index < m_chart->series().count()) { | |
634 | return m_chart->series().at(index); |
|
635 | return m_chart->series().at(index); | |
635 | } |
|
636 | } | |
636 | return 0; |
|
637 | return 0; | |
637 | } |
|
638 | } | |
638 |
|
639 | |||
639 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
640 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
640 | { |
|
641 | { | |
641 | foreach (QAbstractSeries *series, m_chart->series()) { |
|
642 | foreach (QAbstractSeries *series, m_chart->series()) { | |
642 | if (series->name() == seriesName) |
|
643 | if (series->name() == seriesName) | |
643 | return series; |
|
644 | return series; | |
644 | } |
|
645 | } | |
645 | return 0; |
|
646 | return 0; | |
646 | } |
|
647 | } | |
647 |
|
648 | |||
648 | QAbstractSeries *DeclarativeChart::createSeries(int type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) |
|
649 | QAbstractSeries *DeclarativeChart::createSeries(int type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) | |
649 | { |
|
650 | { | |
650 | QAbstractSeries *series = 0; |
|
651 | QAbstractSeries *series = 0; | |
651 |
|
652 | |||
652 | switch (type) { |
|
653 | switch (type) { | |
653 | case DeclarativeChart::SeriesTypeLine: |
|
654 | case DeclarativeChart::SeriesTypeLine: | |
654 | series = new DeclarativeLineSeries(); |
|
655 | series = new DeclarativeLineSeries(); | |
655 | break; |
|
656 | break; | |
656 | case DeclarativeChart::SeriesTypeArea: { |
|
657 | case DeclarativeChart::SeriesTypeArea: { | |
657 | DeclarativeAreaSeries *area = new DeclarativeAreaSeries(); |
|
658 | DeclarativeAreaSeries *area = new DeclarativeAreaSeries(); | |
658 | area->setUpperSeries(new DeclarativeLineSeries()); |
|
659 | area->setUpperSeries(new DeclarativeLineSeries()); | |
659 | series = area; |
|
660 | series = area; | |
660 | break; |
|
661 | break; | |
661 | } |
|
662 | } | |
662 | case DeclarativeChart::SeriesTypeStackedBar: |
|
663 | case DeclarativeChart::SeriesTypeStackedBar: | |
663 | series = new DeclarativeStackedBarSeries(); |
|
664 | series = new DeclarativeStackedBarSeries(); | |
664 | break; |
|
665 | break; | |
665 | case DeclarativeChart::SeriesTypePercentBar: |
|
666 | case DeclarativeChart::SeriesTypePercentBar: | |
666 | series = new DeclarativePercentBarSeries(); |
|
667 | series = new DeclarativePercentBarSeries(); | |
667 | break; |
|
668 | break; | |
668 | case DeclarativeChart::SeriesTypeBar: |
|
669 | case DeclarativeChart::SeriesTypeBar: | |
669 | series = new DeclarativeBarSeries(); |
|
670 | series = new DeclarativeBarSeries(); | |
670 | break; |
|
671 | break; | |
671 | case DeclarativeChart::SeriesTypeHorizontalBar: |
|
672 | case DeclarativeChart::SeriesTypeHorizontalBar: | |
672 | series = new DeclarativeHorizontalBarSeries(); |
|
673 | series = new DeclarativeHorizontalBarSeries(); | |
673 | break; |
|
674 | break; | |
674 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: |
|
675 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: | |
675 | series = new DeclarativeHorizontalPercentBarSeries(); |
|
676 | series = new DeclarativeHorizontalPercentBarSeries(); | |
676 | break; |
|
677 | break; | |
677 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: |
|
678 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: | |
678 | series = new DeclarativeHorizontalStackedBarSeries(); |
|
679 | series = new DeclarativeHorizontalStackedBarSeries(); | |
679 | break; |
|
680 | break; | |
680 | case DeclarativeChart::SeriesTypePie: |
|
681 | case DeclarativeChart::SeriesTypePie: | |
681 | series = new DeclarativePieSeries(); |
|
682 | series = new DeclarativePieSeries(); | |
682 | break; |
|
683 | break; | |
683 | case DeclarativeChart::SeriesTypeScatter: |
|
684 | case DeclarativeChart::SeriesTypeScatter: | |
684 | series = new DeclarativeScatterSeries(); |
|
685 | series = new DeclarativeScatterSeries(); | |
685 | break; |
|
686 | break; | |
686 | case DeclarativeChart::SeriesTypeSpline: |
|
687 | case DeclarativeChart::SeriesTypeSpline: | |
687 | series = new DeclarativeSplineSeries(); |
|
688 | series = new DeclarativeSplineSeries(); | |
688 | break; |
|
689 | break; | |
689 | default: |
|
690 | default: | |
690 | qWarning() << "Illegal series type"; |
|
691 | qWarning() << "Illegal series type"; | |
691 | } |
|
692 | } | |
692 |
|
693 | |||
693 | if (series) { |
|
694 | if (series) { | |
694 | // Connect to axis changed signals (unless this is a pie series) |
|
695 | // Connect to axis changed signals (unless this is a pie series) | |
695 | if (!qobject_cast<DeclarativePieSeries *>(series)) { |
|
696 | if (!qobject_cast<DeclarativePieSeries *>(series)) { | |
696 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
697 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
697 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
698 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); | |
698 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
699 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); | |
699 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); |
|
700 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); | |
700 | } |
|
701 | } | |
701 |
|
702 | |||
702 | series->setName(name); |
|
703 | series->setName(name); | |
703 | m_chart->addSeries(series); |
|
704 | m_chart->addSeries(series); | |
704 |
|
705 | |||
705 | if (axisX) |
|
706 | if (axisX) | |
706 | setAxisX(axisX, series); |
|
707 | setAxisX(axisX, series); | |
707 | if (axisY) |
|
708 | if (axisY) | |
708 | setAxisY(axisY, series); |
|
709 | setAxisY(axisY, series); | |
709 |
|
710 | |||
710 | if (series->attachedAxes().count() < 2) |
|
711 | if (series->attachedAxes().count() < 2) | |
711 | initializeAxes(series); |
|
712 | initializeAxes(series); | |
712 | } |
|
713 | } | |
713 |
|
714 | |||
714 | return series; |
|
715 | return series; | |
715 | } |
|
716 | } | |
716 |
|
717 | |||
717 | void DeclarativeChart::removeSeries(QAbstractSeries *series) |
|
718 | void DeclarativeChart::removeSeries(QAbstractSeries *series) | |
718 | { |
|
719 | { | |
719 | if (series) |
|
720 | if (series) | |
720 | m_chart->removeSeries(series); |
|
721 | m_chart->removeSeries(series); | |
721 | else |
|
722 | else | |
722 | qWarning("removeSeries: cannot remove null"); |
|
723 | qWarning("removeSeries: cannot remove null"); | |
723 | } |
|
724 | } | |
724 |
|
725 | |||
725 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) |
|
726 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) | |
726 | { |
|
727 | { | |
727 | if (axis) |
|
728 | if (axis) | |
728 | m_chart->setAxisX(axis, series); |
|
729 | m_chart->setAxisX(axis, series); | |
729 | } |
|
730 | } | |
730 |
|
731 | |||
731 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) |
|
732 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) | |
732 | { |
|
733 | { | |
733 | if (axis) |
|
734 | if (axis) | |
734 | m_chart->setAxisY(axis, series); |
|
735 | m_chart->setAxisY(axis, series); | |
735 | } |
|
736 | } | |
736 |
|
737 | |||
737 | void DeclarativeChart::createDefaultAxes() |
|
738 | void DeclarativeChart::createDefaultAxes() | |
738 | { |
|
739 | { | |
739 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; |
|
740 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; | |
740 | } |
|
741 | } | |
741 |
|
742 | |||
742 | QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series) |
|
743 | QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series) | |
743 | { |
|
744 | { | |
744 | if (!series) { |
|
745 | if (!series) { | |
745 | qWarning() << "No axis type defined for null series"; |
|
746 | qWarning() << "No axis type defined for null series"; | |
746 | return 0; |
|
747 | return 0; | |
747 | } |
|
748 | } | |
748 |
|
749 | |||
749 | foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { |
|
750 | foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { | |
750 | if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) |
|
751 | if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) | |
751 | return existingAxis; |
|
752 | return existingAxis; | |
752 | } |
|
753 | } | |
753 |
|
754 | |||
754 | switch (series->d_ptr->defaultAxisType(orientation)) { |
|
755 | switch (series->d_ptr->defaultAxisType(orientation)) { | |
755 | case QAbstractAxis::AxisTypeValue: |
|
756 | case QAbstractAxis::AxisTypeValue: | |
756 | return new QValueAxis(this); |
|
757 | return new QValueAxis(this); | |
757 | case QAbstractAxis::AxisTypeBarCategory: |
|
758 | case QAbstractAxis::AxisTypeBarCategory: | |
758 | return new QBarCategoryAxis(this); |
|
759 | return new QBarCategoryAxis(this); | |
759 | case QAbstractAxis::AxisTypeCategory: |
|
760 | case QAbstractAxis::AxisTypeCategory: | |
760 | return new QCategoryAxis(this); |
|
761 | return new QCategoryAxis(this); | |
761 | #ifndef QT_ON_ARM |
|
762 | #ifndef QT_ON_ARM | |
762 | case QAbstractAxis::AxisTypeDateTime: |
|
763 | case QAbstractAxis::AxisTypeDateTime: | |
763 | return new QDateTimeAxis(this); |
|
764 | return new QDateTimeAxis(this); | |
764 | #endif |
|
765 | #endif | |
|
766 | case QAbstractAxis::AxisTypeLogValue: | |||
|
767 | return new QLogValueAxis(this); | |||
765 | default: |
|
768 | default: | |
766 | // assume AxisTypeNoAxis |
|
769 | // assume AxisTypeNoAxis | |
767 | return 0; |
|
770 | return 0; | |
768 | } |
|
771 | } | |
769 | } |
|
772 | } | |
770 |
|
773 | |||
771 | void DeclarativeChart::initializeAxes(QAbstractSeries *series) |
|
774 | void DeclarativeChart::initializeAxes(QAbstractSeries *series) | |
772 | { |
|
775 | { | |
773 | if (qobject_cast<DeclarativeLineSeries *>(series)) |
|
776 | if (qobject_cast<DeclarativeLineSeries *>(series)) | |
774 | doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes); |
|
777 | doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes); | |
775 | else if (qobject_cast<DeclarativeScatterSeries *>(series)) |
|
778 | else if (qobject_cast<DeclarativeScatterSeries *>(series)) | |
776 | doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes); |
|
779 | doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes); | |
777 | else if (qobject_cast<DeclarativeSplineSeries *>(series)) |
|
780 | else if (qobject_cast<DeclarativeSplineSeries *>(series)) | |
778 | doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes); |
|
781 | doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes); | |
779 | else if (qobject_cast<DeclarativeAreaSeries *>(series)) |
|
782 | else if (qobject_cast<DeclarativeAreaSeries *>(series)) | |
780 | doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes); |
|
783 | doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes); | |
781 | else if (qobject_cast<DeclarativeBarSeries *>(series)) |
|
784 | else if (qobject_cast<DeclarativeBarSeries *>(series)) | |
782 | doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes); |
|
785 | doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes); | |
783 | else if (qobject_cast<DeclarativeStackedBarSeries *>(series)) |
|
786 | else if (qobject_cast<DeclarativeStackedBarSeries *>(series)) | |
784 | doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes); |
|
787 | doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes); | |
785 | else if (qobject_cast<DeclarativePercentBarSeries *>(series)) |
|
788 | else if (qobject_cast<DeclarativePercentBarSeries *>(series)) | |
786 | doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes); |
|
789 | doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes); | |
787 | else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series)) |
|
790 | else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series)) | |
788 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes); |
|
791 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes); | |
789 | else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)) |
|
792 | else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)) | |
790 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes); |
|
793 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes); | |
791 | else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)) |
|
794 | else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)) | |
792 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes); |
|
795 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes); | |
793 | // else: do nothing |
|
796 | // else: do nothing | |
794 | } |
|
797 | } | |
795 |
|
798 | |||
796 | void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes) |
|
799 | void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes) | |
797 | { |
|
800 | { | |
798 | // Initialize axis X |
|
801 | // Initialize axis X | |
799 | if (axes->axisX()) |
|
802 | if (axes->axisX()) | |
800 | axes->emitAxisXChanged(); |
|
803 | axes->emitAxisXChanged(); | |
801 | else if (axes->axisXTop()) |
|
804 | else if (axes->axisXTop()) | |
802 | axes->emitAxisXTopChanged(); |
|
805 | axes->emitAxisXTopChanged(); | |
803 | else |
|
806 | else | |
804 | axes->setAxisX(defaultAxis(Qt::Horizontal, series)); |
|
807 | axes->setAxisX(defaultAxis(Qt::Horizontal, series)); | |
805 |
|
808 | |||
806 | // Initialize axis Y |
|
809 | // Initialize axis Y | |
807 | if (axes->axisY()) |
|
810 | if (axes->axisY()) | |
808 | axes->emitAxisYChanged(); |
|
811 | axes->emitAxisYChanged(); | |
809 | else if (axes->axisYRight()) |
|
812 | else if (axes->axisYRight()) | |
810 | axes->emitAxisYRightChanged(); |
|
813 | axes->emitAxisYRightChanged(); | |
811 | else |
|
814 | else | |
812 | axes->setAxisY(defaultAxis(Qt::Vertical, series)); |
|
815 | axes->setAxisY(defaultAxis(Qt::Vertical, series)); | |
813 | } |
|
816 | } | |
814 |
|
817 | |||
815 | #include "moc_declarativechart.cpp" |
|
818 | #include "moc_declarativechart.cpp" | |
816 |
|
819 | |||
817 | QTCOMMERCIALCHART_END_NAMESPACE |
|
820 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,246 +1,249 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qabstractaxis.h" |
|
22 | #include "qabstractaxis.h" | |
23 | #include "qvalueaxis.h" |
|
23 | #include "qvalueaxis.h" | |
|
24 | #include "qlogvalueaxis.h" | |||
24 | #include "declarativecategoryaxis.h" |
|
25 | #include "declarativecategoryaxis.h" | |
25 | #include "qbarcategoryaxis.h" |
|
26 | #include "qbarcategoryaxis.h" | |
26 | #include "declarativechart.h" |
|
27 | #include "declarativechart.h" | |
27 | #include "declarativepolarchart.h" |
|
28 | #include "declarativepolarchart.h" | |
28 | #include "declarativexypoint.h" |
|
29 | #include "declarativexypoint.h" | |
29 | #include "declarativelineseries.h" |
|
30 | #include "declarativelineseries.h" | |
30 | #include "declarativesplineseries.h" |
|
31 | #include "declarativesplineseries.h" | |
31 | #include "declarativeareaseries.h" |
|
32 | #include "declarativeareaseries.h" | |
32 | #include "declarativescatterseries.h" |
|
33 | #include "declarativescatterseries.h" | |
33 | #include "declarativebarseries.h" |
|
34 | #include "declarativebarseries.h" | |
34 | #include "declarativepieseries.h" |
|
35 | #include "declarativepieseries.h" | |
35 | #include "declarativeaxes.h" |
|
36 | #include "declarativeaxes.h" | |
36 | #include "qvxymodelmapper.h" |
|
37 | #include "qvxymodelmapper.h" | |
37 | #include "qhxymodelmapper.h" |
|
38 | #include "qhxymodelmapper.h" | |
38 | #include "qhpiemodelmapper.h" |
|
39 | #include "qhpiemodelmapper.h" | |
39 | #include "qvpiemodelmapper.h" |
|
40 | #include "qvpiemodelmapper.h" | |
40 | #include "qhbarmodelmapper.h" |
|
41 | #include "qhbarmodelmapper.h" | |
41 | #include "qvbarmodelmapper.h" |
|
42 | #include "qvbarmodelmapper.h" | |
42 | #include "declarativemargins.h" |
|
43 | #include "declarativemargins.h" | |
43 | #include "qarealegendmarker.h" |
|
44 | #include "qarealegendmarker.h" | |
44 | #include "qbarlegendmarker.h" |
|
45 | #include "qbarlegendmarker.h" | |
45 | #include "qpielegendmarker.h" |
|
46 | #include "qpielegendmarker.h" | |
46 | #include "qxylegendmarker.h" |
|
47 | #include "qxylegendmarker.h" | |
47 | #ifndef QT_ON_ARM |
|
48 | #ifndef QT_ON_ARM | |
48 | #include "qdatetimeaxis.h" |
|
49 | #include "qdatetimeaxis.h" | |
49 | #endif |
|
50 | #endif | |
50 | #include "shared_defines.h" |
|
51 | #include "shared_defines.h" | |
51 | #include <QAbstractItemModel> |
|
52 | #include <QAbstractItemModel> | |
52 | #ifdef CHARTS_FOR_QUICK2 |
|
53 | #ifdef CHARTS_FOR_QUICK2 | |
53 | #include <QtQml/QQmlExtensionPlugin> |
|
54 | #include <QtQml/QQmlExtensionPlugin> | |
54 | #else |
|
55 | #else | |
55 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
56 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
56 | #include <QtDeclarative/qdeclarative.h> |
|
57 | #include <QtDeclarative/qdeclarative.h> | |
57 | #endif |
|
58 | #endif | |
58 |
|
59 | |||
59 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
60 | QTCOMMERCIALCHART_USE_NAMESPACE | |
60 |
|
61 | |||
61 | Q_DECLARE_METATYPE(QList<QPieSlice *>) |
|
62 | Q_DECLARE_METATYPE(QList<QPieSlice *>) | |
62 | Q_DECLARE_METATYPE(QList<QBarSet *>) |
|
63 | Q_DECLARE_METATYPE(QList<QBarSet *>) | |
63 | Q_DECLARE_METATYPE(QList<QAbstractAxis *>) |
|
64 | Q_DECLARE_METATYPE(QList<QAbstractAxis *>) | |
64 |
|
65 | |||
65 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
66 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
66 |
|
67 | |||
67 | // NOTE: Hackish fixes for Qt5 (beta2). |
|
68 | // NOTE: Hackish fixes for Qt5 (beta2). | |
68 | // These should not be needed or at least they are not needed in Qt4. |
|
69 | // These should not be needed or at least they are not needed in Qt4. | |
69 |
|
70 | |||
70 | Q_DECLARE_METATYPE(DeclarativeChart *) |
|
71 | Q_DECLARE_METATYPE(DeclarativeChart *) | |
71 | Q_DECLARE_METATYPE(DeclarativePolarChart *) |
|
72 | Q_DECLARE_METATYPE(DeclarativePolarChart *) | |
72 | Q_DECLARE_METATYPE(DeclarativeMargins *) |
|
73 | Q_DECLARE_METATYPE(DeclarativeMargins *) | |
73 | Q_DECLARE_METATYPE(DeclarativeAreaSeries *) |
|
74 | Q_DECLARE_METATYPE(DeclarativeAreaSeries *) | |
74 | Q_DECLARE_METATYPE(DeclarativeBarSeries *) |
|
75 | Q_DECLARE_METATYPE(DeclarativeBarSeries *) | |
75 | Q_DECLARE_METATYPE(DeclarativeBarSet *) |
|
76 | Q_DECLARE_METATYPE(DeclarativeBarSet *) | |
76 | Q_DECLARE_METATYPE(DeclarativeLineSeries *) |
|
77 | Q_DECLARE_METATYPE(DeclarativeLineSeries *) | |
77 | Q_DECLARE_METATYPE(DeclarativePieSeries *) |
|
78 | Q_DECLARE_METATYPE(DeclarativePieSeries *) | |
78 | Q_DECLARE_METATYPE(DeclarativeScatterSeries *) |
|
79 | Q_DECLARE_METATYPE(DeclarativeScatterSeries *) | |
79 | Q_DECLARE_METATYPE(DeclarativeSplineSeries *) |
|
80 | Q_DECLARE_METATYPE(DeclarativeSplineSeries *) | |
80 |
|
81 | |||
81 | Q_DECLARE_METATYPE(QAbstractAxis *) |
|
82 | Q_DECLARE_METATYPE(QAbstractAxis *) | |
82 | Q_DECLARE_METATYPE(QValueAxis *) |
|
83 | Q_DECLARE_METATYPE(QValueAxis *) | |
83 | Q_DECLARE_METATYPE(QBarCategoryAxis *) |
|
84 | Q_DECLARE_METATYPE(QBarCategoryAxis *) | |
84 | Q_DECLARE_METATYPE(QCategoryAxis *) |
|
85 | Q_DECLARE_METATYPE(QCategoryAxis *) | |
85 | Q_DECLARE_METATYPE(QDateTimeAxis *) |
|
86 | Q_DECLARE_METATYPE(QDateTimeAxis *) | |
|
87 | Q_DECLARE_METATYPE(QLogValueAxis *) | |||
86 |
|
88 | |||
87 | Q_DECLARE_METATYPE(QLegend *) |
|
89 | Q_DECLARE_METATYPE(QLegend *) | |
88 | Q_DECLARE_METATYPE(QLegendMarker *) |
|
90 | Q_DECLARE_METATYPE(QLegendMarker *) | |
89 | Q_DECLARE_METATYPE(QAreaLegendMarker *) |
|
91 | Q_DECLARE_METATYPE(QAreaLegendMarker *) | |
90 | Q_DECLARE_METATYPE(QBarLegendMarker *) |
|
92 | Q_DECLARE_METATYPE(QBarLegendMarker *) | |
91 | Q_DECLARE_METATYPE(QPieLegendMarker *) |
|
93 | Q_DECLARE_METATYPE(QPieLegendMarker *) | |
92 |
|
94 | |||
93 | Q_DECLARE_METATYPE(QHPieModelMapper *) |
|
95 | Q_DECLARE_METATYPE(QHPieModelMapper *) | |
94 | Q_DECLARE_METATYPE(QHXYModelMapper *) |
|
96 | Q_DECLARE_METATYPE(QHXYModelMapper *) | |
95 | Q_DECLARE_METATYPE(QPieModelMapper *) |
|
97 | Q_DECLARE_METATYPE(QPieModelMapper *) | |
96 | Q_DECLARE_METATYPE(QHBarModelMapper *) |
|
98 | Q_DECLARE_METATYPE(QHBarModelMapper *) | |
97 | Q_DECLARE_METATYPE(QBarModelMapper *) |
|
99 | Q_DECLARE_METATYPE(QBarModelMapper *) | |
98 | Q_DECLARE_METATYPE(QVBarModelMapper *) |
|
100 | Q_DECLARE_METATYPE(QVBarModelMapper *) | |
99 | Q_DECLARE_METATYPE(QVPieModelMapper *) |
|
101 | Q_DECLARE_METATYPE(QVPieModelMapper *) | |
100 | Q_DECLARE_METATYPE(QVXYModelMapper *) |
|
102 | Q_DECLARE_METATYPE(QVXYModelMapper *) | |
101 | Q_DECLARE_METATYPE(QXYLegendMarker *) |
|
103 | Q_DECLARE_METATYPE(QXYLegendMarker *) | |
102 | Q_DECLARE_METATYPE(QXYModelMapper *) |
|
104 | Q_DECLARE_METATYPE(QXYModelMapper *) | |
103 |
|
105 | |||
104 | Q_DECLARE_METATYPE(QAbstractSeries *) |
|
106 | Q_DECLARE_METATYPE(QAbstractSeries *) | |
105 | Q_DECLARE_METATYPE(QXYSeries *) |
|
107 | Q_DECLARE_METATYPE(QXYSeries *) | |
106 | Q_DECLARE_METATYPE(QAbstractBarSeries *) |
|
108 | Q_DECLARE_METATYPE(QAbstractBarSeries *) | |
107 | Q_DECLARE_METATYPE(QBarSeries *) |
|
109 | Q_DECLARE_METATYPE(QBarSeries *) | |
108 | Q_DECLARE_METATYPE(QBarSet *) |
|
110 | Q_DECLARE_METATYPE(QBarSet *) | |
109 | Q_DECLARE_METATYPE(QAreaSeries *) |
|
111 | Q_DECLARE_METATYPE(QAreaSeries *) | |
110 | Q_DECLARE_METATYPE(QHorizontalBarSeries *) |
|
112 | Q_DECLARE_METATYPE(QHorizontalBarSeries *) | |
111 | Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *) |
|
113 | Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *) | |
112 | Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *) |
|
114 | Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *) | |
113 | Q_DECLARE_METATYPE(QLineSeries *) |
|
115 | Q_DECLARE_METATYPE(QLineSeries *) | |
114 | Q_DECLARE_METATYPE(QPercentBarSeries *) |
|
116 | Q_DECLARE_METATYPE(QPercentBarSeries *) | |
115 | Q_DECLARE_METATYPE(QPieSeries *) |
|
117 | Q_DECLARE_METATYPE(QPieSeries *) | |
116 | Q_DECLARE_METATYPE(QPieSlice *) |
|
118 | Q_DECLARE_METATYPE(QPieSlice *) | |
117 | Q_DECLARE_METATYPE(QScatterSeries *) |
|
119 | Q_DECLARE_METATYPE(QScatterSeries *) | |
118 | Q_DECLARE_METATYPE(QSplineSeries *) |
|
120 | Q_DECLARE_METATYPE(QSplineSeries *) | |
119 | Q_DECLARE_METATYPE(QStackedBarSeries *) |
|
121 | Q_DECLARE_METATYPE(QStackedBarSeries *) | |
120 |
|
122 | |||
121 | #endif |
|
123 | #endif | |
122 |
|
124 | |||
123 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
125 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
124 |
|
126 | |||
125 | class ChartQmlPlugin : public QDECLARATIVE_EXTENSION_PLUGIN |
|
127 | class ChartQmlPlugin : public QDECLARATIVE_EXTENSION_PLUGIN | |
126 | { |
|
128 | { | |
127 | Q_OBJECT |
|
129 | Q_OBJECT | |
128 |
|
130 | |||
129 | #ifdef CHARTS_FOR_QUICK2 |
|
131 | #ifdef CHARTS_FOR_QUICK2 | |
130 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
|
132 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | |
131 | #else |
|
133 | #else | |
132 | # if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
134 | # if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | |
133 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface") |
|
135 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface") | |
134 | # endif |
|
136 | # endif | |
135 | #endif |
|
137 | #endif | |
136 |
|
138 | |||
137 | public: |
|
139 | public: | |
138 | virtual void registerTypes(const char *uri) |
|
140 | virtual void registerTypes(const char *uri) | |
139 | { |
|
141 | { | |
140 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
142 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
141 |
|
143 | |||
142 | qRegisterMetaType<QList<QPieSlice *> >(); |
|
144 | qRegisterMetaType<QList<QPieSlice *> >(); | |
143 | qRegisterMetaType<QList<QBarSet *> >(); |
|
145 | qRegisterMetaType<QList<QBarSet *> >(); | |
144 | qRegisterMetaType<QList<QAbstractAxis *> >(); |
|
146 | qRegisterMetaType<QList<QAbstractAxis *> >(); | |
145 |
|
147 | |||
146 | // QtCommercial.Chart 1.0 |
|
148 | // QtCommercial.Chart 1.0 | |
147 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
149 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
148 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); |
|
150 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); | |
149 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
151 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
150 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
152 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
151 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
153 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
152 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
154 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
153 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
155 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
154 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); |
|
156 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); | |
155 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); |
|
157 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); | |
156 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
158 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
157 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
159 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
158 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
160 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
159 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); |
|
161 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); | |
160 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); |
|
162 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); | |
161 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
163 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); | |
162 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
164 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); | |
163 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
165 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); | |
164 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
166 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); | |
165 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); |
|
167 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); | |
166 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); |
|
168 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); | |
167 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", |
|
169 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", | |
168 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
170 | QLatin1String("Trying to create uncreatable: Legend.")); | |
169 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", |
|
171 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", | |
170 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
172 | QLatin1String("Trying to create uncreatable: XYSeries.")); | |
171 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
173 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
172 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
174 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
173 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
175 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
174 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
176 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
175 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
177 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
176 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
178 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
177 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", |
|
179 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", | |
178 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
180 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
179 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
181 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
180 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
182 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
181 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", |
|
183 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", | |
182 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
184 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | |
183 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
185 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", | |
184 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); |
|
186 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); | |
185 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", |
|
187 | qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase", | |
186 | QLatin1String("Trying to create uncreatable: BarsetBase.")); |
|
188 | QLatin1String("Trying to create uncreatable: BarsetBase.")); | |
187 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", |
|
189 | qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries", | |
188 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); |
|
190 | QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead.")); | |
189 | qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes", |
|
191 | qmlRegisterUncreatableType<DeclarativeAxes>(uri, 1, 0, "DeclarativeAxes", | |
190 | QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); |
|
192 | QLatin1String("Trying to create uncreatable: DeclarativeAxes.")); | |
191 |
|
193 | |||
192 | // QtCommercial.Chart 1.1 |
|
194 | // QtCommercial.Chart 1.1 | |
193 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); |
|
195 | qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView"); | |
194 | qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); |
|
196 | qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries"); | |
195 | qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); |
|
197 | qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries"); | |
196 | qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); |
|
198 | qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries"); | |
197 | qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); |
|
199 | qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries"); | |
198 | qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); |
|
200 | qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries"); | |
199 | qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); |
|
201 | qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries"); | |
200 | qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); |
|
202 | qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries"); | |
201 | qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); |
|
203 | qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries"); | |
202 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); |
|
204 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries"); | |
203 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); |
|
205 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries"); | |
204 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); |
|
206 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries"); | |
205 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); |
|
207 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet"); | |
206 | qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis"); |
|
208 | qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis"); | |
207 | #ifndef QT_ON_ARM |
|
209 | #ifndef QT_ON_ARM | |
208 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); |
|
210 | qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis"); | |
209 | #endif |
|
211 | #endif | |
210 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); |
|
212 | qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis"); | |
211 | qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); |
|
213 | qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange"); | |
212 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); |
|
214 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis"); | |
213 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", |
|
215 | qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins", | |
214 | QLatin1String("Trying to create uncreatable: Margins.")); |
|
216 | QLatin1String("Trying to create uncreatable: Margins.")); | |
215 |
|
217 | |||
216 | // QtCommercial.Chart 1.2 |
|
218 | // QtCommercial.Chart 1.2 | |
217 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); |
|
219 | qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView"); | |
218 | qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries"); |
|
220 | qmlRegisterType<DeclarativeScatterSeries, 2>(uri, 1, 2, "ScatterSeries"); | |
219 | qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries"); |
|
221 | qmlRegisterType<DeclarativeLineSeries, 2>(uri, 1, 2, "LineSeries"); | |
220 | qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries"); |
|
222 | qmlRegisterType<DeclarativeSplineSeries, 2>(uri, 1, 2, "SplineSeries"); | |
221 | qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries"); |
|
223 | qmlRegisterType<DeclarativeAreaSeries, 2>(uri, 1, 2, "AreaSeries"); | |
222 | qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries"); |
|
224 | qmlRegisterType<DeclarativeBarSeries, 2>(uri, 1, 2, "BarSeries"); | |
223 | qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries"); |
|
225 | qmlRegisterType<DeclarativeStackedBarSeries, 2>(uri, 1, 2, "StackedBarSeries"); | |
224 | qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries"); |
|
226 | qmlRegisterType<DeclarativePercentBarSeries, 2>(uri, 1, 2, "PercentBarSeries"); | |
225 | qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries"); |
|
227 | qmlRegisterType<DeclarativeHorizontalBarSeries, 2>(uri, 1, 2, "HorizontalBarSeries"); | |
226 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries"); |
|
228 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 2>(uri, 1, 2, "HorizontalStackedBarSeries"); | |
227 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries"); |
|
229 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 2>(uri, 1, 2, "HorizontalPercentBarSeries"); | |
228 |
|
230 | |||
229 | // QtCommercial.Chart 1.3 |
|
231 | // QtCommercial.Chart 1.3 | |
230 | qmlRegisterType<DeclarativePolarChart, 1>(uri, 1, 3, "PolarChartView"); |
|
232 | qmlRegisterType<DeclarativePolarChart, 1>(uri, 1, 3, "PolarChartView"); | |
231 | qmlRegisterType<DeclarativeSplineSeries, 3>(uri, 1, 3, "SplineSeries"); |
|
233 | qmlRegisterType<DeclarativeSplineSeries, 3>(uri, 1, 3, "SplineSeries"); | |
232 | qmlRegisterType<DeclarativeScatterSeries, 3>(uri, 1, 3, "ScatterSeries"); |
|
234 | qmlRegisterType<DeclarativeScatterSeries, 3>(uri, 1, 3, "ScatterSeries"); | |
233 | qmlRegisterType<DeclarativeLineSeries, 3>(uri, 1, 3, "LineSeries"); |
|
235 | qmlRegisterType<DeclarativeLineSeries, 3>(uri, 1, 3, "LineSeries"); | |
234 | qmlRegisterType<DeclarativeAreaSeries, 3>(uri, 1, 3, "AreaSeries"); |
|
236 | qmlRegisterType<DeclarativeAreaSeries, 3>(uri, 1, 3, "AreaSeries"); | |
|
237 | qmlRegisterType<QLogValueAxis>(uri, 1, 3, "LogValueAxis"); | |||
235 | } |
|
238 | } | |
236 | }; |
|
239 | }; | |
237 |
|
240 | |||
238 | #include "plugin.moc" |
|
241 | #include "plugin.moc" | |
239 |
|
242 | |||
240 | QTCOMMERCIALCHART_END_NAMESPACE |
|
243 | QTCOMMERCIALCHART_END_NAMESPACE | |
241 |
|
244 | |||
242 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
245 | QTCOMMERCIALCHART_USE_NAMESPACE | |
243 |
|
246 | |||
244 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) |
|
247 | #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) | |
245 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
248 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) | |
246 | #endif |
|
249 | #endif |
@@ -1,345 +1,396 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qlogvalueaxis.h" |
|
21 | #include "qlogvalueaxis.h" | |
22 | #include "qlogvalueaxis_p.h" |
|
22 | #include "qlogvalueaxis_p.h" | |
23 | #include "chartlogvalueaxisx_p.h" |
|
23 | #include "chartlogvalueaxisx_p.h" | |
24 | #include "chartlogvalueaxisy_p.h" |
|
24 | #include "chartlogvalueaxisy_p.h" | |
25 | #include "polarchartlogvalueaxisangular_p.h" |
|
25 | #include "polarchartlogvalueaxisangular_p.h" | |
26 | #include "polarchartlogvalueaxisradial_p.h" |
|
26 | #include "polarchartlogvalueaxisradial_p.h" | |
27 | #include "abstractdomain_p.h" |
|
27 | #include "abstractdomain_p.h" | |
28 | #include <float.h> |
|
28 | #include <float.h> | |
29 | #include <cmath> |
|
29 | #include <cmath> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 | /*! |
|
32 | /*! | |
33 | \class QLogValueAxis |
|
33 | \class QLogValueAxis | |
34 | \brief The QLogValueAxis class is used for manipulating chart's axis. |
|
34 | \brief The QLogValueAxis class is used for manipulating chart's axis. | |
35 | \mainclass |
|
35 | \mainclass | |
36 |
|
36 | |||
37 | \note If a QLogValueAxis is attached to a series with one or more points with |
|
37 | \note If a QLogValueAxis is attached to a series with one or more points with | |
38 | negative or zero values on the associated dimension, the series will not be |
|
38 | negative or zero values on the associated dimension, the series will not be | |
39 | plotted at all. This is particularly relevant when XYModelMappers are used, |
|
39 | plotted at all. This is particularly relevant when XYModelMappers are used, | |
40 | since empty cells in models typically contain zero values. |
|
40 | since empty cells in models typically contain zero values. | |
41 | */ |
|
41 | */ | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
|
44 | \qmlclass LogValuesAxis QLogValueAxis | |||
|
45 | \brief The LogValueAxis element is used for manipulating chart's axes | |||
|
46 | \inherits AbstractAxis | |||
|
47 | ||||
|
48 | \note If a LogValueAxis is attached to a series with one or more points with | |||
|
49 | negative or zero values on the associated dimension, the series will not be | |||
|
50 | plotted at all. This is particularly relevant when XYModelMappers are used, | |||
|
51 | since empty cells in models typically contain zero values. | |||
|
52 | */ | |||
|
53 | ||||
|
54 | /*! | |||
44 | \property QLogValueAxis::min |
|
55 | \property QLogValueAxis::min | |
45 | Defines the minimum value on the axis. |
|
56 | Defines the minimum value on the axis. | |
46 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. |
|
57 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. | |
47 |
Value has to be greater th |
|
58 | Value has to be greater than 0. | |
|
59 | */ | |||
|
60 | /*! | |||
|
61 | \qmlproperty real LogValuesAxis::min | |||
|
62 | Defines the minimum value on the axis. | |||
|
63 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. | |||
|
64 | Value has to be greater than 0. | |||
48 | */ |
|
65 | */ | |
49 |
|
66 | |||
50 | /*! |
|
67 | /*! | |
51 | \property QLogValueAxis::max |
|
68 | \property QLogValueAxis::max | |
52 | Defines the maximum value on the axis. |
|
69 | Defines the maximum value on the axis. | |
53 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. |
|
70 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. | |
54 |
Value has to be greater th |
|
71 | Value has to be greater than 0. | |
|
72 | */ | |||
|
73 | /*! | |||
|
74 | \qmlproperty real LogValuesAxis::max | |||
|
75 | Defines the maximum value on the axis. | |||
|
76 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. | |||
|
77 | Value has to be greater than 0. | |||
55 | */ |
|
78 | */ | |
56 |
|
79 | |||
57 | /*! |
|
80 | /*! | |
58 | \property QLogValueAxis::base |
|
81 | \property QLogValueAxis::base | |
59 | Defines the base of the logarithm. |
|
82 | Defines the base of the logarithm. | |
60 |
Value has to be greater th |
|
83 | Value has to be greater than 0 and not equal 1 | |
|
84 | */ | |||
|
85 | /*! | |||
|
86 | \qmlproperty real LogValuesAxis::base | |||
|
87 | Defines the maximum value on the axis. | |||
|
88 | Defines the base of the logarithm. | |||
|
89 | Value has to be greater than 0 and not equal 1 | |||
61 | */ |
|
90 | */ | |
62 |
|
91 | |||
63 | /*! |
|
92 | /*! | |
64 | \property QLogValueAxis::labelFormat |
|
93 | \property QLogValueAxis::labelFormat | |
65 | Defines the label format of the axis. |
|
94 | Defines the label format of the axis. | |
66 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c |
|
95 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c | |
67 | See QString::sprintf() for additional details. |
|
96 | See QString::sprintf() for additional details. | |
68 | */ |
|
97 | */ | |
|
98 | /*! | |||
|
99 | \qmlproperty real LogValuesAxis::labelFormat | |||
|
100 | Defines the label format of the axis. | |||
|
101 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c | |||
|
102 | See QString::sprintf() for additional details. | |||
|
103 | */ | |||
69 |
|
104 | |||
70 | /*! |
|
105 | /*! | |
71 | \fn void QLogValueAxis::minChanged(qreal min) |
|
106 | \fn void QLogValueAxis::minChanged(qreal min) | |
72 | Axis emits signal when \a min of axis has changed. |
|
107 | Axis emits signal when \a min of axis has changed. | |
73 | */ |
|
108 | */ | |
|
109 | /*! | |||
|
110 | \qmlsignal LogValuesAxis::onMinChanged(qreal min) | |||
|
111 | Axis emits signal when \a min of axis has changed. | |||
|
112 | */ | |||
74 |
|
113 | |||
75 | /*! |
|
114 | /*! | |
76 | \fn void QLogValueAxis::maxChanged(qreal max) |
|
115 | \fn void QLogValueAxis::maxChanged(qreal max) | |
77 | Axis emits signal when \a max of axis has changed. |
|
116 | Axis emits signal when \a max of axis has changed. | |
78 | */ |
|
117 | */ | |
|
118 | /*! | |||
|
119 | \qmlsignal LogValuesAxis::onMaxChanged(qreal max) | |||
|
120 | Axis emits signal when \a max of axis has changed. | |||
|
121 | */ | |||
79 |
|
122 | |||
80 | /*! |
|
123 | /*! | |
81 | \fn void QLogValueAxis::rangeChanged(qreal min, qreal max) |
|
124 | \fn void QLogValueAxis::rangeChanged(qreal min, qreal max) | |
82 | Axis emits signal when \a min or \a max of axis has changed. |
|
125 | Axis emits signal when \a min or \a max of axis has changed. | |
83 | */ |
|
126 | */ | |
84 |
|
127 | |||
85 | /*! |
|
128 | /*! | |
86 | \fn void QLogValueAxis::labelFormatChanged(const QString &format) |
|
129 | \fn void QLogValueAxis::labelFormatChanged(const QString &format) | |
87 | Axis emits signal when \a format of axis labels has changed. |
|
130 | Axis emits signal when \a format of axis labels has changed. | |
88 | */ |
|
131 | */ | |
|
132 | /*! | |||
|
133 | \qmlsignal LogValueAxis::labelFormatChanged(const QString &format) | |||
|
134 | Axis emits signal when \a format of axis labels has changed. | |||
|
135 | */ | |||
89 |
|
136 | |||
90 | /*! |
|
137 | /*! | |
91 | \fn void QLogValueAxis::baseChanged(qreal base) |
|
138 | \fn void QLogValueAxis::baseChanged(qreal base) | |
92 | Axis emits signal when \a base of logarithm of the axis has changed. |
|
139 | Axis emits signal when \a base of logarithm of the axis has changed. | |
93 | */ |
|
140 | */ | |
|
141 | /*! | |||
|
142 | \qmlsignal LogValuesAxis::baseChanged(qreal base) | |||
|
143 | Axis emits signal when \a base of logarithm of the axis has changed. | |||
|
144 | */ | |||
94 |
|
145 | |||
95 | /*! |
|
146 | /*! | |
96 | Constructs an axis object which is a child of \a parent. |
|
147 | Constructs an axis object which is a child of \a parent. | |
97 | */ |
|
148 | */ | |
98 | QLogValueAxis::QLogValueAxis(QObject *parent) : |
|
149 | QLogValueAxis::QLogValueAxis(QObject *parent) : | |
99 | QAbstractAxis(*new QLogValueAxisPrivate(this), parent) |
|
150 | QAbstractAxis(*new QLogValueAxisPrivate(this), parent) | |
100 | { |
|
151 | { | |
101 |
|
152 | |||
102 | } |
|
153 | } | |
103 |
|
154 | |||
104 | /*! |
|
155 | /*! | |
105 | \internal |
|
156 | \internal | |
106 | */ |
|
157 | */ | |
107 | QLogValueAxis::QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent) : QAbstractAxis(d, parent) |
|
158 | QLogValueAxis::QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent) : QAbstractAxis(d, parent) | |
108 | { |
|
159 | { | |
109 |
|
160 | |||
110 | } |
|
161 | } | |
111 |
|
162 | |||
112 | /*! |
|
163 | /*! | |
113 | Destroys the object |
|
164 | Destroys the object | |
114 | */ |
|
165 | */ | |
115 | QLogValueAxis::~QLogValueAxis() |
|
166 | QLogValueAxis::~QLogValueAxis() | |
116 | { |
|
167 | { | |
117 | Q_D(QLogValueAxis); |
|
168 | Q_D(QLogValueAxis); | |
118 | if (d->m_chart) |
|
169 | if (d->m_chart) | |
119 | d->m_chart->removeAxis(this); |
|
170 | d->m_chart->removeAxis(this); | |
120 | } |
|
171 | } | |
121 |
|
172 | |||
122 | void QLogValueAxis::setMin(qreal min) |
|
173 | void QLogValueAxis::setMin(qreal min) | |
123 | { |
|
174 | { | |
124 | Q_D(QLogValueAxis); |
|
175 | Q_D(QLogValueAxis); | |
125 | setRange(min, qMax(d->m_max, min)); |
|
176 | setRange(min, qMax(d->m_max, min)); | |
126 | } |
|
177 | } | |
127 |
|
178 | |||
128 | qreal QLogValueAxis::min() const |
|
179 | qreal QLogValueAxis::min() const | |
129 | { |
|
180 | { | |
130 | Q_D(const QLogValueAxis); |
|
181 | Q_D(const QLogValueAxis); | |
131 | return d->m_min; |
|
182 | return d->m_min; | |
132 | } |
|
183 | } | |
133 |
|
184 | |||
134 | void QLogValueAxis::setMax(qreal max) |
|
185 | void QLogValueAxis::setMax(qreal max) | |
135 | { |
|
186 | { | |
136 | Q_D(QLogValueAxis); |
|
187 | Q_D(QLogValueAxis); | |
137 | setRange(qMin(d->m_min, max), max); |
|
188 | setRange(qMin(d->m_min, max), max); | |
138 | } |
|
189 | } | |
139 |
|
190 | |||
140 | qreal QLogValueAxis::max() const |
|
191 | qreal QLogValueAxis::max() const | |
141 | { |
|
192 | { | |
142 | Q_D(const QLogValueAxis); |
|
193 | Q_D(const QLogValueAxis); | |
143 | return d->m_max; |
|
194 | return d->m_max; | |
144 | } |
|
195 | } | |
145 |
|
196 | |||
146 | /*! |
|
197 | /*! | |
147 | Sets range from \a min to \a max on the axis. |
|
198 | Sets range from \a min to \a max on the axis. | |
148 | If min is greater than max then this function returns without making any changes. |
|
199 | If min is greater than max then this function returns without making any changes. | |
149 | */ |
|
200 | */ | |
150 | void QLogValueAxis::setRange(qreal min, qreal max) |
|
201 | void QLogValueAxis::setRange(qreal min, qreal max) | |
151 | { |
|
202 | { | |
152 | Q_D(QLogValueAxis); |
|
203 | Q_D(QLogValueAxis); | |
153 | bool changed = false; |
|
204 | bool changed = false; | |
154 |
|
205 | |||
155 | if (min > max) |
|
206 | if (min > max) | |
156 | return; |
|
207 | return; | |
157 |
|
208 | |||
158 | if (min > 0) { |
|
209 | if (min > 0) { | |
159 | if (!qFuzzyCompare(d->m_min, min)) { |
|
210 | if (!qFuzzyCompare(d->m_min, min)) { | |
160 | d->m_min = min; |
|
211 | d->m_min = min; | |
161 | changed = true; |
|
212 | changed = true; | |
162 | emit minChanged(min); |
|
213 | emit minChanged(min); | |
163 | } |
|
214 | } | |
164 |
|
215 | |||
165 | if (!qFuzzyCompare(d->m_max, max)) { |
|
216 | if (!qFuzzyCompare(d->m_max, max)) { | |
166 | d->m_max = max; |
|
217 | d->m_max = max; | |
167 | changed = true; |
|
218 | changed = true; | |
168 | emit maxChanged(max); |
|
219 | emit maxChanged(max); | |
169 | } |
|
220 | } | |
170 |
|
221 | |||
171 | if (changed) { |
|
222 | if (changed) { | |
172 | emit rangeChanged(min, max); |
|
223 | emit rangeChanged(min, max); | |
173 | emit d->rangeChanged(min,max); |
|
224 | emit d->rangeChanged(min,max); | |
174 | } |
|
225 | } | |
175 | } |
|
226 | } | |
176 | } |
|
227 | } | |
177 |
|
228 | |||
178 | void QLogValueAxis::setLabelFormat(const QString &format) |
|
229 | void QLogValueAxis::setLabelFormat(const QString &format) | |
179 | { |
|
230 | { | |
180 | Q_D(QLogValueAxis); |
|
231 | Q_D(QLogValueAxis); | |
181 | d->m_format = format; |
|
232 | d->m_format = format; | |
182 | emit labelFormatChanged(format); |
|
233 | emit labelFormatChanged(format); | |
183 | } |
|
234 | } | |
184 |
|
235 | |||
185 | QString QLogValueAxis::labelFormat() const |
|
236 | QString QLogValueAxis::labelFormat() const | |
186 | { |
|
237 | { | |
187 | Q_D(const QLogValueAxis); |
|
238 | Q_D(const QLogValueAxis); | |
188 | return d->m_format; |
|
239 | return d->m_format; | |
189 | } |
|
240 | } | |
190 |
|
241 | |||
191 | void QLogValueAxis::setBase(qreal base) |
|
242 | void QLogValueAxis::setBase(qreal base) | |
192 | { |
|
243 | { | |
193 | // check if base is correct |
|
244 | // check if base is correct | |
194 | if (qFuzzyCompare(base, 1)) |
|
245 | if (qFuzzyCompare(base, 1)) | |
195 | return; |
|
246 | return; | |
196 |
|
247 | |||
197 | if (base > 0) { |
|
248 | if (base > 0) { | |
198 | Q_D(QLogValueAxis); |
|
249 | Q_D(QLogValueAxis); | |
199 | d->m_base = base; |
|
250 | d->m_base = base; | |
200 | emit baseChanged(base); |
|
251 | emit baseChanged(base); | |
201 | } |
|
252 | } | |
202 | } |
|
253 | } | |
203 |
|
254 | |||
204 | qreal QLogValueAxis::base() const |
|
255 | qreal QLogValueAxis::base() const | |
205 | { |
|
256 | { | |
206 | Q_D(const QLogValueAxis); |
|
257 | Q_D(const QLogValueAxis); | |
207 | return d->m_base; |
|
258 | return d->m_base; | |
208 | } |
|
259 | } | |
209 |
|
260 | |||
210 | /*! |
|
261 | /*! | |
211 | Returns the type of the axis |
|
262 | Returns the type of the axis | |
212 | */ |
|
263 | */ | |
213 | QAbstractAxis::AxisType QLogValueAxis::type() const |
|
264 | QAbstractAxis::AxisType QLogValueAxis::type() const | |
214 | { |
|
265 | { | |
215 | return AxisTypeLogValue; |
|
266 | return AxisTypeLogValue; | |
216 | } |
|
267 | } | |
217 |
|
268 | |||
218 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
269 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
219 |
|
270 | |||
220 | QLogValueAxisPrivate::QLogValueAxisPrivate(QLogValueAxis *q) |
|
271 | QLogValueAxisPrivate::QLogValueAxisPrivate(QLogValueAxis *q) | |
221 | : QAbstractAxisPrivate(q), |
|
272 | : QAbstractAxisPrivate(q), | |
222 | m_min(1), |
|
273 | m_min(1), | |
223 | m_max(1), |
|
274 | m_max(1), | |
224 | m_base(10), |
|
275 | m_base(10), | |
225 | m_format(QString::null) |
|
276 | m_format(QString::null) | |
226 | { |
|
277 | { | |
227 | } |
|
278 | } | |
228 |
|
279 | |||
229 | QLogValueAxisPrivate::~QLogValueAxisPrivate() |
|
280 | QLogValueAxisPrivate::~QLogValueAxisPrivate() | |
230 | { |
|
281 | { | |
231 |
|
282 | |||
232 | } |
|
283 | } | |
233 |
|
284 | |||
234 | void QLogValueAxisPrivate::setMin(const QVariant &min) |
|
285 | void QLogValueAxisPrivate::setMin(const QVariant &min) | |
235 | { |
|
286 | { | |
236 | Q_Q(QLogValueAxis); |
|
287 | Q_Q(QLogValueAxis); | |
237 | bool ok; |
|
288 | bool ok; | |
238 | qreal value = min.toReal(&ok); |
|
289 | qreal value = min.toReal(&ok); | |
239 | if (ok) |
|
290 | if (ok) | |
240 | q->setMin(value); |
|
291 | q->setMin(value); | |
241 | } |
|
292 | } | |
242 |
|
293 | |||
243 | void QLogValueAxisPrivate::setMax(const QVariant &max) |
|
294 | void QLogValueAxisPrivate::setMax(const QVariant &max) | |
244 | { |
|
295 | { | |
245 |
|
296 | |||
246 | Q_Q(QLogValueAxis); |
|
297 | Q_Q(QLogValueAxis); | |
247 | bool ok; |
|
298 | bool ok; | |
248 | qreal value = max.toReal(&ok); |
|
299 | qreal value = max.toReal(&ok); | |
249 | if (ok) |
|
300 | if (ok) | |
250 | q->setMax(value); |
|
301 | q->setMax(value); | |
251 | } |
|
302 | } | |
252 |
|
303 | |||
253 | void QLogValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) |
|
304 | void QLogValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
254 | { |
|
305 | { | |
255 | Q_Q(QLogValueAxis); |
|
306 | Q_Q(QLogValueAxis); | |
256 | bool ok1; |
|
307 | bool ok1; | |
257 | bool ok2; |
|
308 | bool ok2; | |
258 | qreal value1 = min.toReal(&ok1); |
|
309 | qreal value1 = min.toReal(&ok1); | |
259 | qreal value2 = max.toReal(&ok2); |
|
310 | qreal value2 = max.toReal(&ok2); | |
260 | if (ok1 && ok2) |
|
311 | if (ok1 && ok2) | |
261 | q->setRange(value1, value2); |
|
312 | q->setRange(value1, value2); | |
262 | } |
|
313 | } | |
263 |
|
314 | |||
264 | void QLogValueAxisPrivate::setRange(qreal min, qreal max) |
|
315 | void QLogValueAxisPrivate::setRange(qreal min, qreal max) | |
265 | { |
|
316 | { | |
266 | Q_Q(QLogValueAxis); |
|
317 | Q_Q(QLogValueAxis); | |
267 | bool changed = false; |
|
318 | bool changed = false; | |
268 |
|
319 | |||
269 | if (min > max) |
|
320 | if (min > max) | |
270 | return; |
|
321 | return; | |
271 |
|
322 | |||
272 | if (min > 0) { |
|
323 | if (min > 0) { | |
273 | if (!qFuzzyCompare(m_min, min)) { |
|
324 | if (!qFuzzyCompare(m_min, min)) { | |
274 | m_min = min; |
|
325 | m_min = min; | |
275 | changed = true; |
|
326 | changed = true; | |
276 | emit q->minChanged(min); |
|
327 | emit q->minChanged(min); | |
277 | } |
|
328 | } | |
278 |
|
329 | |||
279 | if (!qFuzzyCompare(m_max, max)) { |
|
330 | if (!qFuzzyCompare(m_max, max)) { | |
280 | m_max = max; |
|
331 | m_max = max; | |
281 | changed = true; |
|
332 | changed = true; | |
282 | emit q->maxChanged(max); |
|
333 | emit q->maxChanged(max); | |
283 | } |
|
334 | } | |
284 |
|
335 | |||
285 | if (changed) { |
|
336 | if (changed) { | |
286 | emit rangeChanged(min,max); |
|
337 | emit rangeChanged(min,max); | |
287 | emit q->rangeChanged(min, max); |
|
338 | emit q->rangeChanged(min, max); | |
288 | } |
|
339 | } | |
289 | } |
|
340 | } | |
290 | } |
|
341 | } | |
291 |
|
342 | |||
292 | void QLogValueAxisPrivate::initializeGraphics(QGraphicsItem *parent) |
|
343 | void QLogValueAxisPrivate::initializeGraphics(QGraphicsItem *parent) | |
293 | { |
|
344 | { | |
294 | Q_Q(QLogValueAxis); |
|
345 | Q_Q(QLogValueAxis); | |
295 | ChartAxisElement *axis(0); |
|
346 | ChartAxisElement *axis(0); | |
296 |
|
347 | |||
297 | if (m_chart->chartType() == QChart::ChartTypeCartesian) { |
|
348 | if (m_chart->chartType() == QChart::ChartTypeCartesian) { | |
298 | if (orientation() == Qt::Vertical) |
|
349 | if (orientation() == Qt::Vertical) | |
299 | axis = new ChartLogValueAxisY(q,parent); |
|
350 | axis = new ChartLogValueAxisY(q,parent); | |
300 | if (orientation() == Qt::Horizontal) |
|
351 | if (orientation() == Qt::Horizontal) | |
301 | axis = new ChartLogValueAxisX(q,parent); |
|
352 | axis = new ChartLogValueAxisX(q,parent); | |
302 | } |
|
353 | } | |
303 |
|
354 | |||
304 | if (m_chart->chartType() == QChart::ChartTypePolar) { |
|
355 | if (m_chart->chartType() == QChart::ChartTypePolar) { | |
305 | if (orientation() == Qt::Vertical) |
|
356 | if (orientation() == Qt::Vertical) | |
306 | axis = new PolarChartLogValueAxisRadial(q, parent); |
|
357 | axis = new PolarChartLogValueAxisRadial(q, parent); | |
307 | if (orientation() == Qt::Horizontal) |
|
358 | if (orientation() == Qt::Horizontal) | |
308 | axis = new PolarChartLogValueAxisAngular(q, parent); |
|
359 | axis = new PolarChartLogValueAxisAngular(q, parent); | |
309 | } |
|
360 | } | |
310 |
|
361 | |||
311 | m_item.reset(axis); |
|
362 | m_item.reset(axis); | |
312 | QAbstractAxisPrivate::initializeGraphics(parent); |
|
363 | QAbstractAxisPrivate::initializeGraphics(parent); | |
313 | } |
|
364 | } | |
314 |
|
365 | |||
315 |
|
366 | |||
316 | void QLogValueAxisPrivate::initializeDomain(AbstractDomain *domain) |
|
367 | void QLogValueAxisPrivate::initializeDomain(AbstractDomain *domain) | |
317 | { |
|
368 | { | |
318 | if (orientation() == Qt::Vertical) { |
|
369 | if (orientation() == Qt::Vertical) { | |
319 | if (!qFuzzyCompare(m_max, m_min)) { |
|
370 | if (!qFuzzyCompare(m_max, m_min)) { | |
320 | domain->setRangeY(m_min, m_max); |
|
371 | domain->setRangeY(m_min, m_max); | |
321 | } else if ( domain->minY() > 0) { |
|
372 | } else if ( domain->minY() > 0) { | |
322 | setRange(domain->minY(), domain->maxY()); |
|
373 | setRange(domain->minY(), domain->maxY()); | |
323 | } else if (domain->maxY() > 0) { |
|
374 | } else if (domain->maxY() > 0) { | |
324 | domain->setRangeY(m_min, domain->maxY()); |
|
375 | domain->setRangeY(m_min, domain->maxY()); | |
325 | } else { |
|
376 | } else { | |
326 | domain->setRangeY(1, 10); |
|
377 | domain->setRangeY(1, 10); | |
327 | } |
|
378 | } | |
328 | } |
|
379 | } | |
329 | if (orientation() == Qt::Horizontal) { |
|
380 | if (orientation() == Qt::Horizontal) { | |
330 | if (!qFuzzyCompare(m_max, m_min)) { |
|
381 | if (!qFuzzyCompare(m_max, m_min)) { | |
331 | domain->setRangeX(m_min, m_max); |
|
382 | domain->setRangeX(m_min, m_max); | |
332 | } else if (domain->minX() > 0){ |
|
383 | } else if (domain->minX() > 0){ | |
333 | setRange(domain->minX(), domain->maxX()); |
|
384 | setRange(domain->minX(), domain->maxX()); | |
334 | } else if (domain->maxX() > 0) { |
|
385 | } else if (domain->maxX() > 0) { | |
335 | domain->setRangeX(m_min, domain->maxX()); |
|
386 | domain->setRangeX(m_min, domain->maxX()); | |
336 | } else { |
|
387 | } else { | |
337 | domain->setRangeX(1, 10); |
|
388 | domain->setRangeX(1, 10); | |
338 | } |
|
389 | } | |
339 | } |
|
390 | } | |
340 | } |
|
391 | } | |
341 |
|
392 | |||
342 | #include "moc_qlogvalueaxis.cpp" |
|
393 | #include "moc_qlogvalueaxis.cpp" | |
343 | #include "moc_qlogvalueaxis_p.cpp" |
|
394 | #include "moc_qlogvalueaxis_p.cpp" | |
344 |
|
395 | |||
345 | QTCOMMERCIALCHART_END_NAMESPACE |
|
396 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now