@@ -1,93 +1,69 | |||||
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 "declarativeareaseries.h" |
|
21 | #include "declarativeareaseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qxymodelmapper.h" |
|
24 | #include "qxymodelmapper.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \qmlclass AreaSeries QAreaSeries |
|
29 | \qmlclass AreaSeries QAreaSeries | |
30 |
|
30 | |||
31 | \section1 Example Usage |
|
31 | \section1 Example Usage | |
32 |
|
32 | |||
33 | \beginfloatleft |
|
33 | \beginfloatleft | |
34 | \image demos_qmlchart4.png |
|
34 | \image demos_qmlchart4.png | |
35 | \endfloat |
|
35 | \endfloat | |
36 | \clearfloat |
|
36 | \clearfloat | |
37 |
|
37 | |||
38 | The following QML shows how to create a simple area chart: |
|
38 | The following QML shows how to create a simple area chart: | |
39 | \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1 |
|
39 | \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1 | |
40 | */ |
|
40 | */ | |
41 |
|
41 | |||
42 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : |
|
42 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : | |
43 | QAreaSeries(parent) |
|
43 | QAreaSeries(parent) | |
44 | { |
|
44 | { | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series) |
|
47 | void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series) | |
48 | { |
|
48 | { | |
49 | QAreaSeries::setUpperSeries(series); |
|
49 | QAreaSeries::setUpperSeries(series); | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const |
|
52 | DeclarativeLineSeries* DeclarativeAreaSeries::upperSeries() const | |
53 | { |
|
53 | { | |
54 | return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries()); |
|
54 | return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::upperSeries()); | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series) |
|
57 | void DeclarativeAreaSeries::setLowerSeries(DeclarativeLineSeries* series) | |
58 | { |
|
58 | { | |
59 | QAreaSeries::setLowerSeries(series); |
|
59 | QAreaSeries::setLowerSeries(series); | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const |
|
62 | DeclarativeLineSeries* DeclarativeAreaSeries::lowerSeries() const | |
63 | { |
|
63 | { | |
64 | return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries()); |
|
64 | return qobject_cast<DeclarativeLineSeries *>(QAreaSeries::lowerSeries()); | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | QColor DeclarativeAreaSeries::penColor() const |
|
|||
68 | { |
|
|||
69 | return pen().color(); |
|
|||
70 | } |
|
|||
71 |
|
||||
72 | void DeclarativeAreaSeries::setPenColor(QColor color) |
|
|||
73 | { |
|
|||
74 | QPen p = pen(); |
|
|||
75 | p.setColor(color); |
|
|||
76 | setPen(p); |
|
|||
77 | } |
|
|||
78 |
|
||||
79 | QColor DeclarativeAreaSeries::brushColor() const |
|
|||
80 | { |
|
|||
81 | return brush().color(); |
|
|||
82 | } |
|
|||
83 |
|
||||
84 | void DeclarativeAreaSeries::setBrushColor(QColor color) |
|
|||
85 | { |
|
|||
86 | QBrush b = brush(); |
|
|||
87 | b.setColor(color); |
|
|||
88 | setBrush(b); |
|
|||
89 | } |
|
|||
90 |
|
||||
91 | #include "moc_declarativeareaseries.cpp" |
|
67 | #include "moc_declarativeareaseries.cpp" | |
92 |
|
68 | |||
93 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,52 +1,46 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVEAREASERIES_H |
|
21 | #ifndef DECLARATIVEAREASERIES_H | |
22 | #define DECLARATIVEAREASERIES_H |
|
22 | #define DECLARATIVEAREASERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qareaseries.h" |
|
25 | #include "qareaseries.h" | |
26 | #include "declarativelineseries.h" |
|
26 | #include "declarativelineseries.h" | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | class DeclarativeAreaSeries : public QAreaSeries |
|
30 | class DeclarativeAreaSeries : public QAreaSeries | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries) |
|
33 | Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries) | |
34 | Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) |
|
34 | Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) | |
35 | Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor) |
|
|||
36 | Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor) |
|
|||
37 |
|
35 | |||
38 | public: |
|
36 | public: | |
39 | explicit DeclarativeAreaSeries(QObject *parent = 0); |
|
37 | explicit DeclarativeAreaSeries(QObject *parent = 0); | |
40 | void setUpperSeries(DeclarativeLineSeries* series); |
|
38 | void setUpperSeries(DeclarativeLineSeries* series); | |
41 | DeclarativeLineSeries* upperSeries() const; |
|
39 | DeclarativeLineSeries* upperSeries() const; | |
42 | void setLowerSeries(DeclarativeLineSeries* series); |
|
40 | void setLowerSeries(DeclarativeLineSeries* series); | |
43 | DeclarativeLineSeries* lowerSeries() const; |
|
41 | DeclarativeLineSeries* lowerSeries() const; | |
44 | QColor penColor() const; |
|
|||
45 | void setPenColor(QColor color); |
|
|||
46 | QColor brushColor() const; |
|
|||
47 | void setBrushColor(QColor color); |
|
|||
48 | }; |
|
42 | }; | |
49 |
|
43 | |||
50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
44 | QTCOMMERCIALCHART_END_NAMESPACE | |
51 |
|
45 | |||
52 | #endif // DECLARATIVEAREASERIES_H |
|
46 | #endif // DECLARATIVEAREASERIES_H |
@@ -1,379 +1,373 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
23 | #include "declarativelineseries.h" |
|
23 | #include "declarativelineseries.h" | |
24 | #include "declarativeareaseries.h" |
|
24 | #include "declarativeareaseries.h" | |
25 | #include "declarativebarseries.h" |
|
25 | #include "declarativebarseries.h" | |
26 | #include "declarativepieseries.h" |
|
26 | #include "declarativepieseries.h" | |
27 | #include "declarativesplineseries.h" |
|
27 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
28 | #include "declarativescatterseries.h" | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | /*! |
|
32 | /*! | |
33 | \qmlclass ChartView DeclarativeChart |
|
33 | \qmlclass ChartView DeclarativeChart | |
34 |
|
34 | |||
35 | ChartView element is the parent that is responsible for showing different chart series types. |
|
35 | ChartView element is the parent that is responsible for showing different chart series types. | |
36 |
|
36 | |||
37 | The following QML shows how to create a simple line chart: |
|
37 | The following QML shows how to create a simple line chart: | |
38 | \snippet ../demos/qmlchart/qml/qmlchart/View2.qml 1 |
|
38 | \snippet ../demos/qmlchart/qml/qmlchart/View2.qml 1 | |
39 |
|
39 | |||
40 | \beginfloatleft |
|
40 | \beginfloatleft | |
41 | \image demos_qmlchart2.png |
|
41 | \image demos_qmlchart2.png | |
42 | \endfloat |
|
42 | \endfloat | |
43 | \clearfloat |
|
43 | \clearfloat | |
44 | */ |
|
44 | */ | |
45 |
|
45 | |||
46 | /*! |
|
46 | /*! | |
47 | \qmlproperty Theme ChartView::theme |
|
47 | \qmlproperty Theme ChartView::theme | |
48 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
48 | Theme defines the visual appearance of the chart, including for example colors, fonts, line | |
49 | widths and chart background. |
|
49 | widths and chart background. | |
50 | */ |
|
50 | */ | |
51 |
|
51 | |||
52 | /*! |
|
52 | /*! | |
53 | \qmlproperty Animation ChartView::animation |
|
53 | \qmlproperty Animation ChartView::animation | |
54 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
54 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, | |
55 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
55 | ChartView.SeriesAnimations or ChartView.AllAnimations. | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \qmlproperty string ChartView::title |
|
59 | \qmlproperty string ChartView::title | |
60 | The title of the chart, shown on top of the chart. |
|
60 | The title of the chart, shown on top of the chart. | |
61 | \sa ChartView::titleColor |
|
61 | \sa ChartView::titleColor | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | \qmlproperty string ChartView::titleColor |
|
65 | \qmlproperty string ChartView::titleColor | |
66 | The color of the title text. |
|
66 | The color of the title text. | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \qmlproperty Axis ChartView::axisX |
|
70 | \qmlproperty Axis ChartView::axisX | |
71 | The x-axis of the chart. |
|
71 | The x-axis of the chart. | |
72 | */ |
|
72 | */ | |
73 |
|
73 | |||
74 | /*! |
|
74 | /*! | |
75 | \qmlproperty Axis ChartView::axisY |
|
75 | \qmlproperty Axis ChartView::axisY | |
76 | The default y-axis of the chart. |
|
76 | The default y-axis of the chart. | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \qmlproperty Legend ChartView::legend |
|
80 | \qmlproperty Legend ChartView::legend | |
81 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
81 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. | |
82 | */ |
|
82 | */ | |
83 |
|
83 | |||
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty int ChartView::count |
|
85 | \qmlproperty int ChartView::count | |
86 | The count of series added to the chart. |
|
86 | The count of series added to the chart. | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty color ChartView::backgroundColor |
|
90 | \qmlproperty color ChartView::backgroundColor | |
91 | The color of the chart's background. By default background color is defined by chart theme. |
|
91 | The color of the chart's background. By default background color is defined by chart theme. | |
92 | \sa ChartView::theme |
|
92 | \sa ChartView::theme | |
93 | */ |
|
93 | */ | |
94 |
|
94 | |||
95 | /*! |
|
95 | /*! | |
96 | \qmlproperty bool ChartView::dropShadowEnabled |
|
96 | \qmlproperty bool ChartView::dropShadowEnabled | |
97 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
97 | The chart's border drop shadow. Set to true to enable drop shadow. | |
98 | */ |
|
98 | */ | |
99 |
|
99 | |||
100 | /*! |
|
100 | /*! | |
101 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) |
|
101 | \qmlmethod Axis ChartView::axisY(QAbstractSeries *series) | |
102 | The y-axis of the series. This is the same as the default y-axis of the chart, unless you have |
|
102 | The y-axis of the series. This is the same as the default y-axis of the chart, unless you have | |
103 | explicitly defined the series to have a non-default y-axis. |
|
103 | explicitly defined the series to have a non-default y-axis. | |
104 | */ |
|
104 | */ | |
105 |
|
105 | |||
106 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
106 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) | |
107 | : QDeclarativeItem(parent), |
|
107 | : QDeclarativeItem(parent), | |
108 | m_chart(new QChart(this)) |
|
108 | m_chart(new QChart(this)) | |
109 | { |
|
109 | { | |
110 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
110 | setFlag(QGraphicsItem::ItemHasNoContents, false); | |
111 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
111 | // m_chart->axisX()->setNiceNumbersEnabled(false); | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 | DeclarativeChart::~DeclarativeChart() |
|
114 | DeclarativeChart::~DeclarativeChart() | |
115 | { |
|
115 | { | |
116 | delete m_chart; |
|
116 | delete m_chart; | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
119 | void DeclarativeChart::childEvent(QChildEvent *event) | |
120 | { |
|
120 | { | |
121 | if (event->type() == QEvent::ChildAdded) { |
|
121 | if (event->type() == QEvent::ChildAdded) { | |
122 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
122 | if (qobject_cast<QAbstractSeries *>(event->child())) { | |
123 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
123 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); | |
124 | } |
|
124 | } | |
125 | } |
|
125 | } | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | void DeclarativeChart::componentComplete() |
|
128 | void DeclarativeChart::componentComplete() | |
129 | { |
|
129 | { | |
130 | foreach(QObject *child, children()) { |
|
130 | foreach(QObject *child, children()) { | |
131 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
131 | if (qobject_cast<QAbstractSeries *>(child)) { | |
132 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
132 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; | |
133 | // TODO: how about optional y-axis? |
|
133 | // TODO: how about optional y-axis? | |
134 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
134 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
135 | } |
|
135 | } | |
136 | } |
|
136 | } | |
137 | QDeclarativeItem::componentComplete(); |
|
137 | QDeclarativeItem::componentComplete(); | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
140 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
141 | { |
|
141 | { | |
142 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
142 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
143 | if (newGeometry.isValid()) { |
|
143 | if (newGeometry.isValid()) { | |
144 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
144 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { | |
145 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
145 | m_chart->resize(newGeometry.width(), newGeometry.height()); | |
146 | } |
|
146 | } | |
147 | } |
|
147 | } | |
148 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
148 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
151 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
152 | { |
|
152 | { | |
153 | Q_UNUSED(option) |
|
153 | Q_UNUSED(option) | |
154 | Q_UNUSED(widget) |
|
154 | Q_UNUSED(widget) | |
155 |
|
155 | |||
156 | // TODO: optimized? |
|
156 | // TODO: optimized? | |
157 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
157 | painter->setRenderHint(QPainter::Antialiasing, true); | |
158 | } |
|
158 | } | |
159 |
|
159 | |||
160 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
160 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) | |
161 | { |
|
161 | { | |
162 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
162 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; | |
163 |
if (chartTheme != m_chart->theme()) |
|
163 | if (chartTheme != m_chart->theme()) | |
164 | m_chart->setTheme(chartTheme); |
|
164 | m_chart->setTheme(chartTheme); | |
165 | themeChanged(); |
|
|||
166 | } |
|
|||
167 | } |
|
165 | } | |
168 |
|
166 | |||
169 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
167 | DeclarativeChart::Theme DeclarativeChart::theme() | |
170 | { |
|
168 | { | |
171 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
169 | return (DeclarativeChart::Theme) m_chart->theme(); | |
172 | } |
|
170 | } | |
173 |
|
171 | |||
174 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
172 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) | |
175 | { |
|
173 | { | |
176 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
174 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; | |
177 |
if (animationOptions != m_chart->animationOptions()) |
|
175 | if (animationOptions != m_chart->animationOptions()) | |
178 | m_chart->setAnimationOptions(animationOptions); |
|
176 | m_chart->setAnimationOptions(animationOptions); | |
179 | animationOptionsChanged(); |
|
|||
180 | } |
|
|||
181 | } |
|
177 | } | |
182 |
|
178 | |||
183 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
179 | DeclarativeChart::Animation DeclarativeChart::animationOptions() | |
184 | { |
|
180 | { | |
185 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
181 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) | |
186 | return DeclarativeChart::AllAnimations; |
|
182 | return DeclarativeChart::AllAnimations; | |
187 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
183 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) | |
188 | return DeclarativeChart::GridAxisAnimations; |
|
184 | return DeclarativeChart::GridAxisAnimations; | |
189 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
185 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) | |
190 | return DeclarativeChart::SeriesAnimations; |
|
186 | return DeclarativeChart::SeriesAnimations; | |
191 | else |
|
187 | else | |
192 | return DeclarativeChart::NoAnimation; |
|
188 | return DeclarativeChart::NoAnimation; | |
193 | } |
|
189 | } | |
194 |
|
190 | |||
195 | void DeclarativeChart::setTitle(QString title) |
|
191 | void DeclarativeChart::setTitle(QString title) | |
196 | { |
|
192 | { | |
197 |
if (title != m_chart->title()) |
|
193 | if (title != m_chart->title()) | |
198 | m_chart->setTitle(title); |
|
194 | m_chart->setTitle(title); | |
199 | emit titleChanged(); |
|
|||
200 | } |
|
|||
201 | } |
|
195 | } | |
202 | QString DeclarativeChart::title() |
|
196 | QString DeclarativeChart::title() | |
203 | { |
|
197 | { | |
204 | return m_chart->title(); |
|
198 | return m_chart->title(); | |
205 | } |
|
199 | } | |
206 |
|
200 | |||
207 | QAxis *DeclarativeChart::axisX() |
|
201 | QAxis *DeclarativeChart::axisX() | |
208 | { |
|
202 | { | |
209 | return m_chart->axisX(); |
|
203 | return m_chart->axisX(); | |
210 | } |
|
204 | } | |
211 |
|
205 | |||
212 | QAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
206 | QAxis *DeclarativeChart::axisY(QAbstractSeries *series) | |
213 | { |
|
207 | { | |
214 | return m_chart->axisY(series); |
|
208 | return m_chart->axisY(series); | |
215 | } |
|
209 | } | |
216 |
|
210 | |||
217 | QLegend *DeclarativeChart::legend() |
|
211 | QLegend *DeclarativeChart::legend() | |
218 | { |
|
212 | { | |
219 | return m_chart->legend(); |
|
213 | return m_chart->legend(); | |
220 | } |
|
214 | } | |
221 |
|
215 | |||
222 | QVariantList DeclarativeChart::axisXLabels() |
|
216 | QVariantList DeclarativeChart::axisXLabels() | |
223 | { |
|
217 | { | |
224 | QVariantList labels; |
|
218 | QVariantList labels; | |
225 | foreach (qreal value, m_chart->axisX()->categories()->values()) { |
|
219 | foreach (qreal value, m_chart->axisX()->categories()->values()) { | |
226 | labels.append(value); |
|
220 | labels.append(value); | |
227 | labels.append(m_chart->axisX()->categories()->label(value)); |
|
221 | labels.append(m_chart->axisX()->categories()->label(value)); | |
228 | } |
|
222 | } | |
229 | return labels; |
|
223 | return labels; | |
230 | } |
|
224 | } | |
231 |
|
225 | |||
232 | void DeclarativeChart::setAxisXLabels(QVariantList list) |
|
226 | void DeclarativeChart::setAxisXLabels(QVariantList list) | |
233 | { |
|
227 | { | |
234 | QVariant value(QVariant::Invalid); |
|
228 | QVariant value(QVariant::Invalid); | |
235 | foreach (QVariant element, list) { |
|
229 | foreach (QVariant element, list) { | |
236 | if (value.isValid() && element.type() == QVariant::String) { |
|
230 | if (value.isValid() && element.type() == QVariant::String) { | |
237 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); |
|
231 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); | |
238 | value = QVariant(QVariant::Invalid); |
|
232 | value = QVariant(QVariant::Invalid); | |
239 | } else { |
|
233 | } else { | |
240 | if (element.canConvert(QVariant::Double)) |
|
234 | if (element.canConvert(QVariant::Double)) | |
241 | value = element; |
|
235 | value = element; | |
242 | } |
|
236 | } | |
243 | } |
|
237 | } | |
244 | emit axisLabelsChanged(); |
|
238 | emit axisLabelsChanged(); | |
245 | } |
|
239 | } | |
246 |
|
240 | |||
247 | void DeclarativeChart::setTitleColor(QColor color) |
|
241 | void DeclarativeChart::setTitleColor(QColor color) | |
248 | { |
|
242 | { | |
249 | QBrush b = m_chart->titleBrush(); |
|
243 | QBrush b = m_chart->titleBrush(); | |
250 | if (color != b.color()) { |
|
244 | if (color != b.color()) { | |
251 | b.setColor(color); |
|
245 | b.setColor(color); | |
252 | m_chart->setTitleBrush(b); |
|
246 | m_chart->setTitleBrush(b); | |
253 | emit titleColorChanged(); |
|
247 | emit titleColorChanged(); | |
254 | } |
|
248 | } | |
255 | } |
|
249 | } | |
256 |
|
250 | |||
257 | QColor DeclarativeChart::titleColor() |
|
251 | QColor DeclarativeChart::titleColor() | |
258 | { |
|
252 | { | |
259 | return m_chart->titleBrush().color(); |
|
253 | return m_chart->titleBrush().color(); | |
260 | } |
|
254 | } | |
261 |
|
255 | |||
262 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
256 | void DeclarativeChart::setBackgroundColor(QColor color) | |
263 | { |
|
257 | { | |
264 | QBrush b = m_chart->backgroundBrush(); |
|
258 | QBrush b = m_chart->backgroundBrush(); | |
265 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
259 | if (b.style() != Qt::SolidPattern || color != b.color()) { | |
266 | b.setStyle(Qt::SolidPattern); |
|
260 | b.setStyle(Qt::SolidPattern); | |
267 | b.setColor(color); |
|
261 | b.setColor(color); | |
268 | m_chart->setBackgroundBrush(b); |
|
262 | m_chart->setBackgroundBrush(b); | |
269 | emit backgroundColorChanged(); |
|
263 | emit backgroundColorChanged(); | |
270 | } |
|
264 | } | |
271 | } |
|
265 | } | |
272 |
|
266 | |||
273 | QColor DeclarativeChart::backgroundColor() |
|
267 | QColor DeclarativeChart::backgroundColor() | |
274 | { |
|
268 | { | |
275 | return m_chart->backgroundBrush().color(); |
|
269 | return m_chart->backgroundBrush().color(); | |
276 | } |
|
270 | } | |
277 |
|
271 | |||
278 | int DeclarativeChart::count() |
|
272 | int DeclarativeChart::count() | |
279 | { |
|
273 | { | |
280 | return m_chart->series().count(); |
|
274 | return m_chart->series().count(); | |
281 | } |
|
275 | } | |
282 |
|
276 | |||
283 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
277 | void DeclarativeChart::setDropShadowEnabled(bool enabled) | |
284 | { |
|
278 | { | |
285 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
279 | if (enabled != m_chart->isDropShadowEnabled()) { | |
286 | m_chart->setDropShadowEnabled(enabled); |
|
280 | m_chart->setDropShadowEnabled(enabled); | |
287 | dropShadowEnabledChanged(enabled); |
|
281 | dropShadowEnabledChanged(enabled); | |
288 | } |
|
282 | } | |
289 | } |
|
283 | } | |
290 |
|
284 | |||
291 | bool DeclarativeChart::dropShadowEnabled() |
|
285 | bool DeclarativeChart::dropShadowEnabled() | |
292 | { |
|
286 | { | |
293 | return m_chart->isDropShadowEnabled(); |
|
287 | return m_chart->isDropShadowEnabled(); | |
294 | } |
|
288 | } | |
295 |
|
289 | |||
296 | void DeclarativeChart::zoom(qreal factor) |
|
290 | void DeclarativeChart::zoom(qreal factor) | |
297 | { |
|
291 | { | |
298 | m_chart->zoom(factor); |
|
292 | m_chart->zoom(factor); | |
299 | } |
|
293 | } | |
300 |
|
294 | |||
301 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
295 | void DeclarativeChart::scrollLeft(qreal pixels) | |
302 | { |
|
296 | { | |
303 | m_chart->scroll(QPointF(pixels, 0)); |
|
297 | m_chart->scroll(QPointF(pixels, 0)); | |
304 | } |
|
298 | } | |
305 |
|
299 | |||
306 | void DeclarativeChart::scrollRight(qreal pixels) |
|
300 | void DeclarativeChart::scrollRight(qreal pixels) | |
307 | { |
|
301 | { | |
308 | m_chart->scroll(QPointF(-pixels, 0)); |
|
302 | m_chart->scroll(QPointF(-pixels, 0)); | |
309 | } |
|
303 | } | |
310 |
|
304 | |||
311 | void DeclarativeChart::scrollUp(qreal pixels) |
|
305 | void DeclarativeChart::scrollUp(qreal pixels) | |
312 | { |
|
306 | { | |
313 | m_chart->scroll(QPointF(0, pixels)); |
|
307 | m_chart->scroll(QPointF(0, pixels)); | |
314 | } |
|
308 | } | |
315 |
|
309 | |||
316 | void DeclarativeChart::scrollDown(qreal pixels) |
|
310 | void DeclarativeChart::scrollDown(qreal pixels) | |
317 | { |
|
311 | { | |
318 | m_chart->scroll(QPointF(0, -pixels)); |
|
312 | m_chart->scroll(QPointF(0, -pixels)); | |
319 | } |
|
313 | } | |
320 |
|
314 | |||
321 | QAbstractSeries *DeclarativeChart::series(int index) |
|
315 | QAbstractSeries *DeclarativeChart::series(int index) | |
322 | { |
|
316 | { | |
323 | if (index < m_chart->series().count()) { |
|
317 | if (index < m_chart->series().count()) { | |
324 | return m_chart->series().at(index); |
|
318 | return m_chart->series().at(index); | |
325 | } |
|
319 | } | |
326 | return 0; |
|
320 | return 0; | |
327 | } |
|
321 | } | |
328 |
|
322 | |||
329 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
323 | QAbstractSeries *DeclarativeChart::series(QString seriesName) | |
330 | { |
|
324 | { | |
331 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
325 | foreach(QAbstractSeries *series, m_chart->series()) { | |
332 | if (series->name() == seriesName) |
|
326 | if (series->name() == seriesName) | |
333 | return series; |
|
327 | return series; | |
334 | } |
|
328 | } | |
335 | return 0; |
|
329 | return 0; | |
336 | } |
|
330 | } | |
337 |
|
331 | |||
338 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
332 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
339 | { |
|
333 | { | |
340 | QAbstractSeries *series = 0; |
|
334 | QAbstractSeries *series = 0; | |
341 | switch (type) { |
|
335 | switch (type) { | |
342 | case DeclarativeChart::SeriesTypeLine: |
|
336 | case DeclarativeChart::SeriesTypeLine: | |
343 | series = new DeclarativeLineSeries(); |
|
337 | series = new DeclarativeLineSeries(); | |
344 | break; |
|
338 | break; | |
345 | case DeclarativeChart::SeriesTypeArea: |
|
339 | case DeclarativeChart::SeriesTypeArea: | |
346 | series = new DeclarativeAreaSeries(); |
|
340 | series = new DeclarativeAreaSeries(); | |
347 | break; |
|
341 | break; | |
348 | case DeclarativeChart::SeriesTypeBar: |
|
342 | case DeclarativeChart::SeriesTypeBar: | |
349 | series = new DeclarativeBarSeries(); |
|
343 | series = new DeclarativeBarSeries(); | |
350 | break; |
|
344 | break; | |
351 | case DeclarativeChart::SeriesTypeStackedBar: |
|
345 | case DeclarativeChart::SeriesTypeStackedBar: | |
352 | // TODO |
|
346 | // TODO | |
353 | break; |
|
347 | break; | |
354 | case DeclarativeChart::SeriesTypePercentBar: |
|
348 | case DeclarativeChart::SeriesTypePercentBar: | |
355 | // TODO |
|
349 | // TODO | |
356 | break; |
|
350 | break; | |
357 | case DeclarativeChart::SeriesTypeGroupedBar: |
|
351 | case DeclarativeChart::SeriesTypeGroupedBar: | |
358 | series = new DeclarativeGroupedBarSeries(); |
|
352 | series = new DeclarativeGroupedBarSeries(); | |
359 | break; |
|
353 | break; | |
360 | case DeclarativeChart::SeriesTypePie: |
|
354 | case DeclarativeChart::SeriesTypePie: | |
361 | series = new DeclarativePieSeries(); |
|
355 | series = new DeclarativePieSeries(); | |
362 | break; |
|
356 | break; | |
363 | case DeclarativeChart::SeriesTypeScatter: |
|
357 | case DeclarativeChart::SeriesTypeScatter: | |
364 | series = new DeclarativeScatterSeries(); |
|
358 | series = new DeclarativeScatterSeries(); | |
365 | break; |
|
359 | break; | |
366 | case DeclarativeChart::SeriesTypeSpline: |
|
360 | case DeclarativeChart::SeriesTypeSpline: | |
367 | series = new DeclarativeSplineSeries(); |
|
361 | series = new DeclarativeSplineSeries(); | |
368 | break; |
|
362 | break; | |
369 | default: |
|
363 | default: | |
370 | qWarning() << "Illegal series type"; |
|
364 | qWarning() << "Illegal series type"; | |
371 | } |
|
365 | } | |
372 | series->setName(name); |
|
366 | series->setName(name); | |
373 | m_chart->addSeries(series); |
|
367 | m_chart->addSeries(series); | |
374 | return series; |
|
368 | return series; | |
375 | } |
|
369 | } | |
376 |
|
370 | |||
377 | #include "moc_declarativechart.cpp" |
|
371 | #include "moc_declarativechart.cpp" | |
378 |
|
372 | |||
379 | QTCOMMERCIALCHART_END_NAMESPACE |
|
373 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,139 +1,136 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVECHART_H |
|
21 | #ifndef DECLARATIVECHART_H | |
22 | #define DECLARATIVECHART_H |
|
22 | #define DECLARATIVECHART_H | |
23 |
|
23 | |||
24 | #include <QtCore/QtGlobal> |
|
24 | #include <QtCore/QtGlobal> | |
25 | #include <QDeclarativeItem> |
|
25 | #include <QDeclarativeItem> | |
26 | #include <qchart.h> |
|
26 | #include <qchart.h> | |
27 | #include <QAxis> |
|
27 | #include <QAxis> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | // TODO: Derive from QChart for easier definition of properties? |
|
31 | // TODO: Derive from QChart for easier definition of properties? | |
32 | class DeclarativeChart : public QDeclarativeItem |
|
32 | class DeclarativeChart : public QDeclarativeItem | |
33 | // TODO: for QTQUICK2: extend QQuickPainterItem instead |
|
33 | // TODO: for QTQUICK2: extend QQuickPainterItem instead | |
34 | //class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
34 | //class DeclarativeChart : public QQuickPaintedItem, public Chart | |
35 | { |
|
35 | { | |
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 |
Q_PROPERTY(Theme theme READ theme WRITE setTheme |
|
37 | Q_PROPERTY(Theme theme READ theme WRITE setTheme) | |
38 |
Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions |
|
38 | Q_PROPERTY(Animation animationOptions READ animationOptions WRITE setAnimationOptions) | |
39 |
Q_PROPERTY(QString title READ title WRITE setTitle |
|
39 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) |
|
40 | Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor NOTIFY titleColorChanged) | |
41 | Q_PROPERTY(QAxis *axisX READ axisX) |
|
41 | Q_PROPERTY(QAxis *axisX READ axisX) | |
42 | Q_PROPERTY(QAxis *axisY READ axisY) |
|
42 | Q_PROPERTY(QAxis *axisY READ axisY) | |
43 | Q_PROPERTY(QLegend *legend READ legend) |
|
43 | Q_PROPERTY(QLegend *legend READ legend) | |
44 | // TODO: how to define axis labels? This is not very convenient |
|
44 | // TODO: how to define axis labels? This is not very convenient | |
45 | Q_PROPERTY(QVariantList axisXLabels READ axisXLabels WRITE setAxisXLabels NOTIFY axisLabelsChanged) |
|
45 | Q_PROPERTY(QVariantList axisXLabels READ axisXLabels WRITE setAxisXLabels NOTIFY axisLabelsChanged) | |
46 | Q_PROPERTY(int count READ count) |
|
46 | Q_PROPERTY(int count READ count) | |
47 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
47 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
48 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
48 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |
49 | Q_ENUMS(Animation) |
|
49 | Q_ENUMS(Animation) | |
50 | Q_ENUMS(Theme) |
|
50 | Q_ENUMS(Theme) | |
51 | Q_ENUMS(SeriesType) |
|
51 | Q_ENUMS(SeriesType) | |
52 |
|
52 | |||
53 | public: |
|
53 | public: | |
54 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api |
|
54 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api | |
55 | enum Theme { |
|
55 | enum Theme { | |
56 | ChartThemeLight = 0, |
|
56 | ChartThemeLight = 0, | |
57 | ChartThemeBlueCerulean, |
|
57 | ChartThemeBlueCerulean, | |
58 | ChartThemeDark, |
|
58 | ChartThemeDark, | |
59 | ChartThemeBrownSand, |
|
59 | ChartThemeBrownSand, | |
60 | ChartThemeBlueNcs, |
|
60 | ChartThemeBlueNcs, | |
61 | ChartThemeHighContrast, |
|
61 | ChartThemeHighContrast, | |
62 | ChartThemeBlueIcy |
|
62 | ChartThemeBlueIcy | |
63 | }; |
|
63 | }; | |
64 |
|
64 | |||
65 | enum Animation { |
|
65 | enum Animation { | |
66 | NoAnimation = 0x0, |
|
66 | NoAnimation = 0x0, | |
67 | GridAxisAnimations = 0x1, |
|
67 | GridAxisAnimations = 0x1, | |
68 | SeriesAnimations =0x2, |
|
68 | SeriesAnimations =0x2, | |
69 | AllAnimations = 0x3 |
|
69 | AllAnimations = 0x3 | |
70 | }; |
|
70 | }; | |
71 |
|
71 | |||
72 | enum SeriesType { |
|
72 | enum SeriesType { | |
73 | SeriesTypeLine, |
|
73 | SeriesTypeLine, | |
74 | SeriesTypeArea, |
|
74 | SeriesTypeArea, | |
75 | SeriesTypeBar, |
|
75 | SeriesTypeBar, | |
76 | SeriesTypeStackedBar, |
|
76 | SeriesTypeStackedBar, | |
77 | SeriesTypePercentBar, |
|
77 | SeriesTypePercentBar, | |
78 | SeriesTypeGroupedBar, |
|
78 | SeriesTypeGroupedBar, | |
79 | SeriesTypePie, |
|
79 | SeriesTypePie, | |
80 | SeriesTypeScatter, |
|
80 | SeriesTypeScatter, | |
81 | SeriesTypeSpline |
|
81 | SeriesTypeSpline | |
82 | }; |
|
82 | }; | |
83 |
|
83 | |||
84 | public: |
|
84 | public: | |
85 | DeclarativeChart(QDeclarativeItem *parent = 0); |
|
85 | DeclarativeChart(QDeclarativeItem *parent = 0); | |
86 | ~DeclarativeChart(); |
|
86 | ~DeclarativeChart(); | |
87 |
|
87 | |||
88 | public: // From QDeclarativeItem/QGraphicsItem |
|
88 | public: // From QDeclarativeItem/QGraphicsItem | |
89 | void childEvent(QChildEvent *event); |
|
89 | void childEvent(QChildEvent *event); | |
90 | void componentComplete(); |
|
90 | void componentComplete(); | |
91 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); |
|
91 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); | |
92 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
92 | void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
93 |
|
93 | |||
94 | public: |
|
94 | public: | |
95 | void setTheme(DeclarativeChart::Theme theme); |
|
95 | void setTheme(DeclarativeChart::Theme theme); | |
96 | DeclarativeChart::Theme theme(); |
|
96 | DeclarativeChart::Theme theme(); | |
97 | void setAnimationOptions(DeclarativeChart::Animation animations); |
|
97 | void setAnimationOptions(DeclarativeChart::Animation animations); | |
98 | DeclarativeChart::Animation animationOptions(); |
|
98 | DeclarativeChart::Animation animationOptions(); | |
99 | void setTitle(QString title); |
|
99 | void setTitle(QString title); | |
100 | QString title(); |
|
100 | QString title(); | |
101 | QAxis *axisX(); |
|
101 | QAxis *axisX(); | |
102 | Q_INVOKABLE QAxis *axisY(QAbstractSeries *series = 0); |
|
102 | Q_INVOKABLE QAxis *axisY(QAbstractSeries *series = 0); | |
103 | QLegend *legend(); |
|
103 | QLegend *legend(); | |
104 | QVariantList axisXLabels(); |
|
104 | QVariantList axisXLabels(); | |
105 | void setAxisXLabels(QVariantList list); |
|
105 | void setAxisXLabels(QVariantList list); | |
106 | void setTitleColor(QColor color); |
|
106 | void setTitleColor(QColor color); | |
107 | QColor titleColor(); |
|
107 | QColor titleColor(); | |
108 | void setBackgroundColor(QColor color); |
|
108 | void setBackgroundColor(QColor color); | |
109 | QColor backgroundColor(); |
|
109 | QColor backgroundColor(); | |
110 | int count(); |
|
110 | int count(); | |
111 | void setDropShadowEnabled(bool enabled); |
|
111 | void setDropShadowEnabled(bool enabled); | |
112 | bool dropShadowEnabled(); |
|
112 | bool dropShadowEnabled(); | |
113 | Q_INVOKABLE void zoom(qreal factor); |
|
113 | Q_INVOKABLE void zoom(qreal factor); | |
114 | Q_INVOKABLE void scrollLeft(qreal pixels); |
|
114 | Q_INVOKABLE void scrollLeft(qreal pixels); | |
115 | Q_INVOKABLE void scrollRight(qreal pixels); |
|
115 | Q_INVOKABLE void scrollRight(qreal pixels); | |
116 | Q_INVOKABLE void scrollUp(qreal pixels); |
|
116 | Q_INVOKABLE void scrollUp(qreal pixels); | |
117 | Q_INVOKABLE void scrollDown(qreal pixels); |
|
117 | Q_INVOKABLE void scrollDown(qreal pixels); | |
118 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
118 | Q_INVOKABLE QAbstractSeries *series(int index); | |
119 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); |
|
119 | Q_INVOKABLE QAbstractSeries *series(QString seriesName); | |
120 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); |
|
120 | Q_INVOKABLE QAbstractSeries *createSeries(DeclarativeChart::SeriesType type, QString name = ""); | |
121 |
|
121 | |||
122 | Q_SIGNALS: |
|
122 | Q_SIGNALS: | |
123 | void themeChanged(); |
|
|||
124 | void animationOptionsChanged(); |
|
|||
125 | void titleChanged(); |
|
|||
126 | void axisLabelsChanged(); |
|
123 | void axisLabelsChanged(); | |
127 | void titleColorChanged(); |
|
124 | void titleColorChanged(); | |
128 | void backgroundColorChanged(); |
|
125 | void backgroundColorChanged(); | |
129 | void dropShadowEnabledChanged(bool enabled); |
|
126 | void dropShadowEnabledChanged(bool enabled); | |
130 |
|
127 | |||
131 | public: |
|
128 | public: | |
132 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
129 | // Extending QChart with DeclarativeChart is not possible because QObject does not support | |
133 | // multi inheritance, so we now have a QChart as a member instead |
|
130 | // multi inheritance, so we now have a QChart as a member instead | |
134 | QChart *m_chart; |
|
131 | QChart *m_chart; | |
135 | }; |
|
132 | }; | |
136 |
|
133 | |||
137 | QTCOMMERCIALCHART_END_NAMESPACE |
|
134 | QTCOMMERCIALCHART_END_NAMESPACE | |
138 |
|
135 | |||
139 | #endif // DECLARATIVECHART_H |
|
136 | #endif // DECLARATIVECHART_H |
@@ -1,67 +1,66 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVELINESERIES_H |
|
21 | #ifndef DECLARATIVELINESERIES_H | |
22 | #define DECLARATIVELINESERIES_H |
|
22 | #define DECLARATIVELINESERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qlineseries.h" |
|
25 | #include "qlineseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 | #include <QDeclarativeParserStatus> |
|
27 | #include <QDeclarativeParserStatus> | |
28 | #include <QDeclarativeListProperty> |
|
28 | #include <QDeclarativeListProperty> | |
29 | #include <QDeclarativeParserStatus> |
|
29 | #include <QDeclarativeParserStatus> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus |
|
33 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_INTERFACES(QDeclarativeParserStatus) |
|
36 | Q_INTERFACES(QDeclarativeParserStatus) | |
37 | Q_PROPERTY(QColor color READ penColor WRITE setPenColor) |
|
|||
38 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
37 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
39 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
40 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
41 |
|
40 | |||
42 | public: |
|
41 | public: | |
43 | explicit DeclarativeLineSeries(QObject *parent = 0); |
|
42 | explicit DeclarativeLineSeries(QObject *parent = 0); | |
44 | QXYSeries *xySeries(); |
|
43 | QXYSeries *xySeries(); | |
45 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
44 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
46 |
|
45 | |||
47 | public: // from QDeclarativeParserStatus |
|
46 | public: // from QDeclarativeParserStatus | |
48 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
47 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
49 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
48 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
50 |
|
49 | |||
51 | public: // from QLineSeries |
|
50 | public: // from QLineSeries | |
52 | Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); } |
|
51 | Q_INVOKABLE void append(qreal x, qreal y) { QLineSeries::append(x, y); } | |
53 | Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); } |
|
52 | Q_INVOKABLE void remove(qreal x, qreal y) { QLineSeries::remove(x, y); } | |
54 | Q_INVOKABLE void clear() { QLineSeries::clear(); } |
|
53 | Q_INVOKABLE void clear() { QLineSeries::clear(); } | |
55 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } |
|
54 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } | |
56 |
|
55 | |||
57 | Q_SIGNALS: |
|
56 | Q_SIGNALS: | |
58 | void countChanged(int count); |
|
57 | void countChanged(int count); | |
59 |
|
58 | |||
60 | public Q_SLOTS: |
|
59 | public Q_SLOTS: | |
61 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
60 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
62 | void handleCountChanged(int index); |
|
61 | void handleCountChanged(int index); | |
63 | }; |
|
62 | }; | |
64 |
|
63 | |||
65 | QTCOMMERCIALCHART_END_NAMESPACE |
|
64 | QTCOMMERCIALCHART_END_NAMESPACE | |
66 |
|
65 | |||
67 | #endif // DECLARATIVELINESERIES_H |
|
66 | #endif // DECLARATIVELINESERIES_H |
@@ -1,85 +1,73 | |||||
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 "declarativescatterseries.h" |
|
21 | #include "declarativescatterseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qscatterseries.h" |
|
24 | #include "qscatterseries.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \qmlclass ScatterSeries QScatterSeries |
|
29 | \qmlclass ScatterSeries QScatterSeries | |
30 |
|
30 | |||
31 | The following QML shows how to create a chart with two simple scatter series: |
|
31 | The following QML shows how to create a chart with two simple scatter series: | |
32 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1 |
|
32 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1 | |
33 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 2 |
|
33 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 2 | |
34 |
|
34 | |||
35 | \beginfloatleft |
|
35 | \beginfloatleft | |
36 | \image demos_qmlchart5.png |
|
36 | \image demos_qmlchart5.png | |
37 | \endfloat |
|
37 | \endfloat | |
38 | \clearfloat |
|
38 | \clearfloat | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : |
|
41 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : | |
42 | QScatterSeries(parent) |
|
42 | QScatterSeries(parent) | |
43 | { |
|
43 | { | |
44 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
44 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); | |
45 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
45 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | QXYSeries *DeclarativeScatterSeries::xySeries() |
|
48 | QXYSeries *DeclarativeScatterSeries::xySeries() | |
49 | { |
|
49 | { | |
50 | return this; |
|
50 | return this; | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | void DeclarativeScatterSeries::handleCountChanged(int index) |
|
53 | void DeclarativeScatterSeries::handleCountChanged(int index) | |
54 | { |
|
54 | { | |
55 | Q_UNUSED(index) |
|
55 | Q_UNUSED(index) | |
56 | emit countChanged(QScatterSeries::count()); |
|
56 | emit countChanged(QScatterSeries::count()); | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren() |
|
59 | QDeclarativeListProperty<QObject> DeclarativeScatterSeries::declarativeChildren() | |
60 | { |
|
60 | { | |
61 | return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren); |
|
61 | return QDeclarativeListProperty<QObject>(this, 0, &appendDeclarativeChildren); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element) |
|
64 | void DeclarativeScatterSeries::appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element) | |
65 | { |
|
65 | { | |
66 | Q_UNUSED(list) |
|
66 | Q_UNUSED(list) | |
67 | Q_UNUSED(element) |
|
67 | Q_UNUSED(element) | |
68 | // Empty implementation, childs are parsed in componentComplete |
|
68 | // Empty implementation, childs are parsed in componentComplete | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | QColor DeclarativeScatterSeries::brushColor() |
|
|||
72 | { |
|
|||
73 | return brush().color(); |
|
|||
74 | } |
|
|||
75 |
|
||||
76 | void DeclarativeScatterSeries::setBrushColor(QColor color) |
|
|||
77 | { |
|
|||
78 | QBrush b = brush(); |
|
|||
79 | b.setColor(color); |
|
|||
80 | setBrush(b); |
|
|||
81 | } |
|
|||
82 |
|
||||
83 | #include "moc_declarativescatterseries.cpp" |
|
71 | #include "moc_declarativescatterseries.cpp" | |
84 |
|
72 | |||
85 | QTCOMMERCIALCHART_END_NAMESPACE |
|
73 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,69 +1,65 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVESCATTERSERIES_H |
|
21 | #ifndef DECLARATIVESCATTERSERIES_H | |
22 | #define DECLARATIVESCATTERSERIES_H |
|
22 | #define DECLARATIVESCATTERSERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qscatterseries.h" |
|
25 | #include "qscatterseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 | #include <QDeclarativeListProperty> |
|
27 | #include <QDeclarativeListProperty> | |
28 | #include <QDeclarativeParserStatus> |
|
28 | #include <QDeclarativeParserStatus> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus |
|
32 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries, public QDeclarativeParserStatus | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 | Q_INTERFACES(QDeclarativeParserStatus) |
|
35 | Q_INTERFACES(QDeclarativeParserStatus) | |
36 | Q_PROPERTY(QColor color READ brushColor WRITE setBrushColor) |
|
|||
37 | Q_PROPERTY(QColor borderColor READ penColor WRITE setPenColor) |
|
|||
38 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
36 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
39 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
37 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
40 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
38 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
41 |
|
39 | |||
42 | public: |
|
40 | public: | |
43 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
|
41 | explicit DeclarativeScatterSeries(QObject *parent = 0); | |
44 | QXYSeries *xySeries(); |
|
42 | QXYSeries *xySeries(); | |
45 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
43 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
46 | QColor brushColor(); |
|
|||
47 | void setBrushColor(QColor color); |
|
|||
48 |
|
44 | |||
49 | public: // from QDeclarativeParserStatus |
|
45 | public: // from QDeclarativeParserStatus | |
50 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
46 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
51 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
47 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
52 |
|
48 | |||
53 | public: // from QScatterSeries |
|
49 | public: // from QScatterSeries | |
54 | Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); } |
|
50 | Q_INVOKABLE void append(qreal x, qreal y) { QScatterSeries::append(x, y); } | |
55 | Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); } |
|
51 | Q_INVOKABLE void remove(qreal x, qreal y) { QScatterSeries::remove(x, y); } | |
56 | Q_INVOKABLE void clear() { QScatterSeries::clear(); } |
|
52 | Q_INVOKABLE void clear() { QScatterSeries::clear(); } | |
57 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } |
|
53 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } | |
58 |
|
54 | |||
59 | Q_SIGNALS: |
|
55 | Q_SIGNALS: | |
60 | void countChanged(int count); |
|
56 | void countChanged(int count); | |
61 |
|
57 | |||
62 | public Q_SLOTS: |
|
58 | public Q_SLOTS: | |
63 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
59 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
64 | void handleCountChanged(int index); |
|
60 | void handleCountChanged(int index); | |
65 | }; |
|
61 | }; | |
66 |
|
62 | |||
67 | QTCOMMERCIALCHART_END_NAMESPACE |
|
63 | QTCOMMERCIALCHART_END_NAMESPACE | |
68 |
|
64 | |||
69 | #endif // DECLARATIVESCATTERSERIES_H |
|
65 | #endif // DECLARATIVESCATTERSERIES_H |
@@ -1,66 +1,65 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVESPLINESERIES_H |
|
21 | #ifndef DECLARATIVESPLINESERIES_H | |
22 | #define DECLARATIVESPLINESERIES_H |
|
22 | #define DECLARATIVESPLINESERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qsplineseries.h" |
|
25 | #include "qsplineseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 | #include <QDeclarativeParserStatus> |
|
27 | #include <QDeclarativeParserStatus> | |
28 | #include <QDeclarativeListProperty> |
|
28 | #include <QDeclarativeListProperty> | |
29 | #include <QDeclarativeParserStatus> |
|
29 | #include <QDeclarativeParserStatus> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus |
|
33 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries, public QDeclarativeParserStatus | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_INTERFACES(QDeclarativeParserStatus) |
|
36 | Q_INTERFACES(QDeclarativeParserStatus) | |
37 | Q_PROPERTY(QColor color READ penColor WRITE setPenColor) |
|
|||
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
37 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
38 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
40 |
|
39 | |||
41 | public: |
|
40 | public: | |
42 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
|
41 | explicit DeclarativeSplineSeries(QObject *parent = 0); | |
43 | QXYSeries *xySeries(); |
|
42 | QXYSeries *xySeries(); | |
44 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
43 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
45 |
|
44 | |||
46 | public: // from QDeclarativeParserStatus |
|
45 | public: // from QDeclarativeParserStatus | |
47 | void classBegin() { DeclarativeXySeries::classBegin(); } |
|
46 | void classBegin() { DeclarativeXySeries::classBegin(); } | |
48 | void componentComplete() { DeclarativeXySeries::componentComplete(); } |
|
47 | void componentComplete() { DeclarativeXySeries::componentComplete(); } | |
49 |
|
48 | |||
50 | public: // from QSplineSeries |
|
49 | public: // from QSplineSeries | |
51 | Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); } |
|
50 | Q_INVOKABLE void append(qreal x, qreal y) { QSplineSeries::append(x, y); } | |
52 | Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); } |
|
51 | Q_INVOKABLE void remove(qreal x, qreal y) { QSplineSeries::remove(x, y); } | |
53 | Q_INVOKABLE void clear() { QSplineSeries::clear(); } |
|
52 | Q_INVOKABLE void clear() { QSplineSeries::clear(); } | |
54 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } |
|
53 | Q_INVOKABLE DeclarativeXyPoint *at(int index) { return DeclarativeXySeries::at(index); } | |
55 |
|
54 | |||
56 | Q_SIGNALS: |
|
55 | Q_SIGNALS: | |
57 | void countChanged(int count); |
|
56 | void countChanged(int count); | |
58 |
|
57 | |||
59 | public Q_SLOTS: |
|
58 | public Q_SLOTS: | |
60 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
59 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
61 | void handleCountChanged(int index); |
|
60 | void handleCountChanged(int index); | |
62 | }; |
|
61 | }; | |
63 |
|
62 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
63 | QTCOMMERCIALCHART_END_NAMESPACE | |
65 |
|
64 | |||
66 | #endif // DECLARATIVESPLINESERIES_H |
|
65 | #endif // DECLARATIVESPLINESERIES_H |
@@ -1,94 +1,77 | |||||
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 "DeclarativeXySeries.h" |
|
21 | //#include "DeclarativeXySeries.h" | |
22 | #include "declarativexyseries.h" |
|
22 | #include "declarativexyseries.h" | |
23 | #include "declarativechart.h" |
|
23 | #include "declarativechart.h" | |
24 | #include <QXYSeries> |
|
24 | #include <QXYSeries> | |
25 | #include <QVXYModelMapper> |
|
25 | #include <QVXYModelMapper> | |
26 | #include <QHXYModelMapper> |
|
26 | #include <QHXYModelMapper> | |
27 | #include <QDeclarativeListProperty> |
|
27 | #include <QDeclarativeListProperty> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | DeclarativeXySeries::DeclarativeXySeries() |
|
31 | DeclarativeXySeries::DeclarativeXySeries() | |
32 | { |
|
32 | { | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | DeclarativeXySeries::~DeclarativeXySeries() |
|
35 | DeclarativeXySeries::~DeclarativeXySeries() | |
36 | { |
|
36 | { | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | void DeclarativeXySeries::classBegin() |
|
39 | void DeclarativeXySeries::classBegin() | |
40 | { |
|
40 | { | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | void DeclarativeXySeries::componentComplete() |
|
43 | void DeclarativeXySeries::componentComplete() | |
44 | { |
|
44 | { | |
45 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
45 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
46 | Q_ASSERT(series); |
|
46 | Q_ASSERT(series); | |
47 |
|
47 | |||
48 | foreach(QObject *child, series->children()) { |
|
48 | foreach(QObject *child, series->children()) { | |
49 | if (qobject_cast<DeclarativeXyPoint *>(child)) { |
|
49 | if (qobject_cast<DeclarativeXyPoint *>(child)) { | |
50 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(child); |
|
50 | DeclarativeXyPoint *point = qobject_cast<DeclarativeXyPoint *>(child); | |
51 | series->append(point->x(), point->y()); |
|
51 | series->append(point->x(), point->y()); | |
52 | } else if(qobject_cast<QVXYModelMapper *>(child)) { |
|
52 | } else if(qobject_cast<QVXYModelMapper *>(child)) { | |
53 | QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); |
|
53 | QVXYModelMapper *mapper = qobject_cast<QVXYModelMapper *>(child); | |
54 | mapper->setSeries(series); |
|
54 | mapper->setSeries(series); | |
55 | } else if(qobject_cast<QHXYModelMapper *>(child)) { |
|
55 | } else if(qobject_cast<QHXYModelMapper *>(child)) { | |
56 | QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); |
|
56 | QHXYModelMapper *mapper = qobject_cast<QHXYModelMapper *>(child); | |
57 | mapper->setSeries(series); |
|
57 | mapper->setSeries(series); | |
58 | } |
|
58 | } | |
59 | } |
|
59 | } | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | QColor DeclarativeXySeries::penColor() |
|
|||
63 | { |
|
|||
64 | // All the inherited objects must be of type QXYSeries, so it is safe to cast |
|
|||
65 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
|||
66 | Q_ASSERT(series); |
|
|||
67 | return series->pen().color(); |
|
|||
68 | } |
|
|||
69 |
|
||||
70 | void DeclarativeXySeries::setPenColor(QColor color) |
|
|||
71 | { |
|
|||
72 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
|||
73 | Q_ASSERT(series); |
|
|||
74 | QPen pen = series->pen(); |
|
|||
75 | pen.setColor(color); |
|
|||
76 | series->setPen(pen); |
|
|||
77 | } |
|
|||
78 |
|
||||
79 | DeclarativeXyPoint *DeclarativeXySeries::at(int index) |
|
62 | DeclarativeXyPoint *DeclarativeXySeries::at(int index) | |
80 | { |
|
63 | { | |
81 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); |
|
64 | QXYSeries *series = qobject_cast<QXYSeries *>(xySeries()); | |
82 | Q_ASSERT(series); |
|
65 | Q_ASSERT(series); | |
83 | if (index < series->count()) { |
|
66 | if (index < series->count()) { | |
84 | QPointF point = series->points().at(index); |
|
67 | QPointF point = series->points().at(index); | |
85 | DeclarativeXyPoint *xyPoint = new DeclarativeXyPoint(series); |
|
68 | DeclarativeXyPoint *xyPoint = new DeclarativeXyPoint(series); | |
86 | xyPoint->setX(point.x()); |
|
69 | xyPoint->setX(point.x()); | |
87 | xyPoint->setY(point.y()); |
|
70 | xyPoint->setY(point.y()); | |
88 | return xyPoint; |
|
71 | return xyPoint; | |
89 | } |
|
72 | } | |
90 | return 0; |
|
73 | return 0; | |
91 | } |
|
74 | } | |
92 |
|
75 | |||
93 |
|
76 | |||
94 | QTCOMMERCIALCHART_END_NAMESPACE |
|
77 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,51 +1,49 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVE_XY_SERIES_H |
|
21 | #ifndef DECLARATIVE_XY_SERIES_H | |
22 | #define DECLARATIVE_XY_SERIES_H |
|
22 | #define DECLARATIVE_XY_SERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "declarativexypoint.h" |
|
25 | #include "declarativexypoint.h" | |
26 | #include <QColor> |
|
26 | #include <QColor> | |
27 | #include <QXYSeries> |
|
27 | #include <QXYSeries> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QChart; |
|
31 | class QChart; | |
32 | class QAbstractSeries; |
|
32 | class QAbstractSeries; | |
33 |
|
33 | |||
34 | class DeclarativeXySeries |
|
34 | class DeclarativeXySeries | |
35 | { |
|
35 | { | |
36 | public: |
|
36 | public: | |
37 | explicit DeclarativeXySeries(); |
|
37 | explicit DeclarativeXySeries(); | |
38 | ~DeclarativeXySeries(); |
|
38 | ~DeclarativeXySeries(); | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 | void classBegin(); |
|
41 | void classBegin(); | |
42 | void componentComplete(); |
|
42 | void componentComplete(); | |
43 | virtual QXYSeries *xySeries() = 0; |
|
43 | virtual QXYSeries *xySeries() = 0; | |
44 | QColor penColor(); |
|
|||
45 | void setPenColor(QColor color); |
|
|||
46 | DeclarativeXyPoint *at(int index); |
|
44 | DeclarativeXyPoint *at(int index); | |
47 | }; |
|
45 | }; | |
48 |
|
46 | |||
49 | QTCOMMERCIALCHART_END_NAMESPACE |
|
47 | QTCOMMERCIALCHART_END_NAMESPACE | |
50 |
|
48 | |||
51 | #endif // DECLARATIVE_XY_SERIES_H |
|
49 | #endif // DECLARATIVE_XY_SERIES_H |
@@ -1,291 +1,344 | |||||
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 "qareaseries.h" |
|
21 | #include "qareaseries.h" | |
22 | #include "qareaseries_p.h" |
|
22 | #include "qareaseries_p.h" | |
23 | #include "qlineseries.h" |
|
23 | #include "qlineseries.h" | |
24 | #include "areachartitem_p.h" |
|
24 | #include "areachartitem_p.h" | |
25 | #include "legendmarker_p.h" |
|
25 | #include "legendmarker_p.h" | |
26 | #include "domain_p.h" |
|
26 | #include "domain_p.h" | |
27 | #include "chartdataset_p.h" |
|
27 | #include "chartdataset_p.h" | |
28 | #include "charttheme_p.h" |
|
28 | #include "charttheme_p.h" | |
29 | #include "chartanimator_p.h" |
|
29 | #include "chartanimator_p.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \class QAreaSeries |
|
34 | \class QAreaSeries | |
35 | \brief The QAreaSeries class is used for making area charts. |
|
35 | \brief The QAreaSeries class is used for making area charts. | |
36 |
|
36 | |||
37 | \mainclass |
|
37 | \mainclass | |
38 |
|
38 | |||
39 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line |
|
39 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line | |
40 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, |
|
40 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, | |
41 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. |
|
41 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. | |
42 | In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases |
|
42 | In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases | |
43 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. |
|
43 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. | |
44 |
|
44 | |||
45 | See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart. |
|
45 | See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart. | |
46 | \image examples_areachart.png |
|
46 | \image examples_areachart.png | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \property QAreaSeries::upperSeries |
|
50 | \property QAreaSeries::upperSeries | |
51 | \brief The upper one of the two line series used to define area series boundaries. |
|
51 | \brief The upper one of the two line series used to define area series boundaries. | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | /*! |
|
54 | /*! | |
55 | \property QAreaSeries::lowerSeries |
|
55 | \property QAreaSeries::lowerSeries | |
56 | The lower one of the two line series used to define are series boundaries. Note if |
|
56 | The lower one of the two line series used to define are series boundaries. Note if | |
57 | QAreaSeries was counstucted wihtout a\ lowerSeries this is null. |
|
57 | QAreaSeries was counstucted wihtout a\ lowerSeries this is null. | |
58 | */ |
|
58 | */ | |
59 |
|
59 | |||
60 | /*! |
|
60 | /*! | |
|
61 | \property QAreaSeries::color | |||
|
62 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. | |||
|
63 | \sa QAreaSeries::brush() | |||
|
64 | */ | |||
|
65 | ||||
|
66 | /*! | |||
|
67 | \property QAreaSeries::borderColor | |||
|
68 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. | |||
|
69 | \sa QAreaSeries::pen() | |||
|
70 | */ | |||
|
71 | ||||
|
72 | /*! | |||
61 | \fn QPen QAreaSeries::pen() const |
|
73 | \fn QPen QAreaSeries::pen() const | |
62 | \brief Returns the pen used to draw line for this series. |
|
74 | \brief Returns the pen used to draw line for this series. | |
63 | \sa setPen() |
|
75 | \sa setPen() | |
64 | */ |
|
76 | */ | |
65 |
|
77 | |||
66 | /*! |
|
78 | /*! | |
67 | \fn QPen QAreaSeries::brush() const |
|
79 | \fn QPen QAreaSeries::brush() const | |
68 | \brief Returns the brush used to draw line for this series. |
|
80 | \brief Returns the brush used to draw line for this series. | |
69 | \sa setBrush() |
|
81 | \sa setBrush() | |
70 | */ |
|
82 | */ | |
71 |
|
83 | |||
72 | /*! |
|
84 | /*! | |
|
85 | \fn void QAreaSeries::colorChanged(QColor color) | |||
|
86 | \brief Signal is emitted when the fill (brush) color has changed to \a color. | |||
|
87 | */ | |||
|
88 | ||||
|
89 | /*! | |||
|
90 | \fn void QAreaSeries::borderColorChanged(QColor color) | |||
|
91 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |||
|
92 | */ | |||
|
93 | ||||
|
94 | /*! | |||
73 | \fn bool QAreaSeries::pointsVisible() const |
|
95 | \fn bool QAreaSeries::pointsVisible() const | |
74 | \brief Returns if the points are drawn for this series. |
|
96 | \brief Returns if the points are drawn for this series. | |
75 | \sa setPointsVisible() |
|
97 | \sa setPointsVisible() | |
76 | */ |
|
98 | */ | |
77 |
|
99 | |||
78 | /*! |
|
100 | /*! | |
79 | \fn void QAreaSeries::clicked(const QPointF& point) |
|
101 | \fn void QAreaSeries::clicked(const QPointF& point) | |
80 | \brief Signal is emitted when user clicks the \a point on area chart. |
|
102 | \brief Signal is emitted when user clicks the \a point on area chart. | |
81 | */ |
|
103 | */ | |
82 |
|
104 | |||
83 | /*! |
|
105 | /*! | |
84 | \fn void QAreaSeries::selected() |
|
106 | \fn void QAreaSeries::selected() | |
85 |
|
107 | |||
86 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
108 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
87 | implemented by the user of QAreaSeries API. |
|
109 | implemented by the user of QAreaSeries API. | |
88 | */ |
|
110 | */ | |
89 |
|
111 | |||
90 | /*! |
|
112 | /*! | |
91 | \fn void QAreaSeriesPrivate::updated() |
|
113 | \fn void QAreaSeriesPrivate::updated() | |
92 | \brief \internal |
|
114 | \brief \internal | |
93 | */ |
|
115 | */ | |
94 |
|
116 | |||
95 | /*! |
|
117 | /*! | |
96 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a |
|
118 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a | |
97 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. |
|
119 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. | |
98 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
120 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
99 | */ |
|
121 | */ | |
100 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) |
|
122 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) | |
101 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) |
|
123 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) | |
102 | { |
|
124 | { | |
103 | } |
|
125 | } | |
104 |
|
126 | |||
105 | /*! |
|
127 | /*! | |
106 | Constructs area series object without upper or lower series with \a parent object. |
|
128 | Constructs area series object without upper or lower series with \a parent object. | |
107 | */ |
|
129 | */ | |
108 | QAreaSeries::QAreaSeries(QObject *parent) |
|
130 | QAreaSeries::QAreaSeries(QObject *parent) | |
109 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) |
|
131 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) | |
110 | { |
|
132 | { | |
111 | } |
|
133 | } | |
112 |
|
134 | |||
113 | /*! |
|
135 | /*! | |
114 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
136 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
115 | and are deleted when mentioned object are destroyed. |
|
137 | and are deleted when mentioned object are destroyed. | |
116 | */ |
|
138 | */ | |
117 | QAreaSeries::~QAreaSeries() |
|
139 | QAreaSeries::~QAreaSeries() | |
118 | { |
|
140 | { | |
119 | } |
|
141 | } | |
120 |
|
142 | |||
121 | /*! |
|
143 | /*! | |
122 | Returns QChartSeries::SeriesTypeArea. |
|
144 | Returns QChartSeries::SeriesTypeArea. | |
123 | */ |
|
145 | */ | |
124 | QAbstractSeries::SeriesType QAreaSeries::type() const |
|
146 | QAbstractSeries::SeriesType QAreaSeries::type() const | |
125 | { |
|
147 | { | |
126 | return QAbstractSeries::SeriesTypeArea; |
|
148 | return QAbstractSeries::SeriesTypeArea; | |
127 | } |
|
149 | } | |
128 |
|
150 | |||
129 | /*! |
|
151 | /*! | |
130 | Sets the \a series that is to be used as the area chart upper series. |
|
152 | Sets the \a series that is to be used as the area chart upper series. | |
131 | */ |
|
153 | */ | |
132 | void QAreaSeries::setUpperSeries(QLineSeries* series) |
|
154 | void QAreaSeries::setUpperSeries(QLineSeries* series) | |
133 | { |
|
155 | { | |
134 | Q_D(QAreaSeries); |
|
156 | Q_D(QAreaSeries); | |
135 | d->m_upperSeries = series; |
|
157 | d->m_upperSeries = series; | |
136 | } |
|
158 | } | |
137 |
|
159 | |||
138 | QLineSeries* QAreaSeries::upperSeries() const |
|
160 | QLineSeries* QAreaSeries::upperSeries() const | |
139 | { |
|
161 | { | |
140 | Q_D(const QAreaSeries); |
|
162 | Q_D(const QAreaSeries); | |
141 | return d->m_upperSeries; |
|
163 | return d->m_upperSeries; | |
142 | } |
|
164 | } | |
143 |
|
165 | |||
144 | /*! |
|
166 | /*! | |
145 | Sets the \a series that is to be used as the area chart lower series. |
|
167 | Sets the \a series that is to be used as the area chart lower series. | |
146 | */ |
|
168 | */ | |
147 | void QAreaSeries::setLowerSeries(QLineSeries* series) |
|
169 | void QAreaSeries::setLowerSeries(QLineSeries* series) | |
148 | { |
|
170 | { | |
149 | Q_D(QAreaSeries); |
|
171 | Q_D(QAreaSeries); | |
150 | d->m_lowerSeries = series; |
|
172 | d->m_lowerSeries = series; | |
151 | } |
|
173 | } | |
152 |
|
174 | |||
153 | QLineSeries* QAreaSeries::lowerSeries() const |
|
175 | QLineSeries* QAreaSeries::lowerSeries() const | |
154 | { |
|
176 | { | |
155 | Q_D(const QAreaSeries); |
|
177 | Q_D(const QAreaSeries); | |
156 | return d->m_lowerSeries; |
|
178 | return d->m_lowerSeries; | |
157 | } |
|
179 | } | |
158 |
|
180 | |||
159 | /*! |
|
181 | /*! | |
160 | Sets \a pen used for drawing area outline. |
|
182 | Sets \a pen used for drawing area outline. | |
161 | */ |
|
183 | */ | |
162 | void QAreaSeries::setPen(const QPen &pen) |
|
184 | void QAreaSeries::setPen(const QPen &pen) | |
163 | { |
|
185 | { | |
164 | Q_D(QAreaSeries); |
|
186 | Q_D(QAreaSeries); | |
165 | if (d->m_pen != pen) { |
|
187 | if (d->m_pen != pen) { | |
166 | d->m_pen = pen; |
|
188 | d->m_pen = pen; | |
167 | emit d->updated(); |
|
189 | emit d->updated(); | |
168 | } |
|
190 | } | |
169 | } |
|
191 | } | |
170 |
|
192 | |||
171 | QPen QAreaSeries::pen() const |
|
193 | QPen QAreaSeries::pen() const | |
172 | { |
|
194 | { | |
173 | Q_D(const QAreaSeries); |
|
195 | Q_D(const QAreaSeries); | |
174 | return d->m_pen; |
|
196 | return d->m_pen; | |
175 | } |
|
197 | } | |
176 |
|
198 | |||
177 | /*! |
|
199 | /*! | |
178 | Sets \a brush used for filling the area. |
|
200 | Sets \a brush used for filling the area. | |
179 | */ |
|
201 | */ | |
180 | void QAreaSeries::setBrush(const QBrush &brush) |
|
202 | void QAreaSeries::setBrush(const QBrush &brush) | |
181 | { |
|
203 | { | |
182 | Q_D(QAreaSeries); |
|
204 | Q_D(QAreaSeries); | |
183 | if (d->m_brush != brush) { |
|
205 | if (d->m_brush != brush) { | |
184 | d->m_brush = brush; |
|
206 | d->m_brush = brush; | |
185 | emit d->updated(); |
|
207 | emit d->updated(); | |
186 | } |
|
208 | } | |
187 | } |
|
209 | } | |
188 |
|
210 | |||
189 | QBrush QAreaSeries::brush() const |
|
211 | QBrush QAreaSeries::brush() const | |
190 | { |
|
212 | { | |
191 | Q_D(const QAreaSeries); |
|
213 | Q_D(const QAreaSeries); | |
192 | return d->m_brush; |
|
214 | return d->m_brush; | |
193 | } |
|
215 | } | |
|
216 | ||||
|
217 | void QAreaSeries::setColor(const QColor &color) | |||
|
218 | { | |||
|
219 | QBrush b = brush(); | |||
|
220 | if (b.color() != color) { | |||
|
221 | b.setColor(color); | |||
|
222 | setBrush(b); | |||
|
223 | emit colorChanged(color); | |||
|
224 | } | |||
|
225 | } | |||
|
226 | ||||
|
227 | QColor QAreaSeries::color() const | |||
|
228 | { | |||
|
229 | return brush().color(); | |||
|
230 | } | |||
|
231 | ||||
|
232 | void QAreaSeries::setBorderColor(const QColor &color) | |||
|
233 | { | |||
|
234 | QPen p = pen(); | |||
|
235 | if (p.color() != color) { | |||
|
236 | p.setColor(color); | |||
|
237 | setPen(p); | |||
|
238 | emit borderColorChanged(color); | |||
|
239 | } | |||
|
240 | } | |||
|
241 | ||||
|
242 | QColor QAreaSeries::borderColor() const | |||
|
243 | { | |||
|
244 | return pen().color(); | |||
|
245 | } | |||
|
246 | ||||
194 | /*! |
|
247 | /*! | |
195 | Sets if data points are \a visible and should be drawn on line. |
|
248 | Sets if data points are \a visible and should be drawn on line. | |
196 | */ |
|
249 | */ | |
197 | void QAreaSeries::setPointsVisible(bool visible) |
|
250 | void QAreaSeries::setPointsVisible(bool visible) | |
198 | { |
|
251 | { | |
199 | Q_D(QAreaSeries); |
|
252 | Q_D(QAreaSeries); | |
200 | if (d->m_pointsVisible != visible) { |
|
253 | if (d->m_pointsVisible != visible) { | |
201 | d->m_pointsVisible = visible; |
|
254 | d->m_pointsVisible = visible; | |
202 | emit d->updated(); |
|
255 | emit d->updated(); | |
203 | } |
|
256 | } | |
204 | } |
|
257 | } | |
205 |
|
258 | |||
206 | bool QAreaSeries::pointsVisible() const |
|
259 | bool QAreaSeries::pointsVisible() const | |
207 | { |
|
260 | { | |
208 | Q_D(const QAreaSeries); |
|
261 | Q_D(const QAreaSeries); | |
209 | return d->m_pointsVisible; |
|
262 | return d->m_pointsVisible; | |
210 | } |
|
263 | } | |
211 |
|
264 | |||
212 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
265 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
213 |
|
266 | |||
214 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : |
|
267 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : | |
215 | QAbstractSeriesPrivate(q), |
|
268 | QAbstractSeriesPrivate(q), | |
216 | m_upperSeries(upperSeries), |
|
269 | m_upperSeries(upperSeries), | |
217 | m_lowerSeries(lowerSeries), |
|
270 | m_lowerSeries(lowerSeries), | |
218 | m_pointsVisible(false) |
|
271 | m_pointsVisible(false) | |
219 | { |
|
272 | { | |
220 | } |
|
273 | } | |
221 |
|
274 | |||
222 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) |
|
275 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) | |
223 | { |
|
276 | { | |
224 | Q_Q(QAreaSeries); |
|
277 | Q_Q(QAreaSeries); | |
225 |
|
278 | |||
226 | qreal minX(domain.minX()); |
|
279 | qreal minX(domain.minX()); | |
227 | qreal minY(domain.minY()); |
|
280 | qreal minY(domain.minY()); | |
228 | qreal maxX(domain.maxX()); |
|
281 | qreal maxX(domain.maxX()); | |
229 | qreal maxY(domain.maxY()); |
|
282 | qreal maxY(domain.maxY()); | |
230 | int tickXCount(domain.tickXCount()); |
|
283 | int tickXCount(domain.tickXCount()); | |
231 | int tickYCount(domain.tickYCount()); |
|
284 | int tickYCount(domain.tickYCount()); | |
232 |
|
285 | |||
233 | QLineSeries* upperSeries = q->upperSeries(); |
|
286 | QLineSeries* upperSeries = q->upperSeries(); | |
234 | QLineSeries* lowerSeries = q->lowerSeries(); |
|
287 | QLineSeries* lowerSeries = q->lowerSeries(); | |
235 |
|
288 | |||
236 | const QList<QPointF>& points = upperSeries->points(); |
|
289 | const QList<QPointF>& points = upperSeries->points(); | |
237 |
|
290 | |||
238 | for (int i = 0; i < points.count(); i++) |
|
291 | for (int i = 0; i < points.count(); i++) | |
239 | { |
|
292 | { | |
240 | qreal x = points[i].x(); |
|
293 | qreal x = points[i].x(); | |
241 | qreal y = points[i].y(); |
|
294 | qreal y = points[i].y(); | |
242 | minX = qMin(minX, x); |
|
295 | minX = qMin(minX, x); | |
243 | minY = qMin(minY, y); |
|
296 | minY = qMin(minY, y); | |
244 | maxX = qMax(maxX, x); |
|
297 | maxX = qMax(maxX, x); | |
245 | maxY = qMax(maxY, y); |
|
298 | maxY = qMax(maxY, y); | |
246 | } |
|
299 | } | |
247 | if(lowerSeries) { |
|
300 | if(lowerSeries) { | |
248 |
|
301 | |||
249 | const QList<QPointF>& points = lowerSeries->points(); |
|
302 | const QList<QPointF>& points = lowerSeries->points(); | |
250 |
|
303 | |||
251 | for (int i = 0; i < points.count(); i++) |
|
304 | for (int i = 0; i < points.count(); i++) | |
252 | { |
|
305 | { | |
253 | qreal x = points[i].x(); |
|
306 | qreal x = points[i].x(); | |
254 | qreal y = points[i].y(); |
|
307 | qreal y = points[i].y(); | |
255 | minX = qMin(minX, x); |
|
308 | minX = qMin(minX, x); | |
256 | minY = qMin(minY, y); |
|
309 | minY = qMin(minY, y); | |
257 | maxX = qMax(maxX, x); |
|
310 | maxX = qMax(maxX, x); | |
258 | maxY = qMax(maxY, y); |
|
311 | maxY = qMax(maxY, y); | |
259 | }} |
|
312 | }} | |
260 |
|
313 | |||
261 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
314 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
262 | } |
|
315 | } | |
263 |
|
316 | |||
264 | Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
317 | Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
265 | { |
|
318 | { | |
266 | Q_Q(QAreaSeries); |
|
319 | Q_Q(QAreaSeries); | |
267 |
|
320 | |||
268 | AreaChartItem* area = new AreaChartItem(q,presenter); |
|
321 | AreaChartItem* area = new AreaChartItem(q,presenter); | |
269 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
322 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
270 | area->upperLineItem()->setAnimator(presenter->animator()); |
|
323 | area->upperLineItem()->setAnimator(presenter->animator()); | |
271 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); |
|
324 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); | |
272 | if(q->lowerSeries()) { |
|
325 | if(q->lowerSeries()) { | |
273 | area->lowerLineItem()->setAnimator(presenter->animator()); |
|
326 | area->lowerLineItem()->setAnimator(presenter->animator()); | |
274 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); |
|
327 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); | |
275 | } |
|
328 | } | |
276 | } |
|
329 | } | |
277 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
330 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
278 | return area; |
|
331 | return area; | |
279 | } |
|
332 | } | |
280 |
|
333 | |||
281 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) |
|
334 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) | |
282 | { |
|
335 | { | |
283 | Q_Q(QAreaSeries); |
|
336 | Q_Q(QAreaSeries); | |
284 | QList<LegendMarker*> list; |
|
337 | QList<LegendMarker*> list; | |
285 | return list << new AreaLegendMarker(q,legend); |
|
338 | return list << new AreaLegendMarker(q,legend); | |
286 | } |
|
339 | } | |
287 |
|
340 | |||
288 | #include "moc_qareaseries.cpp" |
|
341 | #include "moc_qareaseries.cpp" | |
289 | #include "moc_qareaseries_p.cpp" |
|
342 | #include "moc_qareaseries_p.cpp" | |
290 |
|
343 | |||
291 | QTCOMMERCIALCHART_END_NAMESPACE |
|
344 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,74 +1,84 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QAREASERIES_H |
|
21 | #ifndef QAREASERIES_H | |
22 | #define QAREASERIES_H |
|
22 | #define QAREASERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qabstractseries.h> |
|
25 | #include <qabstractseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | class QLineSeries; |
|
30 | class QLineSeries; | |
31 | class QAreaSeriesPrivate; |
|
31 | class QAreaSeriesPrivate; | |
32 |
|
32 | |||
33 | class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries |
|
33 | class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_PROPERTY(QAbstractSeries *upperSeries READ upperSeries) |
|
36 | Q_PROPERTY(QAbstractSeries *upperSeries READ upperSeries) | |
37 | Q_PROPERTY(QAbstractSeries *lowerSeries READ lowerSeries) |
|
37 | Q_PROPERTY(QAbstractSeries *lowerSeries READ lowerSeries) | |
|
38 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |||
|
39 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |||
38 |
|
40 | |||
39 | public: |
|
41 | public: | |
40 | explicit QAreaSeries(QObject *parent = 0); |
|
42 | explicit QAreaSeries(QObject *parent = 0); | |
41 | explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0); |
|
43 | explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0); | |
42 | ~QAreaSeries(); |
|
44 | ~QAreaSeries(); | |
43 |
|
45 | |||
44 | public: |
|
46 | public: | |
45 | QAbstractSeries::SeriesType type() const; |
|
47 | QAbstractSeries::SeriesType type() const; | |
46 |
|
48 | |||
47 | void setUpperSeries(QLineSeries* series); |
|
49 | void setUpperSeries(QLineSeries* series); | |
48 | QLineSeries* upperSeries() const; |
|
50 | QLineSeries* upperSeries() const; | |
49 | void setLowerSeries(QLineSeries* series); |
|
51 | void setLowerSeries(QLineSeries* series); | |
50 | QLineSeries* lowerSeries() const; |
|
52 | QLineSeries* lowerSeries() const; | |
51 |
|
53 | |||
52 | void setPen(const QPen &pen); |
|
54 | void setPen(const QPen &pen); | |
53 | QPen pen() const; |
|
55 | QPen pen() const; | |
54 |
|
56 | |||
55 | void setBrush(const QBrush &brush); |
|
57 | void setBrush(const QBrush &brush); | |
56 | QBrush brush() const; |
|
58 | QBrush brush() const; | |
57 |
|
59 | |||
|
60 | void setColor(const QColor &color); | |||
|
61 | QColor color() const; | |||
|
62 | ||||
|
63 | void setBorderColor(const QColor &color); | |||
|
64 | QColor borderColor() const; | |||
|
65 | ||||
58 | void setPointsVisible(bool visible = true); |
|
66 | void setPointsVisible(bool visible = true); | |
59 | bool pointsVisible() const; |
|
67 | bool pointsVisible() const; | |
60 |
|
68 | |||
61 | Q_SIGNALS: |
|
69 | Q_SIGNALS: | |
62 | void clicked(const QPointF &point); |
|
70 | void clicked(const QPointF &point); | |
63 | void selected(); |
|
71 | void selected(); | |
|
72 | void colorChanged(QColor color); | |||
|
73 | void borderColorChanged(QColor color); | |||
64 |
|
74 | |||
65 | private: |
|
75 | private: | |
66 |
Q_DECLARE_PRIVATE(QAreaSeries) |
|
76 | Q_DECLARE_PRIVATE(QAreaSeries) | |
67 |
Q_DISABLE_COPY(QAreaSeries) |
|
77 | Q_DISABLE_COPY(QAreaSeries) | |
68 | friend class AreaLegendMarker; |
|
78 | friend class AreaLegendMarker; | |
69 | friend class AreaChartItem; |
|
79 | friend class AreaChartItem; | |
70 | }; |
|
80 | }; | |
71 |
|
81 | |||
72 | QTCOMMERCIALCHART_END_NAMESPACE |
|
82 | QTCOMMERCIALCHART_END_NAMESPACE | |
73 |
|
83 | |||
74 | #endif |
|
84 | #endif |
@@ -1,674 +1,654 | |||||
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 "qaxis.h" |
|
21 | #include "qaxis.h" | |
22 | #include "qaxis_p.h" |
|
22 | #include "qaxis_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QAxis |
|
27 | \class QAxis | |
28 | \brief The QAxis class is used for manipulating chart's axis |
|
28 | \brief The QAxis class is used for manipulating chart's axis | |
29 | and for adding optional axes to the chart. |
|
29 | and for adding optional axes to the chart. | |
30 | \mainclass |
|
30 | \mainclass | |
31 |
|
31 | |||
32 | There is only one x Axis, however there can be multiple y axes. |
|
32 | There is only one x Axis, however there can be multiple y axes. | |
33 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
33 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
34 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
34 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
35 | */ |
|
35 | */ | |
36 |
|
36 | |||
37 | /*! |
|
37 | /*! | |
38 | \qmlclass Axis QAxis |
|
38 | \qmlclass Axis QAxis | |
39 | \brief The Axis element is used for manipulating chart's axes |
|
39 | \brief The Axis element is used for manipulating chart's axes | |
40 |
|
40 | |||
41 | There is only one x Axis, however there can be multiple y axes on a ChartView. |
|
41 | There is only one x Axis, however there can be multiple y axes on a ChartView. | |
42 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
42 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
43 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
43 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
44 |
|
44 | |||
45 | To access Axes you can use ChartView API. For example: |
|
45 | To access Axes you can use ChartView API. For example: | |
46 | \code |
|
46 | \code | |
47 | ChartView { |
|
47 | ChartView { | |
48 | axisX.min: 0 |
|
48 | axisX.min: 0 | |
49 | axisX.max: 3 |
|
49 | axisX.max: 3 | |
50 | axisX.ticksCount: 4 |
|
50 | axisX.ticksCount: 4 | |
51 | axisY.min: 0 |
|
51 | axisY.min: 0 | |
52 | axisY.max: 4 |
|
52 | axisY.max: 4 | |
53 | // Add a few series... |
|
53 | // Add a few series... | |
54 | } |
|
54 | } | |
55 | \endcode |
|
55 | \endcode | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \property QAxis::labelsVisible |
|
59 | \property QAxis::labelsVisible | |
60 | Defines if axis labels are visible. |
|
60 | Defines if axis labels are visible. | |
61 | */ |
|
61 | */ | |
62 | /*! |
|
62 | /*! | |
63 | \qmlproperty bool Axis::labelsVisible |
|
63 | \qmlproperty bool Axis::labelsVisible | |
64 | Defines if axis labels are visible. |
|
64 | Defines if axis labels are visible. | |
65 | */ |
|
65 | */ | |
66 |
|
66 | |||
67 | /*! |
|
67 | /*! | |
68 | \property QAxis::min |
|
68 | \property QAxis::min | |
69 | Defines the minimum value on the axis. |
|
69 | Defines the minimum value on the axis. | |
70 | */ |
|
70 | */ | |
71 | /*! |
|
71 | /*! | |
72 | \qmlproperty real Axis::min |
|
72 | \qmlproperty real Axis::min | |
73 | Defines the minimum value on the axis. |
|
73 | Defines the minimum value on the axis. | |
74 | */ |
|
74 | */ | |
75 |
|
75 | |||
76 | /*! |
|
76 | /*! | |
77 | \property QAxis::max |
|
77 | \property QAxis::max | |
78 | Defines the maximum value on the axis. |
|
78 | Defines the maximum value on the axis. | |
79 | */ |
|
79 | */ | |
80 | /*! |
|
80 | /*! | |
81 | \qmlproperty real Axis::max |
|
81 | \qmlproperty real Axis::max | |
82 | Defines the maximum value on the axis. |
|
82 | Defines the maximum value on the axis. | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | \property QAxis::visible |
|
86 | \property QAxis::visible | |
87 | The visibility of the axis. |
|
87 | The visibility of the axis. | |
88 | */ |
|
88 | */ | |
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty bool Axis::visible |
|
90 | \qmlproperty bool Axis::visible | |
91 | The visibility of the axis. |
|
91 | The visibility of the axis. | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \property QAxis::gridVisible |
|
95 | \property QAxis::gridVisible | |
96 | The visibility of the grid lines. |
|
96 | The visibility of the grid lines. | |
97 | */ |
|
97 | */ | |
98 | /*! |
|
98 | /*! | |
99 | \qmlproperty bool Axis::gridVisible |
|
99 | \qmlproperty bool Axis::gridVisible | |
100 | The visibility of the grid lines. |
|
100 | The visibility of the grid lines. | |
101 | */ |
|
101 | */ | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | \property QAxis::color |
|
104 | \property QAxis::color | |
105 | The color of the axis and ticks. |
|
105 | The color of the axis and ticks. | |
106 | */ |
|
106 | */ | |
107 | /*! |
|
107 | /*! | |
108 | \qmlproperty color Axis::color |
|
108 | \qmlproperty color Axis::color | |
109 | The color of the axis and ticks. |
|
109 | The color of the axis and ticks. | |
110 | */ |
|
110 | */ | |
111 |
|
111 | |||
112 | /*! |
|
112 | /*! | |
113 | \property QAxis::labelsColor |
|
113 | \property QAxis::labelsColor | |
114 | The color of the axis labels. |
|
114 | The color of the axis labels. | |
115 | */ |
|
115 | */ | |
116 | /*! |
|
116 | /*! | |
117 | \qmlproperty color Axis::labelsColor |
|
117 | \qmlproperty color Axis::labelsColor | |
118 | The color of the axis labels. |
|
118 | The color of the axis labels. | |
119 | */ |
|
119 | */ | |
120 |
|
120 | |||
121 | /*! |
|
121 | /*! | |
122 | \property QAxis::labelsAngle |
|
122 | \property QAxis::labelsAngle | |
123 | The angle of the axis labels in degrees. |
|
123 | The angle of the axis labels in degrees. | |
124 | */ |
|
124 | */ | |
125 | /*! |
|
125 | /*! | |
126 | \qmlproperty int Axis::labelsAngle |
|
126 | \qmlproperty int Axis::labelsAngle | |
127 | The angle of the axis labels in degrees. |
|
127 | The angle of the axis labels in degrees. | |
128 | */ |
|
128 | */ | |
129 |
|
129 | |||
130 | /*! |
|
130 | /*! | |
131 | \property QAxis::shadesVisible |
|
131 | \property QAxis::shadesVisible | |
132 | The visibility of the axis shades. |
|
132 | The visibility of the axis shades. | |
133 | */ |
|
133 | */ | |
134 | /*! |
|
134 | /*! | |
135 | \qmlproperty bool Axis::shadesVisible |
|
135 | \qmlproperty bool Axis::shadesVisible | |
136 | The visibility of the axis shades. |
|
136 | The visibility of the axis shades. | |
137 | */ |
|
137 | */ | |
138 |
|
138 | |||
139 | /*! |
|
139 | /*! | |
140 | \property QAxis::shadesColor |
|
140 | \property QAxis::shadesColor | |
141 | The fill (brush) color of the axis shades. |
|
141 | The fill (brush) color of the axis shades. | |
142 | */ |
|
142 | */ | |
143 | /*! |
|
143 | /*! | |
144 | \qmlproperty color Axis::shadesColor |
|
144 | \qmlproperty color Axis::shadesColor | |
145 | The fill (brush) color of the axis shades. |
|
145 | The fill (brush) color of the axis shades. | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | \property QAxis::shadesBorderColor |
|
149 | \property QAxis::shadesBorderColor | |
150 | The border (pen) color of the axis shades. |
|
150 | The border (pen) color of the axis shades. | |
151 | */ |
|
151 | */ | |
152 | /*! |
|
152 | /*! | |
153 | \qmlproperty color Axis::shadesBorderColor |
|
153 | \qmlproperty color Axis::shadesBorderColor | |
154 | The border (pen) color of the axis shades. |
|
154 | The border (pen) color of the axis shades. | |
155 | */ |
|
155 | */ | |
156 |
|
156 | |||
157 | /*! |
|
157 | /*! | |
158 | \property QAxis::ticksCount |
|
158 | \property QAxis::ticksCount | |
159 | The number of tick marks for the axis. |
|
159 | The number of tick marks for the axis. | |
160 | */ |
|
160 | */ | |
161 | /*! |
|
161 | /*! | |
162 | \qmlproperty int Axis::ticksCount |
|
162 | \qmlproperty int Axis::ticksCount | |
163 | The number of tick marks for the axis. |
|
163 | The number of tick marks for the axis. | |
164 | */ |
|
164 | */ | |
165 |
|
165 | |||
166 | /*! |
|
166 | /*! | |
167 | \property QAxis::niceNumbersEnabled |
|
167 | \property QAxis::niceNumbersEnabled | |
168 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
168 | Whether the nice numbers algorithm is enabled or not for the axis. | |
169 | */ |
|
169 | */ | |
170 | /*! |
|
170 | /*! | |
171 | \qmlproperty bool Axis::niceNumbersEnabled |
|
171 | \qmlproperty bool Axis::niceNumbersEnabled | |
172 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
172 | Whether the nice numbers algorithm is enabled or not for the axis. | |
173 | */ |
|
173 | */ | |
174 |
|
174 | |||
175 | /*! |
|
175 | /*! | |
176 | \fn void QAxis::visibleChanged(bool) |
|
176 | \fn void QAxis::visibleChanged(bool) | |
177 | Visiblity of the axis has changed to \a visible. |
|
177 | Visiblity of the axis has changed to \a visible. | |
178 | */ |
|
178 | */ | |
179 |
|
179 | |||
180 | /*! |
|
180 | /*! | |
181 | \fn void QAxis::labelsVisibleChanged(bool) |
|
181 | \fn void QAxis::labelsVisibleChanged(bool) | |
182 | Visiblity of the labels of the axis has changed to \a visible. |
|
182 | Visiblity of the labels of the axis has changed to \a visible. | |
183 | */ |
|
183 | */ | |
184 |
|
184 | |||
185 | /*! |
|
185 | /*! | |
186 | \fn void QAxis::gridVisibleChanged(bool) |
|
186 | \fn void QAxis::gridVisibleChanged(bool) | |
187 | Visiblity of the grid lines of the axis has changed to \a visible. |
|
187 | Visiblity of the grid lines of the axis has changed to \a visible. | |
188 | */ |
|
188 | */ | |
189 |
|
189 | |||
190 | /*! |
|
190 | /*! | |
191 | \fn void QAxis::minChanged(qreal min) |
|
191 | \fn void QAxis::minChanged(qreal min) | |
192 | Axis emits signal when \a min of axis has changed. |
|
192 | Axis emits signal when \a min of axis has changed. | |
193 | */ |
|
193 | */ | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | \fn void QAxis::maxChanged(qreal max) |
|
196 | \fn void QAxis::maxChanged(qreal max) | |
197 | Axis emits signal when \a max of axis has changed. |
|
197 | Axis emits signal when \a max of axis has changed. | |
198 | */ |
|
198 | */ | |
199 |
|
199 | |||
200 | /*! |
|
200 | /*! | |
201 | \fn void QAxis::rangeChanged(qreal min, qreal max) |
|
201 | \fn void QAxis::rangeChanged(qreal min, qreal max) | |
202 | Axis emits signal when \a min or \a max of axis has changed. |
|
202 | Axis emits signal when \a min or \a max of axis has changed. | |
203 | */ |
|
203 | */ | |
204 |
|
204 | |||
205 | /*! |
|
205 | /*! | |
206 | \fn QChartAxisCategories* QAxis::categories() |
|
206 | \fn QChartAxisCategories* QAxis::categories() | |
207 | Returns pointer to the list of categories which correspond to the values on the axis. |
|
207 | Returns pointer to the list of categories which correspond to the values on the axis. | |
208 | */ |
|
208 | */ | |
209 |
|
209 | |||
210 | /*! |
|
210 | /*! | |
211 | \fn void QAxis::colorChanged(QColor) |
|
211 | \fn void QAxis::colorChanged(QColor) | |
212 | Emitted if the \a color of the axis is changed. |
|
212 | Emitted if the \a color of the axis is changed. | |
213 | */ |
|
213 | */ | |
214 |
|
214 | |||
215 | /*! |
|
215 | /*! | |
216 | \fn void QAxis::labelsColorChanged(QColor) |
|
216 | \fn void QAxis::labelsColorChanged(QColor) | |
217 | Emitted if the \a color of the axis labels is changed. |
|
217 | Emitted if the \a color of the axis labels is changed. | |
218 | */ |
|
218 | */ | |
219 |
|
219 | |||
220 | /*! |
|
220 | /*! | |
221 | \fn void QAxis::labelsAngleChanged(int) |
|
|||
222 | Emitted if the \a angle of the axis labels is changed. |
|
|||
223 | */ |
|
|||
224 |
|
||||
225 | /*! |
|
|||
226 | \fn void QAxis::shadesVisibleChanged(bool) |
|
221 | \fn void QAxis::shadesVisibleChanged(bool) | |
227 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
222 | Emitted if the visibility of the axis shades is changed to \a visible. | |
228 | */ |
|
223 | */ | |
229 |
|
224 | |||
230 | /*! |
|
225 | /*! | |
231 | \fn void QAxis::shadesColorChanged(QColor) |
|
226 | \fn void QAxis::shadesColorChanged(QColor) | |
232 | Emitted if the \a color of the axis shades is changed. |
|
227 | Emitted if the \a color of the axis shades is changed. | |
233 | */ |
|
228 | */ | |
234 |
|
229 | |||
235 | /*! |
|
230 | /*! | |
236 | \fn void QAxis::shadesBorderColorChanged(QColor) |
|
231 | \fn void QAxis::shadesBorderColorChanged(QColor) | |
237 | Emitted if the border \a color of the axis shades is changed. |
|
232 | Emitted if the border \a color of the axis shades is changed. | |
238 | */ |
|
233 | */ | |
239 |
|
234 | |||
240 | /*! |
|
235 | /*! | |
241 | \fn void QAxis::ticksCountChanged(int count) |
|
|||
242 | \brief Emits the new \a count of ticks on the axis |
|
|||
243 | Signal is emitted when the number of the ticks on the axis has been changed to a different value. |
|
|||
244 | Parementer count\a count is the new number of ticks on the axis. |
|
|||
245 | */ |
|
|||
246 |
|
||||
247 | /*! |
|
|||
248 | \fn void QAxis::niceNumbersEnabledChanged(bool) |
|
|||
249 | Nice numbers algorithm was \a enabled or disabled. |
|
|||
250 | */ |
|
|||
251 |
|
||||
252 | /*! |
|
|||
253 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
236 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
254 | QChart when axis added. |
|
237 | QChart when axis added. | |
255 | */ |
|
238 | */ | |
256 | QAxis::QAxis(QObject *parent) : QObject(parent), |
|
239 | QAxis::QAxis(QObject *parent) : QObject(parent), | |
257 | d_ptr(new QAxisPrivate(this)) |
|
240 | d_ptr(new QAxisPrivate(this)) | |
258 | { |
|
241 | { | |
259 |
|
242 | |||
260 | } |
|
243 | } | |
261 |
|
244 | |||
262 | /*! |
|
245 | /*! | |
263 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
246 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
264 | */ |
|
247 | */ | |
265 |
|
248 | |||
266 | QAxis::~QAxis() |
|
249 | QAxis::~QAxis() | |
267 | { |
|
250 | { | |
268 | } |
|
251 | } | |
269 |
|
252 | |||
270 | /*! |
|
253 | /*! | |
271 | Sets \a pen used to draw axis line and ticks. |
|
254 | Sets \a pen used to draw axis line and ticks. | |
272 | */ |
|
255 | */ | |
273 | void QAxis::setAxisPen(const QPen &pen) |
|
256 | void QAxis::setAxisPen(const QPen &pen) | |
274 | { |
|
257 | { | |
275 | if (d_ptr->m_axisPen!=pen) { |
|
258 | if (d_ptr->m_axisPen!=pen) { | |
276 | d_ptr->m_axisPen = pen; |
|
259 | d_ptr->m_axisPen = pen; | |
277 | emit d_ptr->updated(); |
|
260 | emit d_ptr->updated(); | |
278 | } |
|
261 | } | |
279 | } |
|
262 | } | |
280 |
|
263 | |||
281 | /*! |
|
264 | /*! | |
282 | Returns pen used to draw axis and ticks. |
|
265 | Returns pen used to draw axis and ticks. | |
283 | */ |
|
266 | */ | |
284 | QPen QAxis::axisPen() const |
|
267 | QPen QAxis::axisPen() const | |
285 | { |
|
268 | { | |
286 | return d_ptr->m_axisPen; |
|
269 | return d_ptr->m_axisPen; | |
287 | } |
|
270 | } | |
288 |
|
271 | |||
289 | void QAxis::setAxisPenColor(QColor color) |
|
272 | void QAxis::setAxisPenColor(QColor color) | |
290 | { |
|
273 | { | |
291 | QPen p = d_ptr->m_axisPen; |
|
274 | QPen p = d_ptr->m_axisPen; | |
292 | if (p.color() != color) { |
|
275 | if (p.color() != color) { | |
293 | p.setColor(color); |
|
276 | p.setColor(color); | |
294 | setAxisPen(p); |
|
277 | setAxisPen(p); | |
295 | emit colorChanged(color); |
|
278 | emit colorChanged(color); | |
296 | } |
|
279 | } | |
297 | } |
|
280 | } | |
298 |
|
281 | |||
299 | QColor QAxis::axisPenColor() const |
|
282 | QColor QAxis::axisPenColor() const | |
300 | { |
|
283 | { | |
301 | return d_ptr->m_axisPen.color(); |
|
284 | return d_ptr->m_axisPen.color(); | |
302 | } |
|
285 | } | |
303 |
|
286 | |||
304 | /*! |
|
287 | /*! | |
305 | Sets if axis and ticks are \a visible. |
|
288 | Sets if axis and ticks are \a visible. | |
306 | */ |
|
289 | */ | |
307 | void QAxis::setAxisVisible(bool visible) |
|
290 | void QAxis::setAxisVisible(bool visible) | |
308 | { |
|
291 | { | |
309 | if (d_ptr->m_axisVisible != visible) { |
|
292 | if (d_ptr->m_axisVisible != visible) { | |
310 | d_ptr->m_axisVisible = visible; |
|
293 | d_ptr->m_axisVisible = visible; | |
311 | emit d_ptr->updated(); |
|
294 | emit d_ptr->updated(); | |
312 | emit visibleChanged(visible); |
|
295 | emit visibleChanged(visible); | |
313 | } |
|
296 | } | |
314 | } |
|
297 | } | |
315 |
|
298 | |||
316 | bool QAxis::isAxisVisible() const |
|
299 | bool QAxis::isAxisVisible() const | |
317 | { |
|
300 | { | |
318 | return d_ptr->m_axisVisible; |
|
301 | return d_ptr->m_axisVisible; | |
319 | } |
|
302 | } | |
320 |
|
303 | |||
321 | void QAxis::setGridLineVisible(bool visible) |
|
304 | void QAxis::setGridLineVisible(bool visible) | |
322 | { |
|
305 | { | |
323 | if (d_ptr->m_gridLineVisible != visible) { |
|
306 | if (d_ptr->m_gridLineVisible != visible) { | |
324 | d_ptr->m_gridLineVisible = visible; |
|
307 | d_ptr->m_gridLineVisible = visible; | |
325 | emit d_ptr->updated(); |
|
308 | emit d_ptr->updated(); | |
326 | emit gridVisibleChanged(visible); |
|
309 | emit gridVisibleChanged(visible); | |
327 | } |
|
310 | } | |
328 | } |
|
311 | } | |
329 |
|
312 | |||
330 | bool QAxis::isGridLineVisible() const |
|
313 | bool QAxis::isGridLineVisible() const | |
331 | { |
|
314 | { | |
332 | return d_ptr->m_gridLineVisible; |
|
315 | return d_ptr->m_gridLineVisible; | |
333 | } |
|
316 | } | |
334 |
|
317 | |||
335 | /*! |
|
318 | /*! | |
336 | Sets \a pen used to draw grid line. |
|
319 | Sets \a pen used to draw grid line. | |
337 | */ |
|
320 | */ | |
338 | void QAxis::setGridLinePen(const QPen &pen) |
|
321 | void QAxis::setGridLinePen(const QPen &pen) | |
339 | { |
|
322 | { | |
340 | if (d_ptr->m_gridLinePen != pen) { |
|
323 | if (d_ptr->m_gridLinePen != pen) { | |
341 | d_ptr->m_gridLinePen = pen; |
|
324 | d_ptr->m_gridLinePen = pen; | |
342 | emit d_ptr->updated(); |
|
325 | emit d_ptr->updated(); | |
343 | } |
|
326 | } | |
344 | } |
|
327 | } | |
345 |
|
328 | |||
346 | /*! |
|
329 | /*! | |
347 | Returns pen used to draw grid. |
|
330 | Returns pen used to draw grid. | |
348 | */ |
|
331 | */ | |
349 | QPen QAxis::gridLinePen() const |
|
332 | QPen QAxis::gridLinePen() const | |
350 | { |
|
333 | { | |
351 | return d_ptr->m_gridLinePen; |
|
334 | return d_ptr->m_gridLinePen; | |
352 | } |
|
335 | } | |
353 |
|
336 | |||
354 | void QAxis::setLabelsVisible(bool visible) |
|
337 | void QAxis::setLabelsVisible(bool visible) | |
355 | { |
|
338 | { | |
356 | if (d_ptr->m_labelsVisible != visible) { |
|
339 | if (d_ptr->m_labelsVisible != visible) { | |
357 | d_ptr->m_labelsVisible = visible; |
|
340 | d_ptr->m_labelsVisible = visible; | |
358 | emit d_ptr->updated(); |
|
341 | emit d_ptr->updated(); | |
359 | emit labelsVisibleChanged(visible); |
|
342 | emit labelsVisibleChanged(visible); | |
360 | } |
|
343 | } | |
361 | } |
|
344 | } | |
362 |
|
345 | |||
363 | bool QAxis::labelsVisible() const |
|
346 | bool QAxis::labelsVisible() const | |
364 | { |
|
347 | { | |
365 | return d_ptr->m_labelsVisible; |
|
348 | return d_ptr->m_labelsVisible; | |
366 | } |
|
349 | } | |
367 |
|
350 | |||
368 | /*! |
|
351 | /*! | |
369 | Sets \a pen used to draw labels. |
|
352 | Sets \a pen used to draw labels. | |
370 | */ |
|
353 | */ | |
371 | void QAxis::setLabelsPen(const QPen &pen) |
|
354 | void QAxis::setLabelsPen(const QPen &pen) | |
372 | { |
|
355 | { | |
373 | if (d_ptr->m_labelsPen != pen) { |
|
356 | if (d_ptr->m_labelsPen != pen) { | |
374 | d_ptr->m_labelsPen = pen; |
|
357 | d_ptr->m_labelsPen = pen; | |
375 | emit d_ptr->updated(); |
|
358 | emit d_ptr->updated(); | |
376 | } |
|
359 | } | |
377 | } |
|
360 | } | |
378 |
|
361 | |||
379 | /*! |
|
362 | /*! | |
380 | Returns the pen used to labels. |
|
363 | Returns the pen used to labels. | |
381 | */ |
|
364 | */ | |
382 | QPen QAxis::labelsPen() const |
|
365 | QPen QAxis::labelsPen() const | |
383 | { |
|
366 | { | |
384 | return d_ptr->m_labelsPen; |
|
367 | return d_ptr->m_labelsPen; | |
385 | } |
|
368 | } | |
386 |
|
369 | |||
387 | /*! |
|
370 | /*! | |
388 | Sets \a brush used to draw labels. |
|
371 | Sets \a brush used to draw labels. | |
389 | */ |
|
372 | */ | |
390 | void QAxis::setLabelsBrush(const QBrush &brush) |
|
373 | void QAxis::setLabelsBrush(const QBrush &brush) | |
391 | { |
|
374 | { | |
392 | if (d_ptr->m_labelsBrush != brush) { |
|
375 | if (d_ptr->m_labelsBrush != brush) { | |
393 | d_ptr->m_labelsBrush = brush; |
|
376 | d_ptr->m_labelsBrush = brush; | |
394 | emit d_ptr->updated(); |
|
377 | emit d_ptr->updated(); | |
395 | } |
|
378 | } | |
396 | } |
|
379 | } | |
397 |
|
380 | |||
398 | /*! |
|
381 | /*! | |
399 | Returns brush used to draw labels. |
|
382 | Returns brush used to draw labels. | |
400 | */ |
|
383 | */ | |
401 | QBrush QAxis::labelsBrush() const |
|
384 | QBrush QAxis::labelsBrush() const | |
402 | { |
|
385 | { | |
403 | return d_ptr->m_labelsBrush; |
|
386 | return d_ptr->m_labelsBrush; | |
404 | } |
|
387 | } | |
405 |
|
388 | |||
406 | /*! |
|
389 | /*! | |
407 | Sets \a font used to draw labels. |
|
390 | Sets \a font used to draw labels. | |
408 | */ |
|
391 | */ | |
409 | void QAxis::setLabelsFont(const QFont &font) |
|
392 | void QAxis::setLabelsFont(const QFont &font) | |
410 | { |
|
393 | { | |
411 | if (d_ptr->m_labelsFont != font) { |
|
394 | if (d_ptr->m_labelsFont != font) { | |
412 | d_ptr->m_labelsFont = font; |
|
395 | d_ptr->m_labelsFont = font; | |
413 | emit d_ptr->updated(); |
|
396 | emit d_ptr->updated(); | |
414 | } |
|
397 | } | |
415 | } |
|
398 | } | |
416 |
|
399 | |||
417 | /*! |
|
400 | /*! | |
418 | Returns font used to draw labels. |
|
401 | Returns font used to draw labels. | |
419 | */ |
|
402 | */ | |
420 | QFont QAxis::labelsFont() const |
|
403 | QFont QAxis::labelsFont() const | |
421 | { |
|
404 | { | |
422 | return d_ptr->m_labelsFont; |
|
405 | return d_ptr->m_labelsFont; | |
423 | } |
|
406 | } | |
424 |
|
407 | |||
425 | void QAxis::setLabelsAngle(int angle) |
|
408 | void QAxis::setLabelsAngle(int angle) | |
426 | { |
|
409 | { | |
427 | if (d_ptr->m_labelsAngle != angle) { |
|
410 | if (d_ptr->m_labelsAngle != angle) { | |
428 | d_ptr->m_labelsAngle = angle; |
|
411 | d_ptr->m_labelsAngle = angle; | |
429 | emit d_ptr->updated(); |
|
412 | emit d_ptr->updated(); | |
430 | emit labelsAngleChanged(angle); |
|
|||
431 | } |
|
413 | } | |
432 | } |
|
414 | } | |
433 |
|
415 | |||
434 | int QAxis::labelsAngle() const |
|
416 | int QAxis::labelsAngle() const | |
435 | { |
|
417 | { | |
436 | return d_ptr->m_labelsAngle; |
|
418 | return d_ptr->m_labelsAngle; | |
437 | } |
|
419 | } | |
438 |
|
420 | |||
439 | void QAxis::setLabelsColor(QColor color) |
|
421 | void QAxis::setLabelsColor(QColor color) | |
440 | { |
|
422 | { | |
441 | QBrush b = d_ptr->m_labelsBrush; |
|
423 | QBrush b = d_ptr->m_labelsBrush; | |
442 | if (b.color() != color) { |
|
424 | if (b.color() != color) { | |
443 | b.setColor(color); |
|
425 | b.setColor(color); | |
444 | setLabelsBrush(b); |
|
426 | setLabelsBrush(b); | |
445 | emit labelsColorChanged(color); |
|
427 | emit labelsColorChanged(color); | |
446 | } |
|
428 | } | |
447 | } |
|
429 | } | |
448 |
|
430 | |||
449 | QColor QAxis::labelsColor() const |
|
431 | QColor QAxis::labelsColor() const | |
450 | { |
|
432 | { | |
451 | return d_ptr->m_labelsBrush.color(); |
|
433 | return d_ptr->m_labelsBrush.color(); | |
452 | } |
|
434 | } | |
453 |
|
435 | |||
454 | void QAxis::setShadesVisible(bool visible) |
|
436 | void QAxis::setShadesVisible(bool visible) | |
455 | { |
|
437 | { | |
456 | if (d_ptr->m_shadesVisible != visible) { |
|
438 | if (d_ptr->m_shadesVisible != visible) { | |
457 | d_ptr->m_shadesVisible = visible; |
|
439 | d_ptr->m_shadesVisible = visible; | |
458 | emit d_ptr->updated(); |
|
440 | emit d_ptr->updated(); | |
459 | emit shadesVisibleChanged(visible); |
|
441 | emit shadesVisibleChanged(visible); | |
460 | } |
|
442 | } | |
461 | } |
|
443 | } | |
462 |
|
444 | |||
463 | bool QAxis::shadesVisible() const |
|
445 | bool QAxis::shadesVisible() const | |
464 | { |
|
446 | { | |
465 | return d_ptr->m_shadesVisible; |
|
447 | return d_ptr->m_shadesVisible; | |
466 | } |
|
448 | } | |
467 |
|
449 | |||
468 | /*! |
|
450 | /*! | |
469 | Sets \a pen used to draw shades. |
|
451 | Sets \a pen used to draw shades. | |
470 | */ |
|
452 | */ | |
471 | void QAxis::setShadesPen(const QPen &pen) |
|
453 | void QAxis::setShadesPen(const QPen &pen) | |
472 | { |
|
454 | { | |
473 | if (d_ptr->m_shadesPen != pen) { |
|
455 | if (d_ptr->m_shadesPen != pen) { | |
474 | d_ptr->m_shadesPen = pen; |
|
456 | d_ptr->m_shadesPen = pen; | |
475 | emit d_ptr->updated(); |
|
457 | emit d_ptr->updated(); | |
476 | } |
|
458 | } | |
477 | } |
|
459 | } | |
478 |
|
460 | |||
479 | /*! |
|
461 | /*! | |
480 | Returns pen used to draw shades. |
|
462 | Returns pen used to draw shades. | |
481 | */ |
|
463 | */ | |
482 | QPen QAxis::shadesPen() const |
|
464 | QPen QAxis::shadesPen() const | |
483 | { |
|
465 | { | |
484 | return d_ptr->m_shadesPen; |
|
466 | return d_ptr->m_shadesPen; | |
485 | } |
|
467 | } | |
486 |
|
468 | |||
487 | /*! |
|
469 | /*! | |
488 | Sets \a brush used to draw shades. |
|
470 | Sets \a brush used to draw shades. | |
489 | */ |
|
471 | */ | |
490 | void QAxis::setShadesBrush(const QBrush &brush) |
|
472 | void QAxis::setShadesBrush(const QBrush &brush) | |
491 | { |
|
473 | { | |
492 | if (d_ptr->m_shadesBrush != brush) { |
|
474 | if (d_ptr->m_shadesBrush != brush) { | |
493 | d_ptr->m_shadesBrush = brush; |
|
475 | d_ptr->m_shadesBrush = brush; | |
494 | emit d_ptr->updated(); |
|
476 | emit d_ptr->updated(); | |
495 | emit shadesColorChanged(brush.color()); |
|
477 | emit shadesColorChanged(brush.color()); | |
496 | } |
|
478 | } | |
497 | } |
|
479 | } | |
498 |
|
480 | |||
499 | /*! |
|
481 | /*! | |
500 | \brief Returns brush used to draw shades. |
|
482 | \brief Returns brush used to draw shades. | |
501 | */ |
|
483 | */ | |
502 | QBrush QAxis::shadesBrush() const |
|
484 | QBrush QAxis::shadesBrush() const | |
503 | { |
|
485 | { | |
504 | return d_ptr->m_shadesBrush; |
|
486 | return d_ptr->m_shadesBrush; | |
505 | } |
|
487 | } | |
506 |
|
488 | |||
507 | void QAxis::setShadesColor(QColor color) |
|
489 | void QAxis::setShadesColor(QColor color) | |
508 | { |
|
490 | { | |
509 | QBrush b = d_ptr->m_shadesBrush; |
|
491 | QBrush b = d_ptr->m_shadesBrush; | |
510 | b.setColor(color); |
|
492 | b.setColor(color); | |
511 | setShadesBrush(b); |
|
493 | setShadesBrush(b); | |
512 | } |
|
494 | } | |
513 |
|
495 | |||
514 | QColor QAxis::shadesColor() const |
|
496 | QColor QAxis::shadesColor() const | |
515 | { |
|
497 | { | |
516 | return d_ptr->m_shadesBrush.color(); |
|
498 | return d_ptr->m_shadesBrush.color(); | |
517 | } |
|
499 | } | |
518 |
|
500 | |||
519 | void QAxis::setShadesBorderColor(QColor color) |
|
501 | void QAxis::setShadesBorderColor(QColor color) | |
520 | { |
|
502 | { | |
521 | QPen p = d_ptr->m_shadesPen; |
|
503 | QPen p = d_ptr->m_shadesPen; | |
522 | p.setColor(color); |
|
504 | p.setColor(color); | |
523 | setShadesPen(p); |
|
505 | setShadesPen(p); | |
524 | } |
|
506 | } | |
525 |
|
507 | |||
526 | QColor QAxis::shadesBorderColor() const |
|
508 | QColor QAxis::shadesBorderColor() const | |
527 | { |
|
509 | { | |
528 | return d_ptr->m_shadesPen.color(); |
|
510 | return d_ptr->m_shadesPen.color(); | |
529 | } |
|
511 | } | |
530 |
|
512 | |||
531 | void QAxis::setMin(qreal min) |
|
513 | void QAxis::setMin(qreal min) | |
532 | { |
|
514 | { | |
533 | setRange(min,d_ptr->m_max); |
|
515 | setRange(min,d_ptr->m_max); | |
534 | } |
|
516 | } | |
535 |
|
517 | |||
536 | qreal QAxis::min() const |
|
518 | qreal QAxis::min() const | |
537 | { |
|
519 | { | |
538 | return d_ptr->m_min; |
|
520 | return d_ptr->m_min; | |
539 | } |
|
521 | } | |
540 |
|
522 | |||
541 | void QAxis::setMax(qreal max) |
|
523 | void QAxis::setMax(qreal max) | |
542 | { |
|
524 | { | |
543 | setRange(d_ptr->m_min,max); |
|
525 | setRange(d_ptr->m_min,max); | |
544 | } |
|
526 | } | |
545 |
|
527 | |||
546 | qreal QAxis::max() const |
|
528 | qreal QAxis::max() const | |
547 | { |
|
529 | { | |
548 | return d_ptr->m_max; |
|
530 | return d_ptr->m_max; | |
549 | } |
|
531 | } | |
550 |
|
532 | |||
551 | /*! |
|
533 | /*! | |
552 | Sets range from \a min to \a max on the axis. |
|
534 | Sets range from \a min to \a max on the axis. | |
553 | */ |
|
535 | */ | |
554 | void QAxis::setRange(qreal min, qreal max) |
|
536 | void QAxis::setRange(qreal min, qreal max) | |
555 | { |
|
537 | { | |
556 | bool changed = false; |
|
538 | bool changed = false; | |
557 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { |
|
539 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { | |
558 | d_ptr->m_min = min; |
|
540 | d_ptr->m_min = min; | |
559 | changed = true; |
|
541 | changed = true; | |
560 | emit minChanged(min); |
|
542 | emit minChanged(min); | |
561 | } |
|
543 | } | |
562 |
|
544 | |||
563 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { |
|
545 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { | |
564 | d_ptr->m_max = max; |
|
546 | d_ptr->m_max = max; | |
565 | changed = true; |
|
547 | changed = true; | |
566 | emit maxChanged(max); |
|
548 | emit maxChanged(max); | |
567 | } |
|
549 | } | |
568 |
|
550 | |||
569 | if (changed) { |
|
551 | if (changed) { | |
570 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); |
|
552 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); | |
571 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
553 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
572 | } |
|
554 | } | |
573 | } |
|
555 | } | |
574 |
|
556 | |||
575 | /*! |
|
557 | /*! | |
576 | Sets \a count for ticks on the axis. |
|
558 | Sets \a count for ticks on the axis. | |
577 | */ |
|
559 | */ | |
578 | void QAxis::setTicksCount(int count) |
|
560 | void QAxis::setTicksCount(int count) | |
579 | { |
|
561 | { | |
580 | if (d_ptr->m_ticksCount != count) { |
|
562 | if (d_ptr->m_ticksCount != count) { | |
581 | d_ptr->m_ticksCount = count; |
|
563 | d_ptr->m_ticksCount = count; | |
582 | emit ticksCountChanged(count); |
|
|||
583 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
564 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
584 | } |
|
565 | } | |
585 | } |
|
566 | } | |
586 |
|
567 | |||
587 | /*! |
|
568 | /*! | |
588 | \fn int QAxis::ticksCount() const |
|
569 | \fn int QAxis::ticksCount() const | |
589 | Return number of ticks on the axis |
|
570 | Return number of ticks on the axis | |
590 | */ |
|
571 | */ | |
591 | int QAxis::ticksCount() const |
|
572 | int QAxis::ticksCount() const | |
592 | { |
|
573 | { | |
593 | return d_ptr->m_ticksCount; |
|
574 | return d_ptr->m_ticksCount; | |
594 | } |
|
575 | } | |
595 |
|
576 | |||
596 | /*! |
|
577 | /*! | |
597 | Sets axis, shades, labels and grid lines to be visible. |
|
578 | Sets axis, shades, labels and grid lines to be visible. | |
598 | */ |
|
579 | */ | |
599 | void QAxis::show() |
|
580 | void QAxis::show() | |
600 | { |
|
581 | { | |
601 | d_ptr->m_axisVisible=true; |
|
582 | d_ptr->m_axisVisible=true; | |
602 | d_ptr->m_gridLineVisible=true; |
|
583 | d_ptr->m_gridLineVisible=true; | |
603 | d_ptr->m_labelsVisible=true; |
|
584 | d_ptr->m_labelsVisible=true; | |
604 | d_ptr->m_shadesVisible=true; |
|
585 | d_ptr->m_shadesVisible=true; | |
605 | emit d_ptr->updated(); |
|
586 | emit d_ptr->updated(); | |
606 | } |
|
587 | } | |
607 |
|
588 | |||
608 | /*! |
|
589 | /*! | |
609 | Sets axis, shades, labels and grid lines to not be visible. |
|
590 | Sets axis, shades, labels and grid lines to not be visible. | |
610 | */ |
|
591 | */ | |
611 | void QAxis::hide() |
|
592 | void QAxis::hide() | |
612 | { |
|
593 | { | |
613 | d_ptr->m_axisVisible = false; |
|
594 | d_ptr->m_axisVisible = false; | |
614 | d_ptr->m_gridLineVisible = false; |
|
595 | d_ptr->m_gridLineVisible = false; | |
615 | d_ptr->m_labelsVisible = false; |
|
596 | d_ptr->m_labelsVisible = false; | |
616 | d_ptr->m_shadesVisible = false; |
|
597 | d_ptr->m_shadesVisible = false; | |
617 | emit d_ptr->updated(); |
|
598 | emit d_ptr->updated(); | |
618 | } |
|
599 | } | |
619 |
|
600 | |||
620 | void QAxis::setNiceNumbersEnabled(bool enable) |
|
601 | void QAxis::setNiceNumbersEnabled(bool enable) | |
621 | { |
|
602 | { | |
622 | if (d_ptr->m_niceNumbers != enable){ |
|
603 | if (d_ptr->m_niceNumbers != enable){ | |
623 | d_ptr->m_niceNumbers = enable; |
|
604 | d_ptr->m_niceNumbers = enable; | |
624 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); |
|
605 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
625 | emit niceNumbersEnabledChanged(enable); |
|
|||
626 | } |
|
606 | } | |
627 | } |
|
607 | } | |
628 |
|
608 | |||
629 | bool QAxis::niceNumbersEnabled() const |
|
609 | bool QAxis::niceNumbersEnabled() const | |
630 | { |
|
610 | { | |
631 | return d_ptr->m_niceNumbers; |
|
611 | return d_ptr->m_niceNumbers; | |
632 | } |
|
612 | } | |
633 |
|
613 | |||
634 | QAxisCategories* QAxis::categories() |
|
614 | QAxisCategories* QAxis::categories() | |
635 | { |
|
615 | { | |
636 | return &d_ptr->m_category; |
|
616 | return &d_ptr->m_category; | |
637 | } |
|
617 | } | |
638 |
|
618 | |||
639 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
619 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
640 |
|
620 | |||
641 | QAxisPrivate::QAxisPrivate(QAxis* q): |
|
621 | QAxisPrivate::QAxisPrivate(QAxis* q): | |
642 | q_ptr(q), |
|
622 | q_ptr(q), | |
643 | m_axisVisible(true), |
|
623 | m_axisVisible(true), | |
644 | m_gridLineVisible(true), |
|
624 | m_gridLineVisible(true), | |
645 | m_labelsVisible(true), |
|
625 | m_labelsVisible(true), | |
646 | m_labelsAngle(0), |
|
626 | m_labelsAngle(0), | |
647 | m_shadesVisible(false), |
|
627 | m_shadesVisible(false), | |
648 | m_shadesBrush(Qt::SolidPattern), |
|
628 | m_shadesBrush(Qt::SolidPattern), | |
649 | m_shadesOpacity(1.0), |
|
629 | m_shadesOpacity(1.0), | |
650 | m_min(0), |
|
630 | m_min(0), | |
651 | m_max(0), |
|
631 | m_max(0), | |
652 | m_ticksCount(5), |
|
632 | m_ticksCount(5), | |
653 | m_niceNumbers(false) |
|
633 | m_niceNumbers(false) | |
654 | { |
|
634 | { | |
655 |
|
635 | |||
656 | } |
|
636 | } | |
657 |
|
637 | |||
658 | QAxisPrivate::~QAxisPrivate() |
|
638 | QAxisPrivate::~QAxisPrivate() | |
659 | { |
|
639 | { | |
660 |
|
640 | |||
661 | } |
|
641 | } | |
662 |
|
642 | |||
663 | void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
643 | void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
664 | { |
|
644 | { | |
665 | q_ptr->setRange(min,max); |
|
645 | q_ptr->setRange(min,max); | |
666 | q_ptr->setTicksCount(count); |
|
646 | q_ptr->setTicksCount(count); | |
667 | } |
|
647 | } | |
668 |
|
648 | |||
669 | QTCOMMERCIALCHART_END_NAMESPACE |
|
649 | QTCOMMERCIALCHART_END_NAMESPACE | |
670 |
|
650 | |||
671 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
651 | QTCOMMERCIALCHART_USE_NAMESPACE | |
672 |
|
652 | |||
673 | #include "moc_qaxis.cpp" |
|
653 | #include "moc_qaxis.cpp" | |
674 | #include "moc_qaxis_p.cpp" |
|
654 | #include "moc_qaxis_p.cpp" |
@@ -1,138 +1,135 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QAXIS_H |
|
21 | #ifndef QAXIS_H | |
22 | #define QAXIS_H |
|
22 | #define QAXIS_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qaxiscategories.h> |
|
25 | #include <qaxiscategories.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QFont> |
|
27 | #include <QFont> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QAxisPrivate; |
|
31 | class QAxisPrivate; | |
32 |
|
32 | |||
33 | class QTCOMMERCIALCHART_EXPORT QAxis : public QObject |
|
33 | class QTCOMMERCIALCHART_EXPORT QAxis : public QObject | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged) |
|
36 | Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged) | |
37 | Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged) |
|
37 | Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged) | |
38 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
38 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) | |
39 |
Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle |
|
39 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle) | |
40 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
|
40 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) | |
41 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) |
|
41 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) | |
42 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
|
42 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) | |
43 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
|
43 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) | |
44 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
|
44 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) | |
45 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) |
|
45 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) | |
46 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) |
|
46 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) | |
47 |
Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount |
|
47 | Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount) | |
48 |
Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled |
|
48 | Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled) | |
49 |
|
49 | |||
50 | public: |
|
50 | public: | |
51 |
|
51 | |||
52 | QAxis(QObject *parent =0); |
|
52 | QAxis(QObject *parent =0); | |
53 | ~QAxis(); |
|
53 | ~QAxis(); | |
54 |
|
54 | |||
55 | //axis handling |
|
55 | //axis handling | |
56 | bool isAxisVisible() const; |
|
56 | bool isAxisVisible() const; | |
57 | void setAxisVisible(bool visible = true); |
|
57 | void setAxisVisible(bool visible = true); | |
58 | void setAxisPen(const QPen &pen); |
|
58 | void setAxisPen(const QPen &pen); | |
59 | QPen axisPen() const; |
|
59 | QPen axisPen() const; | |
60 | void setAxisPenColor(QColor color); |
|
60 | void setAxisPenColor(QColor color); | |
61 | QColor axisPenColor() const; |
|
61 | QColor axisPenColor() const; | |
62 |
|
62 | |||
63 | //grid handling |
|
63 | //grid handling | |
64 | bool isGridLineVisible() const; |
|
64 | bool isGridLineVisible() const; | |
65 | void setGridLineVisible(bool visible = true); |
|
65 | void setGridLineVisible(bool visible = true); | |
66 | void setGridLinePen(const QPen &pen); |
|
66 | void setGridLinePen(const QPen &pen); | |
67 | QPen gridLinePen() const; |
|
67 | QPen gridLinePen() const; | |
68 |
|
68 | |||
69 | //labels handling |
|
69 | //labels handling | |
70 | bool labelsVisible() const; |
|
70 | bool labelsVisible() const; | |
71 | void setLabelsVisible(bool visible = true); |
|
71 | void setLabelsVisible(bool visible = true); | |
72 | void setLabelsPen(const QPen &pen); |
|
72 | void setLabelsPen(const QPen &pen); | |
73 | QPen labelsPen() const; |
|
73 | QPen labelsPen() const; | |
74 | void setLabelsBrush(const QBrush &brush); |
|
74 | void setLabelsBrush(const QBrush &brush); | |
75 | QBrush labelsBrush() const; |
|
75 | QBrush labelsBrush() const; | |
76 | void setLabelsFont(const QFont &font); |
|
76 | void setLabelsFont(const QFont &font); | |
77 | QFont labelsFont() const; |
|
77 | QFont labelsFont() const; | |
78 | void setLabelsAngle(int angle); |
|
78 | void setLabelsAngle(int angle); | |
79 | int labelsAngle() const; |
|
79 | int labelsAngle() const; | |
80 | void setLabelsColor(QColor color); |
|
80 | void setLabelsColor(QColor color); | |
81 | QColor labelsColor() const; |
|
81 | QColor labelsColor() const; | |
82 |
|
82 | |||
83 | //shades handling |
|
83 | //shades handling | |
84 | bool shadesVisible() const; |
|
84 | bool shadesVisible() const; | |
85 | void setShadesVisible(bool visible = true); |
|
85 | void setShadesVisible(bool visible = true); | |
86 | void setShadesPen(const QPen &pen); |
|
86 | void setShadesPen(const QPen &pen); | |
87 | QPen shadesPen() const; |
|
87 | QPen shadesPen() const; | |
88 | void setShadesBrush(const QBrush &brush); |
|
88 | void setShadesBrush(const QBrush &brush); | |
89 | QBrush shadesBrush() const; |
|
89 | QBrush shadesBrush() const; | |
90 | void setShadesColor(QColor color); |
|
90 | void setShadesColor(QColor color); | |
91 | QColor shadesColor() const; |
|
91 | QColor shadesColor() const; | |
92 | void setShadesBorderColor(QColor color); |
|
92 | void setShadesBorderColor(QColor color); | |
93 | QColor shadesBorderColor() const; |
|
93 | QColor shadesBorderColor() const; | |
94 |
|
94 | |||
95 | //range handling |
|
95 | //range handling | |
96 | void setMin(qreal min); |
|
96 | void setMin(qreal min); | |
97 | qreal min() const; |
|
97 | qreal min() const; | |
98 | void setMax(qreal max); |
|
98 | void setMax(qreal max); | |
99 | qreal max() const; |
|
99 | qreal max() const; | |
100 | void setRange(qreal min, qreal max); |
|
100 | void setRange(qreal min, qreal max); | |
101 |
|
101 | |||
102 | //ticks handling |
|
102 | //ticks handling | |
103 | void setTicksCount(int count); |
|
103 | void setTicksCount(int count); | |
104 | int ticksCount() const; |
|
104 | int ticksCount() const; | |
105 |
|
105 | |||
106 | void setNiceNumbersEnabled(bool enable = true); |
|
106 | void setNiceNumbersEnabled(bool enable = true); | |
107 | bool niceNumbersEnabled() const; |
|
107 | bool niceNumbersEnabled() const; | |
108 |
|
108 | |||
109 | QAxisCategories* categories(); |
|
109 | QAxisCategories* categories(); | |
110 |
|
110 | |||
111 | void show(); |
|
111 | void show(); | |
112 | void hide(); |
|
112 | void hide(); | |
113 |
|
113 | |||
114 | Q_SIGNALS: |
|
114 | Q_SIGNALS: | |
115 | void visibleChanged(bool visible); |
|
115 | void visibleChanged(bool visible); | |
116 | void labelsVisibleChanged(bool visible); |
|
116 | void labelsVisibleChanged(bool visible); | |
117 | void gridVisibleChanged(bool visible); |
|
117 | void gridVisibleChanged(bool visible); | |
118 | void rangeChanged(qreal min, qreal max); |
|
118 | void rangeChanged(qreal min, qreal max); | |
119 | void colorChanged(QColor color); |
|
119 | void colorChanged(QColor color); | |
120 | void labelsColorChanged(QColor color); |
|
120 | void labelsColorChanged(QColor color); | |
121 | void labelsAngleChanged(int angle); |
|
|||
122 | void shadesVisibleChanged(bool visible); |
|
121 | void shadesVisibleChanged(bool visible); | |
123 | void shadesColorChanged(QColor color); |
|
122 | void shadesColorChanged(QColor color); | |
124 | void shadesBorderColorChanged(QColor color); |
|
123 | void shadesBorderColorChanged(QColor color); | |
125 | void minChanged(qreal min); |
|
124 | void minChanged(qreal min); | |
126 | void maxChanged(qreal max); |
|
125 | void maxChanged(qreal max); | |
127 | void ticksCountChanged(int count); |
|
|||
128 | void niceNumbersEnabledChanged(bool enabled); |
|
|||
129 |
|
126 | |||
130 | private: |
|
127 | private: | |
131 | QScopedPointer<QAxisPrivate> d_ptr; |
|
128 | QScopedPointer<QAxisPrivate> d_ptr; | |
132 | Q_DISABLE_COPY(QAxis) |
|
129 | Q_DISABLE_COPY(QAxis) | |
133 | friend class ChartDataSet; |
|
130 | friend class ChartDataSet; | |
134 | friend class ChartAxis; |
|
131 | friend class ChartAxis; | |
135 | }; |
|
132 | }; | |
136 |
|
133 | |||
137 | QTCOMMERCIALCHART_END_NAMESPACE |
|
134 | QTCOMMERCIALCHART_END_NAMESPACE | |
138 | #endif /* QCHARTAXIS_H_ */ |
|
135 | #endif /* QCHARTAXIS_H_ */ |
@@ -1,768 +1,762 | |||||
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 "qlegend.h" |
|
21 | #include "qlegend.h" | |
22 | #include "qlegend_p.h" |
|
22 | #include "qlegend_p.h" | |
23 | #include "qabstractseries.h" |
|
23 | #include "qabstractseries.h" | |
24 | #include "qabstractseries_p.h" |
|
24 | #include "qabstractseries_p.h" | |
25 | #include "qchart_p.h" |
|
25 | #include "qchart_p.h" | |
26 |
|
26 | |||
27 | #include "legendmarker_p.h" |
|
27 | #include "legendmarker_p.h" | |
28 | #include "qxyseries.h" |
|
28 | #include "qxyseries.h" | |
29 | #include "qlineseries.h" |
|
29 | #include "qlineseries.h" | |
30 | #include "qareaseries.h" |
|
30 | #include "qareaseries.h" | |
31 | #include "qscatterseries.h" |
|
31 | #include "qscatterseries.h" | |
32 | #include "qsplineseries.h" |
|
32 | #include "qsplineseries.h" | |
33 | #include "qbarseries.h" |
|
33 | #include "qbarseries.h" | |
34 | #include "qstackedbarseries.h" |
|
34 | #include "qstackedbarseries.h" | |
35 | #include "qpercentbarseries.h" |
|
35 | #include "qpercentbarseries.h" | |
36 | #include "qbarset.h" |
|
36 | #include "qbarset.h" | |
37 | #include "qpieseries.h" |
|
37 | #include "qpieseries.h" | |
38 | #include "qpieseries_p.h" |
|
38 | #include "qpieseries_p.h" | |
39 | #include "qpieslice.h" |
|
39 | #include "qpieslice.h" | |
40 | #include "chartpresenter_p.h" |
|
40 | #include "chartpresenter_p.h" | |
41 | #include <QPainter> |
|
41 | #include <QPainter> | |
42 | #include <QPen> |
|
42 | #include <QPen> | |
43 | #include <QTimer> |
|
43 | #include <QTimer> | |
44 |
|
44 | |||
45 | #include <QGraphicsSceneEvent> |
|
45 | #include <QGraphicsSceneEvent> | |
46 |
|
46 | |||
47 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
47 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \class QLegend |
|
50 | \class QLegend | |
51 | \brief part of QtCommercial chart API. |
|
51 | \brief part of QtCommercial chart API. | |
52 | \mainclass |
|
52 | \mainclass | |
53 |
|
53 | |||
54 | QLegend is a graphical object, whics displays legend of the chart. Legend state is updated by QChart, when |
|
54 | QLegend is a graphical object, whics displays legend of the chart. Legend state is updated by QChart, when | |
55 | series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and |
|
55 | series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and | |
56 | handle the drawing manually. |
|
56 | handle the drawing manually. | |
57 | User isn't supposed to create or delete legend objects, but can reference it via QChart class. |
|
57 | User isn't supposed to create or delete legend objects, but can reference it via QChart class. | |
58 |
|
58 | |||
59 | \image examples_percentbarchart_legend.png |
|
59 | \image examples_percentbarchart_legend.png | |
60 |
|
60 | |||
61 | \sa QChart |
|
61 | \sa QChart | |
62 | */ |
|
62 | */ | |
63 | /*! |
|
63 | /*! | |
64 | \qmlclass Legend QLegend |
|
64 | \qmlclass Legend QLegend | |
65 | \brief Legend is part of QtCommercial Chart QML API. |
|
65 | \brief Legend is part of QtCommercial Chart QML API. | |
66 |
|
66 | |||
67 | Legend is a graphical object, whics displays legend of the chart. Legend state is updated by ChartView, when |
|
67 | Legend is a graphical object, whics displays legend of the chart. Legend state is updated by ChartView, when | |
68 | series have been changed. Legend is used via ChartView class. For example: |
|
68 | series have been changed. Legend is used via ChartView class. For example: | |
69 | \code |
|
69 | \code | |
70 | ChartView { |
|
70 | ChartView { | |
71 | legend.visible: true |
|
71 | legend.visible: true | |
72 | legend.alignment: Qt.AlignBottom |
|
72 | legend.alignment: Qt.AlignBottom | |
73 | // Add a few series... |
|
73 | // Add a few series... | |
74 | } |
|
74 | } | |
75 | \endcode |
|
75 | \endcode | |
76 |
|
76 | |||
77 | \image examples_percentbarchart_legend.png |
|
77 | \image examples_percentbarchart_legend.png | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \property QLegend::alignment |
|
81 | \property QLegend::alignment | |
82 | \brief The alignment of the legend. |
|
82 | \brief The alignment of the legend. | |
83 |
|
83 | |||
84 | Legend paints on the defined position in the chart. The following alignments are supported: |
|
84 | Legend paints on the defined position in the chart. The following alignments are supported: | |
85 | Qt::AlignTop, Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight. If you set more than one flag the result is undefined. |
|
85 | Qt::AlignTop, Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight. If you set more than one flag the result is undefined. | |
86 | */ |
|
86 | */ | |
87 | /*! |
|
87 | /*! | |
88 | \qmlproperty Qt.Alignment Legend::alignment |
|
88 | \qmlproperty Qt.Alignment Legend::alignment | |
89 | \brief The alignment of the legend. |
|
89 | \brief The alignment of the legend. | |
90 |
|
90 | |||
91 | Legend paints on the defined position in the chart. The following alignments are supported: |
|
91 | Legend paints on the defined position in the chart. The following alignments are supported: | |
92 | Qt.AlignTop, Qt.AlignBottom, Qt.AlignLeft, Qt.AlignRight. If you set more than one flag the result is undefined. |
|
92 | Qt.AlignTop, Qt.AlignBottom, Qt.AlignLeft, Qt.AlignRight. If you set more than one flag the result is undefined. | |
93 | */ |
|
93 | */ | |
94 |
|
94 | |||
95 | /*! |
|
95 | /*! | |
96 | \property QLegend::backgroundVisible |
|
96 | \property QLegend::backgroundVisible | |
97 | Whether the legend background is visible or not. |
|
97 | Whether the legend background is visible or not. | |
98 | */ |
|
98 | */ | |
99 | /*! |
|
99 | /*! | |
100 | \qmlproperty bool Legend::backgroundVisible |
|
100 | \qmlproperty bool Legend::backgroundVisible | |
101 | Whether the legend background is visible or not. |
|
101 | Whether the legend background is visible or not. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \property QLegend::color |
|
105 | \property QLegend::color | |
106 | The color of the legend, i.e. the background (brush) color. Note that if you change the color |
|
106 | The color of the legend, i.e. the background (brush) color. Note that if you change the color | |
107 | of the legend, the style of the legend brush is set to Qt::SolidPattern. |
|
107 | of the legend, the style of the legend brush is set to Qt::SolidPattern. | |
108 | */ |
|
108 | */ | |
109 | /*! |
|
109 | /*! | |
110 | \qmlproperty color Legend::color |
|
110 | \qmlproperty color Legend::color | |
111 | The color of the legend, i.e. the background (brush) color. |
|
111 | The color of the legend, i.e. the background (brush) color. | |
112 | */ |
|
112 | */ | |
113 |
|
113 | |||
114 | /*! |
|
114 | /*! | |
115 | \property QLegend::borderColor |
|
115 | \property QLegend::borderColor | |
116 | The border color of the legend, i.e. the line color. |
|
116 | The border color of the legend, i.e. the line color. | |
117 | */ |
|
117 | */ | |
118 | /*! |
|
118 | /*! | |
119 | \qmlproperty color Legend::borderColor |
|
119 | \qmlproperty color Legend::borderColor | |
120 | The border color of the legend, i.e. the line color. |
|
120 | The border color of the legend, i.e. the line color. | |
121 | */ |
|
121 | */ | |
122 |
|
122 | |||
123 | /*! |
|
123 | /*! | |
124 | \fn void QLegend::alignmentChanged(Qt::Alignment) |
|
|||
125 | Emitted when the \a alignment of the legend changes. |
|
|||
126 | */ |
|
|||
127 |
|
||||
128 | /*! |
|
|||
129 | \fn void QLegend::backgroundVisibleChanged(bool) |
|
124 | \fn void QLegend::backgroundVisibleChanged(bool) | |
130 | The visibility of the legend background changed to \a visible. |
|
125 | The visibility of the legend background changed to \a visible. | |
131 | */ |
|
126 | */ | |
132 |
|
127 | |||
133 | /*! |
|
128 | /*! | |
134 | \fn void QLegend::colorChanged(QColor) |
|
129 | \fn void QLegend::colorChanged(QColor) | |
135 | The color of the legend background changed to \a color. |
|
130 | The color of the legend background changed to \a color. | |
136 | */ |
|
131 | */ | |
137 |
|
132 | |||
138 | /*! |
|
133 | /*! | |
139 | \fn void QLegend::borderColorChanged(QColor) |
|
134 | \fn void QLegend::borderColorChanged(QColor) | |
140 | The border color of the legend background changed to \a color. |
|
135 | The border color of the legend background changed to \a color. | |
141 | */ |
|
136 | */ | |
142 |
|
137 | |||
143 | /*! |
|
138 | /*! | |
144 | \fn qreal QLegend::minWidth() const |
|
139 | \fn qreal QLegend::minWidth() const | |
145 | Returns minimum width of the legend |
|
140 | Returns minimum width of the legend | |
146 | */ |
|
141 | */ | |
147 |
|
142 | |||
148 | /*! |
|
143 | /*! | |
149 | \fn qreal QLegend::minHeight() const |
|
144 | \fn qreal QLegend::minHeight() const | |
150 | Returns minimum height of the legend |
|
145 | Returns minimum height of the legend | |
151 | */ |
|
146 | */ | |
152 |
|
147 | |||
153 | /*! |
|
148 | /*! | |
154 | Constructs the legend object and sets the parent to \a parent |
|
149 | Constructs the legend object and sets the parent to \a parent | |
155 | */ |
|
150 | */ | |
156 |
|
151 | |||
157 | QLegend::QLegend(QChart *chart):QGraphicsWidget(chart), |
|
152 | QLegend::QLegend(QChart *chart):QGraphicsWidget(chart), | |
158 | d_ptr(new QLegendPrivate(chart->d_ptr->m_presenter,chart,this)) |
|
153 | d_ptr(new QLegendPrivate(chart->d_ptr->m_presenter,chart,this)) | |
159 | { |
|
154 | { | |
160 | setZValue(ChartPresenter::LegendZValue); |
|
155 | setZValue(ChartPresenter::LegendZValue); | |
161 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
|
156 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); | |
162 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),d_ptr.data(),SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); |
|
157 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),d_ptr.data(),SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); | |
163 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesRemoved(QAbstractSeries*))); |
|
158 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesRemoved(QAbstractSeries*))); | |
164 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesUpdated(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesUpdated(QAbstractSeries*))); |
|
159 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesUpdated(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesUpdated(QAbstractSeries*))); | |
165 | } |
|
160 | } | |
166 |
|
161 | |||
167 | /*! |
|
162 | /*! | |
168 | Destroys the legend object. Legend is always owned by a QChart, so an application should never call this. |
|
163 | Destroys the legend object. Legend is always owned by a QChart, so an application should never call this. | |
169 | */ |
|
164 | */ | |
170 | QLegend::~QLegend() |
|
165 | QLegend::~QLegend() | |
171 | { |
|
166 | { | |
172 | } |
|
167 | } | |
173 |
|
168 | |||
174 | /*! |
|
169 | /*! | |
175 | Paints the legend to given \a painter. Paremeters \a option and \a widget arent used. |
|
170 | Paints the legend to given \a painter. Paremeters \a option and \a widget arent used. | |
176 | */ |
|
171 | */ | |
177 |
|
172 | |||
178 | void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
173 | void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
179 | { |
|
174 | { | |
180 | Q_UNUSED(option) |
|
175 | Q_UNUSED(option) | |
181 | Q_UNUSED(widget) |
|
176 | Q_UNUSED(widget) | |
182 | if(!d_ptr->m_backgroundVisible) return; |
|
177 | if(!d_ptr->m_backgroundVisible) return; | |
183 |
|
178 | |||
184 | painter->setOpacity(opacity()); |
|
179 | painter->setOpacity(opacity()); | |
185 | painter->setPen(d_ptr->m_pen); |
|
180 | painter->setPen(d_ptr->m_pen); | |
186 | painter->setBrush(d_ptr->m_brush); |
|
181 | painter->setBrush(d_ptr->m_brush); | |
187 | painter->drawRoundRect(rect(),d_ptr->roundness(rect().width()),d_ptr->roundness(rect().height())); |
|
182 | painter->drawRoundRect(rect(),d_ptr->roundness(rect().width()),d_ptr->roundness(rect().height())); | |
188 | } |
|
183 | } | |
189 |
|
184 | |||
190 | /*! |
|
185 | /*! | |
191 | Bounding rect of legend. |
|
186 | Bounding rect of legend. | |
192 | */ |
|
187 | */ | |
193 |
|
188 | |||
194 | QRectF QLegend::boundingRect() const |
|
189 | QRectF QLegend::boundingRect() const | |
195 | { |
|
190 | { | |
196 | return d_ptr->m_rect; |
|
191 | return d_ptr->m_rect; | |
197 | } |
|
192 | } | |
198 |
|
193 | |||
199 | /*! |
|
194 | /*! | |
200 | Sets the \a brush of legend. Brush affects the background of legend. |
|
195 | Sets the \a brush of legend. Brush affects the background of legend. | |
201 | */ |
|
196 | */ | |
202 | void QLegend::setBrush(const QBrush &brush) |
|
197 | void QLegend::setBrush(const QBrush &brush) | |
203 | { |
|
198 | { | |
204 | if (d_ptr->m_brush != brush) { |
|
199 | if (d_ptr->m_brush != brush) { | |
205 | d_ptr->m_brush = brush; |
|
200 | d_ptr->m_brush = brush; | |
206 | update(); |
|
201 | update(); | |
207 | } |
|
202 | } | |
208 | } |
|
203 | } | |
209 |
|
204 | |||
210 | /*! |
|
205 | /*! | |
211 | Returns the brush used by legend. |
|
206 | Returns the brush used by legend. | |
212 | */ |
|
207 | */ | |
213 | QBrush QLegend::brush() const |
|
208 | QBrush QLegend::brush() const | |
214 | { |
|
209 | { | |
215 | return d_ptr->m_brush; |
|
210 | return d_ptr->m_brush; | |
216 | } |
|
211 | } | |
217 |
|
212 | |||
218 | void QLegend::setColor(QColor color) |
|
213 | void QLegend::setColor(QColor color) | |
219 | { |
|
214 | { | |
220 | QBrush b = d_ptr->m_brush; |
|
215 | QBrush b = d_ptr->m_brush; | |
221 | if (b.style() != Qt::SolidPattern || b.color() != color) { |
|
216 | if (b.style() != Qt::SolidPattern || b.color() != color) { | |
222 | b.setStyle(Qt::SolidPattern); |
|
217 | b.setStyle(Qt::SolidPattern); | |
223 | b.setColor(color); |
|
218 | b.setColor(color); | |
224 | setBrush(b); |
|
219 | setBrush(b); | |
225 | emit colorChanged(color); |
|
220 | emit colorChanged(color); | |
226 | } |
|
221 | } | |
227 | } |
|
222 | } | |
228 |
|
223 | |||
229 | QColor QLegend::color() |
|
224 | QColor QLegend::color() | |
230 | { |
|
225 | { | |
231 | return d_ptr->m_brush.color(); |
|
226 | return d_ptr->m_brush.color(); | |
232 | } |
|
227 | } | |
233 |
|
228 | |||
234 | /*! |
|
229 | /*! | |
235 | Sets the \a pen of legend. Pen affects the legend borders. |
|
230 | Sets the \a pen of legend. Pen affects the legend borders. | |
236 | */ |
|
231 | */ | |
237 | void QLegend::setPen(const QPen &pen) |
|
232 | void QLegend::setPen(const QPen &pen) | |
238 | { |
|
233 | { | |
239 | if (d_ptr->m_pen != pen) { |
|
234 | if (d_ptr->m_pen != pen) { | |
240 | d_ptr->m_pen = pen; |
|
235 | d_ptr->m_pen = pen; | |
241 | update(); |
|
236 | update(); | |
242 | } |
|
237 | } | |
243 | } |
|
238 | } | |
244 |
|
239 | |||
245 | /*! |
|
240 | /*! | |
246 | Returns the pen used by legend |
|
241 | Returns the pen used by legend | |
247 | */ |
|
242 | */ | |
248 |
|
243 | |||
249 | QPen QLegend::pen() const |
|
244 | QPen QLegend::pen() const | |
250 | { |
|
245 | { | |
251 | return d_ptr->m_pen; |
|
246 | return d_ptr->m_pen; | |
252 | } |
|
247 | } | |
253 |
|
248 | |||
254 | void QLegend::setBorderColor(QColor color) |
|
249 | void QLegend::setBorderColor(QColor color) | |
255 | { |
|
250 | { | |
256 | QPen p = d_ptr->m_pen; |
|
251 | QPen p = d_ptr->m_pen; | |
257 | if (p.color() != color) { |
|
252 | if (p.color() != color) { | |
258 | p.setColor(color); |
|
253 | p.setColor(color); | |
259 | setPen(p); |
|
254 | setPen(p); | |
260 | emit borderColorChanged(color); |
|
255 | emit borderColorChanged(color); | |
261 | } |
|
256 | } | |
262 | } |
|
257 | } | |
263 |
|
258 | |||
264 | QColor QLegend::borderColor() |
|
259 | QColor QLegend::borderColor() | |
265 | { |
|
260 | { | |
266 | return d_ptr->m_pen.color(); |
|
261 | return d_ptr->m_pen.color(); | |
267 | } |
|
262 | } | |
268 |
|
263 | |||
269 | void QLegend::setAlignment(Qt::Alignment alignment) |
|
264 | void QLegend::setAlignment(Qt::Alignment alignment) | |
270 | { |
|
265 | { | |
271 | if(d_ptr->m_alignment!=alignment) { |
|
266 | if(d_ptr->m_alignment!=alignment) { | |
272 | d_ptr->m_alignment = alignment; |
|
267 | d_ptr->m_alignment = alignment; | |
273 | d_ptr->updateLayout(); |
|
268 | d_ptr->updateLayout(); | |
274 | alignmentChanged(alignment); |
|
|||
275 | } |
|
269 | } | |
276 | } |
|
270 | } | |
277 |
|
271 | |||
278 | Qt::Alignment QLegend::alignment() const |
|
272 | Qt::Alignment QLegend::alignment() const | |
279 | { |
|
273 | { | |
280 | return d_ptr->m_alignment; |
|
274 | return d_ptr->m_alignment; | |
281 | } |
|
275 | } | |
282 |
|
276 | |||
283 | /*! |
|
277 | /*! | |
284 | Detaches the legend from chart. Chart won't change layout of the legend. |
|
278 | Detaches the legend from chart. Chart won't change layout of the legend. | |
285 | */ |
|
279 | */ | |
286 | void QLegend::detachFromChart() |
|
280 | void QLegend::detachFromChart() | |
287 | { |
|
281 | { | |
288 | d_ptr->m_attachedToChart = false; |
|
282 | d_ptr->m_attachedToChart = false; | |
289 | } |
|
283 | } | |
290 |
|
284 | |||
291 | /*! |
|
285 | /*! | |
292 | Attaches the legend to chart. Chart may change layout of the legend. |
|
286 | Attaches the legend to chart. Chart may change layout of the legend. | |
293 | */ |
|
287 | */ | |
294 | void QLegend::attachToChart() |
|
288 | void QLegend::attachToChart() | |
295 | { |
|
289 | { | |
296 | d_ptr->attachToChart(); |
|
290 | d_ptr->attachToChart(); | |
297 | } |
|
291 | } | |
298 |
|
292 | |||
299 | /*! |
|
293 | /*! | |
300 | Returns true, if legend is attached to chart. |
|
294 | Returns true, if legend is attached to chart. | |
301 | */ |
|
295 | */ | |
302 | bool QLegend::isAttachedToChart() |
|
296 | bool QLegend::isAttachedToChart() | |
303 | { |
|
297 | { | |
304 | return d_ptr->m_attachedToChart; |
|
298 | return d_ptr->m_attachedToChart; | |
305 | } |
|
299 | } | |
306 |
|
300 | |||
307 | /*! |
|
301 | /*! | |
308 | Sets the visibility of legend background to \a visible |
|
302 | Sets the visibility of legend background to \a visible | |
309 | */ |
|
303 | */ | |
310 | void QLegend::setBackgroundVisible(bool visible) |
|
304 | void QLegend::setBackgroundVisible(bool visible) | |
311 | { |
|
305 | { | |
312 | if(d_ptr->m_backgroundVisible != visible) { |
|
306 | if(d_ptr->m_backgroundVisible != visible) { | |
313 | d_ptr->m_backgroundVisible = visible; |
|
307 | d_ptr->m_backgroundVisible = visible; | |
314 | update(); |
|
308 | update(); | |
315 | emit backgroundVisibleChanged(visible); |
|
309 | emit backgroundVisibleChanged(visible); | |
316 | } |
|
310 | } | |
317 | } |
|
311 | } | |
318 |
|
312 | |||
319 | /*! |
|
313 | /*! | |
320 | Returns the visibility of legend background |
|
314 | Returns the visibility of legend background | |
321 | */ |
|
315 | */ | |
322 | bool QLegend::isBackgroundVisible() const |
|
316 | bool QLegend::isBackgroundVisible() const | |
323 | { |
|
317 | { | |
324 | return d_ptr->m_backgroundVisible; |
|
318 | return d_ptr->m_backgroundVisible; | |
325 | } |
|
319 | } | |
326 |
|
320 | |||
327 | /*! |
|
321 | /*! | |
328 | \internal \a event see QGraphicsWidget for details |
|
322 | \internal \a event see QGraphicsWidget for details | |
329 | */ |
|
323 | */ | |
330 | void QLegend::resizeEvent(QGraphicsSceneResizeEvent *event) |
|
324 | void QLegend::resizeEvent(QGraphicsSceneResizeEvent *event) | |
331 | { |
|
325 | { | |
332 | const QRectF& rect = QRectF(QPoint(0,0),event->newSize()); |
|
326 | const QRectF& rect = QRectF(QPoint(0,0),event->newSize()); | |
333 | QGraphicsWidget::resizeEvent(event); |
|
327 | QGraphicsWidget::resizeEvent(event); | |
334 | if(d_ptr->m_rect != rect) { |
|
328 | if(d_ptr->m_rect != rect) { | |
335 | d_ptr->m_rect = rect; |
|
329 | d_ptr->m_rect = rect; | |
336 | d_ptr->updateLayout(); |
|
330 | d_ptr->updateLayout(); | |
337 | } |
|
331 | } | |
338 | } |
|
332 | } | |
339 |
|
333 | |||
340 | /*! |
|
334 | /*! | |
341 | \internal \a event see QGraphicsWidget for details |
|
335 | \internal \a event see QGraphicsWidget for details | |
342 | */ |
|
336 | */ | |
343 | void QLegend::hideEvent(QHideEvent *event) |
|
337 | void QLegend::hideEvent(QHideEvent *event) | |
344 | { |
|
338 | { | |
345 | QGraphicsWidget::hideEvent(event); |
|
339 | QGraphicsWidget::hideEvent(event); | |
346 | setEnabled(false); |
|
340 | setEnabled(false); | |
347 | d_ptr->updateLayout(); |
|
341 | d_ptr->updateLayout(); | |
348 | } |
|
342 | } | |
349 |
|
343 | |||
350 | /*! |
|
344 | /*! | |
351 | \internal \a event see QGraphicsWidget for details |
|
345 | \internal \a event see QGraphicsWidget for details | |
352 | */ |
|
346 | */ | |
353 | void QLegend::showEvent(QShowEvent *event) |
|
347 | void QLegend::showEvent(QShowEvent *event) | |
354 | { |
|
348 | { | |
355 | QGraphicsWidget::showEvent(event); |
|
349 | QGraphicsWidget::showEvent(event); | |
356 | setEnabled(true); |
|
350 | setEnabled(true); | |
357 | d_ptr->updateLayout(); |
|
351 | d_ptr->updateLayout(); | |
358 | } |
|
352 | } | |
359 |
|
353 | |||
360 | qreal QLegend::minWidth() const |
|
354 | qreal QLegend::minWidth() const | |
361 | { |
|
355 | { | |
362 | return d_ptr->m_minWidth; |
|
356 | return d_ptr->m_minWidth; | |
363 | } |
|
357 | } | |
364 |
|
358 | |||
365 | qreal QLegend::minHeight() const |
|
359 | qreal QLegend::minHeight() const | |
366 | { |
|
360 | { | |
367 | return d_ptr->m_minHeight; |
|
361 | return d_ptr->m_minHeight; | |
368 | } |
|
362 | } | |
369 |
|
363 | |||
370 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
364 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
371 |
|
365 | |||
372 | QLegendPrivate::QLegendPrivate(ChartPresenter* presenter, QChart *chart, QLegend *q): |
|
366 | QLegendPrivate::QLegendPrivate(ChartPresenter* presenter, QChart *chart, QLegend *q): | |
373 | q_ptr(q), |
|
367 | q_ptr(q), | |
374 | m_presenter(presenter), |
|
368 | m_presenter(presenter), | |
375 | m_chart(chart), |
|
369 | m_chart(chart), | |
376 | m_markers(new QGraphicsItemGroup(q)), |
|
370 | m_markers(new QGraphicsItemGroup(q)), | |
377 | m_alignment(Qt::AlignTop), |
|
371 | m_alignment(Qt::AlignTop), | |
378 | m_brush(QBrush()), |
|
372 | m_brush(QBrush()), | |
379 | m_pen(QPen()), |
|
373 | m_pen(QPen()), | |
380 | m_offsetX(0), |
|
374 | m_offsetX(0), | |
381 | m_offsetY(0), |
|
375 | m_offsetY(0), | |
382 | m_minWidth(0), |
|
376 | m_minWidth(0), | |
383 | m_minHeight(0), |
|
377 | m_minHeight(0), | |
384 | m_width(0), |
|
378 | m_width(0), | |
385 | m_height(0), |
|
379 | m_height(0), | |
386 | m_diameter(5), |
|
380 | m_diameter(5), | |
387 | m_attachedToChart(true), |
|
381 | m_attachedToChart(true), | |
388 | m_backgroundVisible(false) |
|
382 | m_backgroundVisible(false) | |
389 | { |
|
383 | { | |
390 |
|
384 | |||
391 | } |
|
385 | } | |
392 |
|
386 | |||
393 | QLegendPrivate::~QLegendPrivate() |
|
387 | QLegendPrivate::~QLegendPrivate() | |
394 | { |
|
388 | { | |
395 |
|
389 | |||
396 | } |
|
390 | } | |
397 |
|
391 | |||
398 | void QLegendPrivate::setOffset(qreal x, qreal y) |
|
392 | void QLegendPrivate::setOffset(qreal x, qreal y) | |
399 | { |
|
393 | { | |
400 | bool scrollHorizontal = true; |
|
394 | bool scrollHorizontal = true; | |
401 | switch(m_alignment) { |
|
395 | switch(m_alignment) { | |
402 | case Qt::AlignTop: |
|
396 | case Qt::AlignTop: | |
403 | case Qt::AlignBottom: { |
|
397 | case Qt::AlignBottom: { | |
404 | scrollHorizontal = true; |
|
398 | scrollHorizontal = true; | |
405 | break; |
|
399 | break; | |
406 | } |
|
400 | } | |
407 | case Qt::AlignLeft: |
|
401 | case Qt::AlignLeft: | |
408 | case Qt::AlignRight: { |
|
402 | case Qt::AlignRight: { | |
409 | scrollHorizontal = false; |
|
403 | scrollHorizontal = false; | |
410 | break; |
|
404 | break; | |
411 | } |
|
405 | } | |
412 | } |
|
406 | } | |
413 |
|
407 | |||
414 | // If detached, the scrolling direction is vertical instead of horizontal and vice versa. |
|
408 | // If detached, the scrolling direction is vertical instead of horizontal and vice versa. | |
415 | if (!m_attachedToChart) { |
|
409 | if (!m_attachedToChart) { | |
416 | scrollHorizontal = !scrollHorizontal; |
|
410 | scrollHorizontal = !scrollHorizontal; | |
417 | } |
|
411 | } | |
418 |
|
412 | |||
419 | // Limit offset between m_minOffset and m_maxOffset |
|
413 | // Limit offset between m_minOffset and m_maxOffset | |
420 | if (scrollHorizontal) { |
|
414 | if (scrollHorizontal) { | |
421 | if(m_width<=m_rect.width()) return; |
|
415 | if(m_width<=m_rect.width()) return; | |
422 |
|
416 | |||
423 | if (x != m_offsetX) { |
|
417 | if (x != m_offsetX) { | |
424 | m_offsetX = qBound(m_minOffsetX, x, m_maxOffsetX); |
|
418 | m_offsetX = qBound(m_minOffsetX, x, m_maxOffsetX); | |
425 | m_markers->setPos(-m_offsetX,m_rect.top()); |
|
419 | m_markers->setPos(-m_offsetX,m_rect.top()); | |
426 | } |
|
420 | } | |
427 | } else { |
|
421 | } else { | |
428 | if(m_height<=m_rect.height()) return; |
|
422 | if(m_height<=m_rect.height()) return; | |
429 |
|
423 | |||
430 | if (y != m_offsetY) { |
|
424 | if (y != m_offsetY) { | |
431 | m_offsetY = qBound(m_minOffsetY, y, m_maxOffsetY); |
|
425 | m_offsetY = qBound(m_minOffsetY, y, m_maxOffsetY); | |
432 | m_markers->setPos(m_rect.left(),-m_offsetY); |
|
426 | m_markers->setPos(m_rect.left(),-m_offsetY); | |
433 | } |
|
427 | } | |
434 | } |
|
428 | } | |
435 | } |
|
429 | } | |
436 |
|
430 | |||
437 | QPointF QLegendPrivate::offset() const |
|
431 | QPointF QLegendPrivate::offset() const | |
438 | { |
|
432 | { | |
439 | return QPointF(m_offsetX,m_offsetY); |
|
433 | return QPointF(m_offsetX,m_offsetY); | |
440 | } |
|
434 | } | |
441 |
|
435 | |||
442 | void QLegendPrivate::updateLayout() |
|
436 | void QLegendPrivate::updateLayout() | |
443 | { |
|
437 | { | |
444 | if (!m_attachedToChart) { |
|
438 | if (!m_attachedToChart) { | |
445 | updateDetachedLayout(); |
|
439 | updateDetachedLayout(); | |
446 | return; |
|
440 | return; | |
447 | } |
|
441 | } | |
448 |
|
442 | |||
449 | m_offsetX=0; |
|
443 | m_offsetX=0; | |
450 | QList<QGraphicsItem *> items = m_markers->childItems(); |
|
444 | QList<QGraphicsItem *> items = m_markers->childItems(); | |
451 |
|
445 | |||
452 | if(items.isEmpty()) return; |
|
446 | if(items.isEmpty()) return; | |
453 |
|
447 | |||
454 | m_minWidth=0; |
|
448 | m_minWidth=0; | |
455 | m_minHeight=0; |
|
449 | m_minHeight=0; | |
456 |
|
450 | |||
457 | switch(m_alignment) { |
|
451 | switch(m_alignment) { | |
458 |
|
452 | |||
459 | case Qt::AlignTop: |
|
453 | case Qt::AlignTop: | |
460 | case Qt::AlignBottom: { |
|
454 | case Qt::AlignBottom: { | |
461 | QPointF point = m_rect.topLeft(); |
|
455 | QPointF point = m_rect.topLeft(); | |
462 | m_width = 0; |
|
456 | m_width = 0; | |
463 | foreach (QGraphicsItem *item, items) { |
|
457 | foreach (QGraphicsItem *item, items) { | |
464 | if (item->isVisible()) { |
|
458 | if (item->isVisible()) { | |
465 | item->setPos(point.x(),m_rect.height()/2 -item->boundingRect().height()/2); |
|
459 | item->setPos(point.x(),m_rect.height()/2 -item->boundingRect().height()/2); | |
466 | const QRectF& rect = item->boundingRect(); |
|
460 | const QRectF& rect = item->boundingRect(); | |
467 | qreal w = rect.width(); |
|
461 | qreal w = rect.width(); | |
468 | m_minWidth=qMax(m_minWidth,w); |
|
462 | m_minWidth=qMax(m_minWidth,w); | |
469 | m_minHeight=qMax(m_minHeight,rect.height()); |
|
463 | m_minHeight=qMax(m_minHeight,rect.height()); | |
470 | m_width+=w; |
|
464 | m_width+=w; | |
471 | point.setX(point.x() + w); |
|
465 | point.setX(point.x() + w); | |
472 | } |
|
466 | } | |
473 | } |
|
467 | } | |
474 | if(m_width<m_rect.width()) { |
|
468 | if(m_width<m_rect.width()) { | |
475 | m_markers->setPos(m_rect.width()/2-m_width/2,m_rect.top()); |
|
469 | m_markers->setPos(m_rect.width()/2-m_width/2,m_rect.top()); | |
476 | } |
|
470 | } | |
477 | else { |
|
471 | else { | |
478 | m_markers->setPos(m_rect.topLeft()); |
|
472 | m_markers->setPos(m_rect.topLeft()); | |
479 | } |
|
473 | } | |
480 | m_height=m_minHeight; |
|
474 | m_height=m_minHeight; | |
481 | } |
|
475 | } | |
482 | break; |
|
476 | break; | |
483 | case Qt::AlignLeft: |
|
477 | case Qt::AlignLeft: | |
484 | case Qt::AlignRight: { |
|
478 | case Qt::AlignRight: { | |
485 | QPointF point = m_rect.topLeft(); |
|
479 | QPointF point = m_rect.topLeft(); | |
486 | m_height = 0; |
|
480 | m_height = 0; | |
487 | foreach (QGraphicsItem *item, items) { |
|
481 | foreach (QGraphicsItem *item, items) { | |
488 | if (item->isVisible()) { |
|
482 | if (item->isVisible()) { | |
489 | item->setPos(point); |
|
483 | item->setPos(point); | |
490 | const QRectF& rect = item->boundingRect(); |
|
484 | const QRectF& rect = item->boundingRect(); | |
491 | qreal h = rect.height(); |
|
485 | qreal h = rect.height(); | |
492 | m_minWidth=qMax(m_minWidth,rect.width()); |
|
486 | m_minWidth=qMax(m_minWidth,rect.width()); | |
493 | m_minHeight=qMax(m_minHeight,h); |
|
487 | m_minHeight=qMax(m_minHeight,h); | |
494 | m_height+=h; |
|
488 | m_height+=h; | |
495 | point.setY(point.y() + h); |
|
489 | point.setY(point.y() + h); | |
496 | } |
|
490 | } | |
497 | } |
|
491 | } | |
498 | if(m_height<m_rect.height()) { |
|
492 | if(m_height<m_rect.height()) { | |
499 | m_markers->setPos(m_rect.left(),m_rect.height()/2-m_height/2); |
|
493 | m_markers->setPos(m_rect.left(),m_rect.height()/2-m_height/2); | |
500 | } |
|
494 | } | |
501 | else { |
|
495 | else { | |
502 | m_markers->setPos(m_rect.topLeft()); |
|
496 | m_markers->setPos(m_rect.topLeft()); | |
503 | } |
|
497 | } | |
504 | m_width=m_minWidth; |
|
498 | m_width=m_minWidth; | |
505 | } |
|
499 | } | |
506 | break; |
|
500 | break; | |
507 | } |
|
501 | } | |
508 |
|
502 | |||
509 | m_minOffsetX = 0; |
|
503 | m_minOffsetX = 0; | |
510 | m_minOffsetY = 0; |
|
504 | m_minOffsetY = 0; | |
511 | m_maxOffsetX = m_width - m_rect.width(); |
|
505 | m_maxOffsetX = m_width - m_rect.width(); | |
512 | m_maxOffsetY = m_height - m_rect.height(); |
|
506 | m_maxOffsetY = m_height - m_rect.height(); | |
513 |
|
507 | |||
514 | m_presenter->updateLayout(); |
|
508 | m_presenter->updateLayout(); | |
515 | } |
|
509 | } | |
516 |
|
510 | |||
517 | void QLegendPrivate::updateDetachedLayout() |
|
511 | void QLegendPrivate::updateDetachedLayout() | |
518 | { |
|
512 | { | |
519 | // Detached layout is different. |
|
513 | // Detached layout is different. | |
520 | // In detached mode legend may have multiple rows and columns, so layout calculations |
|
514 | // In detached mode legend may have multiple rows and columns, so layout calculations | |
521 | // differ a log from attached mode. |
|
515 | // differ a log from attached mode. | |
522 | // Also the scrolling logic is bit different. |
|
516 | // Also the scrolling logic is bit different. | |
523 | m_offsetX=0; |
|
517 | m_offsetX=0; | |
524 | m_offsetY=0; |
|
518 | m_offsetY=0; | |
525 | QList<QGraphicsItem *> items = m_markers->childItems(); |
|
519 | QList<QGraphicsItem *> items = m_markers->childItems(); | |
526 |
|
520 | |||
527 | if(items.isEmpty()) return; |
|
521 | if(items.isEmpty()) return; | |
528 |
|
522 | |||
529 | m_minWidth = 0; |
|
523 | m_minWidth = 0; | |
530 | m_minHeight = 0; |
|
524 | m_minHeight = 0; | |
531 |
|
525 | |||
532 | switch (m_alignment) { |
|
526 | switch (m_alignment) { | |
533 | case Qt::AlignTop: { |
|
527 | case Qt::AlignTop: { | |
534 | QPointF point = m_rect.topLeft(); |
|
528 | QPointF point = m_rect.topLeft(); | |
535 | m_width = 0; |
|
529 | m_width = 0; | |
536 | m_height = 0; |
|
530 | m_height = 0; | |
537 | for (int i=0; i<items.count(); i++) { |
|
531 | for (int i=0; i<items.count(); i++) { | |
538 | QGraphicsItem *item = items.at(i); |
|
532 | QGraphicsItem *item = items.at(i); | |
539 | if (item->isVisible()) { |
|
533 | if (item->isVisible()) { | |
540 | const QRectF& rect = item->boundingRect(); |
|
534 | const QRectF& rect = item->boundingRect(); | |
541 | qreal w = rect.width(); |
|
535 | qreal w = rect.width(); | |
542 | qreal h = rect.height(); |
|
536 | qreal h = rect.height(); | |
543 | m_minWidth = qMax(m_minWidth,w); |
|
537 | m_minWidth = qMax(m_minWidth,w); | |
544 | m_minHeight = qMax(m_minHeight,rect.height()); |
|
538 | m_minHeight = qMax(m_minHeight,rect.height()); | |
545 | m_height = qMax(m_height,h); |
|
539 | m_height = qMax(m_height,h); | |
546 | item->setPos(point.x(),point.y()); |
|
540 | item->setPos(point.x(),point.y()); | |
547 | point.setX(point.x() + w); |
|
541 | point.setX(point.x() + w); | |
548 | if (point.x() + w > m_rect.topLeft().x() + m_rect.width()) { |
|
542 | if (point.x() + w > m_rect.topLeft().x() + m_rect.width()) { | |
549 | // Next item would go off rect. |
|
543 | // Next item would go off rect. | |
550 | point.setX(m_rect.topLeft().x()); |
|
544 | point.setX(m_rect.topLeft().x()); | |
551 | point.setY(point.y() + h); |
|
545 | point.setY(point.y() + h); | |
552 | if (i+1 < items.count()) { |
|
546 | if (i+1 < items.count()) { | |
553 | m_height += h; |
|
547 | m_height += h; | |
554 | } |
|
548 | } | |
555 | } |
|
549 | } | |
556 | } |
|
550 | } | |
557 | } |
|
551 | } | |
558 | m_markers->setPos(m_rect.topLeft()); |
|
552 | m_markers->setPos(m_rect.topLeft()); | |
559 | m_width = m_minWidth; |
|
553 | m_width = m_minWidth; | |
560 |
|
554 | |||
561 | m_minOffsetX = 0; |
|
555 | m_minOffsetX = 0; | |
562 | m_minOffsetY = 0; |
|
556 | m_minOffsetY = 0; | |
563 | m_maxOffsetX = m_width - m_rect.width(); |
|
557 | m_maxOffsetX = m_width - m_rect.width(); | |
564 | m_maxOffsetY = m_height - m_rect.height(); |
|
558 | m_maxOffsetY = m_height - m_rect.height(); | |
565 | } |
|
559 | } | |
566 | break; |
|
560 | break; | |
567 | case Qt::AlignBottom: { |
|
561 | case Qt::AlignBottom: { | |
568 | QPointF point = m_rect.bottomLeft(); |
|
562 | QPointF point = m_rect.bottomLeft(); | |
569 | m_width = 0; |
|
563 | m_width = 0; | |
570 | m_height = 0; |
|
564 | m_height = 0; | |
571 | for (int i=0; i<items.count(); i++) { |
|
565 | for (int i=0; i<items.count(); i++) { | |
572 | QGraphicsItem *item = items.at(i); |
|
566 | QGraphicsItem *item = items.at(i); | |
573 | if (item->isVisible()) { |
|
567 | if (item->isVisible()) { | |
574 | const QRectF& rect = item->boundingRect(); |
|
568 | const QRectF& rect = item->boundingRect(); | |
575 | qreal w = rect.width(); |
|
569 | qreal w = rect.width(); | |
576 | qreal h = rect.height(); |
|
570 | qreal h = rect.height(); | |
577 | m_minWidth = qMax(m_minWidth,w); |
|
571 | m_minWidth = qMax(m_minWidth,w); | |
578 | m_minHeight = qMax(m_minHeight,rect.height()); |
|
572 | m_minHeight = qMax(m_minHeight,rect.height()); | |
579 | m_height = qMax(m_height,h); |
|
573 | m_height = qMax(m_height,h); | |
580 | item->setPos(point.x(),point.y() - h); |
|
574 | item->setPos(point.x(),point.y() - h); | |
581 | point.setX(point.x() + w); |
|
575 | point.setX(point.x() + w); | |
582 | if (point.x() + w > m_rect.bottomLeft().x() + m_rect.width()) { |
|
576 | if (point.x() + w > m_rect.bottomLeft().x() + m_rect.width()) { | |
583 | // Next item would go off rect. |
|
577 | // Next item would go off rect. | |
584 | point.setX(m_rect.bottomLeft().x()); |
|
578 | point.setX(m_rect.bottomLeft().x()); | |
585 | point.setY(point.y() - h); |
|
579 | point.setY(point.y() - h); | |
586 | if (i+1 < items.count()) { |
|
580 | if (i+1 < items.count()) { | |
587 | m_height += h; |
|
581 | m_height += h; | |
588 | } |
|
582 | } | |
589 | } |
|
583 | } | |
590 | } |
|
584 | } | |
591 | } |
|
585 | } | |
592 | m_markers->setPos(m_rect.topLeft()); |
|
586 | m_markers->setPos(m_rect.topLeft()); | |
593 | m_width = m_minWidth; |
|
587 | m_width = m_minWidth; | |
594 |
|
588 | |||
595 | m_minOffsetX = 0; |
|
589 | m_minOffsetX = 0; | |
596 | m_minOffsetY = qMin(m_rect.topLeft().y(), m_rect.topLeft().y() - m_height + m_rect.height()); |
|
590 | m_minOffsetY = qMin(m_rect.topLeft().y(), m_rect.topLeft().y() - m_height + m_rect.height()); | |
597 | m_maxOffsetX = m_width - m_rect.width(); |
|
591 | m_maxOffsetX = m_width - m_rect.width(); | |
598 | m_maxOffsetY = 0; |
|
592 | m_maxOffsetY = 0; | |
599 | } |
|
593 | } | |
600 | break; |
|
594 | break; | |
601 | case Qt::AlignLeft: { |
|
595 | case Qt::AlignLeft: { | |
602 | QPointF point = m_rect.topLeft(); |
|
596 | QPointF point = m_rect.topLeft(); | |
603 | m_width = 0; |
|
597 | m_width = 0; | |
604 | m_height = 0; |
|
598 | m_height = 0; | |
605 | qreal maxWidth = 0; |
|
599 | qreal maxWidth = 0; | |
606 | for (int i=0; i<items.count(); i++) { |
|
600 | for (int i=0; i<items.count(); i++) { | |
607 | QGraphicsItem *item = items.at(i); |
|
601 | QGraphicsItem *item = items.at(i); | |
608 | if (item->isVisible()) { |
|
602 | if (item->isVisible()) { | |
609 | const QRectF& rect = item->boundingRect(); |
|
603 | const QRectF& rect = item->boundingRect(); | |
610 | qreal w = rect.width(); |
|
604 | qreal w = rect.width(); | |
611 | qreal h = rect.height(); |
|
605 | qreal h = rect.height(); | |
612 | m_minWidth = qMax(m_minWidth,rect.width()); |
|
606 | m_minWidth = qMax(m_minWidth,rect.width()); | |
613 | m_minHeight = qMax(m_minHeight,h); |
|
607 | m_minHeight = qMax(m_minHeight,h); | |
614 | maxWidth = qMax(maxWidth,w); |
|
608 | maxWidth = qMax(maxWidth,w); | |
615 | item->setPos(point.x(),point.y()); |
|
609 | item->setPos(point.x(),point.y()); | |
616 | point.setY(point.y() + h); |
|
610 | point.setY(point.y() + h); | |
617 | if (point.y() + h > m_rect.topLeft().y() + m_rect.height()) { |
|
611 | if (point.y() + h > m_rect.topLeft().y() + m_rect.height()) { | |
618 | // Next item would go off rect. |
|
612 | // Next item would go off rect. | |
619 | point.setX(point.x() + maxWidth); |
|
613 | point.setX(point.x() + maxWidth); | |
620 | point.setY(m_rect.topLeft().y()); |
|
614 | point.setY(m_rect.topLeft().y()); | |
621 | if (i+1 < items.count()) { |
|
615 | if (i+1 < items.count()) { | |
622 | m_width += maxWidth; |
|
616 | m_width += maxWidth; | |
623 | maxWidth = 0; |
|
617 | maxWidth = 0; | |
624 | } |
|
618 | } | |
625 | } |
|
619 | } | |
626 | } |
|
620 | } | |
627 | } |
|
621 | } | |
628 | m_width += maxWidth; |
|
622 | m_width += maxWidth; | |
629 | m_markers->setPos(m_rect.topLeft()); |
|
623 | m_markers->setPos(m_rect.topLeft()); | |
630 | m_height = m_minHeight; |
|
624 | m_height = m_minHeight; | |
631 |
|
625 | |||
632 | m_minOffsetX = 0; |
|
626 | m_minOffsetX = 0; | |
633 | m_minOffsetY = 0; |
|
627 | m_minOffsetY = 0; | |
634 | m_maxOffsetX = m_width - m_rect.width(); |
|
628 | m_maxOffsetX = m_width - m_rect.width(); | |
635 | m_maxOffsetY = m_height - m_rect.height(); |
|
629 | m_maxOffsetY = m_height - m_rect.height(); | |
636 | } |
|
630 | } | |
637 | break; |
|
631 | break; | |
638 | case Qt::AlignRight: { |
|
632 | case Qt::AlignRight: { | |
639 | QPointF point = m_rect.topRight(); |
|
633 | QPointF point = m_rect.topRight(); | |
640 | m_width = 0; |
|
634 | m_width = 0; | |
641 | m_height = 0; |
|
635 | m_height = 0; | |
642 | qreal maxWidth = 0; |
|
636 | qreal maxWidth = 0; | |
643 | for (int i=0; i<items.count(); i++) { |
|
637 | for (int i=0; i<items.count(); i++) { | |
644 | QGraphicsItem *item = items.at(i); |
|
638 | QGraphicsItem *item = items.at(i); | |
645 | if (item->isVisible()) { |
|
639 | if (item->isVisible()) { | |
646 | const QRectF& rect = item->boundingRect(); |
|
640 | const QRectF& rect = item->boundingRect(); | |
647 | qreal w = rect.width(); |
|
641 | qreal w = rect.width(); | |
648 | qreal h = rect.height(); |
|
642 | qreal h = rect.height(); | |
649 | m_minWidth = qMax(m_minWidth,rect.width()); |
|
643 | m_minWidth = qMax(m_minWidth,rect.width()); | |
650 | m_minHeight = qMax(m_minHeight,h); |
|
644 | m_minHeight = qMax(m_minHeight,h); | |
651 | maxWidth = qMax(maxWidth,w); |
|
645 | maxWidth = qMax(maxWidth,w); | |
652 | item->setPos(point.x() - w,point.y()); |
|
646 | item->setPos(point.x() - w,point.y()); | |
653 | point.setY(point.y() + h); |
|
647 | point.setY(point.y() + h); | |
654 | if (point.y() + h > m_rect.topLeft().y() + m_rect.height()) { |
|
648 | if (point.y() + h > m_rect.topLeft().y() + m_rect.height()) { | |
655 | // Next item would go off rect. |
|
649 | // Next item would go off rect. | |
656 | point.setX(point.x() - maxWidth); |
|
650 | point.setX(point.x() - maxWidth); | |
657 | point.setY(m_rect.topLeft().y()); |
|
651 | point.setY(m_rect.topLeft().y()); | |
658 | if (i+1 < items.count()) { |
|
652 | if (i+1 < items.count()) { | |
659 | m_width += maxWidth; |
|
653 | m_width += maxWidth; | |
660 | maxWidth = 0; |
|
654 | maxWidth = 0; | |
661 | } |
|
655 | } | |
662 | } |
|
656 | } | |
663 | } |
|
657 | } | |
664 | } |
|
658 | } | |
665 | m_width += maxWidth; |
|
659 | m_width += maxWidth; | |
666 | m_markers->setPos(m_rect.topLeft()); |
|
660 | m_markers->setPos(m_rect.topLeft()); | |
667 | m_height = m_minHeight; |
|
661 | m_height = m_minHeight; | |
668 |
|
662 | |||
669 | m_minOffsetX = qMin(m_rect.topLeft().x(), m_rect.topLeft().x() - m_width + m_rect.width()); |
|
663 | m_minOffsetX = qMin(m_rect.topLeft().x(), m_rect.topLeft().x() - m_width + m_rect.width()); | |
670 | m_minOffsetY = 0; |
|
664 | m_minOffsetY = 0; | |
671 | m_maxOffsetX = 0; |
|
665 | m_maxOffsetX = 0; | |
672 | m_maxOffsetY = m_height - m_rect.height(); |
|
666 | m_maxOffsetY = m_height - m_rect.height(); | |
673 | } |
|
667 | } | |
674 | break; |
|
668 | break; | |
675 | default: |
|
669 | default: | |
676 | break; |
|
670 | break; | |
677 | } |
|
671 | } | |
678 | } |
|
672 | } | |
679 |
|
673 | |||
680 | void QLegendPrivate::attachToChart() |
|
674 | void QLegendPrivate::attachToChart() | |
681 | { |
|
675 | { | |
682 | m_attachedToChart = true; |
|
676 | m_attachedToChart = true; | |
683 | q_ptr->setParent(m_chart); |
|
677 | q_ptr->setParent(m_chart); | |
684 | } |
|
678 | } | |
685 |
|
679 | |||
686 | int QLegendPrivate::roundness(qreal size) |
|
680 | int QLegendPrivate::roundness(qreal size) | |
687 | { |
|
681 | { | |
688 | return 100*m_diameter/int(size); |
|
682 | return 100*m_diameter/int(size); | |
689 | } |
|
683 | } | |
690 |
|
684 | |||
691 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) |
|
685 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |
692 | { |
|
686 | { | |
693 | Q_UNUSED(domain) |
|
687 | Q_UNUSED(domain) | |
694 |
|
688 | |||
695 | QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr); |
|
689 | QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr); | |
696 | foreach(LegendMarker* marker, markers) |
|
690 | foreach(LegendMarker* marker, markers) | |
697 | m_markers->addToGroup(marker); |
|
691 | m_markers->addToGroup(marker); | |
698 |
|
692 | |||
699 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); |
|
693 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); | |
700 |
|
694 | |||
701 | if(series->type() == QAbstractSeries::SeriesTypePie) { |
|
695 | if(series->type() == QAbstractSeries::SeriesTypePie) { | |
702 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
696 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); | |
703 | QObject::connect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); |
|
697 | QObject::connect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
704 | QObject::connect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); |
|
698 | QObject::connect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
705 | } |
|
699 | } | |
706 |
|
700 | |||
707 | updateLayout(); |
|
701 | updateLayout(); | |
708 | } |
|
702 | } | |
709 |
|
703 | |||
710 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) |
|
704 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) | |
711 | { |
|
705 | { | |
712 | QList<QGraphicsItem *> items = m_markers->childItems(); |
|
706 | QList<QGraphicsItem *> items = m_markers->childItems(); | |
713 |
|
707 | |||
714 | foreach (QGraphicsItem *markers, items) { |
|
708 | foreach (QGraphicsItem *markers, items) { | |
715 | LegendMarker *marker = static_cast<LegendMarker*>(markers); |
|
709 | LegendMarker *marker = static_cast<LegendMarker*>(markers); | |
716 | if (marker->series() == series) { |
|
710 | if (marker->series() == series) { | |
717 | delete marker; |
|
711 | delete marker; | |
718 | } |
|
712 | } | |
719 | } |
|
713 | } | |
720 |
|
714 | |||
721 | if(series->type() == QAbstractSeries::SeriesTypePie) |
|
715 | if(series->type() == QAbstractSeries::SeriesTypePie) | |
722 | { |
|
716 | { | |
723 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
717 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); | |
724 | QObject::disconnect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); |
|
718 | QObject::disconnect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
725 | QObject::disconnect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); |
|
719 | QObject::disconnect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
726 | } |
|
720 | } | |
727 |
|
721 | |||
728 | updateLayout(); |
|
722 | updateLayout(); | |
729 | } |
|
723 | } | |
730 |
|
724 | |||
731 | void QLegendPrivate::handleSeriesUpdated(QAbstractSeries *series) |
|
725 | void QLegendPrivate::handleSeriesUpdated(QAbstractSeries *series) | |
732 | { |
|
726 | { | |
733 | // TODO: find out which markers are are added or removed. Update them |
|
727 | // TODO: find out which markers are are added or removed. Update them | |
734 | // TODO: better implementation |
|
728 | // TODO: better implementation | |
735 | handleSeriesRemoved(series); |
|
729 | handleSeriesRemoved(series); | |
736 | Domain domain; |
|
730 | Domain domain; | |
737 | handleSeriesAdded(series, &domain); |
|
731 | handleSeriesAdded(series, &domain); | |
738 | } |
|
732 | } | |
739 |
|
733 | |||
740 | void QLegendPrivate::handleUpdatePieSeries() |
|
734 | void QLegendPrivate::handleUpdatePieSeries() | |
741 | { |
|
735 | { | |
742 | //TODO: reimplement to be optimal |
|
736 | //TODO: reimplement to be optimal | |
743 | QPieSeries* series = qobject_cast<QPieSeries *> (sender()); |
|
737 | QPieSeries* series = qobject_cast<QPieSeries *> (sender()); | |
744 | Q_ASSERT(series); |
|
738 | Q_ASSERT(series); | |
745 | handleSeriesRemoved(series); |
|
739 | handleSeriesRemoved(series); | |
746 | handleSeriesAdded(series, 0); |
|
740 | handleSeriesAdded(series, 0); | |
747 | } |
|
741 | } | |
748 |
|
742 | |||
749 | void QLegendPrivate::handleSeriesVisibleChanged() |
|
743 | void QLegendPrivate::handleSeriesVisibleChanged() | |
750 | { |
|
744 | { | |
751 | QAbstractSeries* series = qobject_cast<QAbstractSeries *> (sender()); |
|
745 | QAbstractSeries* series = qobject_cast<QAbstractSeries *> (sender()); | |
752 | QList<QGraphicsItem *> items = m_markers->childItems(); |
|
746 | QList<QGraphicsItem *> items = m_markers->childItems(); | |
753 |
|
747 | |||
754 | foreach (QGraphicsItem *markers, items) { |
|
748 | foreach (QGraphicsItem *markers, items) { | |
755 | LegendMarker *marker = static_cast<LegendMarker*>(markers); |
|
749 | LegendMarker *marker = static_cast<LegendMarker*>(markers); | |
756 | if (marker->series() == series) { |
|
750 | if (marker->series() == series) { | |
757 | marker->setVisible(!marker->isVisible()); |
|
751 | marker->setVisible(!marker->isVisible()); | |
758 | } |
|
752 | } | |
759 | } |
|
753 | } | |
760 |
|
754 | |||
761 | updateLayout(); |
|
755 | updateLayout(); | |
762 | } |
|
756 | } | |
763 |
|
757 | |||
764 |
|
758 | |||
765 | #include "moc_qlegend.cpp" |
|
759 | #include "moc_qlegend.cpp" | |
766 | #include "moc_qlegend_p.cpp" |
|
760 | #include "moc_qlegend_p.cpp" | |
767 |
|
761 | |||
768 | QTCOMMERCIALCHART_END_NAMESPACE |
|
762 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,102 +1,101 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QLEGEND_H |
|
21 | #ifndef QLEGEND_H | |
22 | #define QLEGEND_H |
|
22 | #define QLEGEND_H | |
23 |
|
23 | |||
24 | #include <QChartGlobal> |
|
24 | #include <QChartGlobal> | |
25 | #include <QGraphicsWidget> |
|
25 | #include <QGraphicsWidget> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class Domain; |
|
31 | class Domain; | |
32 | class LegendMarker; |
|
32 | class LegendMarker; | |
33 | class QPieSlice; |
|
33 | class QPieSlice; | |
34 | class QXYSeries; |
|
34 | class QXYSeries; | |
35 | class QBarSet; |
|
35 | class QBarSet; | |
36 | class QBarSeries; |
|
36 | class QBarSeries; | |
37 | class QPieSeries; |
|
37 | class QPieSeries; | |
38 | class QAreaSeries; |
|
38 | class QAreaSeries; | |
39 | class LegendScrollButton; |
|
39 | class LegendScrollButton; | |
40 | class QChart; |
|
40 | class QChart; | |
41 | class QLegendPrivate; |
|
41 | class QLegendPrivate; | |
42 |
|
42 | |||
43 | class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget |
|
43 | class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget | |
44 | { |
|
44 | { | |
45 | Q_OBJECT |
|
45 | Q_OBJECT | |
46 |
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment |
|
46 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) | |
47 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged) |
|
47 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible NOTIFY backgroundVisibleChanged) | |
48 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
48 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
49 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
49 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
50 |
|
50 | |||
51 | private: |
|
51 | private: | |
52 | explicit QLegend(QChart *chart); |
|
52 | explicit QLegend(QChart *chart); | |
53 |
|
53 | |||
54 | public: |
|
54 | public: | |
55 | ~QLegend(); |
|
55 | ~QLegend(); | |
56 |
|
56 | |||
57 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
57 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
58 | QRectF boundingRect() const; |
|
58 | QRectF boundingRect() const; | |
59 |
|
59 | |||
60 | void setBrush(const QBrush &brush); |
|
60 | void setBrush(const QBrush &brush); | |
61 | QBrush brush() const; |
|
61 | QBrush brush() const; | |
62 | void setColor(QColor color); |
|
62 | void setColor(QColor color); | |
63 | QColor color(); |
|
63 | QColor color(); | |
64 |
|
64 | |||
65 | void setPen(const QPen &pen); |
|
65 | void setPen(const QPen &pen); | |
66 | QPen pen() const; |
|
66 | QPen pen() const; | |
67 | void setBorderColor(QColor color); |
|
67 | void setBorderColor(QColor color); | |
68 | QColor borderColor(); |
|
68 | QColor borderColor(); | |
69 |
|
69 | |||
70 | void setAlignment(Qt::Alignment alignment); |
|
70 | void setAlignment(Qt::Alignment alignment); | |
71 | Qt::Alignment alignment() const; |
|
71 | Qt::Alignment alignment() const; | |
72 |
|
72 | |||
73 | void detachFromChart(); |
|
73 | void detachFromChart(); | |
74 | void attachToChart(); |
|
74 | void attachToChart(); | |
75 | bool isAttachedToChart(); |
|
75 | bool isAttachedToChart(); | |
76 |
|
76 | |||
77 | qreal minWidth() const; |
|
77 | qreal minWidth() const; | |
78 | qreal minHeight() const; |
|
78 | qreal minHeight() const; | |
79 |
|
79 | |||
80 | void setBackgroundVisible(bool visible = true); |
|
80 | void setBackgroundVisible(bool visible = true); | |
81 | bool isBackgroundVisible() const; |
|
81 | bool isBackgroundVisible() const; | |
82 |
|
82 | |||
83 | protected: |
|
83 | protected: | |
84 | void resizeEvent(QGraphicsSceneResizeEvent *event); |
|
84 | void resizeEvent(QGraphicsSceneResizeEvent *event); | |
85 | void hideEvent(QHideEvent *event); |
|
85 | void hideEvent(QHideEvent *event); | |
86 | void showEvent(QShowEvent *event); |
|
86 | void showEvent(QShowEvent *event); | |
87 |
|
87 | |||
88 | Q_SIGNALS: |
|
88 | Q_SIGNALS: | |
89 | void alignmentChanged(Qt::Alignment alignment); |
|
|||
90 | void backgroundVisibleChanged(bool visible); |
|
89 | void backgroundVisibleChanged(bool visible); | |
91 | void colorChanged(QColor color); |
|
90 | void colorChanged(QColor color); | |
92 | void borderColorChanged(QColor color); |
|
91 | void borderColorChanged(QColor color); | |
93 |
|
92 | |||
94 | private: |
|
93 | private: | |
95 | QScopedPointer<QLegendPrivate> d_ptr; |
|
94 | QScopedPointer<QLegendPrivate> d_ptr; | |
96 | Q_DISABLE_COPY(QLegend) |
|
95 | Q_DISABLE_COPY(QLegend) | |
97 | friend class LegendScroller; |
|
96 | friend class LegendScroller; | |
98 | }; |
|
97 | }; | |
99 |
|
98 | |||
100 | QTCOMMERCIALCHART_END_NAMESPACE |
|
99 | QTCOMMERCIALCHART_END_NAMESPACE | |
101 |
|
100 | |||
102 | #endif // QLEGEND_H |
|
101 | #endif // QLEGEND_H |
@@ -1,178 +1,207 | |||||
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 "qscatterseries.h" |
|
21 | #include "qscatterseries.h" | |
22 | #include "qscatterseries_p.h" |
|
22 | #include "qscatterseries_p.h" | |
23 | #include "scatterchartitem_p.h" |
|
23 | #include "scatterchartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QScatterSeries |
|
29 | \class QScatterSeries | |
30 | \brief The QScatterSeries class is used for making scatter charts. |
|
30 | \brief The QScatterSeries class is used for making scatter charts. | |
31 |
|
31 | |||
32 | \mainclass |
|
32 | \mainclass | |
33 |
|
33 | |||
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis |
|
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis | |
35 | and the vertical axis. |
|
35 | and the vertical axis. | |
36 |
|
36 | |||
37 | \image examples_scatterchart.png |
|
37 | \image examples_scatterchart.png | |
38 |
|
38 | |||
39 | Creating basic scatter chart is simple: |
|
39 | Creating basic scatter chart is simple: | |
40 | \code |
|
40 | \code | |
41 | QScatterSeries* series = new QScatterSeries(); |
|
41 | QScatterSeries* series = new QScatterSeries(); | |
42 | series->append(0, 6); |
|
42 | series->append(0, 6); | |
43 | series->append(2, 4); |
|
43 | series->append(2, 4); | |
44 | ... |
|
44 | ... | |
45 | chart->addSeries(series); |
|
45 | chart->addSeries(series); | |
46 | \endcode |
|
46 | \endcode | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \enum QScatterSeries::MarkerShape |
|
50 | \enum QScatterSeries::MarkerShape | |
51 |
|
51 | |||
52 | This enum describes the shape used when rendering marker items. |
|
52 | This enum describes the shape used when rendering marker items. | |
53 |
|
53 | |||
54 | \value MarkerShapeCircle |
|
54 | \value MarkerShapeCircle | |
55 | \value MarkerShapeRectangle |
|
55 | \value MarkerShapeRectangle | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 |
\property QScatterSeries:: |
|
59 | \property QScatterSeries::color | |
60 |
|
60 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. | ||
61 | Defines the shape of the marker used to draw the points in the series. |
|
61 | \sa QScatterSeries::brush() | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 |
\ |
|
65 | \property QScatterSeries::borderColor | |
66 | Emitted when marker shape is changed |
|
66 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. | |
|
67 | \sa QScatterSeries::pen() | |||
67 | */ |
|
68 | */ | |
68 |
|
69 | |||
69 | /*! |
|
70 | /*! | |
70 |
|
|
71 | \property QScatterSeries::markerShape | |
71 | Emitted when marker size is changed |
|
72 | ||
|
73 | Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle. | |||
72 | */ |
|
74 | */ | |
73 |
|
75 | |||
74 | /*! |
|
76 | /*! | |
75 | \property QScatterSeries::markerSize |
|
77 | \property QScatterSeries::markerSize | |
76 |
|
78 | |||
77 | Defines the size of the marker used to draw the points in the series. |
|
79 | Defines the size of the marker used to draw the points in the series. The default size is 15.0. | |
|
80 | */ | |||
|
81 | ||||
|
82 | /*! | |||
|
83 | \fn void QScatterSeries::colorChanged(QColor color) | |||
|
84 | \brief Signal is emitted when the fill (brush) color has changed to \a color. | |||
|
85 | */ | |||
|
86 | ||||
|
87 | /*! | |||
|
88 | \fn void QScatterSeries::borderColorChanged(QColor color) | |||
|
89 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |||
78 | */ |
|
90 | */ | |
79 |
|
91 | |||
80 | /*! |
|
92 | /*! | |
81 | \fn QChartSeriesType QScatterSeries::type() const |
|
93 | \fn QChartSeriesType QScatterSeries::type() const | |
82 | \brief Returns QChartSeries::SeriesTypeScatter. |
|
94 | \brief Returns QChartSeries::SeriesTypeScatter. | |
83 | \sa QAbstractSeries, SeriesType |
|
95 | \sa QAbstractSeries, SeriesType | |
84 | */ |
|
96 | */ | |
85 |
|
97 | |||
86 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
98 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
87 |
|
99 | |||
88 | /*! |
|
100 | /*! | |
89 | Constructs a series object which is a child of \a parent. |
|
101 | Constructs a series object which is a child of \a parent. | |
90 | */ |
|
102 | */ | |
91 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) |
|
103 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) | |
92 | { |
|
104 | { | |
93 | } |
|
105 | } | |
94 |
|
106 | |||
95 | /*! |
|
107 | /*! | |
96 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
108 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
97 | */ |
|
109 | */ | |
98 | QScatterSeries::~QScatterSeries() |
|
110 | QScatterSeries::~QScatterSeries() | |
99 | { |
|
111 | { | |
100 | Q_D(QScatterSeries); |
|
112 | Q_D(QScatterSeries); | |
101 | if(d->m_dataset) { |
|
113 | if(d->m_dataset) { | |
102 | d->m_dataset->removeSeries(this); |
|
114 | d->m_dataset->removeSeries(this); | |
103 | } |
|
115 | } | |
104 | } |
|
116 | } | |
105 |
|
117 | |||
106 | QAbstractSeries::SeriesType QScatterSeries::type() const |
|
118 | QAbstractSeries::SeriesType QScatterSeries::type() const | |
107 | { |
|
119 | { | |
108 | return QAbstractSeries::SeriesTypeScatter; |
|
120 | return QAbstractSeries::SeriesTypeScatter; | |
109 | } |
|
121 | } | |
110 |
|
122 | |||
111 | /*! |
|
123 | void QScatterSeries::setColor(const QColor &color) | |
112 | Returns the shape used for drawing markers. |
|
124 | { | |
113 | */ |
|
125 | QBrush b = brush(); | |
|
126 | if (b.color() != color) { | |||
|
127 | b.setColor(color); | |||
|
128 | setBrush(b); | |||
|
129 | emit colorChanged(color); | |||
|
130 | } | |||
|
131 | } | |||
|
132 | ||||
|
133 | QColor QScatterSeries::color() const | |||
|
134 | { | |||
|
135 | return brush().color(); | |||
|
136 | } | |||
|
137 | ||||
|
138 | void QScatterSeries::setBorderColor(const QColor &color) | |||
|
139 | { | |||
|
140 | QPen p = pen(); | |||
|
141 | if (p.color() != color) { | |||
|
142 | p.setColor(color); | |||
|
143 | setPen(p); | |||
|
144 | emit borderColorChanged(color); | |||
|
145 | } | |||
|
146 | } | |||
|
147 | ||||
|
148 | QColor QScatterSeries::borderColor() const | |||
|
149 | { | |||
|
150 | return pen().color(); | |||
|
151 | } | |||
|
152 | ||||
114 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const |
|
153 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const | |
115 | { |
|
154 | { | |
116 | Q_D(const QScatterSeries); |
|
155 | Q_D(const QScatterSeries); | |
117 | return d->m_shape; |
|
156 | return d->m_shape; | |
118 | } |
|
157 | } | |
119 |
|
158 | |||
120 | /*! |
|
|||
121 | Overrides the default shape of the marker items with a user defined \a shape. The default shape |
|
|||
122 | is defined by chart theme setting. |
|
|||
123 | */ |
|
|||
124 | void QScatterSeries::setMarkerShape(MarkerShape shape) |
|
159 | void QScatterSeries::setMarkerShape(MarkerShape shape) | |
125 | { |
|
160 | { | |
126 | Q_D(QScatterSeries); |
|
161 | Q_D(QScatterSeries); | |
127 | if (d->m_shape != shape) { |
|
162 | if (d->m_shape != shape) { | |
128 | d->m_shape = shape; |
|
163 | d->m_shape = shape; | |
129 |
emit |
|
164 | emit d->updated(); | |
130 | } |
|
165 | } | |
131 | } |
|
166 | } | |
132 |
|
167 | |||
133 | /*! |
|
|||
134 | Returns the size of the marker items. |
|
|||
135 | */ |
|
|||
136 | qreal QScatterSeries::markerSize() const |
|
168 | qreal QScatterSeries::markerSize() const | |
137 | { |
|
169 | { | |
138 | Q_D(const QScatterSeries); |
|
170 | Q_D(const QScatterSeries); | |
139 | return d->m_size; |
|
171 | return d->m_size; | |
140 | } |
|
172 | } | |
141 |
|
173 | |||
142 | /*! |
|
|||
143 | Set the \a size of the marker items. The default size is 15. |
|
|||
144 | */ |
|
|||
145 | void QScatterSeries::setMarkerSize(qreal size) |
|
174 | void QScatterSeries::setMarkerSize(qreal size) | |
146 | { |
|
175 | { | |
147 | Q_D(QScatterSeries); |
|
176 | Q_D(QScatterSeries); | |
148 |
|
177 | |||
149 | if (!qFuzzyIsNull(d->m_size - size)) { |
|
178 | if (!qFuzzyIsNull(d->m_size - size)) { | |
150 | d->m_size = size; |
|
179 | d->m_size = size; | |
151 |
emit |
|
180 | emit d->updated(); | |
152 | } |
|
181 | } | |
153 | } |
|
182 | } | |
154 |
|
183 | |||
155 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
184 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
156 |
|
185 | |||
157 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), |
|
186 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), | |
158 | m_shape(QScatterSeries::MarkerShapeCircle), |
|
187 | m_shape(QScatterSeries::MarkerShapeCircle), | |
159 | m_size(15.0) |
|
188 | m_size(15.0) | |
160 | { |
|
189 | { | |
161 |
|
190 | |||
162 | }; |
|
191 | }; | |
163 |
|
192 | |||
164 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
193 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
165 | { |
|
194 | { | |
166 | Q_Q(QScatterSeries); |
|
195 | Q_Q(QScatterSeries); | |
167 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); |
|
196 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); | |
168 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
197 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
169 | scatter->setAnimator(presenter->animator()); |
|
198 | scatter->setAnimator(presenter->animator()); | |
170 | scatter->setAnimation(new XYAnimation(scatter)); |
|
199 | scatter->setAnimation(new XYAnimation(scatter)); | |
171 | } |
|
200 | } | |
172 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
201 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
173 | return scatter; |
|
202 | return scatter; | |
174 | } |
|
203 | } | |
175 |
|
204 | |||
176 | #include "moc_qscatterseries.cpp" |
|
205 | #include "moc_qscatterseries.cpp" | |
177 |
|
206 | |||
178 | QTCOMMERCIALCHART_END_NAMESPACE |
|
207 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,66 +1,71 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QSCATTERSERIES_H |
|
21 | #ifndef QSCATTERSERIES_H | |
22 | #define QSCATTERSERIES_H |
|
22 | #define QSCATTERSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qxyseries.h> |
|
25 | #include <qxyseries.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | class QScatterSeriesPrivate; |
|
29 | class QScatterSeriesPrivate; | |
30 |
|
30 | |||
31 | class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries |
|
31 | class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape NOTIFY markerShapeChanged) |
|
34 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
35 |
Q_PROPERTY( |
|
35 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
|
36 | Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape) | |||
|
37 | Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize) | |||
36 | Q_ENUMS(MarkerShape) |
|
38 | Q_ENUMS(MarkerShape) | |
37 |
|
39 | |||
38 | public: |
|
40 | public: | |
39 | enum MarkerShape { |
|
41 | enum MarkerShape { | |
40 | MarkerShapeCircle, |
|
42 | MarkerShapeCircle, | |
41 | MarkerShapeRectangle |
|
43 | MarkerShapeRectangle | |
42 | }; |
|
44 | }; | |
43 |
|
45 | |||
44 | public: |
|
46 | public: | |
45 | explicit QScatterSeries(QObject *parent = 0); |
|
47 | explicit QScatterSeries(QObject *parent = 0); | |
46 | ~QScatterSeries(); |
|
48 | ~QScatterSeries(); | |
47 | QAbstractSeries::SeriesType type() const; |
|
49 | QAbstractSeries::SeriesType type() const; | |
|
50 | void setColor(const QColor &color); | |||
|
51 | QColor color() const; | |||
|
52 | void setBorderColor(const QColor &color); | |||
|
53 | QColor borderColor() const; | |||
48 | MarkerShape markerShape() const; |
|
54 | MarkerShape markerShape() const; | |
49 | void setMarkerShape(MarkerShape shape); |
|
55 | void setMarkerShape(MarkerShape shape); | |
50 | qreal markerSize() const; |
|
56 | qreal markerSize() const; | |
51 | void setMarkerSize(qreal size); |
|
57 | void setMarkerSize(qreal size); | |
52 |
|
58 | |||
53 | Q_SIGNALS: |
|
59 | Q_SIGNALS: | |
54 |
void |
|
60 | void colorChanged(QColor color); | |
55 |
void |
|
61 | void borderColorChanged(QColor color); | |
56 |
|
62 | |||
57 | private: |
|
63 | private: | |
58 | Q_DECLARE_PRIVATE(QScatterSeries) |
|
64 | Q_DECLARE_PRIVATE(QScatterSeries) | |
59 | Q_DISABLE_COPY(QScatterSeries) |
|
65 | Q_DISABLE_COPY(QScatterSeries) | |
60 | friend class ScatterChartItem; |
|
66 | friend class ScatterChartItem; | |
61 |
|
||||
62 | }; |
|
67 | }; | |
63 |
|
68 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE | |
65 |
|
70 | |||
66 | #endif // QSCATTERSERIES_H |
|
71 | #endif // QSCATTERSERIES_H |
@@ -1,207 +1,205 | |||||
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 "scatterchartitem_p.h" |
|
21 | #include "scatterchartitem_p.h" | |
22 | #include "qscatterseries.h" |
|
22 | #include "qscatterseries.h" | |
23 | #include "qscatterseries_p.h" |
|
23 | #include "qscatterseries_p.h" | |
24 | #include "chartpresenter_p.h" |
|
24 | #include "chartpresenter_p.h" | |
25 | #include <QPainter> |
|
25 | #include <QPainter> | |
26 | #include <QGraphicsScene> |
|
26 | #include <QGraphicsScene> | |
27 | #include <QDebug> |
|
27 | #include <QDebug> | |
28 | #include <QGraphicsSceneMouseEvent> |
|
28 | #include <QGraphicsSceneMouseEvent> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | ScatterChartItem::ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter) : |
|
32 | ScatterChartItem::ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter) : | |
33 | XYChart(series,presenter), |
|
33 | XYChart(series,presenter), | |
34 | QGraphicsItem(presenter ? presenter->rootItem() : 0), |
|
34 | QGraphicsItem(presenter ? presenter->rootItem() : 0), | |
35 | m_series(series), |
|
35 | m_series(series), | |
36 | m_items(this), |
|
36 | m_items(this), | |
37 | m_visible(true), |
|
37 | m_visible(true), | |
38 | m_shape(QScatterSeries::MarkerShapeRectangle), |
|
38 | m_shape(QScatterSeries::MarkerShapeRectangle), | |
39 | m_size(15) |
|
39 | m_size(15) | |
40 | { |
|
40 | { | |
41 | QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(handleUpdated())); |
|
41 | QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(handleUpdated())); | |
42 | QObject::connect(m_series, SIGNAL(markerShapeChanged()), this, SLOT(handleUpdated())); |
|
|||
43 | QObject::connect(m_series, SIGNAL(markerSizeChanged()), this, SLOT(handleUpdated())); |
|
|||
44 | QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); |
|
42 | QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated())); | |
45 |
|
43 | |||
46 | setZValue(ChartPresenter::ScatterSeriesZValue); |
|
44 | setZValue(ChartPresenter::ScatterSeriesZValue); | |
47 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
|
45 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); | |
48 |
|
46 | |||
49 | handleUpdated(); |
|
47 | handleUpdated(); | |
50 |
|
48 | |||
51 | m_items.setHandlesChildEvents(false); |
|
49 | m_items.setHandlesChildEvents(false); | |
52 |
|
50 | |||
53 | // TODO: how to draw a drop shadow? |
|
51 | // TODO: how to draw a drop shadow? | |
54 | // QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect(); |
|
52 | // QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect(); | |
55 | // dropShadow->setOffset(2.0); |
|
53 | // dropShadow->setOffset(2.0); | |
56 | // dropShadow->setBlurRadius(2.0); |
|
54 | // dropShadow->setBlurRadius(2.0); | |
57 | // setGraphicsEffect(dropShadow); |
|
55 | // setGraphicsEffect(dropShadow); | |
58 | } |
|
56 | } | |
59 |
|
57 | |||
60 | QRectF ScatterChartItem::boundingRect() const |
|
58 | QRectF ScatterChartItem::boundingRect() const | |
61 | { |
|
59 | { | |
62 | return m_rect; |
|
60 | return m_rect; | |
63 | } |
|
61 | } | |
64 |
|
62 | |||
65 | void ScatterChartItem::createPoints(int count) |
|
63 | void ScatterChartItem::createPoints(int count) | |
66 | { |
|
64 | { | |
67 | for (int i = 0; i < count; ++i) { |
|
65 | for (int i = 0; i < count; ++i) { | |
68 |
|
66 | |||
69 | QGraphicsItem *item = 0; |
|
67 | QGraphicsItem *item = 0; | |
70 |
|
68 | |||
71 | switch (m_shape) { |
|
69 | switch (m_shape) { | |
72 | case QScatterSeries::MarkerShapeCircle: { |
|
70 | case QScatterSeries::MarkerShapeCircle: { | |
73 | QGraphicsEllipseItem* i = new QGraphicsEllipseItem(0,0,m_size,m_size); |
|
71 | QGraphicsEllipseItem* i = new QGraphicsEllipseItem(0,0,m_size,m_size); | |
74 | const QRectF& rect = i->boundingRect(); |
|
72 | const QRectF& rect = i->boundingRect(); | |
75 | i->setPos(-rect.width()/2,-rect.height()/2); |
|
73 | i->setPos(-rect.width()/2,-rect.height()/2); | |
76 | item = new Marker(i,this); |
|
74 | item = new Marker(i,this); | |
77 | break; |
|
75 | break; | |
78 | } |
|
76 | } | |
79 | case QScatterSeries::MarkerShapeRectangle: { |
|
77 | case QScatterSeries::MarkerShapeRectangle: { | |
80 | QGraphicsRectItem* i = new QGraphicsRectItem(0,0,m_size,m_size); |
|
78 | QGraphicsRectItem* i = new QGraphicsRectItem(0,0,m_size,m_size); | |
81 | i->setPos(-m_size/2,-m_size/2); |
|
79 | i->setPos(-m_size/2,-m_size/2); | |
82 | item = new Marker(i,this); |
|
80 | item = new Marker(i,this); | |
83 | break; |
|
81 | break; | |
84 | } |
|
82 | } | |
85 | default: |
|
83 | default: | |
86 | qWarning()<<"Unsupported marker type"; |
|
84 | qWarning()<<"Unsupported marker type"; | |
87 | break; |
|
85 | break; | |
88 |
|
86 | |||
89 | } |
|
87 | } | |
90 | m_items.addToGroup(item); |
|
88 | m_items.addToGroup(item); | |
91 | } |
|
89 | } | |
92 | } |
|
90 | } | |
93 |
|
91 | |||
94 | void ScatterChartItem::deletePoints(int count) |
|
92 | void ScatterChartItem::deletePoints(int count) | |
95 | { |
|
93 | { | |
96 | QList<QGraphicsItem *> items = m_items.childItems(); |
|
94 | QList<QGraphicsItem *> items = m_items.childItems(); | |
97 |
|
95 | |||
98 | for (int i = 0; i < count; ++i) { |
|
96 | for (int i = 0; i < count; ++i) { | |
99 | delete(items.takeLast()); |
|
97 | delete(items.takeLast()); | |
100 | } |
|
98 | } | |
101 | } |
|
99 | } | |
102 |
|
100 | |||
103 | void ScatterChartItem::markerSelected(Marker *marker) |
|
101 | void ScatterChartItem::markerSelected(Marker *marker) | |
104 | { |
|
102 | { | |
105 | emit XYChart::clicked(calculateDomainPoint(marker->point())); |
|
103 | emit XYChart::clicked(calculateDomainPoint(marker->point())); | |
106 | } |
|
104 | } | |
107 |
|
105 | |||
108 | void ScatterChartItem::updateGeometry() |
|
106 | void ScatterChartItem::updateGeometry() | |
109 | { |
|
107 | { | |
110 |
|
108 | |||
111 | const QVector<QPointF>& points = geometryPoints(); |
|
109 | const QVector<QPointF>& points = geometryPoints(); | |
112 |
|
110 | |||
113 | if(points.size()==0) |
|
111 | if(points.size()==0) | |
114 | { |
|
112 | { | |
115 | deletePoints(m_items.childItems().count()); |
|
113 | deletePoints(m_items.childItems().count()); | |
116 | return; |
|
114 | return; | |
117 | } |
|
115 | } | |
118 |
|
116 | |||
119 | int diff = m_items.childItems().size() - points.size(); |
|
117 | int diff = m_items.childItems().size() - points.size(); | |
120 |
|
118 | |||
121 | if(diff>0) { |
|
119 | if(diff>0) { | |
122 | deletePoints(diff); |
|
120 | deletePoints(diff); | |
123 | } |
|
121 | } | |
124 | else if(diff<0) { |
|
122 | else if(diff<0) { | |
125 | createPoints(-diff); |
|
123 | createPoints(-diff); | |
126 | } |
|
124 | } | |
127 |
|
125 | |||
128 | if(diff!=0) handleUpdated(); |
|
126 | if(diff!=0) handleUpdated(); | |
129 |
|
127 | |||
130 | QList<QGraphicsItem*> items = m_items.childItems(); |
|
128 | QList<QGraphicsItem*> items = m_items.childItems(); | |
131 |
|
129 | |||
132 | for (int i = 0; i < points.size(); i++) { |
|
130 | for (int i = 0; i < points.size(); i++) { | |
133 | Marker* item = static_cast<Marker*>(items.at(i)); |
|
131 | Marker* item = static_cast<Marker*>(items.at(i)); | |
134 | const QPointF& point = points.at(i); |
|
132 | const QPointF& point = points.at(i); | |
135 | const QRectF& rect = item->boundingRect(); |
|
133 | const QRectF& rect = item->boundingRect(); | |
136 | item->setPoint(point); |
|
134 | item->setPoint(point); | |
137 | item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2); |
|
135 | item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2); | |
138 | if(!m_visible || !clipRect().contains(point)) { |
|
136 | if(!m_visible || !clipRect().contains(point)) { | |
139 | item->setVisible(false); |
|
137 | item->setVisible(false); | |
140 | } |
|
138 | } | |
141 | else { |
|
139 | else { | |
142 | item->setVisible(true); |
|
140 | item->setVisible(true); | |
143 | } |
|
141 | } | |
144 | } |
|
142 | } | |
145 |
|
143 | |||
146 | prepareGeometryChange(); |
|
144 | prepareGeometryChange(); | |
147 | m_rect = clipRect(); |
|
145 | m_rect = clipRect(); | |
148 | setPos(origin()); |
|
146 | setPos(origin()); | |
149 | } |
|
147 | } | |
150 |
|
148 | |||
151 | void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
149 | void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
152 | { |
|
150 | { | |
153 | Q_UNUSED(painter) |
|
151 | Q_UNUSED(painter) | |
154 | Q_UNUSED(option) |
|
152 | Q_UNUSED(option) | |
155 | Q_UNUSED(widget) |
|
153 | Q_UNUSED(widget) | |
156 | } |
|
154 | } | |
157 |
|
155 | |||
158 | void ScatterChartItem::setPen(const QPen& pen) |
|
156 | void ScatterChartItem::setPen(const QPen& pen) | |
159 | { |
|
157 | { | |
160 | foreach(QGraphicsItem* item , m_items.childItems()) { |
|
158 | foreach(QGraphicsItem* item , m_items.childItems()) { | |
161 | static_cast<Marker*>(item)->setPen(pen); |
|
159 | static_cast<Marker*>(item)->setPen(pen); | |
162 | } |
|
160 | } | |
163 | } |
|
161 | } | |
164 |
|
162 | |||
165 | void ScatterChartItem::setBrush(const QBrush& brush) |
|
163 | void ScatterChartItem::setBrush(const QBrush& brush) | |
166 | { |
|
164 | { | |
167 | foreach(QGraphicsItem* item , m_items.childItems()) { |
|
165 | foreach(QGraphicsItem* item , m_items.childItems()) { | |
168 | static_cast<Marker*>(item)->setBrush(brush); |
|
166 | static_cast<Marker*>(item)->setBrush(brush); | |
169 | } |
|
167 | } | |
170 | } |
|
168 | } | |
171 |
|
169 | |||
172 | void ScatterChartItem::handleUpdated() |
|
170 | void ScatterChartItem::handleUpdated() | |
173 | { |
|
171 | { | |
174 | int count = m_items.childItems().count(); |
|
172 | int count = m_items.childItems().count(); | |
175 |
|
173 | |||
176 | if(count==0) return; |
|
174 | if(count==0) return; | |
177 |
|
175 | |||
178 | bool recreate = m_visible != m_series->isVisible() |
|
176 | bool recreate = m_visible != m_series->isVisible() | |
179 | || m_size != m_series->markerSize() |
|
177 | || m_size != m_series->markerSize() | |
180 | || m_shape != m_series->markerShape(); |
|
178 | || m_shape != m_series->markerShape(); | |
181 |
|
179 | |||
182 | m_visible = m_series->isVisible(); |
|
180 | m_visible = m_series->isVisible(); | |
183 | m_size = m_series->markerSize(); |
|
181 | m_size = m_series->markerSize(); | |
184 | m_shape = m_series->markerShape(); |
|
182 | m_shape = m_series->markerShape(); | |
185 |
|
183 | |||
186 | if(recreate) { |
|
184 | if(recreate) { | |
187 | // TODO: optimize handleUpdate to recreate points only in case shape changed |
|
185 | // TODO: optimize handleUpdate to recreate points only in case shape changed | |
188 | deletePoints(count); |
|
186 | deletePoints(count); | |
189 | createPoints(count); |
|
187 | createPoints(count); | |
190 |
|
188 | |||
191 | // Updating geometry is now safe, because it won't call handleUpdated unless it creates/deletes points |
|
189 | // Updating geometry is now safe, because it won't call handleUpdated unless it creates/deletes points | |
192 | updateGeometry(); |
|
190 | updateGeometry(); | |
193 | } |
|
191 | } | |
194 |
|
192 | |||
195 | setPen(m_series->pen()); |
|
193 | setPen(m_series->pen()); | |
196 | setBrush(m_series->brush()); |
|
194 | setBrush(m_series->brush()); | |
197 | update(); |
|
195 | update(); | |
198 | } |
|
196 | } | |
199 |
|
197 | |||
200 | void ScatterChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
198 | void ScatterChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | |
201 | { |
|
199 | { | |
202 | emit XYChart::clicked(calculateDomainPoint(event->pos())); |
|
200 | emit XYChart::clicked(calculateDomainPoint(event->pos())); | |
203 | } |
|
201 | } | |
204 |
|
202 | |||
205 | #include "moc_scatterchartitem_p.cpp" |
|
203 | #include "moc_scatterchartitem_p.cpp" | |
206 |
|
204 | |||
207 | QTCOMMERCIALCHART_END_NAMESPACE |
|
205 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,350 +1,369 | |||||
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 "qxyseries.h" |
|
21 | #include "qxyseries.h" | |
22 | #include "qxyseries_p.h" |
|
22 | #include "qxyseries_p.h" | |
23 | #include "domain_p.h" |
|
23 | #include "domain_p.h" | |
24 | #include "legendmarker_p.h" |
|
24 | #include "legendmarker_p.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QXYSeries |
|
29 | \class QXYSeries | |
30 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
30 | \brief The QXYSeries class is a base class for line, spline and scatter series. | |
31 | */ |
|
31 | */ | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \property QXYSeries::pointsVisible |
|
34 | \property QXYSeries::pointsVisible | |
35 |
|
35 | |||
36 | Controls if the data points are visible and should be drawn. |
|
36 | Controls if the data points are visible and should be drawn. | |
37 | */ |
|
37 | */ | |
38 |
|
38 | |||
39 | /*! |
|
39 | /*! | |
40 | \fn QPen QXYSeries::pen() const |
|
40 | \fn QPen QXYSeries::pen() const | |
41 | \brief Returns pen used to draw points for series. |
|
41 | \brief Returns pen used to draw points for series. | |
42 | \sa setPen() |
|
42 | \sa setPen() | |
43 | */ |
|
43 | */ | |
44 |
|
44 | |||
45 | /*! |
|
45 | /*! | |
46 | \fn QBrush QXYSeries::brush() const |
|
46 | \fn QBrush QXYSeries::brush() const | |
47 | \brief Returns brush used to draw points for series. |
|
47 | \brief Returns brush used to draw points for series. | |
48 | \sa setBrush() |
|
48 | \sa setBrush() | |
49 | */ |
|
49 | */ | |
50 |
|
50 | |||
51 | /*! |
|
51 | /*! | |
|
52 | \property QXYSeries::color | |||
|
53 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. | |||
|
54 | \sa QXYSeries::pen() | |||
|
55 | */ | |||
|
56 | ||||
|
57 | /*! | |||
52 | \fn void QXYSeries::clicked(const QPointF& point) |
|
58 | \fn void QXYSeries::clicked(const QPointF& point) | |
53 | \brief Signal is emitted when user clicks the \a point on chart. |
|
59 | \brief Signal is emitted when user clicks the \a point on chart. | |
54 | */ |
|
60 | */ | |
55 |
|
61 | |||
56 | /*! |
|
62 | /*! | |
57 | \fn void QXYSeries::pointReplaced(int index) |
|
63 | \fn void QXYSeries::pointReplaced(int index) | |
58 | \brief Signal is emitted when user replaces a point at \a index. |
|
64 | \brief Signal is emitted when user replaces a point at \a index. | |
59 | \sa replace() |
|
65 | \sa replace() | |
60 | */ |
|
66 | */ | |
61 |
|
67 | |||
62 | /*! |
|
68 | /*! | |
63 | \fn void QXYSeries::pointAdded(int index) |
|
69 | \fn void QXYSeries::pointAdded(int index) | |
64 | \brief Signal is emitted when user adds a point at \a index. |
|
70 | \brief Signal is emitted when user adds a point at \a index. | |
65 | \sa append(), insert() |
|
71 | \sa append(), insert() | |
66 | */ |
|
72 | */ | |
67 |
|
73 | |||
68 | /*! |
|
74 | /*! | |
69 | \fn void QXYSeries::pointRemoved(int index) |
|
75 | \fn void QXYSeries::pointRemoved(int index) | |
70 | \brief Signal is emitted when user removes a point at \a index. |
|
76 | \brief Signal is emitted when user removes a point at \a index. | |
71 | \sa remove() |
|
77 | \sa remove() | |
72 | */ |
|
78 | */ | |
73 |
|
79 | |||
74 | /*! |
|
80 | /*! | |
75 |
\fn void QXYSeries:: |
|
81 | \fn void QXYSeries::colorChanged(QColor color) | |
76 |
\brief Signal is emitted when the |
|
82 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
77 | */ |
|
83 | */ | |
78 |
|
84 | |||
79 | /*! |
|
85 | /*! | |
80 | \fn void QXYSeriesPrivate::updated() |
|
86 | \fn void QXYSeriesPrivate::updated() | |
81 | \brief \internal |
|
87 | \brief \internal | |
82 | */ |
|
88 | */ | |
83 |
|
89 | |||
84 | /*! |
|
90 | /*! | |
85 | \internal |
|
91 | \internal | |
86 |
|
92 | |||
87 | Constructs empty series object which is a child of \a parent. |
|
93 | Constructs empty series object which is a child of \a parent. | |
88 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
94 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
89 | */ |
|
95 | */ | |
90 | QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent) |
|
96 | QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent) | |
91 | { |
|
97 | { | |
92 | } |
|
98 | } | |
93 |
|
99 | |||
94 | /*! |
|
100 | /*! | |
95 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
101 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
96 | and are deleted when mentioned object are destroyed. |
|
102 | and are deleted when mentioned object are destroyed. | |
97 | */ |
|
103 | */ | |
98 | QXYSeries::~QXYSeries() |
|
104 | QXYSeries::~QXYSeries() | |
99 | { |
|
105 | { | |
100 | } |
|
106 | } | |
101 |
|
107 | |||
102 | /*! |
|
108 | /*! | |
103 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. |
|
109 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. | |
104 | */ |
|
110 | */ | |
105 | void QXYSeries::append(qreal x,qreal y) |
|
111 | void QXYSeries::append(qreal x,qreal y) | |
106 | { |
|
112 | { | |
107 | append(QPointF(x,y)); |
|
113 | append(QPointF(x,y)); | |
108 | } |
|
114 | } | |
109 |
|
115 | |||
110 | /*! |
|
116 | /*! | |
111 | This is an overloaded function. |
|
117 | This is an overloaded function. | |
112 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
118 | Adds data \a point to the series. Points are connected with lines on the chart. | |
113 | */ |
|
119 | */ | |
114 | void QXYSeries::append(const QPointF &point) |
|
120 | void QXYSeries::append(const QPointF &point) | |
115 | { |
|
121 | { | |
116 | Q_D(QXYSeries); |
|
122 | Q_D(QXYSeries); | |
117 | d->m_points<<point; |
|
123 | d->m_points<<point; | |
118 | // emit d->pointAdded(d->m_points.count()-1); |
|
124 | // emit d->pointAdded(d->m_points.count()-1); | |
119 | emit pointAdded(d->m_points.count()-1); |
|
125 | emit pointAdded(d->m_points.count()-1); | |
120 | } |
|
126 | } | |
121 |
|
127 | |||
122 | /*! |
|
128 | /*! | |
123 | This is an overloaded function. |
|
129 | This is an overloaded function. | |
124 | Adds list of data \a points to the series. Points are connected with lines on the chart. |
|
130 | Adds list of data \a points to the series. Points are connected with lines on the chart. | |
125 | */ |
|
131 | */ | |
126 | void QXYSeries::append(const QList<QPointF> &points) |
|
132 | void QXYSeries::append(const QList<QPointF> &points) | |
127 | { |
|
133 | { | |
128 | foreach(const QPointF& point , points) { |
|
134 | foreach(const QPointF& point , points) { | |
129 | append(point); |
|
135 | append(point); | |
130 | } |
|
136 | } | |
131 | } |
|
137 | } | |
132 |
|
138 | |||
133 | /*! |
|
139 | /*! | |
134 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. |
|
140 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. | |
135 | */ |
|
141 | */ | |
136 | void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY) |
|
142 | void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY) | |
137 | { |
|
143 | { | |
138 | replace(QPointF(oldX,oldY),QPointF(newX,newY)); |
|
144 | replace(QPointF(oldX,oldY),QPointF(newX,newY)); | |
139 | } |
|
145 | } | |
140 |
|
146 | |||
141 | /*! |
|
147 | /*! | |
142 | Replaces \a oldPoint with \a newPoint. |
|
148 | Replaces \a oldPoint with \a newPoint. | |
143 | */ |
|
149 | */ | |
144 | void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) |
|
150 | void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) | |
145 | { |
|
151 | { | |
146 | Q_D(QXYSeries); |
|
152 | Q_D(QXYSeries); | |
147 | int index = d->m_points.indexOf(oldPoint); |
|
153 | int index = d->m_points.indexOf(oldPoint); | |
148 | if(index==-1) return; |
|
154 | if(index==-1) return; | |
149 | d->m_points[index] = newPoint; |
|
155 | d->m_points[index] = newPoint; | |
150 | // emit d->pointReplaced(index); |
|
156 | // emit d->pointReplaced(index); | |
151 | emit pointReplaced(index); |
|
157 | emit pointReplaced(index); | |
152 | } |
|
158 | } | |
153 |
|
159 | |||
154 | /*! |
|
160 | /*! | |
155 | Removes current \a x and \a y value. |
|
161 | Removes current \a x and \a y value. | |
156 | */ |
|
162 | */ | |
157 | void QXYSeries::remove(qreal x,qreal y) |
|
163 | void QXYSeries::remove(qreal x,qreal y) | |
158 | { |
|
164 | { | |
159 | remove(QPointF(x,y)); |
|
165 | remove(QPointF(x,y)); | |
160 | } |
|
166 | } | |
161 |
|
167 | |||
162 | /*! |
|
168 | /*! | |
163 | Removes current \a point x value. |
|
169 | Removes current \a point x value. | |
164 |
|
170 | |||
165 | Note: point y value is ignored. |
|
171 | Note: point y value is ignored. | |
166 | */ |
|
172 | */ | |
167 | void QXYSeries::remove(const QPointF &point) |
|
173 | void QXYSeries::remove(const QPointF &point) | |
168 | { |
|
174 | { | |
169 | Q_D(QXYSeries); |
|
175 | Q_D(QXYSeries); | |
170 | int index = d->m_points.indexOf(point); |
|
176 | int index = d->m_points.indexOf(point); | |
171 | if(index==-1) return; |
|
177 | if(index==-1) return; | |
172 | d->m_points.remove(index); |
|
178 | d->m_points.remove(index); | |
173 | // emit d->pointRemoved(index); |
|
179 | // emit d->pointRemoved(index); | |
174 | emit pointRemoved(index); |
|
180 | emit pointRemoved(index); | |
175 | } |
|
181 | } | |
176 |
|
182 | |||
177 | /*! |
|
183 | /*! | |
178 | Inserts a \a point in the series at \a index position. |
|
184 | Inserts a \a point in the series at \a index position. | |
179 | */ |
|
185 | */ | |
180 | void QXYSeries::insert(int index, const QPointF &point) |
|
186 | void QXYSeries::insert(int index, const QPointF &point) | |
181 | { |
|
187 | { | |
182 | Q_D(QXYSeries); |
|
188 | Q_D(QXYSeries); | |
183 | d->m_points.insert(index, point); |
|
189 | d->m_points.insert(index, point); | |
184 | // emit d->pointAdded(index); |
|
190 | // emit d->pointAdded(index); | |
185 | emit pointAdded(index); |
|
191 | emit pointAdded(index); | |
186 | } |
|
192 | } | |
187 |
|
193 | |||
188 | /*! |
|
194 | /*! | |
189 | Removes all points from the series. |
|
195 | Removes all points from the series. | |
190 | */ |
|
196 | */ | |
191 | void QXYSeries::clear() |
|
197 | void QXYSeries::clear() | |
192 | { |
|
198 | { | |
193 | Q_D(QXYSeries); |
|
199 | Q_D(QXYSeries); | |
194 | for (int i = d->m_points.size() - 1; i >= 0; i--) |
|
200 | for (int i = d->m_points.size() - 1; i >= 0; i--) | |
195 | remove(d->m_points.at(i)); |
|
201 | remove(d->m_points.at(i)); | |
196 | } |
|
202 | } | |
197 |
|
203 | |||
198 | /*! |
|
204 | /*! | |
199 | \internal \a pos |
|
205 | \internal \a pos | |
200 | */ |
|
206 | */ | |
201 | QList<QPointF> QXYSeries::points() const |
|
207 | QList<QPointF> QXYSeries::points() const | |
202 | { |
|
208 | { | |
203 | Q_D(const QXYSeries); |
|
209 | Q_D(const QXYSeries); | |
204 | return d->m_points.toList(); |
|
210 | return d->m_points.toList(); | |
205 | } |
|
211 | } | |
206 |
|
212 | |||
207 | /*! |
|
213 | /*! | |
208 | Returns number of data points within series. |
|
214 | Returns number of data points within series. | |
209 | */ |
|
215 | */ | |
210 | int QXYSeries::count() const |
|
216 | int QXYSeries::count() const | |
211 | { |
|
217 | { | |
212 | Q_D(const QXYSeries); |
|
218 | Q_D(const QXYSeries); | |
213 | return d->m_points.count(); |
|
219 | return d->m_points.count(); | |
214 | } |
|
220 | } | |
215 |
|
221 | |||
216 |
|
222 | |||
217 | /*! |
|
223 | /*! | |
218 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
224 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
219 | pen from chart theme is used. |
|
225 | pen from chart theme is used. | |
220 | \sa QChart::setTheme() |
|
226 | \sa QChart::setTheme() | |
221 | */ |
|
227 | */ | |
222 | void QXYSeries::setPen(const QPen &pen) |
|
228 | void QXYSeries::setPen(const QPen &pen) | |
223 | { |
|
229 | { | |
224 | Q_D(QXYSeries); |
|
230 | Q_D(QXYSeries); | |
225 | if (d->m_pen!=pen) { |
|
231 | if (d->m_pen!=pen) { | |
226 | d->m_pen = pen; |
|
232 | d->m_pen = pen; | |
227 | emit d->updated(); |
|
233 | emit d->updated(); | |
228 | } |
|
234 | } | |
229 | } |
|
235 | } | |
230 |
|
236 | |||
231 | QPen QXYSeries::pen() const |
|
237 | QPen QXYSeries::pen() const | |
232 | { |
|
238 | { | |
233 | Q_D(const QXYSeries); |
|
239 | Q_D(const QXYSeries); | |
234 | return d->m_pen; |
|
240 | return d->m_pen; | |
235 | } |
|
241 | } | |
236 |
|
242 | |||
237 | /*! |
|
243 | /*! | |
238 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
244 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
239 | from chart theme setting is used. |
|
245 | from chart theme setting is used. | |
240 | \sa QChart::setTheme() |
|
246 | \sa QChart::setTheme() | |
241 | */ |
|
247 | */ | |
242 | void QXYSeries::setBrush(const QBrush &brush) |
|
248 | void QXYSeries::setBrush(const QBrush &brush) | |
243 | { |
|
249 | { | |
244 | Q_D(QXYSeries); |
|
250 | Q_D(QXYSeries); | |
245 | if (d->m_brush!=brush) { |
|
251 | if (d->m_brush!=brush) { | |
246 | d->m_brush = brush; |
|
252 | d->m_brush = brush; | |
247 | emit d->updated(); |
|
253 | emit d->updated(); | |
248 | } |
|
254 | } | |
249 | } |
|
255 | } | |
250 |
|
256 | |||
251 | QBrush QXYSeries::brush() const |
|
257 | QBrush QXYSeries::brush() const | |
252 | { |
|
258 | { | |
253 | Q_D(const QXYSeries); |
|
259 | Q_D(const QXYSeries); | |
254 | return d->m_brush; |
|
260 | return d->m_brush; | |
255 | } |
|
261 | } | |
256 |
|
262 | |||
|
263 | void QXYSeries::setColor(const QColor &color) | |||
|
264 | { | |||
|
265 | QPen p = pen(); | |||
|
266 | if (p.color() != color) { | |||
|
267 | p.setColor(color); | |||
|
268 | setPen(p); | |||
|
269 | emit colorChanged(color); | |||
|
270 | } | |||
|
271 | } | |||
|
272 | ||||
|
273 | QColor QXYSeries::color() const | |||
|
274 | { | |||
|
275 | return pen().color(); | |||
|
276 | } | |||
257 |
|
277 | |||
258 | void QXYSeries::setPointsVisible(bool visible) |
|
278 | void QXYSeries::setPointsVisible(bool visible) | |
259 | { |
|
279 | { | |
260 | Q_D(QXYSeries); |
|
280 | Q_D(QXYSeries); | |
261 | if (d->m_pointsVisible != visible){ |
|
281 | if (d->m_pointsVisible != visible){ | |
262 | d->m_pointsVisible = visible; |
|
282 | d->m_pointsVisible = visible; | |
263 | emit d->updated(); |
|
283 | emit d->updated(); | |
264 | emit pointsVisibleChanged(visible); |
|
|||
265 | } |
|
284 | } | |
266 | } |
|
285 | } | |
267 |
|
286 | |||
268 | bool QXYSeries::pointsVisible() const |
|
287 | bool QXYSeries::pointsVisible() const | |
269 | { |
|
288 | { | |
270 | Q_D(const QXYSeries); |
|
289 | Q_D(const QXYSeries); | |
271 | return d->m_pointsVisible; |
|
290 | return d->m_pointsVisible; | |
272 | } |
|
291 | } | |
273 |
|
292 | |||
274 |
|
293 | |||
275 | /*! |
|
294 | /*! | |
276 | Stream operator for adding a data \a point to the series. |
|
295 | Stream operator for adding a data \a point to the series. | |
277 | \sa append() |
|
296 | \sa append() | |
278 | */ |
|
297 | */ | |
279 | QXYSeries& QXYSeries::operator<< (const QPointF &point) |
|
298 | QXYSeries& QXYSeries::operator<< (const QPointF &point) | |
280 | { |
|
299 | { | |
281 | append(point); |
|
300 | append(point); | |
282 | return *this; |
|
301 | return *this; | |
283 | } |
|
302 | } | |
284 |
|
303 | |||
285 |
|
304 | |||
286 | /*! |
|
305 | /*! | |
287 | Stream operator for adding a list of \a points to the series. |
|
306 | Stream operator for adding a list of \a points to the series. | |
288 | \sa append() |
|
307 | \sa append() | |
289 | */ |
|
308 | */ | |
290 |
|
309 | |||
291 | QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points) |
|
310 | QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points) | |
292 | { |
|
311 | { | |
293 | append(points); |
|
312 | append(points); | |
294 | return *this; |
|
313 | return *this; | |
295 | } |
|
314 | } | |
296 |
|
315 | |||
297 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
316 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
298 |
|
317 | |||
299 |
|
318 | |||
300 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) : |
|
319 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) : | |
301 | QAbstractSeriesPrivate(q), |
|
320 | QAbstractSeriesPrivate(q), | |
302 | m_pointsVisible(false) |
|
321 | m_pointsVisible(false) | |
303 | { |
|
322 | { | |
304 | } |
|
323 | } | |
305 |
|
324 | |||
306 | void QXYSeriesPrivate::scaleDomain(Domain& domain) |
|
325 | void QXYSeriesPrivate::scaleDomain(Domain& domain) | |
307 | { |
|
326 | { | |
308 | qreal minX(domain.minX()); |
|
327 | qreal minX(domain.minX()); | |
309 | qreal minY(domain.minY()); |
|
328 | qreal minY(domain.minY()); | |
310 | qreal maxX(domain.maxX()); |
|
329 | qreal maxX(domain.maxX()); | |
311 | qreal maxY(domain.maxY()); |
|
330 | qreal maxY(domain.maxY()); | |
312 | int tickXCount(domain.tickXCount()); |
|
331 | int tickXCount(domain.tickXCount()); | |
313 | int tickYCount(domain.tickYCount()); |
|
332 | int tickYCount(domain.tickYCount()); | |
314 |
|
333 | |||
315 | Q_Q(QXYSeries); |
|
334 | Q_Q(QXYSeries); | |
316 |
|
335 | |||
317 | const QList<QPointF>& points = q->points(); |
|
336 | const QList<QPointF>& points = q->points(); | |
318 |
|
337 | |||
319 |
|
338 | |||
320 | if(points.isEmpty()){ |
|
339 | if(points.isEmpty()){ | |
321 | minX=0.0; |
|
340 | minX=0.0; | |
322 | minY=0.0; |
|
341 | minY=0.0; | |
323 | maxX=1.0; |
|
342 | maxX=1.0; | |
324 | maxY=1.0; |
|
343 | maxY=1.0; | |
325 | } |
|
344 | } | |
326 |
|
345 | |||
327 | for (int i = 0; i < points.count(); i++) |
|
346 | for (int i = 0; i < points.count(); i++) | |
328 | { |
|
347 | { | |
329 | qreal x = points[i].x(); |
|
348 | qreal x = points[i].x(); | |
330 | qreal y = points[i].y(); |
|
349 | qreal y = points[i].y(); | |
331 | minX = qMin(minX, x); |
|
350 | minX = qMin(minX, x); | |
332 | minY = qMin(minY, y); |
|
351 | minY = qMin(minY, y); | |
333 | maxX = qMax(maxX, x); |
|
352 | maxX = qMax(maxX, x); | |
334 | maxY = qMax(maxY, y); |
|
353 | maxY = qMax(maxY, y); | |
335 | } |
|
354 | } | |
336 |
|
355 | |||
337 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
356 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
338 | } |
|
357 | } | |
339 |
|
358 | |||
340 | QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) |
|
359 | QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) | |
341 | { |
|
360 | { | |
342 | Q_Q(QXYSeries); |
|
361 | Q_Q(QXYSeries); | |
343 | QList<LegendMarker*> list; |
|
362 | QList<LegendMarker*> list; | |
344 | return list << new XYLegendMarker(q,legend); |
|
363 | return list << new XYLegendMarker(q,legend); | |
345 | } |
|
364 | } | |
346 |
|
365 | |||
347 | #include "moc_qxyseries.cpp" |
|
366 | #include "moc_qxyseries.cpp" | |
348 | #include "moc_qxyseries_p.cpp" |
|
367 | #include "moc_qxyseries_p.cpp" | |
349 |
|
368 | |||
350 | QTCOMMERCIALCHART_END_NAMESPACE |
|
369 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,88 +1,91 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QXYSERIES_H |
|
21 | #ifndef QXYSERIES_H | |
22 | #define QXYSERIES_H |
|
22 | #define QXYSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qabstractseries.h> |
|
25 | #include <qabstractseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | class QModelIndex; |
|
29 | class QModelIndex; | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QXYSeriesPrivate; |
|
33 | class QXYSeriesPrivate; | |
34 | class QXYModelMapper; |
|
34 | class QXYModelMapper; | |
35 |
|
35 | |||
36 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries |
|
36 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 |
Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible |
|
39 | Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) | |
|
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |||
40 |
|
41 | |||
41 | protected: |
|
42 | protected: | |
42 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); |
|
43 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); | |
43 |
|
44 | |||
44 | public: |
|
45 | public: | |
45 | ~QXYSeries(); |
|
46 | ~QXYSeries(); | |
46 | void append(qreal x, qreal y); |
|
47 | void append(qreal x, qreal y); | |
47 | void append(const QPointF &point); |
|
48 | void append(const QPointF &point); | |
48 | void append(const QList<QPointF> &points); |
|
49 | void append(const QList<QPointF> &points); | |
49 | void replace(qreal oldX,qreal oldY,qreal newX,qreal newY); |
|
50 | void replace(qreal oldX,qreal oldY,qreal newX,qreal newY); | |
50 | void replace(const QPointF &oldPoint,const QPointF &newPoint); |
|
51 | void replace(const QPointF &oldPoint,const QPointF &newPoint); | |
51 | void remove(qreal x, qreal y); |
|
52 | void remove(qreal x, qreal y); | |
52 | void remove(const QPointF &point); |
|
53 | void remove(const QPointF &point); | |
53 | void insert(int index, const QPointF &point); |
|
54 | void insert(int index, const QPointF &point); | |
54 | void clear(); |
|
55 | void clear(); | |
55 |
|
56 | |||
56 | int count() const; |
|
57 | int count() const; | |
57 | QList<QPointF> points() const; |
|
58 | QList<QPointF> points() const; | |
58 |
|
59 | |||
59 | QXYSeries& operator << (const QPointF &point); |
|
60 | QXYSeries& operator << (const QPointF &point); | |
60 | QXYSeries& operator << (const QList<QPointF> &points); |
|
61 | QXYSeries& operator << (const QList<QPointF> &points); | |
61 |
|
62 | |||
62 | void setPen(const QPen &pen); |
|
63 | void setPen(const QPen &pen); | |
63 | QPen pen() const; |
|
64 | QPen pen() const; | |
64 |
|
65 | |||
65 | void setBrush(const QBrush &brush); |
|
66 | void setBrush(const QBrush &brush); | |
66 | QBrush brush() const; |
|
67 | QBrush brush() const; | |
67 |
|
68 | |||
|
69 | virtual void setColor(const QColor &color); | |||
|
70 | virtual QColor color() const; | |||
|
71 | ||||
68 | void setPointsVisible(bool visible = true); |
|
72 | void setPointsVisible(bool visible = true); | |
69 | bool pointsVisible() const; |
|
73 | bool pointsVisible() const; | |
70 |
|
74 | |||
71 | Q_SIGNALS: |
|
75 | Q_SIGNALS: | |
72 | void clicked(const QPointF &point); |
|
76 | void clicked(const QPointF &point); | |
73 | void pointReplaced(int index); |
|
77 | void pointReplaced(int index); | |
74 | void pointRemoved(int index); |
|
78 | void pointRemoved(int index); | |
75 | void pointAdded(int index); |
|
79 | void pointAdded(int index); | |
76 |
void |
|
80 | void colorChanged(QColor color); | |
77 |
|
||||
78 |
|
81 | |||
79 | private: |
|
82 | private: | |
80 | Q_DECLARE_PRIVATE(QXYSeries) |
|
83 | Q_DECLARE_PRIVATE(QXYSeries) | |
81 | Q_DISABLE_COPY(QXYSeries) |
|
84 | Q_DISABLE_COPY(QXYSeries) | |
82 | friend class XYLegendMarker; |
|
85 | friend class XYLegendMarker; | |
83 | friend class XYChart; |
|
86 | friend class XYChart; | |
84 | }; |
|
87 | }; | |
85 |
|
88 | |||
86 | QTCOMMERCIALCHART_END_NAMESPACE |
|
89 | QTCOMMERCIALCHART_END_NAMESPACE | |
87 |
|
90 | |||
88 | #endif |
|
91 | #endif |
@@ -1,73 +1,77 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | Flow { |
|
25 | Flow { | |
26 | id: flow |
|
26 | id: flow | |
27 | spacing: 5 |
|
27 | spacing: 5 | |
28 | flow: Flow.TopToBottom |
|
28 | flow: Flow.TopToBottom | |
29 | property variant series |
|
29 | property variant series | |
30 |
|
30 | |||
31 | onSeriesChanged: { |
|
31 | onSeriesChanged: { | |
|
32 | if (series && series.name == "area 1") { | |||
32 | seriesConnections.target = series; |
|
33 | seriesConnections.target = series; | |
|
34 | } else { | |||
|
35 | seriesConnections.target = null; | |||
|
36 | } | |||
33 | } |
|
37 | } | |
34 |
|
38 | |||
35 | Connections { |
|
39 | Connections { | |
36 | id: seriesConnections |
|
40 | id: seriesConnections | |
37 | ignoreUnknownSignals: true |
|
41 | target: null | |
38 | onNameChanged: console.log("series.onNameChanged: " + series.name); |
|
42 | onNameChanged: console.log("series.onNameChanged: " + series.name); | |
39 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); |
|
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
40 | onColorChanged: console.log("series.onColorChanged: " + series.color); |
|
44 | onColorChanged: console.log("series.onColorChanged: " + series.color); | |
41 | onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); |
|
45 | onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); | |
42 | onCountChanged: console.log("series.onCountChanged: " + series.count); |
|
46 | onCountChanged: console.log("series.onCountChanged: " + series.count); | |
43 | } |
|
47 | } | |
44 |
|
48 | |||
45 | Button { |
|
49 | Button { | |
46 | text: "visible" |
|
50 | text: "visible" | |
47 | onClicked: series.visible = !series.visible; |
|
51 | onClicked: series.visible = !series.visible; | |
48 | } |
|
52 | } | |
49 | Button { |
|
53 | Button { | |
50 | text: "color" |
|
54 | text: "color" | |
51 | onClicked: series.color = main.nextColor(); |
|
55 | onClicked: series.color = main.nextColor(); | |
52 | } |
|
56 | } | |
53 | Button { |
|
57 | Button { | |
54 | text: "borderColor" |
|
58 | text: "borderColor" | |
55 | onClicked: series.borderColor = main.nextColor(); |
|
59 | onClicked: series.borderColor = main.nextColor(); | |
56 | } |
|
60 | } | |
57 | Button { |
|
61 | Button { | |
58 | text: "upper color" |
|
62 | text: "upper color" | |
59 | onClicked: series.upperSeries.color = main.nextColor(); |
|
63 | onClicked: series.upperSeries.color = main.nextColor(); | |
60 | } |
|
64 | } | |
61 | Button { |
|
65 | Button { | |
62 | text: "lower color" |
|
66 | text: "lower color" | |
63 | onClicked: series.lowerSeries.color = main.nextColor(); |
|
67 | onClicked: series.lowerSeries.color = main.nextColor(); | |
64 | } |
|
68 | } | |
65 | Button { |
|
69 | Button { | |
66 | text: "upper points visible" |
|
70 | text: "upper points visible" | |
67 | onClicked: series.upperSeries.pointsVisible = !series.pointsVisible; |
|
71 | onClicked: series.upperSeries.pointsVisible = !series.pointsVisible; | |
68 | } |
|
72 | } | |
69 | Button { |
|
73 | Button { | |
70 | text: "lower points visible" |
|
74 | text: "lower points visible" | |
71 | onClicked: series.lowerSeries.pointsVisible = !series.pointsVisible; |
|
75 | onClicked: series.lowerSeries.pointsVisible = !series.pointsVisible; | |
72 | } |
|
76 | } | |
73 | } |
|
77 | } |
@@ -1,39 +1,40 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | ChartView { |
|
24 | ChartView { | |
25 | title: "Bar series" |
|
25 | title: "Bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend.alignment: Qt.AlignBottom |
|
28 | legend.alignment: Qt.AlignBottom | |
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 |
|
30 | |||
31 | property variant series: daSeries |
|
31 | property variant series: daSeries | |
32 |
|
32 | |||
33 | BarSeries { |
|
33 | BarSeries { | |
34 | id: daSeries |
|
34 | id: daSeries | |
|
35 | name: "bar" | |||
35 | BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6] } |
|
36 | BarSet { label: "Bob"; values: [4, 7, 3, 10, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 8] } |
|
37 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 8] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 5, 4, 7] } |
|
38 | BarSet { label: "James"; values: [3, 5, 8, 5, 4, 7] } | |
38 | } |
|
39 | } | |
39 | } |
|
40 | } |
@@ -1,90 +1,95 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | Flow { |
|
24 | Flow { | |
25 | id: flow |
|
25 | id: flow | |
26 | spacing: 5 |
|
26 | spacing: 5 | |
27 | flow: Flow.TopToBottom |
|
27 | flow: Flow.TopToBottom | |
28 | property variant series |
|
28 | property variant series | |
29 |
|
29 | |||
30 | onSeriesChanged: { |
|
30 | onSeriesChanged: { | |
|
31 | if (series && series.name == "bar") { | |||
31 | seriesConnections.target = series; |
|
32 | seriesConnections.target = series; | |
32 | setConnections.target = series.at(0); |
|
33 | setConnections.target = series.at(0); | |
|
34 | } else { | |||
|
35 | seriesConnections.target = null; | |||
|
36 | setConnections.target = null; | |||
|
37 | } | |||
33 | } |
|
38 | } | |
34 |
|
39 | |||
35 | Connections { |
|
40 | Connections { | |
36 | id: seriesConnections |
|
41 | id: seriesConnections | |
37 | ignoreUnknownSignals: true |
|
42 | target: null | |
38 | onNameChanged: console.log("series.onNameChanged: " + series.name); |
|
43 | onNameChanged: console.log("series.onNameChanged: " + series.name); | |
39 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); |
|
44 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
40 | onBarWidthChanged: console.log("series.onBardWidthChanged: " + width) |
|
45 | onBarWidthChanged: console.log("series.onBardWidthChanged: " + width) | |
41 | onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible); |
|
46 | onLabelsVisibleChanged: console.log("series.onLabelsVisibleChanged: " + series.labelsVisible); | |
42 | onCountChanged: console.log("series.onCountChanged: " + count); |
|
47 | onCountChanged: console.log("series.onCountChanged: " + count); | |
43 | } |
|
48 | } | |
44 |
|
49 | |||
45 | Connections { |
|
50 | Connections { | |
46 | id: setConnections |
|
51 | id: setConnections | |
47 | ignoreUnknownSignals: true |
|
52 | target: null | |
48 | onColorChanged: console.log("series.onColorChanged: " + color); |
|
53 | onColorChanged: console.log("series.onColorChanged: " + color); | |
49 | onBorderColorChanged: console.log("series.onBorderColorChanged: " + color); |
|
54 | onBorderColorChanged: console.log("series.onBorderColorChanged: " + color); | |
50 | onLabelColorChanged: console.log("series.onLabelColorChanged: " + color); |
|
55 | onLabelColorChanged: console.log("series.onLabelColorChanged: " + color); | |
51 | onCountChanged: console.log("series.onCountChanged: " + count); |
|
56 | onCountChanged: console.log("series.onCountChanged: " + count); | |
52 | } |
|
57 | } | |
53 |
|
58 | |||
54 | Button { |
|
59 | Button { | |
55 | text: "visible" |
|
60 | text: "visible" | |
56 | onClicked: series.visible = !series.visible; |
|
61 | onClicked: series.visible = !series.visible; | |
57 | } |
|
62 | } | |
58 | Button { |
|
63 | Button { | |
59 | text: "labels visible" |
|
64 | text: "labels visible" | |
60 | onClicked: series.labelsVisible = !series.labelsVisible; |
|
65 | onClicked: series.labelsVisible = !series.labelsVisible; | |
61 | } |
|
66 | } | |
62 | Button { |
|
67 | Button { | |
63 | text: "bar width +" |
|
68 | text: "bar width +" | |
64 | onClicked: series.barWidth += 0.1; |
|
69 | onClicked: series.barWidth += 0.1; | |
65 | } |
|
70 | } | |
66 | Button { |
|
71 | Button { | |
67 | text: "bar width -" |
|
72 | text: "bar width -" | |
68 | onClicked: series.barWidth -= 0.1; |
|
73 | onClicked: series.barWidth -= 0.1; | |
69 | } |
|
74 | } | |
70 | Button { |
|
75 | Button { | |
71 | text: "set 1 color" |
|
76 | text: "set 1 color" | |
72 | onClicked: series.at(0).color = main.nextColor(); |
|
77 | onClicked: series.at(0).color = main.nextColor(); | |
73 | } |
|
78 | } | |
74 | Button { |
|
79 | Button { | |
75 | text: "set 1 border color" |
|
80 | text: "set 1 border color" | |
76 | onClicked: series.at(0).borderColor = main.nextColor(); |
|
81 | onClicked: series.at(0).borderColor = main.nextColor(); | |
77 | } |
|
82 | } | |
78 | Button { |
|
83 | Button { | |
79 | text: "set 1 label color" |
|
84 | text: "set 1 label color" | |
80 | onClicked: series.at(0).labelColor = main.nextColor(); |
|
85 | onClicked: series.at(0).labelColor = main.nextColor(); | |
81 | } |
|
86 | } | |
82 | Button { |
|
87 | Button { | |
83 | text: "set 1 font size +" |
|
88 | text: "set 1 font size +" | |
84 | onClicked: series.at(0).labelFont.pixelSize += 1; |
|
89 | onClicked: series.at(0).labelFont.pixelSize += 1; | |
85 | } |
|
90 | } | |
86 | Button { |
|
91 | Button { | |
87 | text: "set 1 font size -" |
|
92 | text: "set 1 font size -" | |
88 | onClicked: series.at(0).labelFont.pixelSize -= 1; |
|
93 | onClicked: series.at(0).labelFont.pixelSize -= 1; | |
89 | } |
|
94 | } | |
90 | } |
|
95 | } |
@@ -1,319 +1,316 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | Flow { |
|
25 | Flow { | |
26 | id: flow |
|
26 | id: flow | |
27 | spacing: 5 |
|
27 | spacing: 5 | |
28 | flow: Flow.TopToBottom |
|
28 | flow: Flow.TopToBottom | |
29 | property variant series // TODO: rename to chart |
|
29 | property variant series // TODO: rename to chart | |
30 |
|
30 | |||
31 | onSeriesChanged: { |
|
31 | onSeriesChanged: { | |
|
32 | if (series && series.name == "") { | |||
|
33 | chartConnections.target = series; | |||
32 | legendConnections.target = series.legend; |
|
34 | legendConnections.target = series.legend; | |
33 | axisXConnections.target = series.axisX; |
|
35 | axisXConnections.target = series.axisX; | |
34 | axisYConnections.target = series.axisY; |
|
36 | axisYConnections.target = series.axisY; | |
|
37 | } else { | |||
|
38 | legendConnections.target = null; | |||
|
39 | axisXConnections.target = null; | |||
|
40 | axisYConnections.target = null; | |||
|
41 | } | |||
35 | } |
|
42 | } | |
36 |
|
43 | |||
37 | Connections { |
|
44 | Connections { | |
38 | target: series |
|
45 | id: chartConnections | |
39 | ignoreUnknownSignals: true |
|
46 | target: null | |
40 | onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible); |
|
47 | onVisibleChanged: console.log("chart.onVisibleChanged: " + series.visible); | |
41 | onThemeChanged: console.log("chart.onThemeChanged: " + series.theme); |
|
|||
42 | onLegendChanged: console.log("chart.onLegendChanged: " + series.legend); |
|
|||
43 | onAnimationOptionsChanged: console.log("chart.onAnimationOptionsChanged: " + series.animationOptions); |
|
|||
44 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor); |
|
48 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + series.titleColor); | |
45 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); |
|
49 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); | |
46 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); |
|
50 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); | |
47 | } |
|
51 | } | |
48 |
|
52 | |||
49 | Connections { |
|
53 | Connections { | |
50 | id: legendConnections |
|
54 | id: legendConnections | |
51 | ignoreUnknownSignals: true |
|
55 | target: null | |
52 | onAlignmentChanged: console.log("legend.onAlignmentChanged: " + alignment); |
|
|||
53 | onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); |
|
56 | onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); | |
54 | onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); |
|
57 | onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); | |
55 | onColorChanged: console.log("legend.onColorChanged: " + color); |
|
58 | onColorChanged: console.log("legend.onColorChanged: " + color); | |
56 | onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); |
|
59 | onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); | |
57 | } |
|
60 | } | |
58 |
|
61 | |||
59 | Connections { |
|
62 | Connections { | |
60 | id: axisXConnections |
|
63 | id: axisXConnections | |
61 | ignoreUnknownSignals: true |
|
64 | target: null | |
62 | onColorChanged: console.log("axisX.onColorChanged: " + color); |
|
65 | onColorChanged: console.log("axisX.onColorChanged: " + color); | |
63 | onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); |
|
66 | onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); | |
64 | onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); |
|
67 | onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); | |
65 | onLabelsAngleChanged: console.log("axisX.onLabelsAngleChanged: " + angle); |
|
|||
66 | onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); |
|
68 | onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); | |
67 | onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); |
|
69 | onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); | |
68 | onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); |
|
70 | onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); | |
69 | onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); |
|
71 | onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); | |
70 | onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); |
|
72 | onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); | |
71 | onMinChanged: console.log("axisX.onMinChanged: " + min); |
|
73 | onMinChanged: console.log("axisX.onMinChanged: " + min); | |
72 | onMaxChanged: console.log("axisX.onMaxChanged: " + max); |
|
74 | onMaxChanged: console.log("axisX.onMaxChanged: " + max); | |
73 | onTicksCountChanged: console.log("axisX.onTicksCountChanged: " + count); |
|
|||
74 | onNiceNumbersEnabledChanged: console.log("axisX.onNiceNumbersEnabledChanged: " + enabled); |
|
|||
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | Connections { |
|
77 | Connections { | |
78 | id: axisYConnections |
|
78 | id: axisYConnections | |
79 | ignoreUnknownSignals: true |
|
79 | target: null | |
80 | onColorChanged: console.log("axisY.onColorChanged: " + color); |
|
80 | onColorChanged: console.log("axisY.onColorChanged: " + color); | |
81 | onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); |
|
81 | onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); | |
82 | onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); |
|
82 | onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); | |
83 | onLabelsAngleChanged: console.log("axisY.onLabelsAngleChanged: " + angle); |
|
|||
84 | onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); |
|
83 | onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); | |
85 | onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); |
|
84 | onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); | |
86 | onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); |
|
85 | onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); | |
87 | onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); |
|
86 | onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); | |
88 | onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); |
|
87 | onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); | |
89 | onMinChanged: console.log("axisY.onMinChanged: " + min); |
|
88 | onMinChanged: console.log("axisY.onMinChanged: " + min); | |
90 | onMaxChanged: console.log("axisY.onMaxChanged: " + max); |
|
89 | onMaxChanged: console.log("axisY.onMaxChanged: " + max); | |
91 | onTicksCountChanged: console.log("axisY.onTicksCountChanged: " + count); |
|
|||
92 | onNiceNumbersEnabledChanged: console.log("axisY.onNiceNumbersEnabledChanged: " + enabled); |
|
|||
93 | } |
|
90 | } | |
94 |
|
91 | |||
95 | Button { |
|
92 | Button { | |
96 | text: "visible" |
|
93 | text: "visible" | |
97 | onClicked: series.visible = !series.visible; |
|
94 | onClicked: series.visible = !series.visible; | |
98 | } |
|
95 | } | |
99 | Button { |
|
96 | Button { | |
100 | text: "theme +" |
|
97 | text: "theme +" | |
101 | onClicked: series.theme++; |
|
98 | onClicked: series.theme++; | |
102 | } |
|
99 | } | |
103 | Button { |
|
100 | Button { | |
104 | text: "theme -" |
|
101 | text: "theme -" | |
105 | onClicked: series.theme--; |
|
102 | onClicked: series.theme--; | |
106 | } |
|
103 | } | |
107 | Button { |
|
104 | Button { | |
108 | text: "animation opt +" |
|
105 | text: "animation opt +" | |
109 | onClicked: series.animationOptions++; |
|
106 | onClicked: series.animationOptions++; | |
110 | } |
|
107 | } | |
111 | Button { |
|
108 | Button { | |
112 | text: "animation opt -" |
|
109 | text: "animation opt -" | |
113 | onClicked: series.animationOptions--; |
|
110 | onClicked: series.animationOptions--; | |
114 | } |
|
111 | } | |
115 | Button { |
|
112 | Button { | |
116 | text: "title color" |
|
113 | text: "title color" | |
117 | onClicked: series.titleColor = main.nextColor(); |
|
114 | onClicked: series.titleColor = main.nextColor(); | |
118 | } |
|
115 | } | |
119 | Button { |
|
116 | Button { | |
120 | text: "background color" |
|
117 | text: "background color" | |
121 | onClicked: series.backgroundColor = main.nextColor(); |
|
118 | onClicked: series.backgroundColor = main.nextColor(); | |
122 | } |
|
119 | } | |
123 | Button { |
|
120 | Button { | |
124 | text: "drop shadow enabled" |
|
121 | text: "drop shadow enabled" | |
125 | onClicked: series.dropShadowEnabled = !series.dropShadowEnabled; |
|
122 | onClicked: series.dropShadowEnabled = !series.dropShadowEnabled; | |
126 | } |
|
123 | } | |
127 | Button { |
|
124 | Button { | |
128 | text: "zoom +" |
|
125 | text: "zoom +" | |
129 | onClicked: series.zoom(2); |
|
126 | onClicked: series.zoom(2); | |
130 | } |
|
127 | } | |
131 | Button { |
|
128 | Button { | |
132 | text: "zoom -" |
|
129 | text: "zoom -" | |
133 | onClicked: series.zoom(0.5); |
|
130 | onClicked: series.zoom(0.5); | |
134 | } |
|
131 | } | |
135 | Button { |
|
132 | Button { | |
136 | text: "scroll left" |
|
133 | text: "scroll left" | |
137 | onClicked: series.scrollLeft(10); |
|
134 | onClicked: series.scrollLeft(10); | |
138 | } |
|
135 | } | |
139 | Button { |
|
136 | Button { | |
140 | text: "scroll right" |
|
137 | text: "scroll right" | |
141 | onClicked: series.scrollRight(10); |
|
138 | onClicked: series.scrollRight(10); | |
142 | } |
|
139 | } | |
143 | Button { |
|
140 | Button { | |
144 | text: "scroll up" |
|
141 | text: "scroll up" | |
145 | onClicked: series.scrollUp(10); |
|
142 | onClicked: series.scrollUp(10); | |
146 | } |
|
143 | } | |
147 | Button { |
|
144 | Button { | |
148 | text: "scroll down" |
|
145 | text: "scroll down" | |
149 | onClicked: series.scrollDown(10); |
|
146 | onClicked: series.scrollDown(10); | |
150 | } |
|
147 | } | |
151 | Button { |
|
148 | Button { | |
152 | text: "legend visible" |
|
149 | text: "legend visible" | |
153 | onClicked: series.legend.visible = !series.legend.visible; |
|
150 | onClicked: series.legend.visible = !series.legend.visible; | |
154 | } |
|
151 | } | |
155 | Button { |
|
152 | Button { | |
156 | text: "legend bckgrd visible" |
|
153 | text: "legend bckgrd visible" | |
157 | onClicked: series.legend.backgroundVisible = !series.legend.backgroundVisible; |
|
154 | onClicked: series.legend.backgroundVisible = !series.legend.backgroundVisible; | |
158 | } |
|
155 | } | |
159 | Button { |
|
156 | Button { | |
160 | text: "legend color" |
|
157 | text: "legend color" | |
161 | onClicked: series.legend.color = main.nextColor(); |
|
158 | onClicked: series.legend.color = main.nextColor(); | |
162 | } |
|
159 | } | |
163 | Button { |
|
160 | Button { | |
164 | text: "legend border color" |
|
161 | text: "legend border color" | |
165 | onClicked: series.legend.borderColor = main.nextColor(); |
|
162 | onClicked: series.legend.borderColor = main.nextColor(); | |
166 | } |
|
163 | } | |
167 | Button { |
|
164 | Button { | |
168 | text: "legend top" |
|
165 | text: "legend top" | |
169 | onClicked: series.legend.alignment ^= Qt.AlignTop; |
|
166 | onClicked: series.legend.alignment ^= Qt.AlignTop; | |
170 | } |
|
167 | } | |
171 | Button { |
|
168 | Button { | |
172 | text: "legend bottom" |
|
169 | text: "legend bottom" | |
173 | onClicked: series.legend.alignment ^= Qt.AlignBottom; |
|
170 | onClicked: series.legend.alignment ^= Qt.AlignBottom; | |
174 | } |
|
171 | } | |
175 | Button { |
|
172 | Button { | |
176 | text: "legend left" |
|
173 | text: "legend left" | |
177 | onClicked: series.legend.alignment ^= Qt.AlignLeft; |
|
174 | onClicked: series.legend.alignment ^= Qt.AlignLeft; | |
178 | } |
|
175 | } | |
179 | Button { |
|
176 | Button { | |
180 | text: "legend right" |
|
177 | text: "legend right" | |
181 | onClicked: series.legend.alignment ^= Qt.AlignRight; |
|
178 | onClicked: series.legend.alignment ^= Qt.AlignRight; | |
182 | } |
|
179 | } | |
183 | Button { |
|
180 | Button { | |
184 | text: "axis X visible" |
|
181 | text: "axis X visible" | |
185 | onClicked: series.axisX.visible = !series.axisX.visible; |
|
182 | onClicked: series.axisX.visible = !series.axisX.visible; | |
186 | } |
|
183 | } | |
187 | Button { |
|
184 | Button { | |
188 | text: "axis X grid visible" |
|
185 | text: "axis X grid visible" | |
189 | onClicked: series.axisX.gridVisible = !series.axisX.gridVisible; |
|
186 | onClicked: series.axisX.gridVisible = !series.axisX.gridVisible; | |
190 | } |
|
187 | } | |
191 | Button { |
|
188 | Button { | |
192 | text: "axis X labels visible" |
|
189 | text: "axis X labels visible" | |
193 | onClicked: series.axisX.labelsVisible = !series.axisX.labelsVisible; |
|
190 | onClicked: series.axisX.labelsVisible = !series.axisX.labelsVisible; | |
194 | } |
|
191 | } | |
195 | Button { |
|
192 | Button { | |
196 | text: "axis X color" |
|
193 | text: "axis X color" | |
197 | onClicked: series.axisX.color = main.nextColor(); |
|
194 | onClicked: series.axisX.color = main.nextColor(); | |
198 | } |
|
195 | } | |
199 | Button { |
|
196 | Button { | |
200 | text: "axis X labels color" |
|
197 | text: "axis X labels color" | |
201 | onClicked: series.axisX.labelsColor = main.nextColor(); |
|
198 | onClicked: series.axisX.labelsColor = main.nextColor(); | |
202 | } |
|
199 | } | |
203 | Button { |
|
200 | Button { | |
204 | text: "axis X labels angle +" |
|
201 | text: "axis X labels angle +" | |
205 | onClicked: series.axisX.labelsAngle += 5; |
|
202 | onClicked: series.axisX.labelsAngle += 5; | |
206 | } |
|
203 | } | |
207 | Button { |
|
204 | Button { | |
208 | text: "axis X labels angle -" |
|
205 | text: "axis X labels angle -" | |
209 | onClicked: series.axisX.labelsAngle -= 5; |
|
206 | onClicked: series.axisX.labelsAngle -= 5; | |
210 | } |
|
207 | } | |
211 | Button { |
|
208 | Button { | |
212 | text: "axis X shades visible" |
|
209 | text: "axis X shades visible" | |
213 | onClicked: series.axisX.shadesVisible = !series.axisX.shadesVisible; |
|
210 | onClicked: series.axisX.shadesVisible = !series.axisX.shadesVisible; | |
214 | } |
|
211 | } | |
215 | Button { |
|
212 | Button { | |
216 | text: "axis X shades color" |
|
213 | text: "axis X shades color" | |
217 | onClicked: series.axisX.shadesColor = main.nextColor(); |
|
214 | onClicked: series.axisX.shadesColor = main.nextColor(); | |
218 | } |
|
215 | } | |
219 | Button { |
|
216 | Button { | |
220 | text: "axis X shades bcolor" |
|
217 | text: "axis X shades bcolor" | |
221 | onClicked: series.axisX.shadesBorderColor = main.nextColor(); |
|
218 | onClicked: series.axisX.shadesBorderColor = main.nextColor(); | |
222 | } |
|
219 | } | |
223 | Button { |
|
220 | Button { | |
224 | text: "axis X max +" |
|
221 | text: "axis X max +" | |
225 | onClicked: series.axisX.max += 0.1; |
|
222 | onClicked: series.axisX.max += 0.1; | |
226 | } |
|
223 | } | |
227 | Button { |
|
224 | Button { | |
228 | text: "axis X max -" |
|
225 | text: "axis X max -" | |
229 | onClicked: series.axisX.max -= 0.1; |
|
226 | onClicked: series.axisX.max -= 0.1; | |
230 | } |
|
227 | } | |
231 | Button { |
|
228 | Button { | |
232 | text: "axis X min +" |
|
229 | text: "axis X min +" | |
233 | onClicked: series.axisX.min += 0.1; |
|
230 | onClicked: series.axisX.min += 0.1; | |
234 | } |
|
231 | } | |
235 | Button { |
|
232 | Button { | |
236 | text: "axis X min -" |
|
233 | text: "axis X min -" | |
237 | onClicked: series.axisX.min -= 0.1; |
|
234 | onClicked: series.axisX.min -= 0.1; | |
238 | } |
|
235 | } | |
239 | Button { |
|
236 | Button { | |
240 | text: "axis X ticks count +" |
|
237 | text: "axis X ticks count +" | |
241 | onClicked: series.axisX.ticksCount++; |
|
238 | onClicked: series.axisX.ticksCount++; | |
242 | } |
|
239 | } | |
243 | Button { |
|
240 | Button { | |
244 | text: "axis X ticks count -" |
|
241 | text: "axis X ticks count -" | |
245 | onClicked: series.axisX.ticksCount--; |
|
242 | onClicked: series.axisX.ticksCount--; | |
246 | } |
|
243 | } | |
247 | Button { |
|
244 | Button { | |
248 | text: "axis X nice nmb" |
|
245 | text: "axis X nice nmb" | |
249 | onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled; |
|
246 | onClicked: series.axisX.niceNumbersEnabled = !series.axisX.niceNumbersEnabled; | |
250 | } |
|
247 | } | |
251 | Button { |
|
248 | Button { | |
252 | text: "axis Y visible" |
|
249 | text: "axis Y visible" | |
253 | onClicked: series.axisY.visible = !series.axisY.visible; |
|
250 | onClicked: series.axisY.visible = !series.axisY.visible; | |
254 | } |
|
251 | } | |
255 | Button { |
|
252 | Button { | |
256 | text: "axis Y grid visible" |
|
253 | text: "axis Y grid visible" | |
257 | onClicked: series.axisY.gridVisible = !series.axisY.gridVisible; |
|
254 | onClicked: series.axisY.gridVisible = !series.axisY.gridVisible; | |
258 | } |
|
255 | } | |
259 | Button { |
|
256 | Button { | |
260 | text: "axis Y labels visible" |
|
257 | text: "axis Y labels visible" | |
261 | onClicked: series.axisY.labelsVisible = !series.axisY.labelsVisible; |
|
258 | onClicked: series.axisY.labelsVisible = !series.axisY.labelsVisible; | |
262 | } |
|
259 | } | |
263 | Button { |
|
260 | Button { | |
264 | text: "axis Y color" |
|
261 | text: "axis Y color" | |
265 | onClicked: series.axisY.color = main.nextColor(); |
|
262 | onClicked: series.axisY.color = main.nextColor(); | |
266 | } |
|
263 | } | |
267 | Button { |
|
264 | Button { | |
268 | text: "axis Y labels color" |
|
265 | text: "axis Y labels color" | |
269 | onClicked: series.axisY.labelsColor = main.nextColor(); |
|
266 | onClicked: series.axisY.labelsColor = main.nextColor(); | |
270 | } |
|
267 | } | |
271 | Button { |
|
268 | Button { | |
272 | text: "axis Y labels angle +" |
|
269 | text: "axis Y labels angle +" | |
273 | onClicked: series.axisY.labelsAngle += 5; |
|
270 | onClicked: series.axisY.labelsAngle += 5; | |
274 | } |
|
271 | } | |
275 | Button { |
|
272 | Button { | |
276 | text: "axis Y labels angle -" |
|
273 | text: "axis Y labels angle -" | |
277 | onClicked: series.axisY.labelsAngle -= 5; |
|
274 | onClicked: series.axisY.labelsAngle -= 5; | |
278 | } |
|
275 | } | |
279 | Button { |
|
276 | Button { | |
280 | text: "axis Y shades visible" |
|
277 | text: "axis Y shades visible" | |
281 | onClicked: series.axisY.shadesVisible = !series.axisY.shadesVisible; |
|
278 | onClicked: series.axisY.shadesVisible = !series.axisY.shadesVisible; | |
282 | } |
|
279 | } | |
283 | Button { |
|
280 | Button { | |
284 | text: "axis Y shades color" |
|
281 | text: "axis Y shades color" | |
285 | onClicked: series.axisY.shadesColor = main.nextColor(); |
|
282 | onClicked: series.axisY.shadesColor = main.nextColor(); | |
286 | } |
|
283 | } | |
287 | Button { |
|
284 | Button { | |
288 | text: "axis Y shades bcolor" |
|
285 | text: "axis Y shades bcolor" | |
289 | onClicked: series.axisY.shadesBorderColor = main.nextColor(); |
|
286 | onClicked: series.axisY.shadesBorderColor = main.nextColor(); | |
290 | } |
|
287 | } | |
291 | Button { |
|
288 | Button { | |
292 | text: "axis Y max +" |
|
289 | text: "axis Y max +" | |
293 | onClicked: series.axisY.max += 0.1; |
|
290 | onClicked: series.axisY.max += 0.1; | |
294 | } |
|
291 | } | |
295 | Button { |
|
292 | Button { | |
296 | text: "axis Y max -" |
|
293 | text: "axis Y max -" | |
297 | onClicked: series.axisY.max -= 0.1; |
|
294 | onClicked: series.axisY.max -= 0.1; | |
298 | } |
|
295 | } | |
299 | Button { |
|
296 | Button { | |
300 | text: "axis Y min +" |
|
297 | text: "axis Y min +" | |
301 | onClicked: series.axisY.min += 0.1; |
|
298 | onClicked: series.axisY.min += 0.1; | |
302 | } |
|
299 | } | |
303 | Button { |
|
300 | Button { | |
304 | text: "axis Y min -" |
|
301 | text: "axis Y min -" | |
305 | onClicked: series.axisY.min -= 0.1; |
|
302 | onClicked: series.axisY.min -= 0.1; | |
306 | } |
|
303 | } | |
307 | Button { |
|
304 | Button { | |
308 | text: "axis Y ticks count +" |
|
305 | text: "axis Y ticks count +" | |
309 | onClicked: series.axisY.ticksCount++; |
|
306 | onClicked: series.axisY.ticksCount++; | |
310 | } |
|
307 | } | |
311 | Button { |
|
308 | Button { | |
312 | text: "axis Y ticks count -" |
|
309 | text: "axis Y ticks count -" | |
313 | onClicked: series.axisY.ticksCount--; |
|
310 | onClicked: series.axisY.ticksCount--; | |
314 | } |
|
311 | } | |
315 | Button { |
|
312 | Button { | |
316 | text: "axis Y nice nmb" |
|
313 | text: "axis Y nice nmb" | |
317 | onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled; |
|
314 | onClicked: series.axisY.niceNumbersEnabled = !series.axisY.niceNumbersEnabled; | |
318 | } |
|
315 | } | |
319 | } |
|
316 | } |
@@ -1,39 +1,40 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | ChartView { |
|
24 | ChartView { | |
25 | title: "Grouped bar series" |
|
25 | title: "Grouped bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend.alignment: Qt.AlignBottom |
|
28 | legend.alignment: Qt.AlignBottom | |
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 |
|
30 | |||
31 | property variant series: daSeries |
|
31 | property variant series: daSeries | |
32 |
|
32 | |||
33 | GroupedBarSeries { |
|
33 | GroupedBarSeries { | |
34 | id: daSeries |
|
34 | id: daSeries | |
|
35 | name: "bar" | |||
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
37 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
38 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
39 | } | |
39 | } |
|
40 | } |
@@ -1,57 +1,60 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | Flow { |
|
25 | Flow { | |
26 | id: flow |
|
26 | id: flow | |
27 | spacing: 5 |
|
27 | spacing: 5 | |
28 | flow: Flow.TopToBottom |
|
28 | flow: Flow.TopToBottom | |
29 | property variant series |
|
29 | property variant series | |
30 |
|
30 | |||
31 | onSeriesChanged: { |
|
31 | onSeriesChanged: { | |
|
32 | if (series && (series.name == "line 1" || series.name == "spline 1")) { | |||
32 | seriesConnections.target = series; |
|
33 | seriesConnections.target = series; | |
|
34 | } else { | |||
|
35 | seriesConnections.target = null; | |||
|
36 | } | |||
33 | } |
|
37 | } | |
34 |
|
38 | |||
35 | Connections { |
|
39 | Connections { | |
36 | id: seriesConnections |
|
40 | id: seriesConnections | |
37 | ignoreUnknownSignals: true |
|
41 | target: null | |
38 | onNameChanged: console.log("series.onNameChanged: " + series.name); |
|
42 | onNameChanged: console.log("series.onNameChanged: " + series.name); | |
39 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); |
|
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
40 | onPointsVisibleChanged: console.log("series.onPointsVisibleChanged: " + series.pointsVisible); |
|
|||
41 | onColorChanged: console.log("series.onColorChanged: " + series.color); |
|
44 | onColorChanged: console.log("series.onColorChanged: " + series.color); | |
42 | onCountChanged: console.log("series.onCountChanged: " + series.count); |
|
45 | onCountChanged: console.log("series.onCountChanged: " + series.count); | |
43 | } |
|
46 | } | |
44 |
|
47 | |||
45 | Button { |
|
48 | Button { | |
46 | text: "visible" |
|
49 | text: "visible" | |
47 | onClicked: series.visible = !series.visible; |
|
50 | onClicked: series.visible = !series.visible; | |
48 | } |
|
51 | } | |
49 | Button { |
|
52 | Button { | |
50 | text: "color" |
|
53 | text: "color" | |
51 | onClicked: series.color = main.nextColor(); |
|
54 | onClicked: series.color = main.nextColor(); | |
52 | } |
|
55 | } | |
53 | Button { |
|
56 | Button { | |
54 | text: "points visible" |
|
57 | text: "points visible" | |
55 | onClicked: series.pointsVisible = !series.pointsVisible |
|
58 | onClicked: series.pointsVisible = !series.pointsVisible | |
56 | } |
|
59 | } | |
57 | } |
|
60 | } |
@@ -1,39 +1,40 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | ChartView { |
|
24 | ChartView { | |
25 | title: "Percent bar series" |
|
25 | title: "Percent bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend.alignment: Qt.AlignBottom |
|
28 | legend.alignment: Qt.AlignBottom | |
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 |
|
30 | |||
31 | property variant series: daSeries |
|
31 | property variant series: daSeries | |
32 |
|
32 | |||
33 | PercentBarSeries { |
|
33 | PercentBarSeries { | |
34 | id: daSeries |
|
34 | id: daSeries | |
|
35 | name: "bar" | |||
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
37 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
38 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
39 | } | |
39 | } |
|
40 | } |
@@ -1,37 +1,38 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | ChartView { |
|
24 | ChartView { | |
25 | id: chart |
|
25 | id: chart | |
26 | title: "pie series" |
|
26 | title: "pie series" | |
27 | animationOptions: ChartView.SeriesAnimations |
|
27 | animationOptions: ChartView.SeriesAnimations | |
28 |
|
28 | |||
29 | property variant series: pieSeries |
|
29 | property variant series: pieSeries | |
30 |
|
30 | |||
31 | PieSeries { |
|
31 | PieSeries { | |
32 | id: pieSeries |
|
32 | id: pieSeries | |
|
33 | name: "pie" | |||
33 | PieSlice { id: daSlice; label: "slice1"; value: 11 } |
|
34 | PieSlice { id: daSlice; label: "slice1"; value: 11 } | |
34 | PieSlice { label: "slice2"; value: 22 } |
|
35 | PieSlice { label: "slice2"; value: 22 } | |
35 | PieSlice { label: "slice3"; value: 33 } |
|
36 | PieSlice { label: "slice3"; value: 33 } | |
36 | } |
|
37 | } | |
37 | } |
|
38 | } |
@@ -1,168 +1,173 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | Flow { |
|
24 | Flow { | |
25 | id: flow |
|
25 | id: flow | |
26 | spacing: 5 |
|
26 | spacing: 5 | |
27 | flow: Flow.TopToBottom |
|
27 | flow: Flow.TopToBottom | |
28 | property variant series |
|
28 | property variant series | |
29 |
|
29 | |||
30 | onSeriesChanged: { |
|
30 | onSeriesChanged: { | |
|
31 | if (series && series.name == "pie") { | |||
31 | seriesConnections.target = series; |
|
32 | seriesConnections.target = series; | |
32 | sliceConnections.target = series.at(0); |
|
33 | sliceConnections.target = series.at(0); | |
|
34 | } else { | |||
|
35 | seriesConnections.target = null; | |||
|
36 | sliceConnections.target = null; | |||
|
37 | } | |||
33 | } |
|
38 | } | |
34 |
|
39 | |||
35 | Connections { |
|
40 | Connections { | |
36 | id: seriesConnections |
|
41 | id: seriesConnections | |
37 | ignoreUnknownSignals: true |
|
42 | target: null | |
38 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); |
|
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
39 | onHorizontalPositionChanged:console.log("series.onHorizontalPositionChanged: " + series.horizontalPosition); |
|
44 | onHorizontalPositionChanged:console.log("series.onHorizontalPositionChanged: " + series.horizontalPosition); | |
40 | onVerticalPositionChanged: console.log("series.onVerticalPositionChanged: " + series.verticalPosition); |
|
45 | onVerticalPositionChanged: console.log("series.onVerticalPositionChanged: " + series.verticalPosition); | |
41 | onSizeChanged: console.log("series.onSizeChanged: " + series.size); |
|
46 | onSizeChanged: console.log("series.onSizeChanged: " + series.size); | |
42 | onStartAngleChanged: console.log("series.onStartAngleChanged: " + series.startAngle); |
|
47 | onStartAngleChanged: console.log("series.onStartAngleChanged: " + series.startAngle); | |
43 | onEndAngleChanged: console.log("series.onEndAngleChanged: " + series.endAngle); |
|
48 | onEndAngleChanged: console.log("series.onEndAngleChanged: " + series.endAngle); | |
44 | onCountChanged: console.log("series.onCountChanged: " + series.count); |
|
49 | onCountChanged: console.log("series.onCountChanged: " + series.count); | |
45 | onSumChanged: console.log("series.onSumChanged: " + series.sum); |
|
50 | onSumChanged: console.log("series.onSumChanged: " + series.sum); | |
46 | } |
|
51 | } | |
47 |
|
52 | |||
48 | Connections { |
|
53 | Connections { | |
49 | id: sliceConnections |
|
54 | id: sliceConnections | |
50 | ignoreUnknownSignals: true |
|
55 | target: null | |
51 | onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value); |
|
56 | onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value); | |
52 | onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible); |
|
57 | onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible); | |
53 | onLabelPositionChanged: console.log("slice.onLabelPositionChanged: " + series.at(0).labelPosition); |
|
58 | onLabelPositionChanged: console.log("slice.onLabelPositionChanged: " + series.at(0).labelPosition); | |
54 | onExplodedChanged: console.log("slice.onExplodedChanged: " + series.at(0).exploded); |
|
59 | onExplodedChanged: console.log("slice.onExplodedChanged: " + series.at(0).exploded); | |
55 | onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen); |
|
60 | onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen); | |
56 | onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor); |
|
61 | onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor); | |
57 | onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth); |
|
62 | onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth); | |
58 | onBrushChanged: console.log("slice.onBrushChanged: " + series.at(0).brush); |
|
63 | onBrushChanged: console.log("slice.onBrushChanged: " + series.at(0).brush); | |
59 | onColorChanged: console.log("slice.onColorChanged: " + series.at(0).color); |
|
64 | onColorChanged: console.log("slice.onColorChanged: " + series.at(0).color); | |
60 | onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor); |
|
65 | onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor); | |
61 | onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush); |
|
66 | onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush); | |
62 | onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont); |
|
67 | onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont); | |
63 | onLabelArmLengthFactorChanged: console.log("slice.onLabelArmLengthFactorChanged: " + series.at(0).labelArmLengthFactor); |
|
68 | onLabelArmLengthFactorChanged: console.log("slice.onLabelArmLengthFactorChanged: " + series.at(0).labelArmLengthFactor); | |
64 | onExplodeDistanceFactorChanged: console.log("slice.onExplodeDistanceFactorChanged: " + series.at(0).explodeDistanceFactor); |
|
69 | onExplodeDistanceFactorChanged: console.log("slice.onExplodeDistanceFactorChanged: " + series.at(0).explodeDistanceFactor); | |
65 | onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage); |
|
70 | onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage); | |
66 | onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle); |
|
71 | onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle); | |
67 | onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan); |
|
72 | onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan); | |
68 | onClicked: console.log("slice.onClicked"); |
|
73 | onClicked: console.log("slice.onClicked"); | |
69 | onHovered: console.log("slice.onHovered: " + state); |
|
74 | onHovered: console.log("slice.onHovered: " + state); | |
70 | } |
|
75 | } | |
71 |
|
76 | |||
72 | Button { |
|
77 | Button { | |
73 | text: "visible" |
|
78 | text: "visible" | |
74 | onClicked: series.visible = !series.visible; |
|
79 | onClicked: series.visible = !series.visible; | |
75 | } |
|
80 | } | |
76 | Button { |
|
81 | Button { | |
77 | text: "series hpos +" |
|
82 | text: "series hpos +" | |
78 | onClicked: series.horizontalPosition += 0.1; |
|
83 | onClicked: series.horizontalPosition += 0.1; | |
79 | } |
|
84 | } | |
80 | Button { |
|
85 | Button { | |
81 | text: "series hpos -" |
|
86 | text: "series hpos -" | |
82 | onClicked: series.horizontalPosition -= 0.1; |
|
87 | onClicked: series.horizontalPosition -= 0.1; | |
83 | } |
|
88 | } | |
84 | Button { |
|
89 | Button { | |
85 | text: "series vpos +" |
|
90 | text: "series vpos +" | |
86 | onClicked: series.verticalPosition += 0.1; |
|
91 | onClicked: series.verticalPosition += 0.1; | |
87 | } |
|
92 | } | |
88 | Button { |
|
93 | Button { | |
89 | text: "series vpos -" |
|
94 | text: "series vpos -" | |
90 | onClicked: series.verticalPosition -= 0.1; |
|
95 | onClicked: series.verticalPosition -= 0.1; | |
91 | } |
|
96 | } | |
92 | Button { |
|
97 | Button { | |
93 | text: "series size +" |
|
98 | text: "series size +" | |
94 | onClicked: series.size += 0.1; |
|
99 | onClicked: series.size += 0.1; | |
95 | } |
|
100 | } | |
96 | Button { |
|
101 | Button { | |
97 | text: "series size -" |
|
102 | text: "series size -" | |
98 | onClicked: series.size -= 0.1; |
|
103 | onClicked: series.size -= 0.1; | |
99 | } |
|
104 | } | |
100 | Button { |
|
105 | Button { | |
101 | text: "series start angle +" |
|
106 | text: "series start angle +" | |
102 | onClicked: series.startAngle += 1.1; |
|
107 | onClicked: series.startAngle += 1.1; | |
103 | } |
|
108 | } | |
104 | Button { |
|
109 | Button { | |
105 | text: "series start angle -" |
|
110 | text: "series start angle -" | |
106 | onClicked: series.startAngle -= 1.1; |
|
111 | onClicked: series.startAngle -= 1.1; | |
107 | } |
|
112 | } | |
108 | Button { |
|
113 | Button { | |
109 | text: "series end angle +" |
|
114 | text: "series end angle +" | |
110 | onClicked: series.endAngle += 1.1; |
|
115 | onClicked: series.endAngle += 1.1; | |
111 | } |
|
116 | } | |
112 | Button { |
|
117 | Button { | |
113 | text: "series end angle -" |
|
118 | text: "series end angle -" | |
114 | onClicked: series.endAngle -= 1.1; |
|
119 | onClicked: series.endAngle -= 1.1; | |
115 | } |
|
120 | } | |
116 | Button { |
|
121 | Button { | |
117 | text: "slice color" |
|
122 | text: "slice color" | |
118 | onClicked: series.at(0).color = main.nextColor(); |
|
123 | onClicked: series.at(0).color = main.nextColor(); | |
119 | } |
|
124 | } | |
120 | Button { |
|
125 | Button { | |
121 | text: "slice border color" |
|
126 | text: "slice border color" | |
122 | onClicked: series.at(0).borderColor = main.nextColor(); |
|
127 | onClicked: series.at(0).borderColor = main.nextColor(); | |
123 | } |
|
128 | } | |
124 | Button { |
|
129 | Button { | |
125 | text: "slice border width +" |
|
130 | text: "slice border width +" | |
126 | onClicked: series.at(0).borderWidth++; |
|
131 | onClicked: series.at(0).borderWidth++; | |
127 | } |
|
132 | } | |
128 | Button { |
|
133 | Button { | |
129 | text: "slice border width -" |
|
134 | text: "slice border width -" | |
130 | onClicked: series.at(0).borderWidth--; |
|
135 | onClicked: series.at(0).borderWidth--; | |
131 | } |
|
136 | } | |
132 | Button { |
|
137 | Button { | |
133 | text: "slice label visible" |
|
138 | text: "slice label visible" | |
134 | onClicked: series.at(0).labelVisible = !series.at(0).labelVisible; |
|
139 | onClicked: series.at(0).labelVisible = !series.at(0).labelVisible; | |
135 | } |
|
140 | } | |
136 | Button { |
|
141 | Button { | |
137 | text: "slice label position inside" |
|
142 | text: "slice label position inside" | |
138 | onClicked: series.at(0).labelPosition = PieSlice.LabelInside; |
|
143 | onClicked: series.at(0).labelPosition = PieSlice.LabelInside; | |
139 | } |
|
144 | } | |
140 | Button { |
|
145 | Button { | |
141 | text: "slice label position outside" |
|
146 | text: "slice label position outside" | |
142 | onClicked: series.at(0).labelPosition = PieSlice.LabelOutside; |
|
147 | onClicked: series.at(0).labelPosition = PieSlice.LabelOutside; | |
143 | } |
|
148 | } | |
144 | Button { |
|
149 | Button { | |
145 | text: "slice label arm len +" |
|
150 | text: "slice label arm len +" | |
146 | onClicked: series.at(0).labelArmLengthFactor += 0.1; |
|
151 | onClicked: series.at(0).labelArmLengthFactor += 0.1; | |
147 | } |
|
152 | } | |
148 | Button { |
|
153 | Button { | |
149 | text: "slice label arm len -" |
|
154 | text: "slice label arm len -" | |
150 | onClicked: series.at(0).labelArmLengthFactor -= 0.1; |
|
155 | onClicked: series.at(0).labelArmLengthFactor -= 0.1; | |
151 | } |
|
156 | } | |
152 | Button { |
|
157 | Button { | |
153 | text: "slice label color" |
|
158 | text: "slice label color" | |
154 | onClicked: series.at(0).labelColor = main.nextColor(); |
|
159 | onClicked: series.at(0).labelColor = main.nextColor(); | |
155 | } |
|
160 | } | |
156 | Button { |
|
161 | Button { | |
157 | text: "slice exploded" |
|
162 | text: "slice exploded" | |
158 | onClicked: series.at(0).exploded = !series.at(0).exploded; |
|
163 | onClicked: series.at(0).exploded = !series.at(0).exploded; | |
159 | } |
|
164 | } | |
160 | Button { |
|
165 | Button { | |
161 | text: "slice explode dist +" |
|
166 | text: "slice explode dist +" | |
162 | onClicked: series.at(0).explodeDistanceFactor += 0.1; |
|
167 | onClicked: series.at(0).explodeDistanceFactor += 0.1; | |
163 | } |
|
168 | } | |
164 | Button { |
|
169 | Button { | |
165 | text: "slice explode dist -" |
|
170 | text: "slice explode dist -" | |
166 | onClicked: series.at(0).explodeDistanceFactor -= 0.1; |
|
171 | onClicked: series.at(0).explodeDistanceFactor -= 0.1; | |
167 | } |
|
172 | } | |
168 | } |
|
173 | } |
@@ -1,72 +1,73 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | Flow { |
|
25 | Flow { | |
26 | id: flow |
|
26 | id: flow | |
27 | spacing: 5 |
|
27 | spacing: 5 | |
28 | flow: Flow.TopToBottom |
|
28 | flow: Flow.TopToBottom | |
29 | property variant series |
|
29 | property variant series | |
30 |
|
30 | |||
31 | onSeriesChanged: { |
|
31 | onSeriesChanged: { | |
|
32 | if (series && series.name == "scatter 1") { | |||
32 | seriesConnections.target = series; |
|
33 | seriesConnections.target = series; | |
|
34 | } else { | |||
|
35 | seriesConnections.target = null; | |||
|
36 | } | |||
33 | } |
|
37 | } | |
34 |
|
38 | |||
35 | Connections { |
|
39 | Connections { | |
36 | id: seriesConnections |
|
40 | id: seriesConnections | |
37 | ignoreUnknownSignals: true |
|
41 | target: null | |
38 | onNameChanged: console.log("series.onNameChanged: " + series.name); |
|
42 | onNameChanged: console.log("series.onNameChanged: " + series.name); | |
39 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); |
|
43 | onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible); | |
40 | onPointsVisibleChanged: console.log("series.onPointsVisibleChanged: " + series.pointsVisible); |
|
|||
41 | onColorChanged: console.log("series.onColorChanged: " + series.color); |
|
44 | onColorChanged: console.log("series.onColorChanged: " + series.color); | |
42 | onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); |
|
45 | onBorderColorChanged: console.log("series.onBorderColorChanged: " + series.borderColor); | |
43 | onCountChanged: console.log("series.onCountChanged: " + series.count); |
|
46 | onCountChanged: console.log("series.onCountChanged: " + series.count); | |
44 | onMarkerSizeChanged: console.log("series.onMarkerSizeChanged: " + series.markerSize); |
|
|||
45 | onMarkerShapeChanged: console.log("series.onMarkerShapeChanged: " + series.markerShape); |
|
|||
46 | } |
|
47 | } | |
47 |
|
48 | |||
48 | Button { |
|
49 | Button { | |
49 | text: "visible" |
|
50 | text: "visible" | |
50 | onClicked: series.visible = !series.visible; |
|
51 | onClicked: series.visible = !series.visible; | |
51 | } |
|
52 | } | |
52 | Button { |
|
53 | Button { | |
53 | text: "color" |
|
54 | text: "color" | |
54 | onClicked: series.color = main.nextColor(); |
|
55 | onClicked: series.color = main.nextColor(); | |
55 | } |
|
56 | } | |
56 | Button { |
|
57 | Button { | |
57 | text: "borderColor" |
|
58 | text: "borderColor" | |
58 | onClicked: series.borderColor = main.nextColor(); |
|
59 | onClicked: series.borderColor = main.nextColor(); | |
59 | } |
|
60 | } | |
60 | Button { |
|
61 | Button { | |
61 | text: "markerSize +" |
|
62 | text: "markerSize +" | |
62 | onClicked: series.markerSize += 1.0; |
|
63 | onClicked: series.markerSize += 1.0; | |
63 | } |
|
64 | } | |
64 | Button { |
|
65 | Button { | |
65 | text: "markerSize -" |
|
66 | text: "markerSize -" | |
66 | onClicked: series.markerSize -= 1.0; |
|
67 | onClicked: series.markerSize -= 1.0; | |
67 | } |
|
68 | } | |
68 | Button { |
|
69 | Button { | |
69 | text: "markerShape" |
|
70 | text: "markerShape" | |
70 | onClicked: series.markerShape = ((series.markerShape + 1) % 2); |
|
71 | onClicked: series.markerShape = ((series.markerShape + 1) % 2); | |
71 | } |
|
72 | } | |
72 | } |
|
73 | } |
@@ -1,39 +1,40 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.0 |
|
22 | import QtCommercial.Chart 1.0 | |
23 |
|
23 | |||
24 | ChartView { |
|
24 | ChartView { | |
25 | title: "Stacked bar series" |
|
25 | title: "Stacked bar series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | theme: ChartView.ChartThemeLight |
|
27 | theme: ChartView.ChartThemeLight | |
28 | legend.alignment: Qt.AlignBottom |
|
28 | legend.alignment: Qt.AlignBottom | |
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] |
|
29 | axisXLabels: ["0", "2007", "1", "2008", "2", "2009", "3", "2010", "4", "2011", "5", "2012"] | |
30 |
|
30 | |||
31 | property variant series: daSeries |
|
31 | property variant series: daSeries | |
32 |
|
32 | |||
33 | StackedBarSeries { |
|
33 | StackedBarSeries { | |
34 | id: daSeries |
|
34 | id: daSeries | |
|
35 | name: "bar" | |||
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
37 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
38 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
38 | } |
|
39 | } | |
39 | } |
|
40 | } |
General Comments 0
You need to be logged in to leave comments.
Login now