@@ -67,6 +67,7 void ChartPresenter::setGeometry(const QRectF rect) | |||||
67 | chart->domain()->setSize(rect.size()); |
|
67 | chart->domain()->setSize(rect.size()); | |
68 | chart->setPos(rect.topLeft()); |
|
68 | chart->setPos(rect.topLeft()); | |
69 | } |
|
69 | } | |
|
70 | emit plotAreaChanged(m_rect); | |||
70 | } |
|
71 | } | |
71 | } |
|
72 | } | |
72 |
|
73 |
@@ -169,6 +169,9 public Q_SLOTS: | |||||
169 | void handleAxisAdded(QAbstractAxis *axis); |
|
169 | void handleAxisAdded(QAbstractAxis *axis); | |
170 | void handleAxisRemoved(QAbstractAxis *axis); |
|
170 | void handleAxisRemoved(QAbstractAxis *axis); | |
171 |
|
171 | |||
|
172 | signals: | |||
|
173 | void plotAreaChanged(const QRectF &plotArea); | |||
|
174 | ||||
172 | private: |
|
175 | private: | |
173 | QChart *m_chart; |
|
176 | QChart *m_chart; | |
174 | QList<ChartItem *> m_chartItems; |
|
177 | QList<ChartItem *> m_chartItems; |
@@ -169,6 +169,12 QT_CHARTS_BEGIN_NAMESPACE | |||||
169 | */ |
|
169 | */ | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
|
172 | \property QChart::plotArea | |||
|
173 | Holds the rectangle within which the drawing of the chart is done. | |||
|
174 | It does not include the area defined by margins. | |||
|
175 | */ | |||
|
176 | ||||
|
177 | /*! | |||
172 | \internal |
|
178 | \internal | |
173 | Constructs a chart object of \a type which is a child of a \a parent. |
|
179 | Constructs a chart object of \a type which is a child of a \a parent. | |
174 | Parameter \a wFlags is passed to the QGraphicsWidget constructor. |
|
180 | Parameter \a wFlags is passed to the QGraphicsWidget constructor. | |
@@ -526,10 +532,6 QChart::ChartType QChart::chartType() const | |||||
526 | return d_ptr->m_type; |
|
532 | return d_ptr->m_type; | |
527 | } |
|
533 | } | |
528 |
|
534 | |||
529 | /*! |
|
|||
530 | Returns the the rectangle within which the drawing of the chart is done. |
|
|||
531 | It does not include the area defined by margins. |
|
|||
532 | */ |
|
|||
533 | QRectF QChart::plotArea() const |
|
535 | QRectF QChart::plotArea() const | |
534 | { |
|
536 | { | |
535 | return d_ptr->m_presenter->geometry(); |
|
537 | return d_ptr->m_presenter->geometry(); | |
@@ -762,6 +764,7 QChartPrivate::QChartPrivate(QChart *q, QChart::ChartType type): | |||||
762 | QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesRemoved(QAbstractSeries*))); |
|
764 | QObject::connect(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), m_themeManager, SLOT(handleSeriesRemoved(QAbstractSeries*))); | |
763 | QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_themeManager, SLOT(handleAxisAdded(QAbstractAxis*))); |
|
765 | QObject::connect(m_dataset, SIGNAL(axisAdded(QAbstractAxis*)), m_themeManager, SLOT(handleAxisAdded(QAbstractAxis*))); | |
764 | QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_themeManager, SLOT(handleAxisRemoved(QAbstractAxis*))); |
|
766 | QObject::connect(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)), m_themeManager, SLOT(handleAxisRemoved(QAbstractAxis*))); | |
|
767 | QObject::connect(m_presenter, &ChartPresenter::plotAreaChanged, q, &QChart::plotAreaChanged); | |||
765 | } |
|
768 | } | |
766 |
|
769 | |||
767 | QChartPrivate::~QChartPrivate() |
|
770 | QChartPrivate::~QChartPrivate() |
@@ -51,6 +51,7 class QT_CHARTS_EXPORT QChart : public QGraphicsWidget | |||||
51 | Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible) |
|
51 | Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible) | |
52 | Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers) |
|
52 | Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers) | |
53 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale) |
|
53 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale) | |
|
54 | Q_PROPERTY(QRectF plotArea READ plotArea NOTIFY plotAreaChanged) | |||
54 | Q_ENUMS(ChartTheme) |
|
55 | Q_ENUMS(ChartTheme) | |
55 | Q_ENUMS(AnimationOption) |
|
56 | Q_ENUMS(AnimationOption) | |
56 | Q_ENUMS(ChartType) |
|
57 | Q_ENUMS(ChartType) | |
@@ -163,6 +164,9 public: | |||||
163 |
|
164 | |||
164 | ChartType chartType() const; |
|
165 | ChartType chartType() const; | |
165 |
|
166 | |||
|
167 | signals: | |||
|
168 | void plotAreaChanged(const QRectF &plotArea); | |||
|
169 | ||||
166 | protected: |
|
170 | protected: | |
167 | explicit QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags); |
|
171 | explicit QChart(QChart::ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags); | |
168 | QScopedPointer<QChartPrivate> d_ptr; |
|
172 | QScopedPointer<QChartPrivate> d_ptr; |
@@ -265,13 +265,6 QT_CHARTS_BEGIN_NAMESPACE | |||||
265 | */ |
|
265 | */ | |
266 |
|
266 | |||
267 | /*! |
|
267 | /*! | |
268 | \qmlsignal ChartView::onPlotAreaChanged(rect plotArea) |
|
|||
269 | The plot area of the chart has changed. This may happen for example, if you modify minimumMargins |
|
|||
270 | or if you resize the chart, or if you modify font size related properties of the legend or chart |
|
|||
271 | title. |
|
|||
272 | */ |
|
|||
273 |
|
||||
274 | /*! |
|
|||
275 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) |
|
268 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) | |
276 | The \a series has been added to the chart. |
|
269 | The \a series has been added to the chart. | |
277 | */ |
|
270 | */ | |
@@ -327,6 +320,7 void DeclarativeChart::initChart(QChart::ChartType type) | |||||
327 | connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
320 | connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); | |
328 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); |
|
321 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); | |
329 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
322 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
|
323 | connect(m_chart, &QChart::plotAreaChanged, this, &DeclarativeChart::plotAreaChanged); | |||
330 | } |
|
324 | } | |
331 |
|
325 | |||
332 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) |
|
326 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) | |
@@ -338,7 +332,6 void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int r | |||||
338 | { |
|
332 | { | |
339 | m_chart->setMargins(QMargins(left, top, right, bottom)); |
|
333 | m_chart->setMargins(QMargins(left, top, right, bottom)); | |
340 | emit minimumMarginsChanged(); |
|
334 | emit minimumMarginsChanged(); | |
341 | emit plotAreaChanged(m_chart->plotArea()); |
|
|||
342 | } |
|
335 | } | |
343 |
|
336 | |||
344 | DeclarativeChart::~DeclarativeChart() |
|
337 | DeclarativeChart::~DeclarativeChart() | |
@@ -454,11 +447,6 void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF & | |||||
454 | } |
|
447 | } | |
455 | } |
|
448 | } | |
456 | QQuickItem::geometryChanged(newGeometry, oldGeometry); |
|
449 | QQuickItem::geometryChanged(newGeometry, oldGeometry); | |
457 |
|
||||
458 | // It would be better to trigger the plotAreaChanged signal from QChart::plotAreaChanged or |
|
|||
459 | // similar. Since that kind of a signal is not clearly needed in the C++ API the work-around is |
|
|||
460 | // to implement it here for the QML API purposes. |
|
|||
461 | emit plotAreaChanged(m_chart->plotArea()); |
|
|||
462 | } |
|
450 | } | |
463 |
|
451 | |||
464 | void DeclarativeChart::sceneChanged(QList<QRectF> region) |
|
452 | void DeclarativeChart::sceneChanged(QList<QRectF> region) |
General Comments 0
You need to be logged in to leave comments.
Login now