@@ -1,101 +1,105 | |||||
1 | ##################### LIB ################################################# |
|
1 | ##################### LIB ################################################# | |
2 |
|
2 | |||
3 | LIBRARY_NAME = QtCommercialChart |
|
3 | LIBRARY_NAME = QtCommercialChart | |
4 | CONFIG(debug, debug|release) { |
|
4 | CONFIG(debug, debug|release) { | |
5 | mac: LIBRARY_NAME = $$join(LIBRARY_NAME,,,_debug) |
|
5 | mac: LIBRARY_NAME = $$join(LIBRARY_NAME,,,_debug) | |
6 | win32: LIBRARY_NAME = $$join(LIBRARY_NAME,,,d) |
|
6 | win32: LIBRARY_NAME = $$join(LIBRARY_NAME,,,d) | |
7 | } |
|
7 | } | |
8 |
|
8 | |||
9 | LIBS += -l$$LIBRARY_NAME |
|
9 | LIBS += -l$$LIBRARY_NAME | |
10 |
|
10 | |||
11 | # This will undefine Q_DECL_EXPORT/Q_DECL_IMPORT at qchartglobal.h |
|
11 | # This will undefine Q_DECL_EXPORT/Q_DECL_IMPORT at qchartglobal.h | |
12 | # They should not be used for staticlib builds. |
|
12 | # They should not be used for staticlib builds. | |
13 | staticlib:DEFINES+=QTCOMMERCIALCHART_STATICLIB |
|
13 | staticlib:DEFINES+=QTCOMMERCIALCHART_STATICLIB | |
14 |
|
14 | |||
15 | ##################### SHADOW CONFIG ################################################# |
|
15 | ##################### SHADOW CONFIG ################################################# | |
16 |
|
16 | |||
17 | !contains($${PWD}, $${OUT_PWD}){ |
|
17 | !contains($${PWD}, $${OUT_PWD}){ | |
18 | search = "$$PWD:::" |
|
18 | search = "$$PWD:::" | |
19 | temp = $$split(search,"/") |
|
19 | temp = $$split(search,"/") | |
20 | temp = $$last(temp) |
|
20 | temp = $$last(temp) | |
21 | path = $$replace(search,$$temp,'') |
|
21 | path = $$replace(search,$$temp,'') | |
22 | temp = $$split(OUT_PWD,$$path) |
|
22 | temp = $$split(OUT_PWD,$$path) | |
23 | temp = $$split(temp,'/') |
|
23 | temp = $$split(temp,'/') | |
24 | temp = $$first(temp) |
|
24 | temp = $$first(temp) | |
25 | path = "$${path}$${temp}" |
|
25 | path = "$${path}$${temp}" | |
26 | SHADOW=$$path |
|
26 | SHADOW=$$path | |
27 | }else{ |
|
27 | }else{ | |
28 | SHADOW=$$PWD |
|
28 | SHADOW=$$PWD | |
29 | CONFIG-=development_build |
|
29 | CONFIG-=development_build | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | ##################### BUILD PATHS ################################################## |
|
32 | ##################### BUILD PATHS ################################################## | |
33 |
|
33 | |||
34 | CHART_BUILD_PUBLIC_HEADER_DIR = $$SHADOW/include |
|
34 | CHART_BUILD_PUBLIC_HEADER_DIR = $$SHADOW/include | |
35 | CHART_BUILD_PRIVATE_HEADER_DIR = $$CHART_BUILD_PUBLIC_HEADER_DIR/private |
|
35 | CHART_BUILD_PRIVATE_HEADER_DIR = $$CHART_BUILD_PUBLIC_HEADER_DIR/private | |
36 | CHART_BUILD_LIB_DIR = $$SHADOW/lib |
|
36 | CHART_BUILD_LIB_DIR = $$SHADOW/lib | |
37 | CHART_BUILD_DIR = $$SHADOW/build |
|
37 | CHART_BUILD_DIR = $$SHADOW/build | |
38 | CHART_BUILD_BIN_DIR = $$SHADOW/bin |
|
38 | CHART_BUILD_BIN_DIR = $$SHADOW/bin | |
39 | CHART_BUILD_PLUGIN_DIR = $$CHART_BUILD_BIN_DIR/QtCommercial/Chart |
|
39 | CHART_BUILD_PLUGIN_DIR = $$CHART_BUILD_BIN_DIR/QtCommercial/Chart | |
40 | CHART_BUILD_DOC_DIR = $$SHADOW/doc |
|
40 | CHART_BUILD_DOC_DIR = $$SHADOW/doc | |
41 |
|
41 | |||
42 | # Use own folders for debug and release builds |
|
42 | # Use own folders for debug and release builds | |
43 |
|
43 | |||
44 | CONFIG(debug, debug|release):CHART_BUILD_DIR = $$join(CHART_BUILD_DIR,,,/debug) |
|
44 | CONFIG(debug, debug|release):CHART_BUILD_DIR = $$join(CHART_BUILD_DIR,,,/debug) | |
45 | CONFIG(release, debug|release): CHART_BUILD_DIR = $$join(CHART_BUILD_DIR,,,/release) |
|
45 | CONFIG(release, debug|release): CHART_BUILD_DIR = $$join(CHART_BUILD_DIR,,,/release) | |
46 |
|
46 | |||
47 |
|
47 | |||
48 | win32:{ |
|
48 | win32:{ | |
49 | CHART_BUILD_PUBLIC_HEADER_DIR = $$replace(CHART_BUILD_PUBLIC_HEADER_DIR, "/","\\") |
|
49 | CHART_BUILD_PUBLIC_HEADER_DIR = $$replace(CHART_BUILD_PUBLIC_HEADER_DIR, "/","\\") | |
50 | CHART_BUILD_PRIVATE_HEADER_DIR = $$replace(CHART_BUILD_PRIVATE_HEADER_DIR, "/","\\") |
|
50 | CHART_BUILD_PRIVATE_HEADER_DIR = $$replace(CHART_BUILD_PRIVATE_HEADER_DIR, "/","\\") | |
51 | CHART_BUILD_BUILD_DIR = $$replace(CHART_BUILD_BUILD_DIR, "/","\\") |
|
51 | CHART_BUILD_BUILD_DIR = $$replace(CHART_BUILD_BUILD_DIR, "/","\\") | |
52 | CHART_BUILD_BIN_DIR = $$replace(CHART_BUILD_BIN_DIR, "/","\\") |
|
52 | CHART_BUILD_BIN_DIR = $$replace(CHART_BUILD_BIN_DIR, "/","\\") | |
53 | CHART_BUILD_PLUGIN_DIR = $$replace(CHART_BUILD_PLUGIN_DIR, "/","\\") |
|
53 | CHART_BUILD_PLUGIN_DIR = $$replace(CHART_BUILD_PLUGIN_DIR, "/","\\") | |
54 | CHART_BUILD_DOC_DIR = $$replace(CHART_BUILD_DOC_DIR, "/","\\") |
|
54 | CHART_BUILD_DOC_DIR = $$replace(CHART_BUILD_DOC_DIR, "/","\\") | |
55 | CHART_BUILD_LIB_DIR = $$replace(CHART_BUILD_LIB_DIR, "/","\\") |
|
55 | CHART_BUILD_LIB_DIR = $$replace(CHART_BUILD_LIB_DIR, "/","\\") | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | mac: { |
|
58 | mac: { | |
59 | # TODO: The following qmake flags are a work-around to make QtCommercial Charts compile on |
|
59 | # TODO: The following qmake flags are a work-around to make QtCommercial Charts compile on | |
60 | # QtCommercial 4.8. On the other hand Charts builds successfully with Qt open source 4.8 |
|
60 | # QtCommercial 4.8. On the other hand Charts builds successfully with Qt open source 4.8 | |
61 | # without these definitions, so this is probably a configuration issue on QtCommercial 4.8; |
|
61 | # without these definitions, so this is probably a configuration issue on QtCommercial 4.8; | |
62 | # it should probably define the minimum OSX version to be 10.5... |
|
62 | # it should probably define the minimum OSX version to be 10.5... | |
63 | QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5 |
|
63 | QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5 | |
64 | QMAKE_LFLAGS *= -mmacosx-version-min=10.5 |
|
64 | QMAKE_LFLAGS *= -mmacosx-version-min=10.5 | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
|
67 | linux-arm*: { | |||
|
68 | DEFINES+=QT_ON_ARM | |||
|
69 | } | |||
|
70 | ||||
67 | ##################### INCLUDES ############################################################ |
|
71 | ##################### INCLUDES ############################################################ | |
68 |
|
72 | |||
69 |
|
73 | |||
70 | INCLUDEPATH += $$CHART_BUILD_PUBLIC_HEADER_DIR |
|
74 | INCLUDEPATH += $$CHART_BUILD_PUBLIC_HEADER_DIR | |
71 |
|
75 | |||
72 | !win32: { |
|
76 | !win32: { | |
73 | LIBS += -L$$CHART_BUILD_LIB_DIR -Wl,-rpath,$$CHART_BUILD_LIB_DIR |
|
77 | LIBS += -L$$CHART_BUILD_LIB_DIR -Wl,-rpath,$$CHART_BUILD_LIB_DIR | |
74 | } else { |
|
78 | } else { | |
75 | win32-msvc*: { |
|
79 | win32-msvc*: { | |
76 | # hack fix for error: |
|
80 | # hack fix for error: | |
77 | # "LINK : fatal error LNK1146: no argument specified with option '/LIBPATH:'" |
|
81 | # "LINK : fatal error LNK1146: no argument specified with option '/LIBPATH:'" | |
78 | QMAKE_LIBDIR += $$CHART_BUILD_LIB_DIR |
|
82 | QMAKE_LIBDIR += $$CHART_BUILD_LIB_DIR | |
79 | } else { |
|
83 | } else { | |
80 | LIBS += -L$$CHART_BUILD_LIB_DIR |
|
84 | LIBS += -L$$CHART_BUILD_LIB_DIR | |
81 | } |
|
85 | } | |
82 | } |
|
86 | } | |
83 |
|
87 | |||
84 | ##################### DEVELOPMENT BUILD ################################################### |
|
88 | ##################### DEVELOPMENT BUILD ################################################### | |
85 |
|
89 | |||
86 | development_build: { |
|
90 | development_build: { | |
87 | DEFINES+=DEVELOPMENT_BUILD |
|
91 | DEFINES+=DEVELOPMENT_BUILD | |
88 | CONFIG+=debug_and_release |
|
92 | CONFIG+=debug_and_release | |
89 | CONFIG+=build_all |
|
93 | CONFIG+=build_all | |
90 | } |
|
94 | } | |
91 |
|
95 | |||
92 | #################### COVERAGE ################################################################# |
|
96 | #################### COVERAGE ################################################################# | |
93 | coverage: CONFIG += debug |
|
97 | coverage: CONFIG += debug | |
94 |
|
98 | |||
95 | ##################### UNIT TESTS ############################################################## |
|
99 | ##################### UNIT TESTS ############################################################## | |
96 |
|
100 | |||
97 | CONFIG(debug, debug|release) { |
|
101 | CONFIG(debug, debug|release) { | |
98 | CONFIG+=test_private |
|
102 | CONFIG+=test_private | |
99 | DEFINES+=BUILD_PRIVATE_UNIT_TESTS |
|
103 | DEFINES+=BUILD_PRIVATE_UNIT_TESTS | |
100 | } |
|
104 | } | |
101 |
|
105 |
@@ -1,35 +1,39 | |||||
1 | CURRENTLY_BUILDING_COMPONENTS = "examples" |
|
1 | CURRENTLY_BUILDING_COMPONENTS = "examples" | |
2 | !include( ../config.pri ) { |
|
2 | !include( ../config.pri ) { | |
3 | error( "Couldn't find the config.pri file!" ) |
|
3 | error( "Couldn't find the config.pri file!" ) | |
4 | } |
|
4 | } | |
5 |
|
5 | |||
6 | TEMPLATE = subdirs |
|
6 | TEMPLATE = subdirs | |
7 | SUBDIRS += \ |
|
7 | SUBDIRS += \ | |
8 | areachart \ |
|
8 | areachart \ | |
9 | customchart \ |
|
9 | customchart \ | |
10 | linechart \ |
|
10 | linechart \ | |
11 | percentbarchart \ |
|
11 | percentbarchart \ | |
12 | piechart \ |
|
12 | piechart \ | |
13 | piechartdrilldown \ |
|
13 | piechartdrilldown \ | |
14 | presenterchart \ |
|
14 | presenterchart \ | |
15 | scatterchart \ |
|
15 | scatterchart \ | |
16 | scatterinteractions \ |
|
16 | scatterinteractions \ | |
17 | splinechart \ |
|
17 | splinechart \ | |
18 | stackedbarchart \ |
|
18 | stackedbarchart \ | |
19 | stackedbarchartdrilldown \ |
|
19 | stackedbarchartdrilldown \ | |
20 | zoomlinechart \ |
|
20 | zoomlinechart \ | |
21 | modeldata \ |
|
21 | modeldata \ | |
22 | barchart \ |
|
22 | barchart \ | |
23 | legend \ |
|
23 | legend \ | |
24 | barmodelmapper \ |
|
24 | barmodelmapper \ | |
25 | qmlpiechart \ |
|
25 | qmlpiechart \ | |
26 | lineandbar \ |
|
26 | lineandbar \ | |
27 | horizontalbarchart \ |
|
27 | horizontalbarchart \ | |
28 | horizontalstackedbarchart \ |
|
28 | horizontalstackedbarchart \ | |
29 | horizontalpercentbarchart \ |
|
29 | horizontalpercentbarchart \ | |
30 | donut \ |
|
30 | donut \ | |
31 | donutbreakdown \ |
|
31 | donutbreakdown \ | |
32 | scrollchart \ |
|
32 | scrollchart \ | |
33 | datetimeaxis \ |
|
|||
34 | populationpyramid \ |
|
33 | populationpyramid \ | |
35 | donutchart |
|
34 | donutchart | |
|
35 | ||||
|
36 | !linux-arm*: { | |||
|
37 | SUBDIRS += \ | |||
|
38 | datetimeaxis | |||
|
39 | } |
@@ -1,676 +1,683 | |||||
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 <QDeclarativeEngine> |
|
23 | #include <QDeclarativeEngine> | |
24 | #include "declarativelineseries.h" |
|
24 | #include "declarativelineseries.h" | |
25 | #include "declarativeareaseries.h" |
|
25 | #include "declarativeareaseries.h" | |
26 | #include "declarativebarseries.h" |
|
26 | #include "declarativebarseries.h" | |
27 | #include "declarativepieseries.h" |
|
27 | #include "declarativepieseries.h" | |
28 | #include "declarativesplineseries.h" |
|
28 | #include "declarativesplineseries.h" | |
29 | #include "declarativescatterseries.h" |
|
29 | #include "declarativescatterseries.h" | |
30 | #include "qbarcategoryaxis.h" |
|
30 | #include "qbarcategoryaxis.h" | |
31 | #include "qvalueaxis.h" |
|
31 | #include "qvalueaxis.h" | |
32 | #include "qdatetimeaxis.h" |
|
|||
33 | #include "qcategoryaxis.h" |
|
32 | #include "qcategoryaxis.h" | |
34 | #include "qabstractseries_p.h" |
|
33 | #include "qabstractseries_p.h" | |
35 |
|
34 | |||
|
35 | #ifndef QT_ON_ARM | |||
|
36 | #include "qdatetimeaxis.h" | |||
|
37 | #endif | |||
|
38 | ||||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
40 | |||
38 | /*! |
|
41 | /*! | |
39 | \qmlclass ChartView DeclarativeChart |
|
42 | \qmlclass ChartView DeclarativeChart | |
40 |
|
43 | |||
41 | ChartView element is the parent that is responsible for showing different chart series types. |
|
44 | ChartView element is the parent that is responsible for showing different chart series types. | |
42 |
|
45 | |||
43 | The following QML shows how to create a simple chart with one pie series: |
|
46 | The following QML shows how to create a simple chart with one pie series: | |
44 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
47 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1 | |
45 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
48 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2 | |
46 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
49 | \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3 | |
47 |
|
50 | |||
48 | \beginfloatleft |
|
51 | \beginfloatleft | |
49 | \image examples_qmlpiechart.png |
|
52 | \image examples_qmlpiechart.png | |
50 | \endfloat |
|
53 | \endfloat | |
51 | \clearfloat |
|
54 | \clearfloat | |
52 | */ |
|
55 | */ | |
53 |
|
56 | |||
54 | /*! |
|
57 | /*! | |
55 | \qmlproperty Theme ChartView::theme |
|
58 | \qmlproperty Theme ChartView::theme | |
56 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
59 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
57 | widths and chart background. |
|
60 | widths and chart background. | |
58 | */ |
|
61 | */ | |
59 |
|
62 | |||
60 | /*! |
|
63 | /*! | |
61 | \qmlproperty Animation ChartView::animation |
|
64 | \qmlproperty Animation ChartView::animation | |
62 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
65 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
63 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
66 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
64 | */ |
|
67 | */ | |
65 |
|
68 | |||
66 | /*! |
|
69 | /*! | |
67 | \qmlproperty Font ChartView::titleFont |
|
70 | \qmlproperty Font ChartView::titleFont | |
68 | The title font of the chart |
|
71 | The title font of the chart | |
69 |
|
72 | |||
70 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
73 | See the \l {Font} {QML Font Element} for detailed documentation. | |
71 | */ |
|
74 | */ | |
72 |
|
75 | |||
73 | /*! |
|
76 | /*! | |
74 | \qmlproperty string ChartView::title |
|
77 | \qmlproperty string ChartView::title | |
75 | The title of the chart, shown on top of the chart. |
|
78 | The title of the chart, shown on top of the chart. | |
76 | \sa ChartView::titleColor |
|
79 | \sa ChartView::titleColor | |
77 | */ |
|
80 | */ | |
78 |
|
81 | |||
79 | /*! |
|
82 | /*! | |
80 | \qmlproperty string ChartView::titleColor |
|
83 | \qmlproperty string ChartView::titleColor | |
81 | The color of the title text. |
|
84 | The color of the title text. | |
82 | */ |
|
85 | */ | |
83 |
|
86 | |||
84 | /*! |
|
87 | /*! | |
85 | \qmlproperty Axis ChartView::axisX |
|
88 | \qmlproperty Axis ChartView::axisX | |
86 | The x-axis of the chart. |
|
89 | The x-axis of the chart. | |
87 | */ |
|
90 | */ | |
88 |
|
91 | |||
89 | /*! |
|
92 | /*! | |
90 | \qmlproperty Axis ChartView::axisY |
|
93 | \qmlproperty Axis ChartView::axisY | |
91 | The default y-axis of the chart. |
|
94 | The default y-axis of the chart. | |
92 | */ |
|
95 | */ | |
93 |
|
96 | |||
94 | /*! |
|
97 | /*! | |
95 | \qmlproperty Legend ChartView::legend |
|
98 | \qmlproperty Legend ChartView::legend | |
96 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
99 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
97 | */ |
|
100 | */ | |
98 |
|
101 | |||
99 | /*! |
|
102 | /*! | |
100 | \qmlproperty int ChartView::count |
|
103 | \qmlproperty int ChartView::count | |
101 | The count of series added to the chart. |
|
104 | The count of series added to the chart. | |
102 | */ |
|
105 | */ | |
103 |
|
106 | |||
104 | /*! |
|
107 | /*! | |
105 | \qmlproperty color ChartView::backgroundColor |
|
108 | \qmlproperty color ChartView::backgroundColor | |
106 | The color of the chart's background. By default background color is defined by chart theme. |
|
109 | The color of the chart's background. By default background color is defined by chart theme. | |
107 | \sa ChartView::theme |
|
110 | \sa ChartView::theme | |
108 | */ |
|
111 | */ | |
109 |
|
112 | |||
110 | /*! |
|
113 | /*! | |
111 | \qmlproperty bool ChartView::dropShadowEnabled |
|
114 | \qmlproperty bool ChartView::dropShadowEnabled | |
112 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
115 | The chart's border drop shadow. Set to true to enable drop shadow. | |
113 | */ |
|
116 | */ | |
114 |
|
117 | |||
115 | /*! |
|
118 | /*! | |
116 | \qmlproperty real ChartView::topMargin |
|
119 | \qmlproperty real ChartView::topMargin | |
117 | 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 |
|
120 | 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 | |
118 | area of the chart view. Top margin area is also used by legend, if aligned to top. |
|
121 | area of the chart view. Top margin area is also used by legend, if aligned to top. | |
119 | */ |
|
122 | */ | |
120 |
|
123 | |||
121 | /*! |
|
124 | /*! | |
122 | \qmlproperty real ChartView::bottomMargin |
|
125 | \qmlproperty real ChartView::bottomMargin | |
123 | The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by |
|
126 | The space between the bottom of chart view and the bottom of the plot area. The bottom margin area may be used by | |
124 | legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks. |
|
127 | legend (if aligned to bottom), x-axis, x-axis labels and x-axis tick marks. | |
125 | */ |
|
128 | */ | |
126 |
|
129 | |||
127 | /*! |
|
130 | /*! | |
128 | \qmlproperty real ChartView::leftMargin |
|
131 | \qmlproperty real ChartView::leftMargin | |
129 | 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 |
|
132 | 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 | |
130 | legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks. |
|
133 | legend (if aligned to left), y-axis, y-axis labels and y-axis tick marks. | |
131 | */ |
|
134 | */ | |
132 |
|
135 | |||
133 | /*! |
|
136 | /*! | |
134 | \qmlproperty real ChartView::rightMargin |
|
137 | \qmlproperty real ChartView::rightMargin | |
135 | The space between the right side of chart view and the right side of the plot area. The right margin area may be used |
|
138 | The space between the right side of chart view and the right side of the plot area. The right margin area may be used | |
136 | by legend (if aligned to right). |
|
139 | by legend (if aligned to right). | |
137 | */ |
|
140 | */ | |
138 |
|
141 | |||
139 | /*! |
|
142 | /*! | |
140 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
143 | \qmlmethod AbstractSeries ChartView::series(int index) | |
141 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
144 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with | |
142 | the count property of the chart. |
|
145 | the count property of the chart. | |
143 | */ |
|
146 | */ | |
144 |
|
147 | |||
145 | /*! |
|
148 | /*! | |
146 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
149 | \qmlmethod AbstractSeries ChartView::series(string name) | |
147 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
150 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. | |
148 | */ |
|
151 | */ | |
149 |
|
152 | |||
150 | /*! |
|
153 | /*! | |
151 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) |
|
154 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name) | |
152 | Creates a series object of \a type to the chart. For example: |
|
155 | Creates a series object of \a type to the chart. For example: | |
153 | \code |
|
156 | \code | |
154 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); |
|
157 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series"); | |
155 | scatter.markerSize = 22; |
|
158 | scatter.markerSize = 22; | |
156 | scatter.append(1.1, 2.0); |
|
159 | scatter.append(1.1, 2.0); | |
157 | \endcode |
|
160 | \endcode | |
158 | */ |
|
161 | */ | |
159 |
|
162 | |||
160 | /*! |
|
163 | /*! | |
161 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) |
|
164 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) | |
162 | 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. |
|
165 | 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. | |
163 | */ |
|
166 | */ | |
164 |
|
167 | |||
165 | /*! |
|
168 | /*! | |
166 | \qmlmethod ChartView::zoomY(real factor) |
|
169 | \qmlmethod ChartView::zoomY(real factor) | |
167 | Zooms in by \a factor on the center of the chart. |
|
170 | Zooms in by \a factor on the center of the chart. | |
168 | */ |
|
171 | */ | |
169 |
|
172 | |||
170 | /*! |
|
173 | /*! | |
171 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
174 | \qmlmethod ChartView::scrollLeft(real pixels) | |
172 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
175 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
173 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
176 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
174 | */ |
|
177 | */ | |
175 |
|
178 | |||
176 | /*! |
|
179 | /*! | |
177 | \qmlmethod ChartView::scrollRight(real pixels) |
|
180 | \qmlmethod ChartView::scrollRight(real pixels) | |
178 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
181 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
179 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
182 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
180 | */ |
|
183 | */ | |
181 |
|
184 | |||
182 | /*! |
|
185 | /*! | |
183 | \qmlmethod ChartView::scrollUp(real pixels) |
|
186 | \qmlmethod ChartView::scrollUp(real pixels) | |
184 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
187 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
185 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
188 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
186 | */ |
|
189 | */ | |
187 |
|
190 | |||
188 | /*! |
|
191 | /*! | |
189 | \qmlmethod ChartView::scrollDown(real pixels) |
|
192 | \qmlmethod ChartView::scrollDown(real pixels) | |
190 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
193 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
191 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max |
|
194 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
192 | */ |
|
195 | */ | |
193 |
|
196 | |||
194 | /*! |
|
197 | /*! | |
195 | \qmlsignal ChartView::onTopMarginChanged(real margin) |
|
198 | \qmlsignal ChartView::onTopMarginChanged(real margin) | |
196 | The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
199 | The top margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
197 | related properties of the legend or chart title. |
|
200 | related properties of the legend or chart title. | |
198 | */ |
|
201 | */ | |
199 |
|
202 | |||
200 | /*! |
|
203 | /*! | |
201 | \qmlsignal ChartView::onBottomMarginChanged(real margin) |
|
204 | \qmlsignal ChartView::onBottomMarginChanged(real margin) | |
202 | The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
205 | The bottom margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
203 | related properties of the legend or chart title. |
|
206 | related properties of the legend or chart title. | |
204 | */ |
|
207 | */ | |
205 |
|
208 | |||
206 | /*! |
|
209 | /*! | |
207 | \qmlsignal ChartView::onLeftMarginChanged(real margin) |
|
210 | \qmlsignal ChartView::onLeftMarginChanged(real margin) | |
208 | The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
211 | The left margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
209 | related properties of the legend or chart title. |
|
212 | related properties of the legend or chart title. | |
210 | */ |
|
213 | */ | |
211 |
|
214 | |||
212 | /*! |
|
215 | /*! | |
213 | \qmlsignal ChartView::onRightMarginChanged(real margin) |
|
216 | \qmlsignal ChartView::onRightMarginChanged(real margin) | |
214 | The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size |
|
217 | The right margin of the chart view has changed to \a margin. This may happen for example if you modify font size | |
215 | related properties of the legend or chart title. |
|
218 | related properties of the legend or chart title. | |
216 | */ |
|
219 | */ | |
217 |
|
220 | |||
218 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
221 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
219 | : QDeclarativeItem(parent), |
|
222 | : QDeclarativeItem(parent), | |
220 | m_chart(new QChart(this)) |
|
223 | m_chart(new QChart(this)) | |
221 | { |
|
224 | { | |
222 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
225 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
223 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
226 | // m_chart->axisX()->setNiceNumbersEnabled(false); | |
224 | m_chartMargins = m_chart->margins(); |
|
227 | m_chartMargins = m_chart->margins(); | |
225 | connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); |
|
228 | connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); | |
226 | } |
|
229 | } | |
227 |
|
230 | |||
228 | void DeclarativeChart::handleMarginsChanged(QRectF newMargins) |
|
231 | void DeclarativeChart::handleMarginsChanged(QRectF newMargins) | |
229 | { |
|
232 | { | |
230 | if (m_chartMargins.top() != newMargins.top()) |
|
233 | if (m_chartMargins.top() != newMargins.top()) | |
231 | topMarginChanged(m_chart->margins().top()); |
|
234 | topMarginChanged(m_chart->margins().top()); | |
232 | if (m_chartMargins.bottom() != newMargins.bottom()) |
|
235 | if (m_chartMargins.bottom() != newMargins.bottom()) | |
233 | bottomMarginChanged(m_chart->margins().bottom()); |
|
236 | bottomMarginChanged(m_chart->margins().bottom()); | |
234 | if (m_chartMargins.left() != newMargins.left()) |
|
237 | if (m_chartMargins.left() != newMargins.left()) | |
235 | leftMarginChanged(m_chart->margins().left()); |
|
238 | leftMarginChanged(m_chart->margins().left()); | |
236 | if (m_chartMargins.right() != newMargins.right()) |
|
239 | if (m_chartMargins.right() != newMargins.right()) | |
237 | rightMarginChanged(m_chart->margins().right()); |
|
240 | rightMarginChanged(m_chart->margins().right()); | |
238 |
|
241 | |||
239 | m_chartMargins = m_chart->margins(); |
|
242 | m_chartMargins = m_chart->margins(); | |
240 | } |
|
243 | } | |
241 |
|
244 | |||
242 | DeclarativeChart::~DeclarativeChart() |
|
245 | DeclarativeChart::~DeclarativeChart() | |
243 | { |
|
246 | { | |
244 | delete m_chart; |
|
247 | delete m_chart; | |
245 | } |
|
248 | } | |
246 |
|
249 | |||
247 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
250 | void DeclarativeChart::childEvent(QChildEvent *event) | |
248 | { |
|
251 | { | |
249 | if (event->type() == QEvent::ChildAdded) { |
|
252 | if (event->type() == QEvent::ChildAdded) { | |
250 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
253 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
251 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
254 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
252 | } |
|
255 | } | |
253 | } |
|
256 | } | |
254 | } |
|
257 | } | |
255 |
|
258 | |||
256 | void DeclarativeChart::componentComplete() |
|
259 | void DeclarativeChart::componentComplete() | |
257 | { |
|
260 | { | |
258 | foreach(QObject *child, children()) { |
|
261 | foreach(QObject *child, children()) { | |
259 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
262 | if (qobject_cast<QAbstractSeries *>(child)) { | |
260 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
263 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
261 | if (qobject_cast<DeclarativeLineSeries *>(child)) { |
|
264 | if (qobject_cast<DeclarativeLineSeries *>(child)) { | |
262 | DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child); |
|
265 | DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child); | |
263 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
266 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
264 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
267 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
265 | setAxisX(s->axisX(), s); |
|
268 | setAxisX(s->axisX(), s); | |
266 | setAxisY(s->axisY(), s); |
|
269 | setAxisY(s->axisY(), s); | |
267 | } else if (qobject_cast<DeclarativeSplineSeries *>(child)) { |
|
270 | } else if (qobject_cast<DeclarativeSplineSeries *>(child)) { | |
268 | DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child); |
|
271 | DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child); | |
269 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
272 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
270 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
273 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
271 | setAxisX(s->axisX(), s); |
|
274 | setAxisX(s->axisX(), s); | |
272 | setAxisY(s->axisY(), s); |
|
275 | setAxisY(s->axisY(), s); | |
273 | } else if (qobject_cast<DeclarativeScatterSeries *>(child)) { |
|
276 | } else if (qobject_cast<DeclarativeScatterSeries *>(child)) { | |
274 | DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child); |
|
277 | DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child); | |
275 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
278 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
276 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
279 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
277 | setAxisX(s->axisX(), s); |
|
280 | setAxisX(s->axisX(), s); | |
278 | setAxisY(s->axisY(), s); |
|
281 | setAxisY(s->axisY(), s); | |
279 | } else if (qobject_cast<DeclarativeAreaSeries *>(child)) { |
|
282 | } else if (qobject_cast<DeclarativeAreaSeries *>(child)) { | |
280 | DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child); |
|
283 | DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child); | |
281 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
284 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
282 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
285 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
283 | setAxisX(s->axisX(), s); |
|
286 | setAxisX(s->axisX(), s); | |
284 | setAxisY(s->axisY(), s); |
|
287 | setAxisY(s->axisY(), s); | |
285 | } else if (qobject_cast<DeclarativeBarSeries *>(child)) { |
|
288 | } else if (qobject_cast<DeclarativeBarSeries *>(child)) { | |
286 | DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child); |
|
289 | DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child); | |
287 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
290 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
288 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
291 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
289 | setAxisX(s->axisX(), s); |
|
292 | setAxisX(s->axisX(), s); | |
290 | setAxisY(s->axisY(), s); |
|
293 | setAxisY(s->axisY(), s); | |
291 | } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) { |
|
294 | } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) { | |
292 | DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child); |
|
295 | DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child); | |
293 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
296 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
294 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
297 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
295 | setAxisX(s->axisX(), s); |
|
298 | setAxisX(s->axisX(), s); | |
296 | setAxisY(s->axisY(), s); |
|
299 | setAxisY(s->axisY(), s); | |
297 | } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) { |
|
300 | } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) { | |
298 | DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child); |
|
301 | DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child); | |
299 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
302 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
300 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
303 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
301 | setAxisX(s->axisX(), s); |
|
304 | setAxisX(s->axisX(), s); | |
302 | setAxisY(s->axisY(), s); |
|
305 | setAxisY(s->axisY(), s); | |
303 | } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) { |
|
306 | } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) { | |
304 | DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child); |
|
307 | DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child); | |
305 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
308 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
306 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
309 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
307 | setAxisX(s->axisX(), s); |
|
310 | setAxisX(s->axisX(), s); | |
308 | setAxisY(s->axisY(), s); |
|
311 | setAxisY(s->axisY(), s); | |
309 | } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) { |
|
312 | } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) { | |
310 | DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child); |
|
313 | DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child); | |
311 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
314 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
312 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
315 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
313 | setAxisX(s->axisX(), s); |
|
316 | setAxisX(s->axisX(), s); | |
314 | setAxisY(s->axisY(), s); |
|
317 | setAxisY(s->axisY(), s); | |
315 | } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) { |
|
318 | } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) { | |
316 | DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child); |
|
319 | DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child); | |
317 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); |
|
320 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |
318 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); |
|
321 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |
319 | setAxisX(s->axisX(), s); |
|
322 | setAxisX(s->axisX(), s); | |
320 | setAxisY(s->axisY(), s); |
|
323 | setAxisY(s->axisY(), s); | |
321 | } |
|
324 | } | |
322 | } else if(qobject_cast<QAbstractAxis *>(child)) { |
|
325 | } else if(qobject_cast<QAbstractAxis *>(child)) { | |
323 | // Do nothing, axes are set for the chart in the context of series |
|
326 | // Do nothing, axes are set for the chart in the context of series | |
324 | } |
|
327 | } | |
325 | } |
|
328 | } | |
326 |
|
329 | |||
327 | // Create the missing axes for the series that cannot be painted without axes |
|
330 | // Create the missing axes for the series that cannot be painted without axes | |
328 | foreach(QAbstractSeries *series, m_chart->series()) |
|
331 | foreach(QAbstractSeries *series, m_chart->series()) | |
329 | createDefaultAxes(series); |
|
332 | createDefaultAxes(series); | |
330 |
|
333 | |||
331 | QDeclarativeItem::componentComplete(); |
|
334 | QDeclarativeItem::componentComplete(); | |
332 | } |
|
335 | } | |
333 |
|
336 | |||
334 | void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis) |
|
337 | void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis) | |
335 | { |
|
338 | { | |
336 | // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; |
|
339 | // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; | |
337 | if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) { |
|
340 | if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) { | |
338 | m_chart->setAxisX(axis, qobject_cast<DeclarativeLineSeries *>(sender())); |
|
341 | m_chart->setAxisX(axis, qobject_cast<DeclarativeLineSeries *>(sender())); | |
339 | } |
|
342 | } | |
340 | } |
|
343 | } | |
341 |
|
344 | |||
342 | void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis) |
|
345 | void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis) | |
343 | { |
|
346 | { | |
344 | // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; |
|
347 | // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; | |
345 | if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) { |
|
348 | if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) { | |
346 | m_chart->setAxisY(axis, qobject_cast<DeclarativeLineSeries *>(sender())); |
|
349 | m_chart->setAxisY(axis, qobject_cast<DeclarativeLineSeries *>(sender())); | |
347 | } |
|
350 | } | |
348 | } |
|
351 | } | |
349 |
|
352 | |||
350 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
353 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
351 | { |
|
354 | { | |
352 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
355 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
353 | if (newGeometry.isValid()) { |
|
356 | if (newGeometry.isValid()) { | |
354 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
357 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
355 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
358 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
356 | } |
|
359 | } | |
357 | } |
|
360 | } | |
358 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
361 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
359 | } |
|
362 | } | |
360 |
|
363 | |||
361 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
364 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
362 | { |
|
365 | { | |
363 | Q_UNUSED(option) |
|
366 | Q_UNUSED(option) | |
364 | Q_UNUSED(widget) |
|
367 | Q_UNUSED(widget) | |
365 |
|
368 | |||
366 | // TODO: optimized? |
|
369 | // TODO: optimized? | |
367 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
370 | painter->setRenderHint(QPainter::Antialiasing, true); | |
368 | } |
|
371 | } | |
369 |
|
372 | |||
370 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
373 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
371 | { |
|
374 | { | |
372 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
375 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
373 | if (chartTheme != m_chart->theme()) |
|
376 | if (chartTheme != m_chart->theme()) | |
374 | m_chart->setTheme(chartTheme); |
|
377 | m_chart->setTheme(chartTheme); | |
375 | } |
|
378 | } | |
376 |
|
379 | |||
377 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
380 | DeclarativeChart::Theme DeclarativeChart::theme() | |
378 | { |
|
381 | { | |
379 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
382 | return (DeclarativeChart::Theme) m_chart->theme(); | |
380 | } |
|
383 | } | |
381 |
|
384 | |||
382 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
385 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
383 | { |
|
386 | { | |
384 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
387 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
385 | if (animationOptions != m_chart->animationOptions()) |
|
388 | if (animationOptions != m_chart->animationOptions()) | |
386 | m_chart->setAnimationOptions(animationOptions); |
|
389 | m_chart->setAnimationOptions(animationOptions); | |
387 | } |
|
390 | } | |
388 |
|
391 | |||
389 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
392 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
390 | { |
|
393 | { | |
391 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
394 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
392 | return DeclarativeChart::AllAnimations; |
|
395 | return DeclarativeChart::AllAnimations; | |
393 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
396 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
394 | return DeclarativeChart::GridAxisAnimations; |
|
397 | return DeclarativeChart::GridAxisAnimations; | |
395 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
398 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
396 | return DeclarativeChart::SeriesAnimations; |
|
399 | return DeclarativeChart::SeriesAnimations; | |
397 | else |
|
400 | else | |
398 | return DeclarativeChart::NoAnimation; |
|
401 | return DeclarativeChart::NoAnimation; | |
399 | } |
|
402 | } | |
400 |
|
403 | |||
401 | void DeclarativeChart::setTitle(QString title) |
|
404 | void DeclarativeChart::setTitle(QString title) | |
402 | { |
|
405 | { | |
403 | if (title != m_chart->title()) |
|
406 | if (title != m_chart->title()) | |
404 | m_chart->setTitle(title); |
|
407 | m_chart->setTitle(title); | |
405 | } |
|
408 | } | |
406 | QString DeclarativeChart::title() |
|
409 | QString DeclarativeChart::title() | |
407 | { |
|
410 | { | |
408 | return m_chart->title(); |
|
411 | return m_chart->title(); | |
409 | } |
|
412 | } | |
410 |
|
413 | |||
411 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
414 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) | |
412 | { |
|
415 | { | |
413 | return m_chart->axisX(series); |
|
416 | return m_chart->axisX(series); | |
414 | } |
|
417 | } | |
415 |
|
418 | |||
416 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
419 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
417 | { |
|
420 | { | |
418 | return m_chart->axisY(series); |
|
421 | return m_chart->axisY(series); | |
419 | } |
|
422 | } | |
420 |
|
423 | |||
421 | QLegend *DeclarativeChart::legend() |
|
424 | QLegend *DeclarativeChart::legend() | |
422 | { |
|
425 | { | |
423 | return m_chart->legend(); |
|
426 | return m_chart->legend(); | |
424 | } |
|
427 | } | |
425 |
|
428 | |||
426 | void DeclarativeChart::setTitleColor(QColor color) |
|
429 | void DeclarativeChart::setTitleColor(QColor color) | |
427 | { |
|
430 | { | |
428 | QBrush b = m_chart->titleBrush(); |
|
431 | QBrush b = m_chart->titleBrush(); | |
429 | if (color != b.color()) { |
|
432 | if (color != b.color()) { | |
430 | b.setColor(color); |
|
433 | b.setColor(color); | |
431 | m_chart->setTitleBrush(b); |
|
434 | m_chart->setTitleBrush(b); | |
432 | emit titleColorChanged(color); |
|
435 | emit titleColorChanged(color); | |
433 | } |
|
436 | } | |
434 | } |
|
437 | } | |
435 |
|
438 | |||
436 | QFont DeclarativeChart::titleFont() const |
|
439 | QFont DeclarativeChart::titleFont() const | |
437 | { |
|
440 | { | |
438 | return m_chart->titleFont(); |
|
441 | return m_chart->titleFont(); | |
439 | } |
|
442 | } | |
440 |
|
443 | |||
441 | void DeclarativeChart::setTitleFont(const QFont& font) |
|
444 | void DeclarativeChart::setTitleFont(const QFont& font) | |
442 | { |
|
445 | { | |
443 | m_chart->setTitleFont(font); |
|
446 | m_chart->setTitleFont(font); | |
444 | } |
|
447 | } | |
445 |
|
448 | |||
446 | QColor DeclarativeChart::titleColor() |
|
449 | QColor DeclarativeChart::titleColor() | |
447 | { |
|
450 | { | |
448 | return m_chart->titleBrush().color(); |
|
451 | return m_chart->titleBrush().color(); | |
449 | } |
|
452 | } | |
450 |
|
453 | |||
451 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
454 | void DeclarativeChart::setBackgroundColor(QColor color) | |
452 | { |
|
455 | { | |
453 | QBrush b = m_chart->backgroundBrush(); |
|
456 | QBrush b = m_chart->backgroundBrush(); | |
454 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
457 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
455 | b.setStyle(Qt::SolidPattern); |
|
458 | b.setStyle(Qt::SolidPattern); | |
456 | b.setColor(color); |
|
459 | b.setColor(color); | |
457 | m_chart->setBackgroundBrush(b); |
|
460 | m_chart->setBackgroundBrush(b); | |
458 | emit backgroundColorChanged(); |
|
461 | emit backgroundColorChanged(); | |
459 | } |
|
462 | } | |
460 | } |
|
463 | } | |
461 |
|
464 | |||
462 | QColor DeclarativeChart::backgroundColor() |
|
465 | QColor DeclarativeChart::backgroundColor() | |
463 | { |
|
466 | { | |
464 | return m_chart->backgroundBrush().color(); |
|
467 | return m_chart->backgroundBrush().color(); | |
465 | } |
|
468 | } | |
466 |
|
469 | |||
467 | int DeclarativeChart::count() |
|
470 | int DeclarativeChart::count() | |
468 | { |
|
471 | { | |
469 | return m_chart->series().count(); |
|
472 | return m_chart->series().count(); | |
470 | } |
|
473 | } | |
471 |
|
474 | |||
472 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
475 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
473 | { |
|
476 | { | |
474 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
477 | if (enabled != m_chart->isDropShadowEnabled()) { | |
475 | m_chart->setDropShadowEnabled(enabled); |
|
478 | m_chart->setDropShadowEnabled(enabled); | |
476 | dropShadowEnabledChanged(enabled); |
|
479 | dropShadowEnabledChanged(enabled); | |
477 | } |
|
480 | } | |
478 | } |
|
481 | } | |
479 |
|
482 | |||
480 | bool DeclarativeChart::dropShadowEnabled() |
|
483 | bool DeclarativeChart::dropShadowEnabled() | |
481 | { |
|
484 | { | |
482 | return m_chart->isDropShadowEnabled(); |
|
485 | return m_chart->isDropShadowEnabled(); | |
483 | } |
|
486 | } | |
484 |
|
487 | |||
485 | qreal DeclarativeChart::topMargin() |
|
488 | qreal DeclarativeChart::topMargin() | |
486 | { |
|
489 | { | |
487 | return m_chart->margins().top(); |
|
490 | return m_chart->margins().top(); | |
488 | } |
|
491 | } | |
489 |
|
492 | |||
490 | qreal DeclarativeChart::bottomMargin() |
|
493 | qreal DeclarativeChart::bottomMargin() | |
491 | { |
|
494 | { | |
492 | return m_chart->margins().bottom(); |
|
495 | return m_chart->margins().bottom(); | |
493 | } |
|
496 | } | |
494 |
|
497 | |||
495 | qreal DeclarativeChart::leftMargin() |
|
498 | qreal DeclarativeChart::leftMargin() | |
496 | { |
|
499 | { | |
497 | return m_chart->margins().left(); |
|
500 | return m_chart->margins().left(); | |
498 | } |
|
501 | } | |
499 |
|
502 | |||
500 | qreal DeclarativeChart::rightMargin() |
|
503 | qreal DeclarativeChart::rightMargin() | |
501 | { |
|
504 | { | |
502 | return m_chart->margins().right(); |
|
505 | return m_chart->margins().right(); | |
503 | } |
|
506 | } | |
504 |
|
507 | |||
505 | void DeclarativeChart::zoom(qreal factor) |
|
508 | void DeclarativeChart::zoom(qreal factor) | |
506 | { |
|
509 | { | |
507 | m_chart->zoom(factor); |
|
510 | m_chart->zoom(factor); | |
508 | } |
|
511 | } | |
509 |
|
512 | |||
510 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
513 | void DeclarativeChart::scrollLeft(qreal pixels) | |
511 | { |
|
514 | { | |
512 | m_chart->scroll(pixels, 0); |
|
515 | m_chart->scroll(pixels, 0); | |
513 | } |
|
516 | } | |
514 |
|
517 | |||
515 | void DeclarativeChart::scrollRight(qreal pixels) |
|
518 | void DeclarativeChart::scrollRight(qreal pixels) | |
516 | { |
|
519 | { | |
517 | m_chart->scroll(-pixels, 0); |
|
520 | m_chart->scroll(-pixels, 0); | |
518 | } |
|
521 | } | |
519 |
|
522 | |||
520 | void DeclarativeChart::scrollUp(qreal pixels) |
|
523 | void DeclarativeChart::scrollUp(qreal pixels) | |
521 | { |
|
524 | { | |
522 | m_chart->scroll(0, pixels); |
|
525 | m_chart->scroll(0, pixels); | |
523 | } |
|
526 | } | |
524 |
|
527 | |||
525 | void DeclarativeChart::scrollDown(qreal pixels) |
|
528 | void DeclarativeChart::scrollDown(qreal pixels) | |
526 | { |
|
529 | { | |
527 | m_chart->scroll(0, -pixels); |
|
530 | m_chart->scroll(0, -pixels); | |
528 | } |
|
531 | } | |
529 |
|
532 | |||
530 | QAbstractSeries *DeclarativeChart::series(int index) |
|
533 | QAbstractSeries *DeclarativeChart::series(int index) | |
531 | { |
|
534 | { | |
532 | if (index < m_chart->series().count()) { |
|
535 | if (index < m_chart->series().count()) { | |
533 | return m_chart->series().at(index); |
|
536 | return m_chart->series().at(index); | |
534 | } |
|
537 | } | |
535 | return 0; |
|
538 | return 0; | |
536 | } |
|
539 | } | |
537 |
|
540 | |||
538 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
541 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
539 | { |
|
542 | { | |
540 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
543 | foreach(QAbstractSeries *series, m_chart->series()) { | |
541 | if (series->name() == seriesName) |
|
544 | if (series->name() == seriesName) | |
542 | return series; |
|
545 | return series; | |
543 | } |
|
546 | } | |
544 | return 0; |
|
547 | return 0; | |
545 | } |
|
548 | } | |
546 |
|
549 | |||
547 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
550 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
548 | { |
|
551 | { | |
549 | QAbstractSeries *series = 0; |
|
552 | QAbstractSeries *series = 0; | |
550 |
|
553 | |||
551 | switch (type) { |
|
554 | switch (type) { | |
552 | case DeclarativeChart::SeriesTypeLine: |
|
555 | case DeclarativeChart::SeriesTypeLine: | |
553 | series = new DeclarativeLineSeries(); |
|
556 | series = new DeclarativeLineSeries(); | |
554 | break; |
|
557 | break; | |
555 | case DeclarativeChart::SeriesTypeArea: |
|
558 | case DeclarativeChart::SeriesTypeArea: | |
556 | series = new DeclarativeAreaSeries(); |
|
559 | series = new DeclarativeAreaSeries(); | |
557 | break; |
|
560 | break; | |
558 | case DeclarativeChart::SeriesTypeStackedBar: |
|
561 | case DeclarativeChart::SeriesTypeStackedBar: | |
559 | series = new DeclarativeStackedBarSeries(); |
|
562 | series = new DeclarativeStackedBarSeries(); | |
560 | break; |
|
563 | break; | |
561 | case DeclarativeChart::SeriesTypePercentBar: |
|
564 | case DeclarativeChart::SeriesTypePercentBar: | |
562 | series = new DeclarativePercentBarSeries(); |
|
565 | series = new DeclarativePercentBarSeries(); | |
563 | break; |
|
566 | break; | |
564 | case DeclarativeChart::SeriesTypeBar: |
|
567 | case DeclarativeChart::SeriesTypeBar: | |
565 | series = new DeclarativeBarSeries(); |
|
568 | series = new DeclarativeBarSeries(); | |
566 | break; |
|
569 | break; | |
567 | case DeclarativeChart::SeriesTypeHorizontalBar: |
|
570 | case DeclarativeChart::SeriesTypeHorizontalBar: | |
568 | series = new DeclarativeHorizontalBarSeries(); |
|
571 | series = new DeclarativeHorizontalBarSeries(); | |
569 | break; |
|
572 | break; | |
570 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: |
|
573 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: | |
571 | series = new DeclarativeHorizontalPercentBarSeries(); |
|
574 | series = new DeclarativeHorizontalPercentBarSeries(); | |
572 | break; |
|
575 | break; | |
573 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: |
|
576 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: | |
574 | series = new DeclarativeHorizontalStackedBarSeries(); |
|
577 | series = new DeclarativeHorizontalStackedBarSeries(); | |
575 | break; |
|
578 | break; | |
576 | case DeclarativeChart::SeriesTypePie: |
|
579 | case DeclarativeChart::SeriesTypePie: | |
577 | series = new DeclarativePieSeries(); |
|
580 | series = new DeclarativePieSeries(); | |
578 | break; |
|
581 | break; | |
579 | case DeclarativeChart::SeriesTypeScatter: |
|
582 | case DeclarativeChart::SeriesTypeScatter: | |
580 | series = new DeclarativeScatterSeries(); |
|
583 | series = new DeclarativeScatterSeries(); | |
581 | break; |
|
584 | break; | |
582 | case DeclarativeChart::SeriesTypeSpline: |
|
585 | case DeclarativeChart::SeriesTypeSpline: | |
583 | series = new DeclarativeSplineSeries(); |
|
586 | series = new DeclarativeSplineSeries(); | |
584 | break; |
|
587 | break; | |
585 | default: |
|
588 | default: | |
586 | qWarning() << "Illegal series type"; |
|
589 | qWarning() << "Illegal series type"; | |
587 | } |
|
590 | } | |
588 |
|
591 | |||
589 | if (series) { |
|
592 | if (series) { | |
590 | series->setName(name); |
|
593 | series->setName(name); | |
591 | m_chart->addSeries(series); |
|
594 | m_chart->addSeries(series); | |
592 | createDefaultAxes(series); |
|
595 | createDefaultAxes(series); | |
593 | } |
|
596 | } | |
594 |
|
597 | |||
595 | return series; |
|
598 | return series; | |
596 | } |
|
599 | } | |
597 |
|
600 | |||
598 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) |
|
601 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) | |
599 | { |
|
602 | { | |
600 | if (axis) |
|
603 | if (axis) | |
601 | m_chart->setAxisX(axis, series); |
|
604 | m_chart->setAxisX(axis, series); | |
602 | } |
|
605 | } | |
603 |
|
606 | |||
604 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) |
|
607 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) | |
605 | { |
|
608 | { | |
606 | if (axis) |
|
609 | if (axis) | |
607 | m_chart->setAxisY(axis, series); |
|
610 | m_chart->setAxisY(axis, series); | |
608 | } |
|
611 | } | |
609 |
|
612 | |||
610 | void DeclarativeChart::createDefaultAxes() |
|
613 | void DeclarativeChart::createDefaultAxes() | |
611 | { |
|
614 | { | |
612 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; |
|
615 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; | |
613 | } |
|
616 | } | |
614 |
|
617 | |||
615 | void DeclarativeChart::createDefaultAxes(QAbstractSeries* series) |
|
618 | void DeclarativeChart::createDefaultAxes(QAbstractSeries* series) | |
616 | { |
|
619 | { | |
617 | foreach (QAbstractSeries *s, m_chart->series()) { |
|
620 | foreach (QAbstractSeries *s, m_chart->series()) { | |
618 | // If there is already an x axis of the correct type, re-use it |
|
621 | // If there is already an x axis of the correct type, re-use it | |
619 | if (!m_chart->axisX(series) && s != series && m_chart->axisX(s) |
|
622 | if (!m_chart->axisX(series) && s != series && m_chart->axisX(s) | |
620 | && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal)) |
|
623 | && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal)) | |
621 | m_chart->setAxisX(m_chart->axisX(s), series); |
|
624 | m_chart->setAxisX(m_chart->axisX(s), series); | |
622 |
|
625 | |||
623 | // If there is already a y axis of the correct type, re-use it |
|
626 | // If there is already a y axis of the correct type, re-use it | |
624 | if (!m_chart->axisY(series) && s != series && m_chart->axisY(s) |
|
627 | if (!m_chart->axisY(series) && s != series && m_chart->axisY(s) | |
625 | && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical)) |
|
628 | && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical)) | |
626 | m_chart->setAxisY(m_chart->axisY(s), series); |
|
629 | m_chart->setAxisY(m_chart->axisY(s), series); | |
627 | } |
|
630 | } | |
628 |
|
631 | |||
629 | // If no x axis of correct type was found, create a new x axis based of default axis type |
|
632 | // If no x axis of correct type was found, create a new x axis based of default axis type | |
630 | if (!m_chart->axisX(series)) { |
|
633 | if (!m_chart->axisX(series)) { | |
631 | switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) { |
|
634 | switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) { | |
632 | case QAbstractAxis::AxisTypeValue: |
|
635 | case QAbstractAxis::AxisTypeValue: | |
633 | m_chart->setAxisX(new QValueAxis(this), series); |
|
636 | m_chart->setAxisX(new QValueAxis(this), series); | |
634 | break; |
|
637 | break; | |
635 | case QAbstractAxis::AxisTypeBarCategory: |
|
638 | case QAbstractAxis::AxisTypeBarCategory: | |
636 | m_chart->setAxisX(new QBarCategoryAxis(this), series); |
|
639 | m_chart->setAxisX(new QBarCategoryAxis(this), series); | |
637 | break; |
|
640 | break; | |
638 | case QAbstractAxis::AxisTypeCategory: |
|
641 | case QAbstractAxis::AxisTypeCategory: | |
639 | m_chart->setAxisX(new QCategoryAxis(this), series); |
|
642 | m_chart->setAxisX(new QCategoryAxis(this), series); | |
640 | break; |
|
643 | break; | |
|
644 | #ifndef QT_ON_ARM | |||
641 | case QAbstractAxis::AxisTypeDateTime: |
|
645 | case QAbstractAxis::AxisTypeDateTime: | |
642 | m_chart->setAxisX(new QDateTimeAxis(this), series); |
|
646 | m_chart->setAxisX(new QDateTimeAxis(this), series); | |
643 | break; |
|
647 | break; | |
|
648 | #endif | |||
644 | default: |
|
649 | default: | |
645 | // Do nothing, assume AxisTypeNoAxis |
|
650 | // Do nothing, assume AxisTypeNoAxis | |
646 | break; |
|
651 | break; | |
647 | } |
|
652 | } | |
648 | } |
|
653 | } | |
649 |
|
654 | |||
650 | // If no y axis of correct type was found, create a new y axis based of default axis type |
|
655 | // If no y axis of correct type was found, create a new y axis based of default axis type | |
651 | if (!m_chart->axisY(series)) { |
|
656 | if (!m_chart->axisY(series)) { | |
652 | switch (series->d_ptr->defaultAxisType(Qt::Vertical)) { |
|
657 | switch (series->d_ptr->defaultAxisType(Qt::Vertical)) { | |
653 | case QAbstractAxis::AxisTypeValue: |
|
658 | case QAbstractAxis::AxisTypeValue: | |
654 | m_chart->setAxisY(new QValueAxis(this), series); |
|
659 | m_chart->setAxisY(new QValueAxis(this), series); | |
655 | break; |
|
660 | break; | |
656 | case QAbstractAxis::AxisTypeBarCategory: |
|
661 | case QAbstractAxis::AxisTypeBarCategory: | |
657 | m_chart->setAxisY(new QBarCategoryAxis(this), series); |
|
662 | m_chart->setAxisY(new QBarCategoryAxis(this), series); | |
658 | break; |
|
663 | break; | |
659 | case QAbstractAxis::AxisTypeCategory: |
|
664 | case QAbstractAxis::AxisTypeCategory: | |
660 | m_chart->setAxisY(new QCategoryAxis(this), series); |
|
665 | m_chart->setAxisY(new QCategoryAxis(this), series); | |
661 | break; |
|
666 | break; | |
|
667 | #ifndef QT_ON_ARM | |||
662 | case QAbstractAxis::AxisTypeDateTime: |
|
668 | case QAbstractAxis::AxisTypeDateTime: | |
663 | m_chart->setAxisY(new QDateTimeAxis(this), series); |
|
669 | m_chart->setAxisY(new QDateTimeAxis(this), series); | |
664 | break; |
|
670 | break; | |
|
671 | #endif | |||
665 | default: |
|
672 | default: | |
666 | // Do nothing, assume AxisTypeNoAxis |
|
673 | // Do nothing, assume AxisTypeNoAxis | |
667 | break; |
|
674 | break; | |
668 | } |
|
675 | } | |
669 | } |
|
676 | } | |
670 |
|
677 | |||
671 | //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series); |
|
678 | //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series); | |
672 | } |
|
679 | } | |
673 |
|
680 | |||
674 | #include "moc_declarativechart.cpp" |
|
681 | #include "moc_declarativechart.cpp" | |
675 |
|
682 | |||
676 | QTCOMMERCIALCHART_END_NAMESPACE |
|
683 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,52 +1,64 | |||||
1 | #Subdirectiores are defined here, because qt creator doesn't handle nested include(foo.pri) chains very well. |
|
1 | #Subdirectiores are defined here, because qt creator doesn't handle nested include(foo.pri) chains very well. | |
2 |
|
2 | |||
3 | INCLUDEPATH += $$PWD \ |
|
3 | INCLUDEPATH += $$PWD \ | |
4 | $$PWD/valueaxis \ |
|
4 | $$PWD/valueaxis \ | |
5 | $$PWD/barcategoryaxis \ |
|
5 | $$PWD/barcategoryaxis \ | |
6 |
$$PWD/categoryaxis |
|
6 | $$PWD/categoryaxis | |
7 | $$PWD/datetimeaxis |
|
|||
8 |
|
7 | |||
9 | DEPENDPATH += $$PWD \ |
|
8 | DEPENDPATH += $$PWD \ | |
10 | $$PWD/valueaxis \ |
|
9 | $$PWD/valueaxis \ | |
11 | $$PWD/barcategoryaxis \ |
|
10 | $$PWD/barcategoryaxis \ | |
12 |
$$PWD/categoryaxis |
|
11 | $$PWD/categoryaxis | |
13 | $$PWD/datetimeaxis |
|
|||
14 |
|
12 | |||
15 | SOURCES += \ |
|
13 | SOURCES += \ | |
16 | $$PWD/chartaxis.cpp \ |
|
14 | $$PWD/chartaxis.cpp \ | |
17 | $$PWD/qabstractaxis.cpp \ |
|
15 | $$PWD/qabstractaxis.cpp \ | |
18 | $$PWD/valueaxis/chartvalueaxisx.cpp \ |
|
16 | $$PWD/valueaxis/chartvalueaxisx.cpp \ | |
19 | $$PWD/valueaxis/chartvalueaxisy.cpp \ |
|
17 | $$PWD/valueaxis/chartvalueaxisy.cpp \ | |
20 | $$PWD/valueaxis/qvalueaxis.cpp \ |
|
18 | $$PWD/valueaxis/qvalueaxis.cpp \ | |
21 | $$PWD/barcategoryaxis/chartbarcategoryaxisx.cpp \ |
|
19 | $$PWD/barcategoryaxis/chartbarcategoryaxisx.cpp \ | |
22 | $$PWD/barcategoryaxis/chartbarcategoryaxisy.cpp \ |
|
20 | $$PWD/barcategoryaxis/chartbarcategoryaxisy.cpp \ | |
23 | $$PWD/barcategoryaxis/qbarcategoryaxis.cpp \ |
|
21 | $$PWD/barcategoryaxis/qbarcategoryaxis.cpp \ | |
24 | $$PWD/categoryaxis/chartcategoryaxisx.cpp \ |
|
22 | $$PWD/categoryaxis/chartcategoryaxisx.cpp \ | |
25 | $$PWD/categoryaxis/chartcategoryaxisy.cpp \ |
|
23 | $$PWD/categoryaxis/chartcategoryaxisy.cpp \ | |
26 |
$$PWD/categoryaxis/qcategoryaxis.cpp |
|
24 | $$PWD/categoryaxis/qcategoryaxis.cpp | |
27 | $$PWD/datetimeaxis/chartdatetimeaxisx.cpp \ |
|
|||
28 | $$PWD/datetimeaxis/chartdatetimeaxisy.cpp \ |
|
|||
29 | $$PWD/datetimeaxis/qdatetimeaxis.cpp |
|
|||
30 |
|
25 | |||
31 | PRIVATE_HEADERS += \ |
|
26 | PRIVATE_HEADERS += \ | |
32 | $$PWD/chartaxis_p.h \ |
|
27 | $$PWD/chartaxis_p.h \ | |
33 | $$PWD/qabstractaxis_p.h \ |
|
28 | $$PWD/qabstractaxis_p.h \ | |
34 | $$PWD/valueaxis/chartvalueaxisx_p.h \ |
|
29 | $$PWD/valueaxis/chartvalueaxisx_p.h \ | |
35 | $$PWD/valueaxis/chartvalueaxisy_p.h \ |
|
30 | $$PWD/valueaxis/chartvalueaxisy_p.h \ | |
36 | $$PWD/valueaxis/qvalueaxis_p.h \ |
|
31 | $$PWD/valueaxis/qvalueaxis_p.h \ | |
37 | $$PWD/barcategoryaxis/chartbarcategoryaxisx_p.h \ |
|
32 | $$PWD/barcategoryaxis/chartbarcategoryaxisx_p.h \ | |
38 | $$PWD/barcategoryaxis/chartbarcategoryaxisy_p.h \ |
|
33 | $$PWD/barcategoryaxis/chartbarcategoryaxisy_p.h \ | |
39 | $$PWD/barcategoryaxis/qbarcategoryaxis_p.h \ |
|
34 | $$PWD/barcategoryaxis/qbarcategoryaxis_p.h \ | |
40 | $$PWD/categoryaxis/chartcategoryaxisx_p.h \ |
|
35 | $$PWD/categoryaxis/chartcategoryaxisx_p.h \ | |
41 | $$PWD/categoryaxis/chartcategoryaxisy_p.h \ |
|
36 | $$PWD/categoryaxis/chartcategoryaxisy_p.h \ | |
42 |
$$PWD/categoryaxis/qcategoryaxis_p.h |
|
37 | $$PWD/categoryaxis/qcategoryaxis_p.h | |
43 | $$PWD/datetimeaxis/chartdatetimeaxisx_p.h \ |
|
|||
44 | $$PWD/datetimeaxis/chartdatetimeaxisy_p.h \ |
|
|||
45 | $$PWD/datetimeaxis/qdatetimeaxis_p.h |
|
|||
46 |
|
38 | |||
47 | PUBLIC_HEADERS += \ |
|
39 | PUBLIC_HEADERS += \ | |
48 | $$PWD/qabstractaxis.h \ |
|
40 | $$PWD/qabstractaxis.h \ | |
49 | $$PWD/valueaxis/qvalueaxis.h \ |
|
41 | $$PWD/valueaxis/qvalueaxis.h \ | |
50 | $$PWD/barcategoryaxis/qbarcategoryaxis.h \ |
|
42 | $$PWD/barcategoryaxis/qbarcategoryaxis.h \ | |
51 |
$$PWD/categoryaxis/qcategoryaxis.h |
|
43 | $$PWD/categoryaxis/qcategoryaxis.h | |
|
44 | ||||
|
45 | !linux-arm*: { | |||
|
46 | INCLUDEPATH += \ | |||
|
47 | $$PWD/datetimeaxis | |||
|
48 | ||||
|
49 | DEPENDPATH += \ | |||
|
50 | $$PWD/datetimeaxis | |||
|
51 | ||||
|
52 | SOURCES += \ | |||
|
53 | $$PWD/datetimeaxis/chartdatetimeaxisx.cpp \ | |||
|
54 | $$PWD/datetimeaxis/chartdatetimeaxisy.cpp \ | |||
|
55 | $$PWD/datetimeaxis/qdatetimeaxis.cpp | |||
|
56 | ||||
|
57 | PRIVATE_HEADERS += \ | |||
|
58 | $$PWD/datetimeaxis/chartdatetimeaxisx_p.h \ | |||
|
59 | $$PWD/datetimeaxis/chartdatetimeaxisy_p.h \ | |||
|
60 | $$PWD/datetimeaxis/qdatetimeaxis_p.h | |||
|
61 | ||||
|
62 | PUBLIC_HEADERS += \ | |||
52 | $$PWD/datetimeaxis/qdatetimeaxis.h |
|
63 | $$PWD/datetimeaxis/qdatetimeaxis.h | |
|
64 | } |
@@ -1,491 +1,496 | |||||
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 "chartdataset_p.h" |
|
21 | #include "chartdataset_p.h" | |
22 | #include "qchart.h" |
|
22 | #include "qchart.h" | |
23 | #include "qvalueaxis.h" |
|
23 | #include "qvalueaxis.h" | |
24 | #include "qbarcategoryaxis.h" |
|
24 | #include "qbarcategoryaxis.h" | |
25 | #include "qvalueaxis_p.h" |
|
25 | #include "qvalueaxis_p.h" | |
26 | #include "qcategoryaxis.h" |
|
26 | #include "qcategoryaxis.h" | |
27 | #include "qdatetimeaxis.h" |
|
|||
28 | #include "qabstractseries_p.h" |
|
27 | #include "qabstractseries_p.h" | |
29 | #include "qabstractbarseries.h" |
|
28 | #include "qabstractbarseries.h" | |
30 | #include "qstackedbarseries.h" |
|
29 | #include "qstackedbarseries.h" | |
31 | #include "qpercentbarseries.h" |
|
30 | #include "qpercentbarseries.h" | |
32 | #include "qpieseries.h" |
|
31 | #include "qpieseries.h" | |
33 |
|
32 | |||
|
33 | #ifndef QT_ON_ARM | |||
|
34 | #include "qdatetimeaxis.h" | |||
|
35 | #endif | |||
|
36 | ||||
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
35 |
|
38 | |||
36 | ChartDataSet::ChartDataSet(QChart *parent):QObject(parent) |
|
39 | ChartDataSet::ChartDataSet(QChart *parent):QObject(parent) | |
37 | { |
|
40 | { | |
38 |
|
41 | |||
39 | } |
|
42 | } | |
40 |
|
43 | |||
41 | ChartDataSet::~ChartDataSet() |
|
44 | ChartDataSet::~ChartDataSet() | |
42 | { |
|
45 | { | |
43 | removeAllSeries(); |
|
46 | removeAllSeries(); | |
44 | } |
|
47 | } | |
45 |
|
48 | |||
46 | void ChartDataSet::addSeries(QAbstractSeries* series) |
|
49 | void ChartDataSet::addSeries(QAbstractSeries* series) | |
47 | { |
|
50 | { | |
48 | Domain* domain = m_seriesDomainMap.value(series); |
|
51 | Domain* domain = m_seriesDomainMap.value(series); | |
49 |
|
52 | |||
50 | if(domain) { |
|
53 | if(domain) { | |
51 | qWarning() << "Can not add series. Series already on the chart"; |
|
54 | qWarning() << "Can not add series. Series already on the chart"; | |
52 | return; |
|
55 | return; | |
53 | } |
|
56 | } | |
54 |
|
57 | |||
55 | domain = new Domain(series); |
|
58 | domain = new Domain(series); | |
56 | m_seriesDomainMap.insert(series,domain); |
|
59 | m_seriesDomainMap.insert(series,domain); | |
57 | series->d_ptr->scaleDomain(*domain); |
|
60 | series->d_ptr->scaleDomain(*domain); | |
58 |
|
61 | |||
59 | createSeriesIndex(series); |
|
62 | createSeriesIndex(series); | |
60 |
|
63 | |||
61 | series->setParent(this); // take ownership |
|
64 | series->setParent(this); // take ownership | |
62 | series->d_ptr->m_chart = qobject_cast<QChart*>(parent()); |
|
65 | series->d_ptr->m_chart = qobject_cast<QChart*>(parent()); | |
63 | series->d_ptr->m_dataset = this; |
|
66 | series->d_ptr->m_dataset = this; | |
64 |
|
67 | |||
65 | emit seriesAdded(series,domain); |
|
68 | emit seriesAdded(series,domain); | |
66 |
|
69 | |||
67 | } |
|
70 | } | |
68 |
|
71 | |||
69 | void ChartDataSet::removeSeries(QAbstractSeries* series) |
|
72 | void ChartDataSet::removeSeries(QAbstractSeries* series) | |
70 | { |
|
73 | { | |
71 |
|
74 | |||
72 | if(!m_seriesDomainMap.contains(series)) { |
|
75 | if(!m_seriesDomainMap.contains(series)) { | |
73 | qWarning()<<"Can not remove series. Series not found on the chart."; |
|
76 | qWarning()<<"Can not remove series. Series not found on the chart."; | |
74 | return; |
|
77 | return; | |
75 | } |
|
78 | } | |
76 |
|
79 | |||
77 | emit seriesRemoved(series); |
|
80 | emit seriesRemoved(series); | |
78 |
|
81 | |||
79 | Domain* domain = m_seriesDomainMap.take(series); |
|
82 | Domain* domain = m_seriesDomainMap.take(series); | |
80 | delete domain; |
|
83 | delete domain; | |
81 | domain = 0; |
|
84 | domain = 0; | |
82 |
|
85 | |||
83 | removeSeriesIndex(series); |
|
86 | removeSeriesIndex(series); | |
84 |
|
87 | |||
85 | series->setParent(0); |
|
88 | series->setParent(0); | |
86 | series->d_ptr->m_chart = 0; |
|
89 | series->d_ptr->m_chart = 0; | |
87 | series->d_ptr->m_dataset = 0; |
|
90 | series->d_ptr->m_dataset = 0; | |
88 |
|
91 | |||
89 | removeAxes(series); |
|
92 | removeAxes(series); | |
90 | } |
|
93 | } | |
91 |
|
94 | |||
92 |
|
95 | |||
93 |
|
96 | |||
94 | void ChartDataSet::createSeriesIndex(QAbstractSeries* series) |
|
97 | void ChartDataSet::createSeriesIndex(QAbstractSeries* series) | |
95 | { |
|
98 | { | |
96 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); |
|
99 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); | |
97 |
|
100 | |||
98 | int key=0; |
|
101 | int key=0; | |
99 | while (i.hasNext()) { |
|
102 | while (i.hasNext()) { | |
100 | i.next(); |
|
103 | i.next(); | |
101 | if(i.key()!=key) { |
|
104 | if(i.key()!=key) { | |
102 | break; |
|
105 | break; | |
103 | } |
|
106 | } | |
104 | key++; |
|
107 | key++; | |
105 | } |
|
108 | } | |
106 |
|
109 | |||
107 | m_indexSeriesMap.insert(key,series); |
|
110 | m_indexSeriesMap.insert(key,series); | |
108 | } |
|
111 | } | |
109 |
|
112 | |||
110 | void ChartDataSet::removeSeriesIndex(QAbstractSeries* series) |
|
113 | void ChartDataSet::removeSeriesIndex(QAbstractSeries* series) | |
111 | { |
|
114 | { | |
112 | int key = seriesIndex(series); |
|
115 | int key = seriesIndex(series); | |
113 | Q_ASSERT(key!=-1); |
|
116 | Q_ASSERT(key!=-1); | |
114 | m_indexSeriesMap.remove(key); |
|
117 | m_indexSeriesMap.remove(key); | |
115 | } |
|
118 | } | |
116 |
|
119 | |||
117 | void ChartDataSet::createDefaultAxes() |
|
120 | void ChartDataSet::createDefaultAxes() | |
118 | { |
|
121 | { | |
119 | if (m_seriesDomainMap.isEmpty()) |
|
122 | if (m_seriesDomainMap.isEmpty()) | |
120 | return; |
|
123 | return; | |
121 |
|
124 | |||
122 | QAbstractAxis::AxisTypes typeX(0); |
|
125 | QAbstractAxis::AxisTypes typeX(0); | |
123 | QAbstractAxis::AxisTypes typeY(0); |
|
126 | QAbstractAxis::AxisTypes typeY(0); | |
124 |
|
127 | |||
125 | // Remove possibly existing axes |
|
128 | // Remove possibly existing axes | |
126 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
129 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
127 | while (i.hasNext()) { |
|
130 | while (i.hasNext()) { | |
128 | i.next(); |
|
131 | i.next(); | |
129 | removeAxes(i.key()); |
|
132 | removeAxes(i.key()); | |
130 | } |
|
133 | } | |
131 |
|
134 | |||
132 | i.toFront(); |
|
135 | i.toFront(); | |
133 |
|
136 | |||
134 | // Select the required axis x and axis y types based on the types of the current series |
|
137 | // Select the required axis x and axis y types based on the types of the current series | |
135 | while (i.hasNext()) { |
|
138 | while (i.hasNext()) { | |
136 | i.next(); |
|
139 | i.next(); | |
137 |
|
140 | |||
138 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); |
|
141 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); | |
139 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); |
|
142 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); | |
140 | if(axisX) typeX&=axisX->type(); |
|
143 | if(axisX) typeX&=axisX->type(); | |
141 | else typeX|=i.key()->d_ptr->defaultAxisType(Qt::Horizontal); |
|
144 | else typeX|=i.key()->d_ptr->defaultAxisType(Qt::Horizontal); | |
142 | if(axisY) typeY&=axisY->type(); |
|
145 | if(axisY) typeY&=axisY->type(); | |
143 | else typeY|=i.key()->d_ptr->defaultAxisType(Qt::Vertical); |
|
146 | else typeY|=i.key()->d_ptr->defaultAxisType(Qt::Vertical); | |
144 | } |
|
147 | } | |
145 |
|
148 | |||
146 | // Create the axes of the types selected |
|
149 | // Create the axes of the types selected | |
147 | createAxes(typeX, Qt::Horizontal); |
|
150 | createAxes(typeX, Qt::Horizontal); | |
148 | createAxes(typeY, Qt::Vertical); |
|
151 | createAxes(typeY, Qt::Vertical); | |
149 | } |
|
152 | } | |
150 |
|
153 | |||
151 | void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation orientation) |
|
154 | void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation orientation) | |
152 | { |
|
155 | { | |
153 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
156 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
154 |
|
157 | |||
155 | // TODO: Add a descriptive comment of what happens here |
|
158 | // TODO: Add a descriptive comment of what happens here | |
156 | if (type.testFlag(QAbstractAxis::AxisTypeValue) && type.testFlag(QAbstractAxis::AxisTypeBarCategory)) { |
|
159 | if (type.testFlag(QAbstractAxis::AxisTypeValue) && type.testFlag(QAbstractAxis::AxisTypeBarCategory)) { | |
157 | while (i.hasNext()) { |
|
160 | while (i.hasNext()) { | |
158 | i.next(); |
|
161 | i.next(); | |
159 | QAbstractAxis* axis = createAxis(i.key()->d_ptr->defaultAxisType(orientation), orientation); |
|
162 | QAbstractAxis* axis = createAxis(i.key()->d_ptr->defaultAxisType(orientation), orientation); | |
160 | if (axis) { |
|
163 | if (axis) { | |
161 | initializeAxis(axis, i.key()); |
|
164 | initializeAxis(axis, i.key()); | |
162 | emit axisAdded(axis, i.value()); |
|
165 | emit axisAdded(axis, i.value()); | |
163 | } |
|
166 | } | |
164 | } |
|
167 | } | |
165 | } else if (!type.testFlag(QAbstractAxis::AxisTypeNoAxis)) { |
|
168 | } else if (!type.testFlag(QAbstractAxis::AxisTypeNoAxis)) { | |
166 | QAbstractAxis* axis = createAxis(QAbstractAxis::AxisType(int(type)), orientation); |
|
169 | QAbstractAxis* axis = createAxis(QAbstractAxis::AxisType(int(type)), orientation); | |
167 | i.toFront(); |
|
170 | i.toFront(); | |
168 | while (i.hasNext()) { |
|
171 | while (i.hasNext()) { | |
169 | i.next(); |
|
172 | i.next(); | |
170 | initializeAxis(axis,i.key()); |
|
173 | initializeAxis(axis,i.key()); | |
171 | } |
|
174 | } | |
172 | emit axisAdded(axis,i.value()); |
|
175 | emit axisAdded(axis,i.value()); | |
173 | } |
|
176 | } | |
174 | } |
|
177 | } | |
175 |
|
178 | |||
176 | QAbstractAxis* ChartDataSet::createAxis(QAbstractAxis::AxisType type, Qt::Orientation orientation) |
|
179 | QAbstractAxis* ChartDataSet::createAxis(QAbstractAxis::AxisType type, Qt::Orientation orientation) | |
177 | { |
|
180 | { | |
178 | QAbstractAxis* axis = 0; |
|
181 | QAbstractAxis* axis = 0; | |
179 |
|
182 | |||
180 | switch(type) { |
|
183 | switch(type) { | |
181 | case QAbstractAxis::AxisTypeValue: |
|
184 | case QAbstractAxis::AxisTypeValue: | |
182 | axis = new QValueAxis(this); |
|
185 | axis = new QValueAxis(this); | |
183 | break; |
|
186 | break; | |
184 | case QAbstractAxis::AxisTypeBarCategory: |
|
187 | case QAbstractAxis::AxisTypeBarCategory: | |
185 | axis = new QBarCategoryAxis(this); |
|
188 | axis = new QBarCategoryAxis(this); | |
186 | break; |
|
189 | break; | |
187 | case QAbstractAxis::AxisTypeCategory: |
|
190 | case QAbstractAxis::AxisTypeCategory: | |
188 | axis = new QCategoryAxis(this); |
|
191 | axis = new QCategoryAxis(this); | |
189 | break; |
|
192 | break; | |
|
193 | #ifndef Q_WS_QWS | |||
190 | case QAbstractAxis::AxisTypeDateTime: |
|
194 | case QAbstractAxis::AxisTypeDateTime: | |
191 | axis = new QDateTimeAxis(this); |
|
195 | axis = new QDateTimeAxis(this); | |
192 | break; |
|
196 | break; | |
|
197 | #endif | |||
193 | default: |
|
198 | default: | |
194 | axis = 0; |
|
199 | axis = 0; | |
195 | break; |
|
200 | break; | |
196 | } |
|
201 | } | |
197 |
|
202 | |||
198 | if(axis) |
|
203 | if(axis) | |
199 | axis->d_ptr->setOrientation(orientation); |
|
204 | axis->d_ptr->setOrientation(orientation); | |
200 |
|
205 | |||
201 | return axis; |
|
206 | return axis; | |
202 | } |
|
207 | } | |
203 |
|
208 | |||
204 | void ChartDataSet::initializeAxis(QAbstractAxis* axis,QAbstractSeries* series) |
|
209 | void ChartDataSet::initializeAxis(QAbstractAxis* axis,QAbstractSeries* series) | |
205 | { |
|
210 | { | |
206 | Domain* domain = m_seriesDomainMap.value(series); |
|
211 | Domain* domain = m_seriesDomainMap.value(series); | |
207 | axis->d_ptr->m_dataset = this; |
|
212 | axis->d_ptr->m_dataset = this; | |
208 | series->d_ptr->initializeAxis(axis); |
|
213 | series->d_ptr->initializeAxis(axis); | |
209 | axis->d_ptr->intializeDomain(domain); |
|
214 | axis->d_ptr->intializeDomain(domain); | |
210 | if(axis->orientation()==Qt::Horizontal) { |
|
215 | if(axis->orientation()==Qt::Horizontal) { | |
211 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); |
|
216 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); | |
212 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); |
|
217 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); | |
213 | m_seriesAxisXMap.insert(series,axis); |
|
218 | m_seriesAxisXMap.insert(series,axis); | |
214 | } |
|
219 | } | |
215 | else { |
|
220 | else { | |
216 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); |
|
221 | QObject::connect(axis->d_ptr.data(),SIGNAL(updated()),domain,SLOT(handleAxisUpdated())); | |
217 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); |
|
222 | QObject::connect(domain,SIGNAL(updated()),axis->d_ptr.data(),SLOT(handleDomainUpdated())); | |
218 | m_seriesAxisYMap.insert(series,axis); |
|
223 | m_seriesAxisYMap.insert(series,axis); | |
219 | } |
|
224 | } | |
220 | axis->d_ptr->emitUpdated(); |
|
225 | axis->d_ptr->emitUpdated(); | |
221 | } |
|
226 | } | |
222 |
|
227 | |||
223 | void ChartDataSet::removeAxes(QAbstractSeries* series) |
|
228 | void ChartDataSet::removeAxes(QAbstractSeries* series) | |
224 | { |
|
229 | { | |
225 | QAbstractAxis* axisX = m_seriesAxisXMap.take(series); |
|
230 | QAbstractAxis* axisX = m_seriesAxisXMap.take(series); | |
226 |
|
231 | |||
227 | if(axisX) { |
|
232 | if(axisX) { | |
228 | QList<QAbstractAxis*> axesX = m_seriesAxisXMap.values(); |
|
233 | QList<QAbstractAxis*> axesX = m_seriesAxisXMap.values(); | |
229 | int x = axesX.indexOf(axisX); |
|
234 | int x = axesX.indexOf(axisX); | |
230 |
|
235 | |||
231 | if(x==-1) { |
|
236 | if(x==-1) { | |
232 | emit axisRemoved(axisX); |
|
237 | emit axisRemoved(axisX); | |
233 | axisX->d_ptr->m_dataset=0; |
|
238 | axisX->d_ptr->m_dataset=0; | |
234 | axisX->deleteLater(); |
|
239 | axisX->deleteLater(); | |
235 | } |
|
240 | } | |
236 | } |
|
241 | } | |
237 |
|
242 | |||
238 | QAbstractAxis* axisY = m_seriesAxisYMap.take(series); |
|
243 | QAbstractAxis* axisY = m_seriesAxisYMap.take(series); | |
239 |
|
244 | |||
240 | if(axisY) { |
|
245 | if(axisY) { | |
241 | QList<QAbstractAxis*> axesY = m_seriesAxisYMap.values(); |
|
246 | QList<QAbstractAxis*> axesY = m_seriesAxisYMap.values(); | |
242 |
|
247 | |||
243 | int y = axesY.indexOf(axisY); |
|
248 | int y = axesY.indexOf(axisY); | |
244 |
|
249 | |||
245 | if(y==-1) { |
|
250 | if(y==-1) { | |
246 | emit axisRemoved(axisY); |
|
251 | emit axisRemoved(axisY); | |
247 | axisY->d_ptr->m_dataset=0; |
|
252 | axisY->d_ptr->m_dataset=0; | |
248 | axisY->deleteLater(); |
|
253 | axisY->deleteLater(); | |
249 | } |
|
254 | } | |
250 | } |
|
255 | } | |
251 | } |
|
256 | } | |
252 |
|
257 | |||
253 | void ChartDataSet::removeAxis(QAbstractAxis* axis) |
|
258 | void ChartDataSet::removeAxis(QAbstractAxis* axis) | |
254 | { |
|
259 | { | |
255 | if(!axis->d_ptr->m_dataset) { |
|
260 | if(!axis->d_ptr->m_dataset) { | |
256 | qWarning()<<"UnBound axis found !"; |
|
261 | qWarning()<<"UnBound axis found !"; | |
257 | return; |
|
262 | return; | |
258 | } |
|
263 | } | |
259 |
|
264 | |||
260 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; |
|
265 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; | |
261 |
|
266 | |||
262 | if(axis->orientation()==Qt::Vertical) { |
|
267 | if(axis->orientation()==Qt::Vertical) { | |
263 | seriesAxisMap= &m_seriesAxisYMap; |
|
268 | seriesAxisMap= &m_seriesAxisYMap; | |
264 | } |
|
269 | } | |
265 | else { |
|
270 | else { | |
266 | seriesAxisMap= &m_seriesAxisXMap; |
|
271 | seriesAxisMap= &m_seriesAxisXMap; | |
267 | } |
|
272 | } | |
268 |
|
273 | |||
269 | QMapIterator<QAbstractSeries*, QAbstractAxis*> i(*seriesAxisMap); |
|
274 | QMapIterator<QAbstractSeries*, QAbstractAxis*> i(*seriesAxisMap); | |
270 |
|
275 | |||
271 | while (i.hasNext()) { |
|
276 | while (i.hasNext()) { | |
272 | i.next(); |
|
277 | i.next(); | |
273 | if(i.value()==axis) { |
|
278 | if(i.value()==axis) { | |
274 | removeSeries(i.key()); |
|
279 | removeSeries(i.key()); | |
275 | } |
|
280 | } | |
276 | } |
|
281 | } | |
277 | } |
|
282 | } | |
278 |
|
283 | |||
279 | void ChartDataSet::removeAllSeries() |
|
284 | void ChartDataSet::removeAllSeries() | |
280 | { |
|
285 | { | |
281 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); |
|
286 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); | |
282 | foreach(QAbstractSeries *s , series) { |
|
287 | foreach(QAbstractSeries *s , series) { | |
283 | removeSeries(s); |
|
288 | removeSeries(s); | |
284 | } |
|
289 | } | |
285 |
|
290 | |||
286 | Q_ASSERT(m_seriesAxisXMap.count()==0); |
|
291 | Q_ASSERT(m_seriesAxisXMap.count()==0); | |
287 | Q_ASSERT(m_seriesAxisXMap.count()==0); |
|
292 | Q_ASSERT(m_seriesAxisXMap.count()==0); | |
288 | Q_ASSERT(m_seriesDomainMap.count()==0); |
|
293 | Q_ASSERT(m_seriesDomainMap.count()==0); | |
289 |
|
294 | |||
290 | qDeleteAll(series); |
|
295 | qDeleteAll(series); | |
291 | } |
|
296 | } | |
292 |
|
297 | |||
293 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) |
|
298 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) | |
294 | { |
|
299 | { | |
295 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates |
|
300 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates | |
296 |
|
301 | |||
297 |
|
302 | |||
298 | blockAxisSignals(true); |
|
303 | blockAxisSignals(true); | |
299 |
|
304 | |||
300 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
305 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
301 |
|
306 | |||
302 | while (i.hasNext()) { |
|
307 | while (i.hasNext()) { | |
303 | i.next(); |
|
308 | i.next(); | |
304 | i.value()->zoomIn(rect,size); |
|
309 | i.value()->zoomIn(rect,size); | |
305 | } |
|
310 | } | |
306 |
|
311 | |||
307 | blockAxisSignals(false); |
|
312 | blockAxisSignals(false); | |
308 |
|
313 | |||
309 | } |
|
314 | } | |
310 |
|
315 | |||
311 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) |
|
316 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) | |
312 | { |
|
317 | { | |
313 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates |
|
318 | //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates | |
314 |
|
319 | |||
315 | blockAxisSignals(true); |
|
320 | blockAxisSignals(true); | |
316 |
|
321 | |||
317 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
322 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
318 |
|
323 | |||
319 | while (i.hasNext()) { |
|
324 | while (i.hasNext()) { | |
320 | i.next(); |
|
325 | i.next(); | |
321 | i.value()->zoomOut(rect,size); |
|
326 | i.value()->zoomOut(rect,size); | |
322 | } |
|
327 | } | |
323 |
|
328 | |||
324 | blockAxisSignals(false); |
|
329 | blockAxisSignals(false); | |
325 | } |
|
330 | } | |
326 |
|
331 | |||
327 | void ChartDataSet::blockAxisSignals(bool enabled) |
|
332 | void ChartDataSet::blockAxisSignals(bool enabled) | |
328 | { |
|
333 | { | |
329 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
334 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
330 | while (i.hasNext()) { |
|
335 | while (i.hasNext()) { | |
331 | i.next(); |
|
336 | i.next(); | |
332 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); |
|
337 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); | |
333 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); |
|
338 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); | |
334 | if(axisX) { |
|
339 | if(axisX) { | |
335 | axisX->d_ptr->blockSignals(enabled); |
|
340 | axisX->d_ptr->blockSignals(enabled); | |
336 | if(!enabled) { |
|
341 | if(!enabled) { | |
337 | axisX->d_ptr->setDirty(false); |
|
342 | axisX->d_ptr->setDirty(false); | |
338 | axisX->d_ptr->emitUpdated(); |
|
343 | axisX->d_ptr->emitUpdated(); | |
339 | } |
|
344 | } | |
340 | } |
|
345 | } | |
341 | if(axisY) { |
|
346 | if(axisY) { | |
342 | axisY->d_ptr->blockSignals(enabled); |
|
347 | axisY->d_ptr->blockSignals(enabled); | |
343 | if(!enabled) { |
|
348 | if(!enabled) { | |
344 | axisY->d_ptr->setDirty(false); |
|
349 | axisY->d_ptr->setDirty(false); | |
345 | axisY->d_ptr->emitUpdated(); |
|
350 | axisY->d_ptr->emitUpdated(); | |
346 | } |
|
351 | } | |
347 | } |
|
352 | } | |
348 | } |
|
353 | } | |
349 | } |
|
354 | } | |
350 |
|
355 | |||
351 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) |
|
356 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) | |
352 | { |
|
357 | { | |
353 | int count=0; |
|
358 | int count=0; | |
354 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
359 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
355 | while (i.hasNext()) { |
|
360 | while (i.hasNext()) { | |
356 | i.next(); |
|
361 | i.next(); | |
357 | if(i.key()->type()==type) count++; |
|
362 | if(i.key()->type()==type) count++; | |
358 | } |
|
363 | } | |
359 | return count; |
|
364 | return count; | |
360 | } |
|
365 | } | |
361 |
|
366 | |||
362 | int ChartDataSet::seriesIndex(QAbstractSeries *series) |
|
367 | int ChartDataSet::seriesIndex(QAbstractSeries *series) | |
363 | { |
|
368 | { | |
364 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); |
|
369 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); | |
365 | while (i.hasNext()) { |
|
370 | while (i.hasNext()) { | |
366 | i.next(); |
|
371 | i.next(); | |
367 | if (i.value() == series) |
|
372 | if (i.value() == series) | |
368 | return i.key(); |
|
373 | return i.key(); | |
369 | } |
|
374 | } | |
370 | return -1; |
|
375 | return -1; | |
371 | } |
|
376 | } | |
372 |
|
377 | |||
373 | QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const |
|
378 | QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const | |
374 | { |
|
379 | { | |
375 | if(series == 0) { |
|
380 | if(series == 0) { | |
376 |
|
381 | |||
377 | QMapIterator<QAbstractSeries*, QAbstractAxis *> i(m_seriesAxisXMap); |
|
382 | QMapIterator<QAbstractSeries*, QAbstractAxis *> i(m_seriesAxisXMap); | |
378 |
|
383 | |||
379 | while (i.hasNext()) { |
|
384 | while (i.hasNext()) { | |
380 | i.next(); |
|
385 | i.next(); | |
381 | if(i.value()->isVisible()) return i.value(); |
|
386 | if(i.value()->isVisible()) return i.value(); | |
382 | } |
|
387 | } | |
383 | return 0; |
|
388 | return 0; | |
384 | } |
|
389 | } | |
385 | return m_seriesAxisXMap.value(series); |
|
390 | return m_seriesAxisXMap.value(series); | |
386 | } |
|
391 | } | |
387 |
|
392 | |||
388 | QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const |
|
393 | QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const | |
389 | { |
|
394 | { | |
390 | if(series == 0) { |
|
395 | if(series == 0) { | |
391 | QMapIterator<QAbstractSeries*, QAbstractAxis *> i(m_seriesAxisYMap); |
|
396 | QMapIterator<QAbstractSeries*, QAbstractAxis *> i(m_seriesAxisYMap); | |
392 |
|
397 | |||
393 | while (i.hasNext()) { |
|
398 | while (i.hasNext()) { | |
394 | i.next(); |
|
399 | i.next(); | |
395 | if(i.value()->isVisible()) return i.value(); |
|
400 | if(i.value()->isVisible()) return i.value(); | |
396 | } |
|
401 | } | |
397 | return 0; |
|
402 | return 0; | |
398 | } |
|
403 | } | |
399 | return m_seriesAxisYMap.value(series); |
|
404 | return m_seriesAxisYMap.value(series); | |
400 | } |
|
405 | } | |
401 |
|
406 | |||
402 | void ChartDataSet::setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Orientation orientation) |
|
407 | void ChartDataSet::setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Orientation orientation) | |
403 | { |
|
408 | { | |
404 | Q_ASSERT(axis); |
|
409 | Q_ASSERT(axis); | |
405 |
|
410 | |||
406 | if(!series) { |
|
411 | if(!series) { | |
407 | qWarning() << "Series not found on the chart."; |
|
412 | qWarning() << "Series not found on the chart."; | |
408 | return; |
|
413 | return; | |
409 | } |
|
414 | } | |
410 |
|
415 | |||
411 | Domain* domain = m_seriesDomainMap.value(series); |
|
416 | Domain* domain = m_seriesDomainMap.value(series); | |
412 |
|
417 | |||
413 | if(!domain) { |
|
418 | if(!domain) { | |
414 | qWarning() << "Series not found on the chart."; |
|
419 | qWarning() << "Series not found on the chart."; | |
415 | return; |
|
420 | return; | |
416 | } |
|
421 | } | |
417 |
|
422 | |||
418 | if(orientation==Qt::Horizontal && axis->orientation()==Qt::Vertical) { |
|
423 | if(orientation==Qt::Horizontal && axis->orientation()==Qt::Vertical) { | |
419 | qWarning()<<"Axis already defined as axis Y"; |
|
424 | qWarning()<<"Axis already defined as axis Y"; | |
420 | return; |
|
425 | return; | |
421 | } |
|
426 | } | |
422 |
|
427 | |||
423 | if(orientation==Qt::Vertical && axis->orientation()==Qt::Horizontal) { |
|
428 | if(orientation==Qt::Vertical && axis->orientation()==Qt::Horizontal) { | |
424 | qWarning()<<"Axis already defined as axis X"; |
|
429 | qWarning()<<"Axis already defined as axis X"; | |
425 | return; |
|
430 | return; | |
426 | } |
|
431 | } | |
427 |
|
432 | |||
428 | axis->d_ptr->setOrientation(orientation); |
|
433 | axis->d_ptr->setOrientation(orientation); | |
429 |
|
434 | |||
430 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; |
|
435 | QMap<QAbstractSeries*, QAbstractAxis*> *seriesAxisMap; | |
431 |
|
436 | |||
432 | if(orientation==Qt::Vertical) { |
|
437 | if(orientation==Qt::Vertical) { | |
433 | seriesAxisMap= &m_seriesAxisYMap; |
|
438 | seriesAxisMap= &m_seriesAxisYMap; | |
434 | }else{ |
|
439 | }else{ | |
435 | seriesAxisMap= &m_seriesAxisXMap; |
|
440 | seriesAxisMap= &m_seriesAxisXMap; | |
436 | } |
|
441 | } | |
437 |
|
442 | |||
438 | if (seriesAxisMap->value(series) == axis) { |
|
443 | if (seriesAxisMap->value(series) == axis) { | |
439 | qWarning() << "The axis already set for the series"; |
|
444 | qWarning() << "The axis already set for the series"; | |
440 | return; |
|
445 | return; | |
441 | } |
|
446 | } | |
442 |
|
447 | |||
443 | QAbstractAxis *oldAxis = seriesAxisMap->take(series); |
|
448 | QAbstractAxis *oldAxis = seriesAxisMap->take(series); | |
444 | QList<QAbstractAxis*> axes = seriesAxisMap->values(); |
|
449 | QList<QAbstractAxis*> axes = seriesAxisMap->values(); | |
445 | if(oldAxis) { |
|
450 | if(oldAxis) { | |
446 | if(axes.indexOf(oldAxis)==-1) { |
|
451 | if(axes.indexOf(oldAxis)==-1) { | |
447 | emit axisRemoved(oldAxis); |
|
452 | emit axisRemoved(oldAxis); | |
448 | oldAxis->disconnect(); |
|
453 | oldAxis->disconnect(); | |
449 | QObject::disconnect(domain,0,oldAxis,0); |
|
454 | QObject::disconnect(domain,0,oldAxis,0); | |
450 | oldAxis->d_ptr->m_dataset=0; |
|
455 | oldAxis->d_ptr->m_dataset=0; | |
451 | oldAxis->deleteLater(); |
|
456 | oldAxis->deleteLater(); | |
452 | } |
|
457 | } | |
453 | } |
|
458 | } | |
454 |
|
459 | |||
455 | if(axes.indexOf(axis)==-1) { |
|
460 | if(axes.indexOf(axis)==-1) { | |
456 | initializeAxis(axis,series); |
|
461 | initializeAxis(axis,series); | |
457 | emit axisAdded(axis,domain); |
|
462 | emit axisAdded(axis,domain); | |
458 | }else{ |
|
463 | }else{ | |
459 | initializeAxis(axis,series); |
|
464 | initializeAxis(axis,series); | |
460 | } |
|
465 | } | |
461 | } |
|
466 | } | |
462 |
|
467 | |||
463 | Domain* ChartDataSet::domain(QAbstractSeries *series) const |
|
468 | Domain* ChartDataSet::domain(QAbstractSeries *series) const | |
464 | { |
|
469 | { | |
465 | return m_seriesDomainMap.value(series); |
|
470 | return m_seriesDomainMap.value(series); | |
466 | } |
|
471 | } | |
467 |
|
472 | |||
468 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) |
|
473 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) | |
469 | { |
|
474 | { | |
470 | blockAxisSignals(true); |
|
475 | blockAxisSignals(true); | |
471 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
476 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
472 | while (i.hasNext()) { |
|
477 | while (i.hasNext()) { | |
473 | i.next(); |
|
478 | i.next(); | |
474 | i.value()->move(dx,dy,size); |
|
479 | i.value()->move(dx,dy,size); | |
475 | } |
|
480 | } | |
476 | blockAxisSignals(false); |
|
481 | blockAxisSignals(false); | |
477 | } |
|
482 | } | |
478 |
|
483 | |||
479 | QList<QAbstractSeries*> ChartDataSet::series() const |
|
484 | QList<QAbstractSeries*> ChartDataSet::series() const | |
480 | { |
|
485 | { | |
481 | return m_seriesDomainMap.keys(); |
|
486 | return m_seriesDomainMap.keys(); | |
482 | } |
|
487 | } | |
483 |
|
488 | |||
484 | void ChartDataSet::updateSeries(QAbstractSeries *series) |
|
489 | void ChartDataSet::updateSeries(QAbstractSeries *series) | |
485 | { |
|
490 | { | |
486 | emit seriesUpdated(series); |
|
491 | emit seriesUpdated(series); | |
487 | } |
|
492 | } | |
488 |
|
493 | |||
489 | #include "moc_chartdataset_p.cpp" |
|
494 | #include "moc_chartdataset_p.cpp" | |
490 |
|
495 | |||
491 | QTCOMMERCIALCHART_END_NAMESPACE |
|
496 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,30 +1,34 | |||||
1 | !include( ../tests.pri ) { |
|
1 | !include( ../tests.pri ) { | |
2 | error( "Couldn't find the tests.pri file!" ) |
|
2 | error( "Couldn't find the tests.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | TEMPLATE = subdirs |
|
5 | TEMPLATE = subdirs | |
6 | SUBDIRS += \ |
|
6 | SUBDIRS += \ | |
7 | qchartview \ |
|
7 | qchartview \ | |
8 | qchart \ |
|
8 | qchart \ | |
9 | qlineseries \ |
|
9 | qlineseries \ | |
10 | qbarset \ |
|
10 | qbarset \ | |
11 | qbarseries \ |
|
11 | qbarseries \ | |
12 | qstackedbarseries \ |
|
12 | qstackedbarseries \ | |
13 | qpercentbarseries \ |
|
13 | qpercentbarseries \ | |
14 | qpieslice qpieseries \ |
|
14 | qpieslice qpieseries \ | |
15 | qpiemodelmapper \ |
|
15 | qpiemodelmapper \ | |
16 | qsplineseries \ |
|
16 | qsplineseries \ | |
17 | qscatterseries \ |
|
17 | qscatterseries \ | |
18 | qxymodelmapper \ |
|
18 | qxymodelmapper \ | |
19 | qbarmodelmapper \ |
|
19 | qbarmodelmapper \ | |
20 | qhorizontalbarseries \ |
|
20 | qhorizontalbarseries \ | |
21 | qhorizontalstackedbarseries \ |
|
21 | qhorizontalstackedbarseries \ | |
22 | qhorizontalpercentbarseries \ |
|
22 | qhorizontalpercentbarseries \ | |
23 | qvalueaxis \ |
|
23 | qvalueaxis \ | |
24 | qcategoryaxis \ |
|
24 | qcategoryaxis \ | |
25 | qdatetimeaxis \ |
|
|||
26 | qbarcategoryaxis |
|
25 | qbarcategoryaxis | |
27 |
|
26 | |||
|
27 | !linux-arm*: { | |||
|
28 | SUBDIRS += \ | |||
|
29 | qdatetimeaxis | |||
|
30 | } | |||
|
31 | ||||
28 | test_private:{ |
|
32 | test_private:{ | |
29 | SUBDIRS += domain chartdataset |
|
33 | SUBDIRS += domain chartdataset | |
30 | } |
|
34 | } |
General Comments 0
You need to be logged in to leave comments.
Login now