##// END OF EJS Templates
Minor modifications to properties of abstract, area and bar series
Tero Ahola -
r1462:62d898329cbd
parent child
Show More
@@ -29,7 +29,7 ChartView::ChartView(QChart* chart,QWidget* parent):QChartView(chart,parent),
29 m_index(-1),m_chart(chart)
29 m_index(-1),m_chart(chart)
30 {
30 {
31 m_chart->setTitle("Charts presenter");
31 m_chart->setTitle("Charts presenter");
32 m_chart->setBackgroundDropShadowEnabled(false);
32 m_chart->setDropShadowEnabled(false);
33 QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
33 QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
34 m_timer.setInterval(3000);
34 m_timer.setInterval(3000);
35
35
@@ -51,6 +51,6 ChartView::ChartView(QWidget *parent) :
51 chart()->addSeries(series0);
51 chart()->addSeries(series0);
52 chart()->addSeries(series1);
52 chart()->addSeries(series1);
53 chart()->setTitle("Simple scatterchart example");
53 chart()->setTitle("Simple scatterchart example");
54 chart()->setBackgroundDropShadowEnabled(false);
54 chart()->setDropShadowEnabled(false);
55 //![3]
55 //![3]
56 }
56 }
@@ -42,6 +42,44 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42 \clearfloat
42 \clearfloat
43 */
43 */
44
44
45 /*!
46 \qmlproperty Theme ChartView::theme
47 Theme defines the visual appearance of the chart, including for example colors, fonts, line
48 widths and chart background.
49 */
50
51 /*!
52 \qmlproperty Animation ChartView::animation
53 Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations,
54 ChartView.SeriesAnimations or ChartView.AllAnimations.
55 */
56
57 /*!
58 \qmlproperty string ChartView::title
59 The title of the chart, shown on top of the chart.
60 */
61
62 /*!
63 \qmlproperty string ChartView::titleColor
64 The color of the title text.
65 */
66
67 /*!
68 \qmlproperty Axis ChartView::axisX
69 The x-axis of the chart.
70 */
71
72 /*!
73 \qmlproperty Axis ChartView::axisY
74 The default y-axis of the chart.
75 */
76
77 /*!
78 \qmlmethod Axis ChartView::axisY(QAbstractSeries *series)
79 The y-axis of the series. This is the same as the default y-axis of the chart, unless you have
80 explicitly defined the series to have a non-default y-axis.
81 */
82
45 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
83 DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent)
46 : QDeclarativeItem(parent),
84 : QDeclarativeItem(parent),
47 m_chart(new QChart(this))
85 m_chart(new QChart(this))
@@ -66,15 +104,13 void DeclarativeChart::childEvent(QChildEvent *event)
66
104
67 void DeclarativeChart::componentComplete()
105 void DeclarativeChart::componentComplete()
68 {
106 {
69 // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max();
70 foreach(QObject *child, children()) {
107 foreach(QObject *child, children()) {
71 if (qobject_cast<QAbstractSeries *>(child)) {
108 if (qobject_cast<QAbstractSeries *>(child)) {
72 // qDebug() << "DeclarativeChart::componentComplete(), add: " << child;
109 // qDebug() << "DeclarativeChart::componentComplete(), add: " << child;
110 // TODO: how about optional y-axis?
73 m_chart->addSeries(qobject_cast<QAbstractSeries *>(child));
111 m_chart->addSeries(qobject_cast<QAbstractSeries *>(child));
74 }
112 }
75 }
113 }
76 // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max();
77
78 QDeclarativeItem::componentComplete();
114 QDeclarativeItem::componentComplete();
79 }
115 }
80
116
@@ -150,9 +186,9 QAxis *DeclarativeChart::axisX()
150 return m_chart->axisX();
186 return m_chart->axisX();
151 }
187 }
152
188
153 QAxis *DeclarativeChart::axisY()
189 QAxis *DeclarativeChart::axisY(QAbstractSeries *series)
154 {
190 {
155 return m_chart->axisY();
191 return m_chart->axisY(series);
156 }
192 }
157
193
158 QLegend *DeclarativeChart::legend()
194 QLegend *DeclarativeChart::legend()
@@ -222,15 +258,15 int DeclarativeChart::count()
222
258
223 void DeclarativeChart::setDropShadowEnabled(bool enabled)
259 void DeclarativeChart::setDropShadowEnabled(bool enabled)
224 {
260 {
225 if (enabled != m_chart->isBackgroundDropShadowEnabled()) {
261 if (enabled != m_chart->isDropShadowEnabled()) {
226 m_chart->setBackgroundDropShadowEnabled(enabled);
262 m_chart->setDropShadowEnabled(enabled);
227 dropShadowEnabledChanged(enabled);
263 dropShadowEnabledChanged(enabled);
228 }
264 }
229 }
265 }
230
266
231 bool DeclarativeChart::dropShadowEnabled()
267 bool DeclarativeChart::dropShadowEnabled()
232 {
268 {
233 return m_chart->isBackgroundDropShadowEnabled();
269 return m_chart->isDropShadowEnabled();
234 }
270 }
235
271
236 void DeclarativeChart::zoom(qreal factor)
272 void DeclarativeChart::zoom(qreal factor)
@@ -258,33 +294,6 void DeclarativeChart::scrollDown(qreal pixels)
258 m_chart->scroll(QPointF(0, -pixels));
294 m_chart->scroll(QPointF(0, -pixels));
259 }
295 }
260
296
261 //void DeclarativeChart::scrollLeft(qreal ticks)
262 //{
263 // m_chart->scroll(QPointF(ticksToPixels(m_chart->axisX(), ticks), 0));
264 //}
265
266 //void DeclarativeChart::scrollRight(qreal ticks)
267 //{
268 // m_chart->scroll(QPointF(-ticksToPixels(m_chart->axisX(), ticks), 0));
269 //}
270
271 //void DeclarativeChart::scrollUp(qreal ticks)
272 //{
273 // m_chart->scroll(QPointF(0, ticksToPixels(m_chart->axisY(), ticks)));
274 //}
275
276 //void DeclarativeChart::scrollDown(qreal ticks)
277 //{
278 // m_chart->scroll(QPointF(0, -ticksToPixels(m_chart->axisY(), ticks)));
279 //}
280
281 //qreal DeclarativeChart::ticksToPixels(QAxis *axis, qreal ticks)
282 //{
283 // qreal tickCount = axis->max() - axis->min();
284 // qreal tickPixels = (m_chart->size().width() - m_chart->margins().width() * 2) / tickCount;
285 // return tickPixels * ticks;
286 //}
287
288 QAbstractSeries *DeclarativeChart::series(int index)
297 QAbstractSeries *DeclarativeChart::series(int index)
289 {
298 {
290 if (index < m_chart->series().count()) {
299 if (index < m_chart->series().count()) {
@@ -99,7 +99,7 public:
99 void setTitle(QString title);
99 void setTitle(QString title);
100 QString title();
100 QString title();
101 QAxis *axisX();
101 QAxis *axisX();
102 QAxis *axisY();
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);
@@ -47,14 +47,14 QTCOMMERCIALCHART_BEGIN_NAMESPACE
47 */
47 */
48
48
49 /*!
49 /*!
50 \fn QLineSeries* QAreaSeries::upperSeries() const
50 \property QAreaSeries::upperSeries
51 \brief Returns upperSeries used to define one of area boundaries.
51 \brief The upper one of the two line series used to define area series boundaries.
52 */
52 */
53
53
54 /*!
54 /*!
55 \fn QLineSeries* QAreaSeries::lowerSeries() const
55 \property QAreaSeries::lowerSeries
56 \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries
56 The lower one of the two line series used to define are series boundaries. Note if
57 this function return Null pointer.
57 QAreaSeries was counstucted wihtout a\ lowerSeries this is null.
58 */
58 */
59
59
60 /*!
60 /*!
@@ -33,6 +33,8 class QAreaSeriesPrivate;
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)
37 Q_PROPERTY(QAbstractSeries *lowerSeries READ lowerSeries)
36
38
37 public:
39 public:
38 explicit QAreaSeries(QObject *parent = 0);
40 explicit QAreaSeries(QObject *parent = 0);
@@ -75,7 +75,7 void BarChartItem::handleDataStructureChanged()
75
75
76 // Create new graphic items for bars
76 // Create new graphic items for bars
77 for (int c = 0; c < m_series->d_func()->categoryCount(); c++) {
77 for (int c = 0; c < m_series->d_func()->categoryCount(); c++) {
78 for (int s = 0; s < m_series->barsetCount(); s++) {
78 for (int s = 0; s < m_series->count(); s++) {
79 QBarSet *set = m_series->d_func()->barsetAt(s);
79 QBarSet *set = m_series->d_func()->barsetAt(s);
80
80
81 // Bars
81 // Bars
@@ -103,7 +103,7 QVector<QRectF> BarChartItem::calculateLayout()
103
103
104 // Use temporary qreals for accuracy
104 // Use temporary qreals for accuracy
105 qreal categoryCount = m_series->d_func()->categoryCount();
105 qreal categoryCount = m_series->d_func()->categoryCount();
106 qreal setCount = m_series->barsetCount();
106 qreal setCount = m_series->count();
107 bool barsVisible = m_series->isVisible();
107 bool barsVisible = m_series->isVisible();
108
108
109 // Domain:
109 // Domain:
@@ -37,7 +37,7 QVector<QRectF> GroupedBarChartItem::calculateLayout()
37
37
38 // Use temporary qreals for accuracy
38 // Use temporary qreals for accuracy
39 qreal categoryCount = m_series->d_func()->categoryCount();
39 qreal categoryCount = m_series->d_func()->categoryCount();
40 qreal setCount = m_series->barsetCount();
40 qreal setCount = m_series->count();
41 bool barsVisible = m_series->isVisible();
41 bool barsVisible = m_series->isVisible();
42
42
43 // Domain:
43 // Domain:
@@ -37,7 +37,7 QVector<QRectF> PercentBarChartItem::calculateLayout()
37
37
38 // Use temporary qreals for accuracy
38 // Use temporary qreals for accuracy
39 qreal categoryCount = m_series->d_func()->categoryCount();
39 qreal categoryCount = m_series->d_func()->categoryCount();
40 qreal setCount = m_series->barsetCount();
40 qreal setCount = m_series->count();
41 bool barsVisible = m_series->isVisible();
41 bool barsVisible = m_series->isVisible();
42
42
43 // Domain:
43 // Domain:
@@ -88,7 +88,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
88 */
88 */
89
89
90 /*!
90 /*!
91 \fn void QBarSeries::barsetCountChanged()
91 \fn void QBarSeries::countChanged()
92
92
93 This signal is emitted when barset count has been changed, for example by append or remove.
93 This signal is emitted when barset count has been changed, for example by append or remove.
94 */
94 */
@@ -191,7 +191,7 bool QBarSeries::append(QBarSet *set)
191 QList<QBarSet*> sets;
191 QList<QBarSet*> sets;
192 sets.append(set);
192 sets.append(set);
193 emit barsetsAdded(sets);
193 emit barsetsAdded(sets);
194 emit barsetCountChanged();
194 emit countChanged();
195 }
195 }
196 return success;
196 return success;
197 }
197 }
@@ -208,7 +208,7 bool QBarSeries::remove(QBarSet *set)
208 QList<QBarSet*> sets;
208 QList<QBarSet*> sets;
209 sets.append(set);
209 sets.append(set);
210 emit barsetsRemoved(sets);
210 emit barsetsRemoved(sets);
211 emit barsetCountChanged();
211 emit countChanged();
212 }
212 }
213 return success;
213 return success;
214 }
214 }
@@ -225,7 +225,7 bool QBarSeries::append(QList<QBarSet* > sets)
225 bool success = d->append(sets);
225 bool success = d->append(sets);
226 if (success) {
226 if (success) {
227 emit barsetsAdded(sets);
227 emit barsetsAdded(sets);
228 emit barsetCountChanged();
228 emit countChanged();
229 }
229 }
230 return success;
230 return success;
231 }
231 }
@@ -243,7 +243,7 bool QBarSeries::insert(int index, QBarSet *set)
243 QList<QBarSet*> sets;
243 QList<QBarSet*> sets;
244 sets.append(set);
244 sets.append(set);
245 emit barsetsAdded(sets);
245 emit barsetsAdded(sets);
246 emit barsetCountChanged();
246 emit countChanged();
247 }
247 }
248 return success;
248 return success;
249 }
249 }
@@ -258,14 +258,14 void QBarSeries::clear()
258 bool success = d->remove(sets);
258 bool success = d->remove(sets);
259 if (success) {
259 if (success) {
260 emit barsetsRemoved(sets);
260 emit barsetsRemoved(sets);
261 emit barsetCountChanged();
261 emit countChanged();
262 }
262 }
263 }
263 }
264
264
265 /*!
265 /*!
266 Returns number of sets in series.
266 Returns number of sets in series.
267 */
267 */
268 int QBarSeries::barsetCount() const
268 int QBarSeries::count() const
269 {
269 {
270 Q_D(const QBarSeries);
270 Q_D(const QBarSeries);
271 return d->m_barSets.count();
271 return d->m_barSets.count();
@@ -34,7 +34,7 class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth NOTIFY barWidthChanged)
36 Q_PROPERTY(qreal barWidth READ barWidth WRITE setBarWidth NOTIFY barWidthChanged)
37 Q_PROPERTY(int count READ barsetCount NOTIFY barsetCountChanged)
37 Q_PROPERTY(int count READ count NOTIFY countChanged)
38 Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
38 Q_PROPERTY(bool labelsVisible READ isLabelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
39
39
40 public:
40 public:
@@ -50,7 +50,7 public:
50 bool remove(QBarSet *set);
50 bool remove(QBarSet *set);
51 bool append(QList<QBarSet* > sets);
51 bool append(QList<QBarSet* > sets);
52 bool insert(int index, QBarSet *set);
52 bool insert(int index, QBarSet *set);
53 int barsetCount() const;
53 int count() const;
54 QList<QBarSet*> barSets() const;
54 QList<QBarSet*> barSets() const;
55 void clear();
55 void clear();
56
56
@@ -64,7 +64,7 Q_SIGNALS:
64 void clicked(QBarSet *barset, int index);
64 void clicked(QBarSet *barset, int index);
65 void hovered(QBarSet* barset, bool status);
65 void hovered(QBarSet* barset, bool status);
66 void barWidthChanged();
66 void barWidthChanged();
67 void barsetCountChanged();
67 void countChanged();
68 void labelsVisibleChanged();
68 void labelsVisibleChanged();
69
69
70 void barsetsAdded(QList<QBarSet*> sets);
70 void barsetsAdded(QList<QBarSet*> sets);
@@ -37,7 +37,7 QVector<QRectF> StackedBarChartItem::calculateLayout()
37 QVector<QRectF> layout;
37 QVector<QRectF> layout;
38 // Use temporary qreals for accuracy
38 // Use temporary qreals for accuracy
39 qreal categoryCount = m_series->d_func()->categoryCount();
39 qreal categoryCount = m_series->d_func()->categoryCount();
40 qreal setCount = m_series->barsetCount();
40 qreal setCount = m_series->count();
41 bool barsVisible = m_series->isVisible();
41 bool barsVisible = m_series->isVisible();
42
42
43 // Domain:
43 // Domain:
@@ -110,7 +110,7 void ChartTheme::decorate(QChart *chart)
110 chart->setBackgroundBrush(m_chartBackgroundGradient);
110 chart->setBackgroundBrush(m_chartBackgroundGradient);
111 chart->setTitleFont(m_masterFont);
111 chart->setTitleFont(m_masterFont);
112 chart->setTitleBrush(m_titleBrush);
112 chart->setTitleBrush(m_titleBrush);
113 chart->setBackgroundDropShadowEnabled(m_backgroundDropShadowEnabled);
113 chart->setDropShadowEnabled(m_backgroundDropShadowEnabled);
114 }
114 }
115
115
116 void ChartTheme::decorate(QLegend *legend)
116 void ChartTheme::decorate(QLegend *legend)
@@ -51,8 +51,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
51 */
51 */
52
52
53 /*!
53 /*!
54 \fn QSeriesType QAbstractSeries::type() const
54 \property QAbstractSeries::type
55 \brief The type of the series.
55 The type of the series.
56 */
56 */
57
57
58 /*!
58 /*!
@@ -35,6 +35,7 class QTCOMMERCIALCHART_EXPORT QAbstractSeries : public QObject
35 Q_OBJECT
35 Q_OBJECT
36 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
36 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
37 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
37 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
38 Q_PROPERTY(SeriesType type READ type)
38 Q_ENUMS(SeriesType)
39 Q_ENUMS(SeriesType)
39
40
40 public:
41 public:
@@ -424,7 +424,7 bool QChart::isBackgroundVisible() const
424 /*!
424 /*!
425 Sets the background drop shadow effect state to \a enabled.
425 Sets the background drop shadow effect state to \a enabled.
426 */
426 */
427 void QChart::setBackgroundDropShadowEnabled(bool enabled)
427 void QChart::setDropShadowEnabled(bool enabled)
428 {
428 {
429 d_ptr->m_presenter->createChartBackgroundItem();
429 d_ptr->m_presenter->createChartBackgroundItem();
430 d_ptr->m_presenter->m_backgroundItem->setDropShadowEnabled(enabled);
430 d_ptr->m_presenter->m_backgroundItem->setDropShadowEnabled(enabled);
@@ -433,7 +433,7 void QChart::setBackgroundDropShadowEnabled(bool enabled)
433 /*!
433 /*!
434 Returns true if the drop shadow effect is enabled for the chart background.
434 Returns true if the drop shadow effect is enabled for the chart background.
435 */
435 */
436 bool QChart::isBackgroundDropShadowEnabled() const
436 bool QChart::isDropShadowEnabled() const
437 {
437 {
438 if (!d_ptr->m_presenter->m_backgroundItem)
438 if (!d_ptr->m_presenter->m_backgroundItem)
439 return false;
439 return false;
@@ -85,9 +85,9 public:
85 QPen backgroundPen() const;
85 QPen backgroundPen() const;
86 void setBackgroundVisible(bool visible = true);
86 void setBackgroundVisible(bool visible = true);
87 bool isBackgroundVisible() const;
87 bool isBackgroundVisible() const;
88 void setBackgroundDropShadowEnabled(bool enabled = true);
89 bool isBackgroundDropShadowEnabled() const;
90
88
89 void setDropShadowEnabled(bool enabled = true);
90 bool isDropShadowEnabled() const;
91 void setAnimationOptions(AnimationOptions options);
91 void setAnimationOptions(AnimationOptions options);
92 AnimationOptions animationOptions() const;
92 AnimationOptions animationOptions() const;
93
93
General Comments 0
You need to be logged in to leave comments. Login now