@@ -0,0 +1,48 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | Rectangle { | |||
|
25 | anchors.fill: parent | |||
|
26 | ||||
|
27 | //![1] | |||
|
28 | ChartView { | |||
|
29 | title: "Horizontal Stacked Bar series" | |||
|
30 | anchors.fill: parent | |||
|
31 | legend.alignment: Qt.AlignBottom | |||
|
32 | BarCategoriesAxis { | |||
|
33 | id: myAxis; | |||
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |||
|
35 | } | |||
|
36 | HorizontalStackedBarSeries { | |||
|
37 | id: mySeries; | |||
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |||
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |||
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |||
|
41 | } | |||
|
42 | Component.onCompleted: { | |||
|
43 | createDefaultAxes(); | |||
|
44 | setAxisY(myAxis,mySeries); | |||
|
45 | } | |||
|
46 | } | |||
|
47 | //![1] | |||
|
48 | } |
@@ -0,0 +1,49 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | Rectangle { | |||
|
25 | anchors.fill: parent | |||
|
26 | ||||
|
27 | //![1] | |||
|
28 | ChartView { | |||
|
29 | title: "Horizontal Percent Bar series" | |||
|
30 | anchors.fill: parent | |||
|
31 | legend.alignment: Qt.AlignBottom | |||
|
32 | BarCategoriesAxis { | |||
|
33 | id: myAxis | |||
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |||
|
35 | } | |||
|
36 | HorizontalPercentBarSeries { | |||
|
37 | id: mySeries | |||
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |||
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |||
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |||
|
41 | } | |||
|
42 | Component.onCompleted: { | |||
|
43 | createDefaultAxes(); | |||
|
44 | setAxisY(myAxis,mySeries); | |||
|
45 | } | |||
|
46 | } | |||
|
47 | //![1] | |||
|
48 | } | |||
|
49 |
@@ -0,0 +1,49 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | Rectangle { | |||
|
25 | anchors.fill: parent | |||
|
26 | ||||
|
27 | //![1] | |||
|
28 | ChartView { | |||
|
29 | title: "Horizontal Bar series" | |||
|
30 | anchors.fill: parent | |||
|
31 | legend.alignment: Qt.AlignBottom | |||
|
32 | BarCategoriesAxis { | |||
|
33 | id: myAxis | |||
|
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] | |||
|
35 | } | |||
|
36 | HorizontalBarSeries { | |||
|
37 | id: mySeries | |||
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |||
|
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |||
|
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |||
|
41 | } | |||
|
42 | Component.onCompleted: { | |||
|
43 | createDefaultAxes(); | |||
|
44 | setAxisY(myAxis,mySeries); | |||
|
45 | } | |||
|
46 | } | |||
|
47 | //![1] | |||
|
48 | } | |||
|
49 |
@@ -1,90 +1,90 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | Rectangle { |
|
24 | Rectangle { | |
25 | width: parent.width |
|
25 | width: parent.width | |
26 | height: parent.height |
|
26 | height: parent.height | |
27 | property int viewNumber: 1 |
|
27 | property int viewNumber: 1 | |
28 |
|
28 | |||
29 | Loader { |
|
29 | Loader { | |
30 | id: loader |
|
30 | id: loader | |
31 | anchors.fill: parent |
|
31 | anchors.fill: parent | |
32 | source: "View" + viewNumber + ".qml"; |
|
32 | source: "View" + viewNumber + ".qml"; | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | Rectangle { |
|
35 | Rectangle { | |
36 | id: infoText |
|
36 | id: infoText | |
37 | anchors.centerIn: parent |
|
37 | anchors.centerIn: parent | |
38 | width: parent.width |
|
38 | width: parent.width | |
39 | height: 40 |
|
39 | height: 40 | |
40 | color: "black" |
|
40 | color: "black" | |
41 | Text { |
|
41 | Text { | |
42 | color: "white" |
|
42 | color: "white" | |
43 | anchors.centerIn: parent |
|
43 | anchors.centerIn: parent | |
44 | text: "Use left and right arrow keys to navigate between chart types" |
|
44 | text: "Use left and right arrow keys to navigate between chart types" | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | Behavior on opacity { |
|
47 | Behavior on opacity { | |
48 | NumberAnimation { duration: 400 } |
|
48 | NumberAnimation { duration: 400 } | |
49 | } |
|
49 | } | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | MouseArea { |
|
52 | MouseArea { | |
53 | focus: true |
|
53 | focus: true | |
54 | anchors.fill: parent |
|
54 | anchors.fill: parent | |
55 | onClicked: { |
|
55 | onClicked: { | |
56 | if (infoText.opacity > 0) { |
|
56 | if (infoText.opacity > 0) { | |
57 | infoText.opacity = 0.0; |
|
57 | infoText.opacity = 0.0; | |
58 | } else { |
|
58 | } else { | |
59 | nextView(); |
|
59 | nextView(); | |
60 | } |
|
60 | } | |
61 | } |
|
61 | } | |
62 | Keys.onPressed: { |
|
62 | Keys.onPressed: { | |
63 | if (infoText.opacity > 0) { |
|
63 | if (infoText.opacity > 0) { | |
64 | infoText.opacity = 0.0; |
|
64 | infoText.opacity = 0.0; | |
65 | } else { |
|
65 | } else { | |
66 | if (event.key == Qt.Key_Left) { |
|
66 | if (event.key == Qt.Key_Left) { | |
67 | previousView(); |
|
67 | previousView(); | |
68 | } else { |
|
68 | } else { | |
69 | nextView(); |
|
69 | nextView(); | |
70 | } |
|
70 | } | |
71 | } |
|
71 | } | |
72 | } |
|
72 | } | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | function nextView() { |
|
75 | function nextView() { | |
76 | var i = viewNumber + 1; |
|
76 | var i = viewNumber + 1; | |
77 |
if (i > |
|
77 | if (i > 11) | |
78 | viewNumber = 1; |
|
78 | viewNumber = 1; | |
79 | else |
|
79 | else | |
80 | viewNumber = i; |
|
80 | viewNumber = i; | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | function previousView() { |
|
83 | function previousView() { | |
84 | var i = viewNumber - 1; |
|
84 | var i = viewNumber - 1; | |
85 | if (i <= 0) |
|
85 | if (i <= 0) | |
86 |
viewNumber = |
|
86 | viewNumber = 11; | |
87 | else |
|
87 | else | |
88 | viewNumber = i; |
|
88 | viewNumber = i; | |
89 | } |
|
89 | } | |
90 | } |
|
90 | } |
@@ -1,14 +1,17 | |||||
1 | <RCC> |
|
1 | <RCC> | |
2 | <qresource prefix="/"> |
|
2 | <qresource prefix="/"> | |
3 | <file>qml/qmlchart/loader.qml</file> |
|
3 | <file>qml/qmlchart/loader.qml</file> | |
4 | <file>qml/qmlchart/main.qml</file> |
|
4 | <file>qml/qmlchart/main.qml</file> | |
5 | <file>qml/qmlchart/View1.qml</file> |
|
5 | <file>qml/qmlchart/View1.qml</file> | |
6 | <file>qml/qmlchart/View2.qml</file> |
|
6 | <file>qml/qmlchart/View2.qml</file> | |
7 | <file>qml/qmlchart/View3.qml</file> |
|
7 | <file>qml/qmlchart/View3.qml</file> | |
8 | <file>qml/qmlchart/View4.qml</file> |
|
8 | <file>qml/qmlchart/View4.qml</file> | |
9 | <file>qml/qmlchart/View5.qml</file> |
|
9 | <file>qml/qmlchart/View5.qml</file> | |
10 | <file>qml/qmlchart/View6.qml</file> |
|
10 | <file>qml/qmlchart/View6.qml</file> | |
11 | <file>qml/qmlchart/View7.qml</file> |
|
11 | <file>qml/qmlchart/View7.qml</file> | |
12 | <file>qml/qmlchart/View8.qml</file> |
|
12 | <file>qml/qmlchart/View8.qml</file> | |
|
13 | <file>qml/qmlchart/View9.qml</file> | |||
|
14 | <file>qml/qmlchart/View10.qml</file> | |||
|
15 | <file>qml/qmlchart/View11.qml</file> | |||
13 | </qresource> |
|
16 | </qresource> | |
14 | </RCC> |
|
17 | </RCC> |
@@ -1,515 +1,524 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "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 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \qmlclass ChartView DeclarativeChart |
|
34 | \qmlclass ChartView DeclarativeChart | |
35 |
|
35 | |||
36 | ChartView element is the parent that is responsible for showing different chart series types. |
|
36 | ChartView element is the parent that is responsible for showing different chart series types. | |
37 |
|
37 | |||
38 | The following QML shows how to create a simple chart with one pie series: |
|
38 | The following QML shows how to create a simple chart with one pie series: | |
39 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
39 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
40 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
40 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
41 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
41 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
42 |
|
42 | |||
43 | \beginfloatleft |
|
43 | \beginfloatleft | |
44 | \image examples_qmlpiechart.png |
|
44 | \image examples_qmlpiechart.png | |
45 | \endfloat |
|
45 | \endfloat | |
46 | \clearfloat |
|
46 | \clearfloat | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \qmlproperty Theme ChartView::theme |
|
50 | \qmlproperty Theme ChartView::theme | |
51 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
51 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
52 | widths and chart background. |
|
52 | widths and chart background. | |
53 | */ |
|
53 | */ | |
54 |
|
54 | |||
55 | /*! |
|
55 | /*! | |
56 | \qmlproperty Animation ChartView::animation |
|
56 | \qmlproperty Animation ChartView::animation | |
57 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
57 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
58 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
58 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
59 | */ |
|
59 | */ | |
60 |
|
60 | |||
61 | /*! |
|
61 | /*! | |
62 | \qmlproperty Font ChartView::titleFont |
|
62 | \qmlproperty Font ChartView::titleFont | |
63 | The title font of the chart |
|
63 | The title font of the chart | |
64 |
|
64 | |||
65 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
65 | See the \l {Font} {QML Font Element} for detailed documentation. | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \qmlproperty string ChartView::title |
|
69 | \qmlproperty string ChartView::title | |
70 | The title of the chart, shown on top of the chart. |
|
70 | The title of the chart, shown on top of the chart. | |
71 | \sa ChartView::titleColor |
|
71 | \sa ChartView::titleColor | |
72 | */ |
|
72 | */ | |
73 |
|
73 | |||
74 | /*! |
|
74 | /*! | |
75 | \qmlproperty string ChartView::titleColor |
|
75 | \qmlproperty string ChartView::titleColor | |
76 | The color of the title text. |
|
76 | The color of the title text. | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \qmlproperty Axis ChartView::axisX |
|
80 | \qmlproperty Axis ChartView::axisX | |
81 | The x-axis of the chart. |
|
81 | The x-axis of the chart. | |
82 | */ |
|
82 | */ | |
83 |
|
83 | |||
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty Axis ChartView::axisY |
|
85 | \qmlproperty Axis ChartView::axisY | |
86 | The default y-axis of the chart. |
|
86 | The default y-axis of the chart. | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty Legend ChartView::legend |
|
90 | \qmlproperty Legend ChartView::legend | |
91 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
91 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \qmlproperty int ChartView::count |
|
95 | \qmlproperty int ChartView::count | |
96 | The count of series added to the chart. |
|
96 | The count of series added to the chart. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \qmlproperty color ChartView::backgroundColor |
|
100 | \qmlproperty color ChartView::backgroundColor | |
101 | The color of the chart's background. By default background color is defined by chart theme. |
|
101 | The color of the chart's background. By default background color is defined by chart theme. | |
102 | \sa ChartView::theme |
|
102 | \sa ChartView::theme | |
103 | */ |
|
103 | */ | |
104 |
|
104 | |||
105 | /*! |
|
105 | /*! | |
106 | \qmlproperty bool ChartView::dropShadowEnabled |
|
106 | \qmlproperty bool ChartView::dropShadowEnabled | |
107 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
107 | The chart's border drop shadow. Set to true to enable drop shadow. | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | \qmlproperty real ChartView::topMargin |
|
111 | \qmlproperty real ChartView::topMargin | |
112 | The space between the top of chart view and the top of the plot area. The title (if non-empty) is drawn on top margin |
|
112 | The space between the top of chart view and the top of the plot area. The title (if non-empty) is drawn on top margin | |
113 | area of the chart view. Top margin area is also used by legend, if aligned to top. |
|
113 | area of the chart view. Top margin area is also used by legend, if aligned to top. | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \qmlproperty real ChartView::bottomMargin |
|
117 | \qmlproperty real ChartView::bottomMargin | |
118 | The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by |
|
118 | The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by | |
119 | legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks. |
|
119 | legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks. | |
120 | */ |
|
120 | */ | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | \qmlproperty real ChartView::leftMargin |
|
123 | \qmlproperty real ChartView::leftMargin | |
124 | The space between the left side of chart view and the left side of the plot area. The left margin area may be used by |
|
124 | The space between the left side of chart view and the left side of the plot area. The left margin area may be used by | |
125 | legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks. |
|
125 | legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks. | |
126 | */ |
|
126 | */ | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | \qmlproperty real ChartView::rightMargin |
|
129 | \qmlproperty real ChartView::rightMargin | |
130 | The space between the right side of chart view and the right side of the plot area. The right margin area may be used |
|
130 | The space between the right side of chart view and the right side of the plot area. The right margin area may be used | |
131 | by legend (if aligned to right). |
|
131 | by legend (if aligned to right). | |
132 | */ |
|
132 | */ | |
133 |
|
133 | |||
134 | /*! |
|
134 | /*! | |
135 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
135 | \qmlmethod AbstractSeries ChartView::series(int index) | |
136 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
136 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with | |
137 | the count property of the chart. |
|
137 | the count property of the chart. | |
138 | */ |
|
138 | */ | |
139 |
|
139 | |||
140 | /*! |
|
140 | /*! | |
141 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
141 | \qmlmethod AbstractSeries ChartView::series(string name) | |
142 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
142 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
143 | */ |
|
143 | */ | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) |
|
146 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) | |
147 | Creates a series object of \a type to the chart. For example: |
|
147 | Creates a series object of \a type to the chart. For example: | |
148 | \code |
|
148 | \code | |
149 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); |
|
149 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); | |
150 | scatter.markerSize = 22; |
|
150 | scatter.markerSize = 22; | |
151 | scatter.append(1.1, 2.0); |
|
151 | scatter.append(1.1, 2.0); | |
152 | \endcode |
|
152 | \endcode | |
153 | */ |
|
153 | */ | |
154 |
|
154 | |||
155 | /*! |
|
155 | /*! | |
156 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) |
|
156 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) | |
157 | The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported. |
|
157 | The y-axis of the series. This is the same as the default y-axis of the chart as multiple y-axes are not yet supported. | |
158 | */ |
|
158 | */ | |
159 |
|
159 | |||
160 | /*! |
|
160 | /*! | |
161 | \qmlmethod ChartView::zoomY(real factor) |
|
161 | \qmlmethod ChartView::zoomY(real factor) | |
162 | Zooms in by \a factor on the center of the chart. |
|
162 | Zooms in by \a factor on the center of the chart. | |
163 | */ |
|
163 | */ | |
164 |
|
164 | |||
165 | /*! |
|
165 | /*! | |
166 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
166 | \qmlmethod ChartView::scrollLeft(real pixels) | |
167 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
167 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
168 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
168 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
169 | */ |
|
169 | */ | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
172 | \qmlmethod ChartView::scrollRight(real pixels) |
|
172 | \qmlmethod ChartView::scrollRight(real pixels) | |
173 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
173 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
174 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
174 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
175 | */ |
|
175 | */ | |
176 |
|
176 | |||
177 | /*! |
|
177 | /*! | |
178 | \qmlmethod ChartView::scrollUp(real pixels) |
|
178 | \qmlmethod ChartView::scrollUp(real pixels) | |
179 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
179 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
180 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
180 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
181 | */ |
|
181 | */ | |
182 |
|
182 | |||
183 | /*! |
|
183 | /*! | |
184 | \qmlmethod ChartView::scrollDown(real pixels) |
|
184 | \qmlmethod ChartView::scrollDown(real pixels) | |
185 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
185 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
186 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
186 | \sa ValuesAxis::min, ValuesAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
187 | */ |
|
187 | */ | |
188 |
|
188 | |||
189 | /*! |
|
189 | /*! | |
190 | \qmlsignal ChartView::onTopMarginChanged(real margin) |
|
190 | \qmlsignal ChartView::onTopMarginChanged(real margin) | |
191 | The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
191 | The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
192 | related properties of the legend or chart title. |
|
192 | related properties of the legend or chart title. | |
193 | */ |
|
193 | */ | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | \qmlsignal ChartView::onBottomMarginChanged(real margin) |
|
196 | \qmlsignal ChartView::onBottomMarginChanged(real margin) | |
197 | The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
197 | The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
198 | related properties of the legend or chart title. |
|
198 | related properties of the legend or chart title. | |
199 | */ |
|
199 | */ | |
200 |
|
200 | |||
201 | /*! |
|
201 | /*! | |
202 | \qmlsignal ChartView::onLeftMarginChanged(real margin) |
|
202 | \qmlsignal ChartView::onLeftMarginChanged(real margin) | |
203 | The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
203 | The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
204 | related properties of the legend or chart title. |
|
204 | related properties of the legend or chart title. | |
205 | */ |
|
205 | */ | |
206 |
|
206 | |||
207 | /*! |
|
207 | /*! | |
208 | \qmlsignal ChartView::onRightMarginChanged(real margin) |
|
208 | \qmlsignal ChartView::onRightMarginChanged(real margin) | |
209 | The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
209 | The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
210 | related properties of the legend or chart title. |
|
210 | related properties of the legend or chart title. | |
211 | */ |
|
211 | */ | |
212 |
|
212 | |||
213 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
213 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
214 | : QDeclarativeItem(parent), |
|
214 | : QDeclarativeItem(parent), | |
215 | m_chart(new QChart(this)) |
|
215 | m_chart(new QChart(this)) | |
216 | { |
|
216 | { | |
217 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
217 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
218 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
218 | // m_chart->axisX()->setNiceNumbersEnabled(false); | |
219 | m_chartMargins = m_chart->margins(); |
|
219 | m_chartMargins = m_chart->margins(); | |
220 | connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); |
|
220 | connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 | void DeclarativeChart::handleMarginsChanged(QRectF newMargins) |
|
223 | void DeclarativeChart::handleMarginsChanged(QRectF newMargins) | |
224 | { |
|
224 | { | |
225 | if (m_chartMargins.top() != newMargins.top()) |
|
225 | if (m_chartMargins.top() != newMargins.top()) | |
226 | topMarginChanged(m_chart->margins().top()); |
|
226 | topMarginChanged(m_chart->margins().top()); | |
227 | if (m_chartMargins.bottom() != newMargins.bottom()) |
|
227 | if (m_chartMargins.bottom() != newMargins.bottom()) | |
228 | bottomMarginChanged(m_chart->margins().bottom()); |
|
228 | bottomMarginChanged(m_chart->margins().bottom()); | |
229 | if (m_chartMargins.left() != newMargins.left()) |
|
229 | if (m_chartMargins.left() != newMargins.left()) | |
230 | leftMarginChanged(m_chart->margins().left()); |
|
230 | leftMarginChanged(m_chart->margins().left()); | |
231 | if (m_chartMargins.right() != newMargins.right()) |
|
231 | if (m_chartMargins.right() != newMargins.right()) | |
232 | rightMarginChanged(m_chart->margins().right()); |
|
232 | rightMarginChanged(m_chart->margins().right()); | |
233 |
|
233 | |||
234 | m_chartMargins = m_chart->margins(); |
|
234 | m_chartMargins = m_chart->margins(); | |
235 | } |
|
235 | } | |
236 |
|
236 | |||
237 | DeclarativeChart::~DeclarativeChart() |
|
237 | DeclarativeChart::~DeclarativeChart() | |
238 | { |
|
238 | { | |
239 | delete m_chart; |
|
239 | delete m_chart; | |
240 | } |
|
240 | } | |
241 |
|
241 | |||
242 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
242 | void DeclarativeChart::childEvent(QChildEvent *event) | |
243 | { |
|
243 | { | |
244 | if (event->type() == QEvent::ChildAdded) { |
|
244 | if (event->type() == QEvent::ChildAdded) { | |
245 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
245 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
246 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
246 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | void DeclarativeChart::componentComplete() |
|
251 | void DeclarativeChart::componentComplete() | |
252 | { |
|
252 | { | |
253 | foreach(QObject *child, children()) { |
|
253 | foreach(QObject *child, children()) { | |
254 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
254 | if (qobject_cast<QAbstractSeries *>(child)) { | |
255 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
255 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; | |
256 | // TODO: how about optional y-axis? |
|
256 | // TODO: how about optional y-axis? | |
257 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
257 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
258 | }else if(qobject_cast<QAbstractAxis *>(child)){ |
|
258 | }else if(qobject_cast<QAbstractAxis *>(child)){ | |
259 |
|
259 | |||
260 | } |
|
260 | } | |
261 | } |
|
261 | } | |
262 | QDeclarativeItem::componentComplete(); |
|
262 | QDeclarativeItem::componentComplete(); | |
263 | } |
|
263 | } | |
264 |
|
264 | |||
265 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
265 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
266 | { |
|
266 | { | |
267 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
267 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
268 | if (newGeometry.isValid()) { |
|
268 | if (newGeometry.isValid()) { | |
269 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
269 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
270 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
270 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
271 | } |
|
271 | } | |
272 | } |
|
272 | } | |
273 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
273 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
274 | } |
|
274 | } | |
275 |
|
275 | |||
276 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
276 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
277 | { |
|
277 | { | |
278 | Q_UNUSED(option) |
|
278 | Q_UNUSED(option) | |
279 | Q_UNUSED(widget) |
|
279 | Q_UNUSED(widget) | |
280 |
|
280 | |||
281 | // TODO: optimized? |
|
281 | // TODO: optimized? | |
282 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
282 | painter->setRenderHint(QPainter::Antialiasing, true); | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
285 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
286 | { |
|
286 | { | |
287 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
287 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
288 | if (chartTheme != m_chart->theme()) |
|
288 | if (chartTheme != m_chart->theme()) | |
289 | m_chart->setTheme(chartTheme); |
|
289 | m_chart->setTheme(chartTheme); | |
290 | } |
|
290 | } | |
291 |
|
291 | |||
292 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
292 | DeclarativeChart::Theme DeclarativeChart::theme() | |
293 | { |
|
293 | { | |
294 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
294 | return (DeclarativeChart::Theme) m_chart->theme(); | |
295 | } |
|
295 | } | |
296 |
|
296 | |||
297 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
297 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
298 | { |
|
298 | { | |
299 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
299 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
300 | if (animationOptions != m_chart->animationOptions()) |
|
300 | if (animationOptions != m_chart->animationOptions()) | |
301 | m_chart->setAnimationOptions(animationOptions); |
|
301 | m_chart->setAnimationOptions(animationOptions); | |
302 | } |
|
302 | } | |
303 |
|
303 | |||
304 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
304 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
305 | { |
|
305 | { | |
306 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
306 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
307 | return DeclarativeChart::AllAnimations; |
|
307 | return DeclarativeChart::AllAnimations; | |
308 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
308 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
309 | return DeclarativeChart::GridAxisAnimations; |
|
309 | return DeclarativeChart::GridAxisAnimations; | |
310 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
310 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
311 | return DeclarativeChart::SeriesAnimations; |
|
311 | return DeclarativeChart::SeriesAnimations; | |
312 | else |
|
312 | else | |
313 | return DeclarativeChart::NoAnimation; |
|
313 | return DeclarativeChart::NoAnimation; | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | void DeclarativeChart::setTitle(QString title) |
|
316 | void DeclarativeChart::setTitle(QString title) | |
317 | { |
|
317 | { | |
318 | if (title != m_chart->title()) |
|
318 | if (title != m_chart->title()) | |
319 | m_chart->setTitle(title); |
|
319 | m_chart->setTitle(title); | |
320 | } |
|
320 | } | |
321 | QString DeclarativeChart::title() |
|
321 | QString DeclarativeChart::title() | |
322 | { |
|
322 | { | |
323 | return m_chart->title(); |
|
323 | return m_chart->title(); | |
324 | } |
|
324 | } | |
325 |
|
325 | |||
326 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
326 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) | |
327 | { |
|
327 | { | |
328 | return m_chart->axisX(series); |
|
328 | return m_chart->axisX(series); | |
329 | } |
|
329 | } | |
330 |
|
330 | |||
331 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
331 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
332 | { |
|
332 | { | |
333 | return m_chart->axisY(series); |
|
333 | return m_chart->axisY(series); | |
334 | } |
|
334 | } | |
335 |
|
335 | |||
336 | QLegend *DeclarativeChart::legend() |
|
336 | QLegend *DeclarativeChart::legend() | |
337 | { |
|
337 | { | |
338 | return m_chart->legend(); |
|
338 | return m_chart->legend(); | |
339 | } |
|
339 | } | |
340 |
|
340 | |||
341 | void DeclarativeChart::setTitleColor(QColor color) |
|
341 | void DeclarativeChart::setTitleColor(QColor color) | |
342 | { |
|
342 | { | |
343 | QBrush b = m_chart->titleBrush(); |
|
343 | QBrush b = m_chart->titleBrush(); | |
344 | if (color != b.color()) { |
|
344 | if (color != b.color()) { | |
345 | b.setColor(color); |
|
345 | b.setColor(color); | |
346 | m_chart->setTitleBrush(b); |
|
346 | m_chart->setTitleBrush(b); | |
347 | emit titleColorChanged(color); |
|
347 | emit titleColorChanged(color); | |
348 | } |
|
348 | } | |
349 | } |
|
349 | } | |
350 |
|
350 | |||
351 | QFont DeclarativeChart::titleFont() const |
|
351 | QFont DeclarativeChart::titleFont() const | |
352 | { |
|
352 | { | |
353 | return m_chart->titleFont(); |
|
353 | return m_chart->titleFont(); | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | void DeclarativeChart::setTitleFont(const QFont& font) |
|
356 | void DeclarativeChart::setTitleFont(const QFont& font) | |
357 | { |
|
357 | { | |
358 | m_chart->setTitleFont(font); |
|
358 | m_chart->setTitleFont(font); | |
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 | QColor DeclarativeChart::titleColor() |
|
361 | QColor DeclarativeChart::titleColor() | |
362 | { |
|
362 | { | |
363 | return m_chart->titleBrush().color(); |
|
363 | return m_chart->titleBrush().color(); | |
364 | } |
|
364 | } | |
365 |
|
365 | |||
366 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
366 | void DeclarativeChart::setBackgroundColor(QColor color) | |
367 | { |
|
367 | { | |
368 | QBrush b = m_chart->backgroundBrush(); |
|
368 | QBrush b = m_chart->backgroundBrush(); | |
369 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
369 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
370 | b.setStyle(Qt::SolidPattern); |
|
370 | b.setStyle(Qt::SolidPattern); | |
371 | b.setColor(color); |
|
371 | b.setColor(color); | |
372 | m_chart->setBackgroundBrush(b); |
|
372 | m_chart->setBackgroundBrush(b); | |
373 | emit backgroundColorChanged(); |
|
373 | emit backgroundColorChanged(); | |
374 | } |
|
374 | } | |
375 | } |
|
375 | } | |
376 |
|
376 | |||
377 | QColor DeclarativeChart::backgroundColor() |
|
377 | QColor DeclarativeChart::backgroundColor() | |
378 | { |
|
378 | { | |
379 | return m_chart->backgroundBrush().color(); |
|
379 | return m_chart->backgroundBrush().color(); | |
380 | } |
|
380 | } | |
381 |
|
381 | |||
382 | int DeclarativeChart::count() |
|
382 | int DeclarativeChart::count() | |
383 | { |
|
383 | { | |
384 | return m_chart->series().count(); |
|
384 | return m_chart->series().count(); | |
385 | } |
|
385 | } | |
386 |
|
386 | |||
387 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
387 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
388 | { |
|
388 | { | |
389 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
389 | if (enabled != m_chart->isDropShadowEnabled()) { | |
390 | m_chart->setDropShadowEnabled(enabled); |
|
390 | m_chart->setDropShadowEnabled(enabled); | |
391 | dropShadowEnabledChanged(enabled); |
|
391 | dropShadowEnabledChanged(enabled); | |
392 | } |
|
392 | } | |
393 | } |
|
393 | } | |
394 |
|
394 | |||
395 | bool DeclarativeChart::dropShadowEnabled() |
|
395 | bool DeclarativeChart::dropShadowEnabled() | |
396 | { |
|
396 | { | |
397 | return m_chart->isDropShadowEnabled(); |
|
397 | return m_chart->isDropShadowEnabled(); | |
398 | } |
|
398 | } | |
399 |
|
399 | |||
400 | qreal DeclarativeChart::topMargin() |
|
400 | qreal DeclarativeChart::topMargin() | |
401 | { |
|
401 | { | |
402 | return m_chart->margins().top(); |
|
402 | return m_chart->margins().top(); | |
403 | } |
|
403 | } | |
404 |
|
404 | |||
405 | qreal DeclarativeChart::bottomMargin() |
|
405 | qreal DeclarativeChart::bottomMargin() | |
406 | { |
|
406 | { | |
407 | return m_chart->margins().bottom(); |
|
407 | return m_chart->margins().bottom(); | |
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 | qreal DeclarativeChart::leftMargin() |
|
410 | qreal DeclarativeChart::leftMargin() | |
411 | { |
|
411 | { | |
412 | return m_chart->margins().left(); |
|
412 | return m_chart->margins().left(); | |
413 | } |
|
413 | } | |
414 |
|
414 | |||
415 | qreal DeclarativeChart::rightMargin() |
|
415 | qreal DeclarativeChart::rightMargin() | |
416 | { |
|
416 | { | |
417 | return m_chart->margins().right(); |
|
417 | return m_chart->margins().right(); | |
418 | } |
|
418 | } | |
419 |
|
419 | |||
420 | void DeclarativeChart::zoom(qreal factor) |
|
420 | void DeclarativeChart::zoom(qreal factor) | |
421 | { |
|
421 | { | |
422 | m_chart->zoom(factor); |
|
422 | m_chart->zoom(factor); | |
423 | } |
|
423 | } | |
424 |
|
424 | |||
425 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
425 | void DeclarativeChart::scrollLeft(qreal pixels) | |
426 | { |
|
426 | { | |
427 | m_chart->scroll(pixels, 0); |
|
427 | m_chart->scroll(pixels, 0); | |
428 | } |
|
428 | } | |
429 |
|
429 | |||
430 | void DeclarativeChart::scrollRight(qreal pixels) |
|
430 | void DeclarativeChart::scrollRight(qreal pixels) | |
431 | { |
|
431 | { | |
432 | m_chart->scroll(-pixels, 0); |
|
432 | m_chart->scroll(-pixels, 0); | |
433 | } |
|
433 | } | |
434 |
|
434 | |||
435 | void DeclarativeChart::scrollUp(qreal pixels) |
|
435 | void DeclarativeChart::scrollUp(qreal pixels) | |
436 | { |
|
436 | { | |
437 | m_chart->scroll(0, pixels); |
|
437 | m_chart->scroll(0, pixels); | |
438 | } |
|
438 | } | |
439 |
|
439 | |||
440 | void DeclarativeChart::scrollDown(qreal pixels) |
|
440 | void DeclarativeChart::scrollDown(qreal pixels) | |
441 | { |
|
441 | { | |
442 | m_chart->scroll(0, -pixels); |
|
442 | m_chart->scroll(0, -pixels); | |
443 | } |
|
443 | } | |
444 |
|
444 | |||
445 | QAbstractSeries *DeclarativeChart::series(int index) |
|
445 | QAbstractSeries *DeclarativeChart::series(int index) | |
446 | { |
|
446 | { | |
447 | if (index < m_chart->series().count()) { |
|
447 | if (index < m_chart->series().count()) { | |
448 | return m_chart->series().at(index); |
|
448 | return m_chart->series().at(index); | |
449 | } |
|
449 | } | |
450 | return 0; |
|
450 | return 0; | |
451 | } |
|
451 | } | |
452 |
|
452 | |||
453 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
453 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
454 | { |
|
454 | { | |
455 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
455 | foreach(QAbstractSeries *series, m_chart->series()) { | |
456 | if (series->name() == seriesName) |
|
456 | if (series->name() == seriesName) | |
457 | return series; |
|
457 | return series; | |
458 | } |
|
458 | } | |
459 | return 0; |
|
459 | return 0; | |
460 | } |
|
460 | } | |
461 |
|
461 | |||
462 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
462 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
463 | { |
|
463 | { | |
464 | QAbstractSeries *series = 0; |
|
464 | QAbstractSeries *series = 0; | |
465 | switch (type) { |
|
465 | switch (type) { | |
466 | case DeclarativeChart::SeriesTypeLine: |
|
466 | case DeclarativeChart::SeriesTypeLine: | |
467 | series = new DeclarativeLineSeries(); |
|
467 | series = new DeclarativeLineSeries(); | |
468 | break; |
|
468 | break; | |
469 | case DeclarativeChart::SeriesTypeArea: |
|
469 | case DeclarativeChart::SeriesTypeArea: | |
470 | series = new DeclarativeAreaSeries(); |
|
470 | series = new DeclarativeAreaSeries(); | |
471 | break; |
|
471 | break; | |
472 | case DeclarativeChart::SeriesTypeStackedBar: |
|
472 | case DeclarativeChart::SeriesTypeStackedBar: | |
473 | series = new DeclarativeStackedBarSeries(); |
|
473 | series = new DeclarativeStackedBarSeries(); | |
474 | break; |
|
474 | break; | |
475 | case DeclarativeChart::SeriesTypePercentBar: |
|
475 | case DeclarativeChart::SeriesTypePercentBar: | |
476 | series = new DeclarativePercentBarSeries(); |
|
476 | series = new DeclarativePercentBarSeries(); | |
477 | break; |
|
477 | break; | |
478 | case DeclarativeChart::SeriesTypeBar: |
|
478 | case DeclarativeChart::SeriesTypeBar: | |
479 | series = new DeclarativeBarSeries(); |
|
479 | series = new DeclarativeBarSeries(); | |
480 | break; |
|
480 | break; | |
|
481 | case DeclarativeChart::SeriesTypeHorizontalBar: | |||
|
482 | series = new DeclarativeHorizontalBarSeries(); | |||
|
483 | break; | |||
|
484 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: | |||
|
485 | series = new DeclarativeHorizontalPercentBarSeries(); | |||
|
486 | break; | |||
|
487 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: | |||
|
488 | series = new DeclarativeHorizontalStackedBarSeries(); | |||
|
489 | break; | |||
481 | case DeclarativeChart::SeriesTypePie: |
|
490 | case DeclarativeChart::SeriesTypePie: | |
482 | series = new DeclarativePieSeries(); |
|
491 | series = new DeclarativePieSeries(); | |
483 | break; |
|
492 | break; | |
484 | case DeclarativeChart::SeriesTypeScatter: |
|
493 | case DeclarativeChart::SeriesTypeScatter: | |
485 | series = new DeclarativeScatterSeries(); |
|
494 | series = new DeclarativeScatterSeries(); | |
486 | break; |
|
495 | break; | |
487 | case DeclarativeChart::SeriesTypeSpline: |
|
496 | case DeclarativeChart::SeriesTypeSpline: | |
488 | series = new DeclarativeSplineSeries(); |
|
497 | series = new DeclarativeSplineSeries(); | |
489 | break; |
|
498 | break; | |
490 | default: |
|
499 | default: | |
491 | qWarning() << "Illegal series type"; |
|
500 | qWarning() << "Illegal series type"; | |
492 | } |
|
501 | } | |
493 | series->setName(name); |
|
502 | series->setName(name); | |
494 | m_chart->addSeries(series); |
|
503 | m_chart->addSeries(series); | |
495 | return series; |
|
504 | return series; | |
496 | } |
|
505 | } | |
497 |
|
506 | |||
498 | void DeclarativeChart::setAxisX(QAbstractAxis* axis, QAbstractSeries *series) |
|
507 | void DeclarativeChart::setAxisX(QAbstractAxis* axis, QAbstractSeries *series) | |
499 | { |
|
508 | { | |
500 | m_chart->setAxisX(axis,series); |
|
509 | m_chart->setAxisX(axis,series); | |
501 | } |
|
510 | } | |
502 |
|
511 | |||
503 | void DeclarativeChart::setAxisY(QAbstractAxis* axis, QAbstractSeries *series) |
|
512 | void DeclarativeChart::setAxisY(QAbstractAxis* axis, QAbstractSeries *series) | |
504 | { |
|
513 | { | |
505 | m_chart->setAxisY(axis,series); |
|
514 | m_chart->setAxisY(axis,series); | |
506 | } |
|
515 | } | |
507 |
|
516 | |||
508 | void DeclarativeChart::createDefaultAxes() |
|
517 | void DeclarativeChart::createDefaultAxes() | |
509 | { |
|
518 | { | |
510 | m_chart->createDefaultAxes(); |
|
519 | m_chart->createDefaultAxes(); | |
511 | } |
|
520 | } | |
512 |
|
521 | |||
513 | #include "moc_declarativechart.cpp" |
|
522 | #include "moc_declarativechart.cpp" | |
514 |
|
523 | |||
515 | QTCOMMERCIALCHART_END_NAMESPACE |
|
524 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,155 +1,158 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVECHART_H |
|
21 | #ifndef DECLARATIVECHART_H | |
22 | #define DECLARATIVECHART_H |
|
22 | #define DECLARATIVECHART_H | |
23 |
|
23 | |||
24 | #include <QtCore/QtGlobal> |
|
24 | #include <QtCore/QtGlobal> | |
25 | #include <QDeclarativeItem> |
|
25 | #include <QDeclarativeItem> | |
26 | #include <qchart.h> |
|
26 | #include <qchart.h> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | // TODO: Derive from QChart for easier definition of properties? |
|
30 | // TODO: Derive from QChart for easier definition of properties? | |
31 | class DeclarativeChart : public QDeclarativeItem |
|
31 | class DeclarativeChart : public QDeclarativeItem | |
32 | // TODO: for QTQUICK2: extend QQuickPainterItem instead |
|
32 | // TODO: for QTQUICK2: extend QQuickPainterItem instead | |
33 | //class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
33 | //class DeclarativeChart : public QQuickPaintedItem, public Chart | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) |
|
36 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) | |
37 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) |
|
37 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) | |
38 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
38 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
39 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |
|
39 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | |
40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |
41 | Q_PROPERTY(QLegend *legend READ legend) |
|
41 | Q_PROPERTY(QLegend *legend READ legend) | |
42 | Q_PROPERTY(int count READ count) |
|
42 | Q_PROPERTY(int count READ count) | |
43 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
43 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
44 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
44 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |
45 | Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged) |
|
45 | Q_PROPERTY(qreal topMargin READ topMargin NOTIFY topMarginChanged) | |
46 | Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged) |
|
46 | Q_PROPERTY(qreal bottomMargin READ bottomMargin NOTIFY bottomMarginChanged) | |
47 | Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged) |
|
47 | Q_PROPERTY(qreal leftMargin READ leftMargin NOTIFY leftMarginChanged) | |
48 | Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged) |
|
48 | Q_PROPERTY(qreal rightMargin READ rightMargin NOTIFY rightMarginChanged) | |
49 | Q_ENUMS(Animation) |
|
49 | Q_ENUMS(Animation) | |
50 | Q_ENUMS(Theme) |
|
50 | Q_ENUMS(Theme) | |
51 | Q_ENUMS(SeriesType) |
|
51 | Q_ENUMS(SeriesType) | |
52 |
|
52 | |||
53 | public: |
|
53 | public: | |
54 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api |
|
54 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api | |
55 | enum Theme { |
|
55 | enum Theme { | |
56 | ChartThemeLight = 0, |
|
56 | ChartThemeLight = 0, | |
57 | ChartThemeBlueCerulean, |
|
57 | ChartThemeBlueCerulean, | |
58 | ChartThemeDark, |
|
58 | ChartThemeDark, | |
59 | ChartThemeBrownSand, |
|
59 | ChartThemeBrownSand, | |
60 | ChartThemeBlueNcs, |
|
60 | ChartThemeBlueNcs, | |
61 | ChartThemeHighContrast, |
|
61 | ChartThemeHighContrast, | |
62 | ChartThemeBlueIcy |
|
62 | ChartThemeBlueIcy | |
63 | }; |
|
63 | }; | |
64 |
|
64 | |||
65 | enum Animation { |
|
65 | enum Animation { | |
66 | NoAnimation = 0x0, |
|
66 | NoAnimation = 0x0, | |
67 | GridAxisAnimations = 0x1, |
|
67 | GridAxisAnimations = 0x1, | |
68 | SeriesAnimations =0x2, |
|
68 | SeriesAnimations =0x2, | |
69 | AllAnimations = 0x3 |
|
69 | AllAnimations = 0x3 | |
70 | }; |
|
70 | }; | |
71 |
|
71 | |||
72 | enum SeriesType { |
|
72 | enum SeriesType { | |
73 | SeriesTypeLine, |
|
73 | SeriesTypeLine, | |
74 | SeriesTypeArea, |
|
74 | SeriesTypeArea, | |
75 | SeriesTypeBar, |
|
75 | SeriesTypeBar, | |
76 | SeriesTypeStackedBar, |
|
76 | SeriesTypeStackedBar, | |
77 | SeriesTypePercentBar, |
|
77 | SeriesTypePercentBar, | |
78 | SeriesTypePie, |
|
78 | SeriesTypePie, | |
79 | SeriesTypeScatter, |
|
79 | SeriesTypeScatter, | |
80 | SeriesTypeSpline |
|
80 | SeriesTypeSpline, | |
|
81 | SeriesTypeHorizontalBar, | |||
|
82 | SeriesTypeHorizontalStackedBar, | |||
|
83 | SeriesTypeHorizontalPercentBar | |||
81 | }; |
|
84 | }; | |
82 |
|
85 | |||
83 | public: |
|
86 | public: | |
84 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
87 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
85 | ~DeclarativeChart(); |
|
88 | ~DeclarativeChart(); | |
86 |
|
89 | |||
87 | public: // From QDeclarativeItem/QGraphicsItem |
|
90 | public: // From QDeclarativeItem/QGraphicsItem | |
88 | void childEvent(QChildEvent *event); |
|
91 | void childEvent(QChildEvent *event); | |
89 | void componentComplete(); |
|
92 | void componentComplete(); | |
90 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
93 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
91 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
94 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
92 |
|
95 | |||
93 | public: |
|
96 | public: | |
94 | void setTheme(DeclarativeChart::Theme theme); |
|
97 | void setTheme(DeclarativeChart::Theme theme); | |
95 | DeclarativeChart::Theme theme(); |
|
98 | DeclarativeChart::Theme theme(); | |
96 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
99 | void setAnimationOptions(DeclarativeChart::Animation animations); | |
97 | DeclarativeChart::Animation animationOptions(); |
|
100 | DeclarativeChart::Animation animationOptions(); | |
98 | void setTitle(QString title); |
|
101 | void setTitle(QString title); | |
99 | QString title(); |
|
102 | QString title(); | |
100 | QLegend *legend(); |
|
103 | QLegend *legend(); | |
101 | QFont titleFont() const; |
|
104 | QFont titleFont() const; | |
102 | void setTitleFont(const QFont& font); |
|
105 | void setTitleFont(const QFont& font); | |
103 | void setTitleColor(QColor color); |
|
106 | void setTitleColor(QColor color); | |
104 | QColor titleColor(); |
|
107 | QColor titleColor(); | |
105 | void setBackgroundColor(QColor color); |
|
108 | void setBackgroundColor(QColor color); | |
106 | QColor backgroundColor(); |
|
109 | QColor backgroundColor(); | |
107 | int count(); |
|
110 | int count(); | |
108 | void setDropShadowEnabled(bool enabled); |
|
111 | void setDropShadowEnabled(bool enabled); | |
109 | bool dropShadowEnabled(); |
|
112 | bool dropShadowEnabled(); | |
110 | qreal topMargin(); |
|
113 | qreal topMargin(); | |
111 | qreal bottomMargin(); |
|
114 | qreal bottomMargin(); | |
112 | qreal leftMargin(); |
|
115 | qreal leftMargin(); | |
113 | qreal rightMargin(); |
|
116 | qreal rightMargin(); | |
114 |
|
117 | |||
115 |
|
118 | |||
116 |
|
119 | |||
117 | public: |
|
120 | public: | |
118 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
121 | Q_INVOKABLE QAbstractSeries *series(int index); | |
119 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
122 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
120 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
123 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
121 | Q_INVOKABLE void setAxisX(QAbstractAxis* axis, QAbstractSeries *series = 0); |
|
124 | Q_INVOKABLE void setAxisX(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
122 | Q_INVOKABLE void setAxisY(QAbstractAxis* axis, QAbstractSeries *series = 0); |
|
125 | Q_INVOKABLE void setAxisY(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
123 | Q_INVOKABLE void createDefaultAxes(); |
|
126 | Q_INVOKABLE void createDefaultAxes(); | |
124 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); |
|
127 | Q_INVOKABLE QAbstractAxis *axisX(QAbstractSeries *series = 0); | |
125 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); |
|
128 | Q_INVOKABLE QAbstractAxis *axisY(QAbstractSeries *series = 0); | |
126 |
|
129 | |||
127 | Q_INVOKABLE void zoom(qreal factor); |
|
130 | Q_INVOKABLE void zoom(qreal factor); | |
128 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
131 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
129 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
132 | Q_INVOKABLE void scrollRight(qreal pixels); | |
130 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
133 | Q_INVOKABLE void scrollUp(qreal pixels); | |
131 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
134 | Q_INVOKABLE void scrollDown(qreal pixels); | |
132 |
|
135 | |||
133 | Q_SIGNALS: |
|
136 | Q_SIGNALS: | |
134 | void axisLabelsChanged(); |
|
137 | void axisLabelsChanged(); | |
135 | void titleColorChanged(QColor color); |
|
138 | void titleColorChanged(QColor color); | |
136 | void backgroundColorChanged(); |
|
139 | void backgroundColorChanged(); | |
137 | void dropShadowEnabledChanged(bool enabled); |
|
140 | void dropShadowEnabledChanged(bool enabled); | |
138 | void topMarginChanged(qreal margin); |
|
141 | void topMarginChanged(qreal margin); | |
139 | void bottomMarginChanged(qreal margin); |
|
142 | void bottomMarginChanged(qreal margin); | |
140 | void leftMarginChanged(qreal margin); |
|
143 | void leftMarginChanged(qreal margin); | |
141 | void rightMarginChanged(qreal margin); |
|
144 | void rightMarginChanged(qreal margin); | |
142 |
|
145 | |||
143 | public Q_SLOTS: |
|
146 | public Q_SLOTS: | |
144 | void handleMarginsChanged(QRectF newMargins); |
|
147 | void handleMarginsChanged(QRectF newMargins); | |
145 |
|
148 | |||
146 | private: |
|
149 | private: | |
147 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
150 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
148 | // multi inheritance, so we now have a QChart as a member instead |
|
151 | // multi inheritance, so we now have a QChart as a member instead | |
149 | QChart *m_chart; |
|
152 | QChart *m_chart; | |
150 | QRectF m_chartMargins; |
|
153 | QRectF m_chartMargins; | |
151 | }; |
|
154 | }; | |
152 |
|
155 | |||
153 | QTCOMMERCIALCHART_END_NAMESPACE |
|
156 | QTCOMMERCIALCHART_END_NAMESPACE | |
154 |
|
157 | |||
155 | #endif // DECLARATIVECHART_H |
|
158 | #endif // DECLARATIVECHART_H |
@@ -1,101 +1,104 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> |
|
21 | #include <QtDeclarative/qdeclarativeextensionplugin.h> | |
22 | #include <QtDeclarative/qdeclarative.h> |
|
22 | #include <QtDeclarative/qdeclarative.h> | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qabstractaxis.h" |
|
24 | #include "qabstractaxis.h" | |
25 | #include "qvalueaxis.h" |
|
25 | #include "qvalueaxis.h" | |
26 | #include "qbarcategoryaxis.h" |
|
26 | #include "qbarcategoryaxis.h" | |
27 | #include "declarativechart.h" |
|
27 | #include "declarativechart.h" | |
28 | #include "declarativexypoint.h" |
|
28 | #include "declarativexypoint.h" | |
29 | #include "declarativelineseries.h" |
|
29 | #include "declarativelineseries.h" | |
30 | #include "declarativesplineseries.h" |
|
30 | #include "declarativesplineseries.h" | |
31 | #include "declarativeareaseries.h" |
|
31 | #include "declarativeareaseries.h" | |
32 | #include "declarativescatterseries.h" |
|
32 | #include "declarativescatterseries.h" | |
33 | #include "declarativebarseries.h" |
|
33 | #include "declarativebarseries.h" | |
34 | #include "declarativepieseries.h" |
|
34 | #include "declarativepieseries.h" | |
35 | #include "qvxymodelmapper.h" |
|
35 | #include "qvxymodelmapper.h" | |
36 | #include "qhxymodelmapper.h" |
|
36 | #include "qhxymodelmapper.h" | |
37 | #include "qhpiemodelmapper.h" |
|
37 | #include "qhpiemodelmapper.h" | |
38 | #include "qvpiemodelmapper.h" |
|
38 | #include "qvpiemodelmapper.h" | |
39 | #include "qhbarmodelmapper.h" |
|
39 | #include "qhbarmodelmapper.h" | |
40 | #include "qvbarmodelmapper.h" |
|
40 | #include "qvbarmodelmapper.h" | |
41 | #include <QAbstractItemModel> |
|
41 | #include <QAbstractItemModel> | |
42 |
|
42 | |||
43 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
43 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
44 |
|
44 | |||
45 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin |
|
45 | class ChartQmlPlugin : public QDeclarativeExtensionPlugin | |
46 | { |
|
46 | { | |
47 | Q_OBJECT |
|
47 | Q_OBJECT | |
48 | public: |
|
48 | public: | |
49 | virtual void registerTypes(const char *uri) |
|
49 | virtual void registerTypes(const char *uri) | |
50 | { |
|
50 | { | |
51 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); |
|
51 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart")); | |
52 |
|
52 | |||
53 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
53 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); | |
54 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); |
|
54 | qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint"); | |
55 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
|
55 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); | |
56 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); |
|
56 | qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries"); | |
57 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); |
|
57 | qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries"); | |
58 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); |
|
58 | qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries"); | |
59 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
59 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); | |
60 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); |
|
60 | qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries"); | |
61 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); |
|
61 | qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries"); | |
|
62 | qmlRegisterType<DeclarativeHorizontalBarSeries>(uri, 1, 0, "HorizontalBarSeries"); | |||
|
63 | qmlRegisterType<DeclarativeHorizontalStackedBarSeries>(uri, 1, 0, "HorizontalStackedBarSeries"); | |||
|
64 | qmlRegisterType<DeclarativeHorizontalPercentBarSeries>(uri, 1, 0, "HorizontalPercentBarSeries"); | |||
62 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
65 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); | |
63 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
66 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); | |
64 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
67 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); | |
65 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); |
|
68 | qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper"); | |
66 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); |
|
69 | qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper"); | |
67 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); |
|
70 | qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper"); | |
68 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); |
|
71 | qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper"); | |
69 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); |
|
72 | qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper"); | |
70 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); |
|
73 | qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper"); | |
71 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); |
|
74 | qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis"); | |
72 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); |
|
75 | qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis"); | |
73 |
|
76 | |||
74 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", |
|
77 | qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend", | |
75 | QLatin1String("Trying to create uncreatable: Legend.")); |
|
78 | QLatin1String("Trying to create uncreatable: Legend.")); | |
76 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", |
|
79 | qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries", | |
77 | QLatin1String("Trying to create uncreatable: XYSeries.")); |
|
80 | QLatin1String("Trying to create uncreatable: XYSeries.")); | |
78 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", |
|
81 | qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel", | |
79 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); |
|
82 | QLatin1String("Trying to create uncreatable: AbstractItemModel.")); | |
80 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", |
|
83 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
81 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); |
|
84 | QLatin1String("Trying to create uncreatable: XYModelMapper.")); | |
82 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", |
|
85 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
83 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); |
|
86 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
84 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", |
|
87 | qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper", | |
85 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); |
|
88 | QLatin1String("Trying to create uncreatable: BarModelMapper.")); | |
86 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", |
|
89 | qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries", | |
87 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); |
|
90 | QLatin1String("Trying to create uncreatable: AbstractSeries.")); | |
88 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", |
|
91 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", | |
89 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
92 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | |
90 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
93 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", | |
91 | QLatin1String("Trying to create uncreatable: AbstractAxis.")); |
|
94 | QLatin1String("Trying to create uncreatable: AbstractAxis.")); | |
92 | } |
|
95 | } | |
93 | }; |
|
96 | }; | |
94 |
|
97 | |||
95 | #include "plugin.moc" |
|
98 | #include "plugin.moc" | |
96 |
|
99 | |||
97 | QTCOMMERCIALCHART_END_NAMESPACE |
|
100 | QTCOMMERCIALCHART_END_NAMESPACE | |
98 |
|
101 | |||
99 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
102 | QTCOMMERCIALCHART_USE_NAMESPACE | |
100 |
|
103 | |||
101 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
|
104 | Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin)) |
General Comments 0
You need to be logged in to leave comments.
Login now