@@ -115,6 +115,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
115 | */ |
|
115 | */ | |
116 |
|
116 | |||
117 | /*! |
|
117 | /*! | |
|
118 | \qmlproperty real ChartView::backgroundRoundness | |||
|
119 | The diameter of the rounding cirle at the corners of the chart background. | |||
|
120 | */ | |||
|
121 | ||||
|
122 | /*! | |||
118 | \qmlproperty color ChartView::plotAreaColor |
|
123 | \qmlproperty color ChartView::plotAreaColor | |
119 | The color of the background of the chart's plot area. By default plot area background uses chart's |
|
124 | The color of the background of the chart's plot area. By default plot area background uses chart's | |
120 | background color. |
|
125 | background color. | |
@@ -706,6 +711,19 bool DeclarativeChart::dropShadowEnabled() | |||||
706 | return m_chart->isDropShadowEnabled(); |
|
711 | return m_chart->isDropShadowEnabled(); | |
707 | } |
|
712 | } | |
708 |
|
713 | |||
|
714 | qreal DeclarativeChart::backgroundRoundness() const | |||
|
715 | { | |||
|
716 | return m_chart->backgroundRoundness(); | |||
|
717 | } | |||
|
718 | ||||
|
719 | void DeclarativeChart::setBackgroundRoundness(qreal diameter) | |||
|
720 | { | |||
|
721 | if (m_chart->backgroundRoundness() != diameter) { | |||
|
722 | m_chart->setBackgroundRoundness(diameter); | |||
|
723 | emit backgroundRoundnessChanged(diameter); | |||
|
724 | } | |||
|
725 | } | |||
|
726 | ||||
709 | qreal DeclarativeChart::topMargin() |
|
727 | qreal DeclarativeChart::topMargin() | |
710 | { |
|
728 | { | |
711 | qWarning() << "ChartView.topMargin is deprecated. Use margins instead."; |
|
729 | qWarning() << "ChartView.topMargin is deprecated. Use margins instead."; |
@@ -53,6 +53,7 class DeclarativeChart : public QDECLARATIVE_PAINTED_ITEM | |||||
53 | Q_PROPERTY(int count READ count) |
|
53 | Q_PROPERTY(int count READ count) | |
54 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) |
|
54 | Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) | |
55 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) |
|
55 | Q_PROPERTY(bool dropShadowEnabled READ dropShadowEnabled WRITE setDropShadowEnabled NOTIFY dropShadowEnabledChanged) | |
|
56 | Q_PROPERTY(qreal backgroundRoundness READ backgroundRoundness WRITE setBackgroundRoundness NOTIFY backgroundRoundnessChanged REVISION 3) | |||
56 | Q_PROPERTY(qreal topMargin READ topMargin) |
|
57 | Q_PROPERTY(qreal topMargin READ topMargin) | |
57 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) |
|
58 | Q_PROPERTY(qreal bottomMargin READ bottomMargin) | |
58 | Q_PROPERTY(qreal leftMargin READ leftMargin) |
|
59 | Q_PROPERTY(qreal leftMargin READ leftMargin) | |
@@ -143,6 +144,8 public: | |||||
143 | int count(); |
|
144 | int count(); | |
144 | void setDropShadowEnabled(bool enabled); |
|
145 | void setDropShadowEnabled(bool enabled); | |
145 | bool dropShadowEnabled(); |
|
146 | bool dropShadowEnabled(); | |
|
147 | Q_REVISION(3) qreal backgroundRoundness() const; | |||
|
148 | Q_REVISION(3) void setBackgroundRoundness(qreal diameter); | |||
146 |
|
149 | |||
147 | // Margins & plotArea |
|
150 | // Margins & plotArea | |
148 | qreal topMargin(); |
|
151 | qreal topMargin(); | |
@@ -191,6 +194,7 Q_SIGNALS: | |||||
191 | void seriesAdded(QAbstractSeries *series); |
|
194 | void seriesAdded(QAbstractSeries *series); | |
192 | void seriesRemoved(QAbstractSeries *series); |
|
195 | void seriesRemoved(QAbstractSeries *series); | |
193 | Q_REVISION(3) void plotAreaColorChanged(); |
|
196 | Q_REVISION(3) void plotAreaColorChanged(); | |
|
197 | Q_REVISION(3) void backgroundRoundnessChanged(qreal diameter); | |||
194 |
|
198 | |||
195 | private Q_SLOTS: |
|
199 | private Q_SLOTS: | |
196 | void changeMinimumMargins(int top, int bottom, int left, int right); |
|
200 | void changeMinimumMargins(int top, int bottom, int left, int right); |
@@ -29,7 +29,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
29 |
|
29 | |||
30 | ChartBackground::ChartBackground(QGraphicsItem *parent) |
|
30 | ChartBackground::ChartBackground(QGraphicsItem *parent) | |
31 | : QGraphicsRectItem(parent), |
|
31 | : QGraphicsRectItem(parent), | |
32 |
m_diameter( |
|
32 | m_diameter(5), | |
33 | m_dropShadow(0) |
|
33 | m_dropShadow(0) | |
34 | { |
|
34 | { | |
35 | } |
|
35 | } | |
@@ -69,7 +69,7 void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *o | |||||
69 | painter->save(); |
|
69 | painter->save(); | |
70 | painter->setPen(pen()); |
|
70 | painter->setPen(pen()); | |
71 | painter->setBrush(brush()); |
|
71 | painter->setBrush(brush()); | |
72 | painter->drawRoundRect(rect(), roundness(rect().width()), roundness(rect().height())); |
|
72 | painter->drawRoundedRect(rect(), m_diameter, m_diameter); | |
73 | #ifndef QT_NO_DEBUG |
|
73 | #ifndef QT_NO_DEBUG | |
74 | painter->setPen(Qt::black); |
|
74 | painter->setPen(Qt::black); | |
75 | QFont font; |
|
75 | QFont font; | |
@@ -81,21 +81,15 void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *o | |||||
81 | painter->restore(); |
|
81 | painter->restore(); | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 |
|
|
84 | qreal ChartBackground::diameter() const | |
85 | { |
|
|||
86 | if (qFuzzyCompare(size, 0)) |
|
|||
87 | return 0; |
|
|||
88 | return 100 * m_diameter / int(size); |
|
|||
89 | } |
|
|||
90 |
|
||||
91 | int ChartBackground::diameter() const |
|
|||
92 | { |
|
85 | { | |
93 | return m_diameter; |
|
86 | return m_diameter; | |
94 | } |
|
87 | } | |
95 |
|
88 | |||
96 |
void ChartBackground::setDiameter( |
|
89 | void ChartBackground::setDiameter(qreal diameter) | |
97 | { |
|
90 | { | |
98 | m_diameter = diameter; |
|
91 | m_diameter = diameter; | |
|
92 | update(); | |||
99 | } |
|
93 | } | |
100 |
|
94 | |||
101 | QTCOMMERCIALCHART_END_NAMESPACE |
|
95 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -42,8 +42,8 public: | |||||
42 | ChartBackground(QGraphicsItem *parent = 0); |
|
42 | ChartBackground(QGraphicsItem *parent = 0); | |
43 | ~ChartBackground(); |
|
43 | ~ChartBackground(); | |
44 |
|
44 | |||
45 |
void setDiameter( |
|
45 | void setDiameter(qreal diameter); | |
46 |
|
|
46 | qreal diameter() const; | |
47 | void setDropShadowEnabled(bool enabled); |
|
47 | void setDropShadowEnabled(bool enabled); | |
48 | bool isDropShadowEnabled() { return m_dropShadow != 0; } |
|
48 | bool isDropShadowEnabled() { return m_dropShadow != 0; } | |
49 |
|
49 | |||
@@ -51,10 +51,7 protected: | |||||
51 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
51 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | |
52 |
|
52 | |||
53 | private: |
|
53 | private: | |
54 | int roundness(qreal size) const; |
|
54 | qreal m_diameter; | |
55 |
|
||||
56 | private: |
|
|||
57 | int m_diameter; |
|
|||
58 | QGraphicsDropShadowEffect *m_dropShadow; |
|
55 | QGraphicsDropShadowEffect *m_dropShadow; | |
59 | }; |
|
56 | }; | |
60 |
|
57 |
@@ -227,6 +227,20 QPen ChartPresenter::backgroundPen() const | |||||
227 | return m_background->pen(); |
|
227 | return m_background->pen(); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
|
230 | void ChartPresenter::setBackgroundRoundness(qreal diameter) | |||
|
231 | { | |||
|
232 | createBackgroundItem(); | |||
|
233 | m_background->setDiameter(diameter); | |||
|
234 | m_layout->invalidate(); | |||
|
235 | } | |||
|
236 | ||||
|
237 | qreal ChartPresenter::backgroundRoundness() const | |||
|
238 | { | |||
|
239 | if (!m_background) | |||
|
240 | return 0; | |||
|
241 | return m_background->diameter(); | |||
|
242 | } | |||
|
243 | ||||
230 | void ChartPresenter::setPlotAreaBackgroundBrush(const QBrush &brush) |
|
244 | void ChartPresenter::setPlotAreaBackgroundBrush(const QBrush &brush) | |
231 | { |
|
245 | { | |
232 | createPlotAreaBackgroundItem(); |
|
246 | createPlotAreaBackgroundItem(); |
@@ -102,6 +102,9 public: | |||||
102 | void setBackgroundPen(const QPen &pen); |
|
102 | void setBackgroundPen(const QPen &pen); | |
103 | QPen backgroundPen() const; |
|
103 | QPen backgroundPen() const; | |
104 |
|
104 | |||
|
105 | void setBackgroundRoundness(qreal diameter); | |||
|
106 | qreal backgroundRoundness() const; | |||
|
107 | ||||
105 | void setPlotAreaBackgroundBrush(const QBrush &brush); |
|
108 | void setPlotAreaBackgroundBrush(const QBrush &brush); | |
106 | QBrush plotAreaBackgroundBrush() const; |
|
109 | QBrush plotAreaBackgroundBrush() const; | |
107 |
|
110 |
@@ -97,6 +97,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
|
100 | \property QChart::backgroundRoundness | |||
|
101 | The diameter of the rounding cirle at the corners of the chart background. | |||
|
102 | */ | |||
|
103 | ||||
|
104 | /*! | |||
100 | \property QChart::minimumMargins |
|
105 | \property QChart::minimumMargins | |
101 | Minimum margins between the plot area (axes) and the edge of the chart widget. |
|
106 | Minimum margins between the plot area (axes) and the edge of the chart widget. | |
102 | This property is deprecated; use margins property instead. |
|
107 | This property is deprecated; use margins property instead. | |
@@ -594,6 +599,16 bool QChart::isDropShadowEnabled() const | |||||
594 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); |
|
599 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); | |
595 | } |
|
600 | } | |
596 |
|
601 | |||
|
602 | void QChart::setBackgroundRoundness(qreal diameter) | |||
|
603 | { | |||
|
604 | d_ptr->m_presenter->setBackgroundRoundness(diameter); | |||
|
605 | } | |||
|
606 | ||||
|
607 | qreal QChart::backgroundRoundness() const | |||
|
608 | { | |||
|
609 | return d_ptr->m_presenter->backgroundRoundness(); | |||
|
610 | } | |||
|
611 | ||||
597 | /*! |
|
612 | /*! | |
598 | Returns all series that are added to the chart. |
|
613 | Returns all series that are added to the chart. | |
599 |
|
614 |
@@ -43,6 +43,7 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget | |||||
43 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
43 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
44 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) |
|
44 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) | |
45 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) |
|
45 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) | |
|
46 | Q_PROPERTY(qreal backgroundRoundness READ backgroundRoundness WRITE setBackgroundRoundness) | |||
46 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) |
|
47 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) | |
47 | Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins) |
|
48 | Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins) | |
48 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) |
|
49 | Q_PROPERTY(QMargins margins READ margins WRITE setMargins) | |
@@ -119,6 +120,8 public: | |||||
119 |
|
120 | |||
120 | void setDropShadowEnabled(bool enabled = true); |
|
121 | void setDropShadowEnabled(bool enabled = true); | |
121 | bool isDropShadowEnabled() const; |
|
122 | bool isDropShadowEnabled() const; | |
|
123 | void setBackgroundRoundness(qreal diameter); | |||
|
124 | qreal backgroundRoundness() const; | |||
122 | void setAnimationOptions(AnimationOptions options); |
|
125 | void setAnimationOptions(AnimationOptions options); | |
123 | AnimationOptions animationOptions() const; |
|
126 | AnimationOptions animationOptions() const; | |
124 |
|
127 |
@@ -109,6 +109,7 private slots: | |||||
109 | void createDefaultAxesForLineSeries_data(); |
|
109 | void createDefaultAxesForLineSeries_data(); | |
110 | void createDefaultAxesForLineSeries(); |
|
110 | void createDefaultAxesForLineSeries(); | |
111 | void axisPolarOrientation(); |
|
111 | void axisPolarOrientation(); | |
|
112 | void backgroundRoundness(); | |||
112 | private: |
|
113 | private: | |
113 | void createTestData(); |
|
114 | void createTestData(); | |
114 |
|
115 | |||
@@ -1028,6 +1029,14 void tst_QChart::axisPolarOrientation() | |||||
1028 | QCOMPARE(chart.axisPolarOrientation(yAxes[0]), QPolarChart::PolarOrientationRadial); |
|
1029 | QCOMPARE(chart.axisPolarOrientation(yAxes[0]), QPolarChart::PolarOrientationRadial); | |
1029 | } |
|
1030 | } | |
1030 |
|
1031 | |||
|
1032 | void tst_QChart::backgroundRoundness() | |||
|
1033 | { | |||
|
1034 | createTestData(); | |||
|
1035 | m_chart->createDefaultAxes(); | |||
|
1036 | m_chart->setBackgroundRoundness(100.0); | |||
|
1037 | QVERIFY(m_chart->backgroundRoundness() == 100.0); | |||
|
1038 | } | |||
|
1039 | ||||
1031 | QTEST_MAIN(tst_QChart) |
|
1040 | QTEST_MAIN(tst_QChart) | |
1032 | #include "tst_qchart.moc" |
|
1041 | #include "tst_qchart.moc" | |
1033 |
|
1042 |
@@ -42,6 +42,7 ChartView { | |||||
42 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color); |
|
42 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color); | |
43 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + chart.backgroundColor); |
|
43 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + chart.backgroundColor); | |
44 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); |
|
44 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); | |
|
45 | onBackgroundRoundnessChanged: console.log("chart.onBackgroundRoundnessChanged: " + diameter); | |||
45 | onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name); |
|
46 | onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name); | |
46 | onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name); |
|
47 | onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name); | |
47 | onPlotAreaColorChanged: console.log("chart.plotAreaColorChanged: " + chart.plotAreaColor); |
|
48 | onPlotAreaColorChanged: console.log("chart.plotAreaColorChanged: " + chart.plotAreaColor); |
@@ -58,6 +58,10 Flow { | |||||
58 | onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled; |
|
58 | onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled; | |
59 | } |
|
59 | } | |
60 | Button { |
|
60 | Button { | |
|
61 | text: "roundness" | |||
|
62 | onClicked: chart.backgroundRoundness++; | |||
|
63 | } | |||
|
64 | Button { | |||
61 | text: "zoom +" |
|
65 | text: "zoom +" | |
62 | onClicked: chart.zoom(2); |
|
66 | onClicked: chart.zoom(2); | |
63 | } |
|
67 | } |
@@ -42,6 +42,7 ChartView { | |||||
42 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color); |
|
42 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color); | |
43 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + chart.backgroundColor); |
|
43 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + chart.backgroundColor); | |
44 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); |
|
44 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); | |
|
45 | onBackgroundRoundnessChanged: console.log("chart.onBackgroundRoundnessChanged: " + diameter); | |||
45 | onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name); |
|
46 | onSeriesAdded: console.log("chart.onSeriesAdded: " + series.name); | |
46 | onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name); |
|
47 | onSeriesRemoved: console.log("chart.onSeriesRemoved: " + series.name); | |
47 | onPlotAreaColorChanged: console.log("chart.plotAreaColorChanged: " + chart.plotAreaColor); |
|
48 | onPlotAreaColorChanged: console.log("chart.plotAreaColorChanged: " + chart.plotAreaColor); |
@@ -58,6 +58,10 Flow { | |||||
58 | onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled; |
|
58 | onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled; | |
59 | } |
|
59 | } | |
60 | Button { |
|
60 | Button { | |
|
61 | text: "roundness" | |||
|
62 | onClicked: chart.backgroundRoundness++; | |||
|
63 | } | |||
|
64 | Button { | |||
61 | text: "zoom +" |
|
65 | text: "zoom +" | |
62 | onClicked: chart.zoom(2); |
|
66 | onClicked: chart.zoom(2); | |
63 | } |
|
67 | } |
General Comments 0
You need to be logged in to leave comments.
Login now