##// END OF EJS Templates
Barchart value layout fix
Barchart value layout fix

File last commit:

r804:02c84d5a1cd8
r817:2ecb2f756c9b
Show More
qchart.cpp
501 lines | 13.1 KiB | text/x-c | CppLexer
Michal Klocek
adds QChartView PIMPL, refactor public API
r746 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
Michal Klocek
adds missing files form previous commit
r12 #include "qchart.h"
Michal Klocek
Adds PIMPL to qchart
r740 #include "qchart_p.h"
Tero Ahola
Integrated scatter type series...
r42 #include <QGraphicsScene>
Michal Klocek
Adds layout support for charts....
r115 #include <QGraphicsSceneResizeEvent>
Michal Klocek
adds missing files form previous commit
r12
Marek Rosa
Added some more documentation to QChart and QChartView
r277 QTCOMMERCIALCHART_BEGIN_NAMESPACE
/*!
Michal Klocek
Adds PIMPL to qchart
r740 \enum QChart::ChartTheme
Marek Rosa
Added some more documentation to QChart and QChartView
r277
Michal Klocek
Adds PIMPL to qchart
r740 This enum describes the theme used by the chart.
Marek Rosa
Added some more documentation to QChart and QChartView
r277
Michal Klocek
Adds PIMPL to qchart
r740 \value ChartThemeDefault Follows the GUI style of the Operating System
\value ChartThemeLight
\value ChartThemeBlueCerulean
\value ChartThemeDark
\value ChartThemeBrownSand
\value ChartThemeBlueNcs
Tero Ahola
Added Icy Blue and High Contrast theme
r757 \value ChartThemeHighContrast
\value ChartThemeBlueIcy
Michal Klocek
Adds PIMPL to qchart
r740 \value ChartThemeCount Not really a theme; the total count of themes.
*/
Marek Rosa
Added some more documentation to QChart and QChartView
r277
Tero Ahola
QDoc for animation options in QChart
r302 /*!
Michal Klocek
Adds PIMPL to qchart
r740 \enum QChart::AnimationOption
Tero Ahola
QDoc for animation options in QChart
r302
Michal Klocek
Adds PIMPL to qchart
r740 For enabling/disabling animations. Defaults to NoAnimation.
Tero Ahola
QDoc for animation options in QChart
r302
Michal Klocek
Adds PIMPL to qchart
r740 \value NoAnimation
\value GridAxisAnimations
\value SeriesAnimations
\value AllAnimations
*/
Tero Ahola
QDoc for animation options in QChart
r302
Tero Ahola
Started documenting QChart
r264 /*!
Michal Klocek
Adds PIMPL to qchart
r740 \class QChart
\brief QtCommercial chart API.
Tero Ahola
Started documenting QChart
r264
Michal Klocek
Adds PIMPL to qchart
r740 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
representation of different types of QChartSeries and other chart related objects like
QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the
convenience class QChartView instead of QChart.
\sa QChartView
*/
Tero Ahola
Started documenting QChart
r264
/*!
Michal Klocek
Adds PIMPL to qchart
r740 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
*/
Michal Klocek
Adds layout support for charts....
r115 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr(new QChartPrivate(this))
Michal Klocek
adds missing files form previous commit
r12 {
Michal Klocek
Add stub from minimum size
r782 //setMinimumSize(200,200);
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_legend = new QLegend(this);
d_ptr->m_dataset = new ChartDataSet(this);
d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset);
sauimone
legend pos to theme example, legend padding
r803 setMinimumSize(d_ptr->m_padding.left() * 3, d_ptr->m_padding.top() * 3);
Michal Klocek
Adds PIMPL to qchart
r740 connect(d_ptr->m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),d_ptr->m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
connect(d_ptr->m_dataset,SIGNAL(seriesRemoved(QSeries*)),d_ptr->m_legend,SLOT(handleSeriesRemoved(QSeries*)));
Michal Klocek
adds missing files form previous commit
r12 }
Tero Ahola
Started documenting QChart
r264 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
*/
Tero Ahola
Started documenting QChart
r264 QChart::~QChart()
{
Michal Klocek
Bugfix: delete presenter first, before root of all graphical items
r686 //delete first presenter , since this is a root of all the graphical items
Michal Klocek
Adds PIMPL to qchart
r740 delete d_ptr->m_presenter;
d_ptr->m_presenter=0;
Tero Ahola
Started documenting QChart
r264 }
Michal Klocek
adds missing files form previous commit
r12
Tero Ahola
Started documenting QChart
r264 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
the y axis).
*/
Michal Klocek
Rename QChartSeries to QSeries
r360 void QChart::addSeries(QSeries* series, QChartAxis* axisY)
Michal Klocek
Refactors axis handling...
r223 {
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_dataset->addSeries(series, axisY);
Michal Klocek
Refactors axis handling...
r223 }
Tero Ahola
Integrated scatter type series...
r42
Marek Rosa
Added some documentation to QChart and QChartView
r274 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Removes the \a series specified in a perameter from the QChartView.
It releses its ownership of the specified QChartSeries object.
It does not delete the pointed QChartSeries data object
\sa addSeries(), removeAllSeries()
*/
Michal Klocek
Rename QChartSeries to QSeries
r360 void QChart::removeSeries(QSeries* series)
Michal Klocek
Refactors axis handling...
r223 {
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_dataset->removeSeries(series);
Tero Ahola
Integrated scatter type series...
r42 }
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48
Marek Rosa
Added some documentation to QChart and QChartView
r274 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Removes all the QChartSeries that have been added to the QChartView
It also deletes the pointed QChartSeries data objects
\sa addSeries(), removeSeries()
*/
Michal Klocek
Adds RemoveAllSeries method to API
r258 void QChart::removeAllSeries()
{
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_dataset->removeAllSeries();
Michal Klocek
Adds RemoveAllSeries method to API
r258 }
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Sets the \a brush that is used for painting the background of the chart area.
*/
Michal Klocek
Adds force option to chartTheme...
r645 void QChart::setBackgroundBrush(const QBrush& brush)
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 {
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->createChartBackgroundItem();
d_ptr->m_backgroundItem->setBrush(brush);
d_ptr->m_backgroundItem->update();
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 }
Michal Klocek
Adds force option to chartTheme...
r645 QBrush QChart::backgroundBrush() const
{
Michal Klocek
Polishing qchart class
r742 if (!d_ptr->m_backgroundItem) return QBrush();
Michal Klocek
Adds PIMPL to qchart
r740 return (d_ptr->m_backgroundItem)->brush();
Michal Klocek
Adds force option to chartTheme...
r645 }
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Sets the \a pen that is used for painting the background of the chart area.
*/
Michal Klocek
Adds force option to chartTheme...
r645 void QChart::setBackgroundPen(const QPen& pen)
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 {
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->createChartBackgroundItem();
d_ptr->m_backgroundItem->setPen(pen);
d_ptr->m_backgroundItem->update();
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122 }
Michal Klocek
Adds force option to chartTheme...
r645 QPen QChart::backgroundPen() const
{
Michal Klocek
Polishing qchart class
r742 if (!d_ptr->m_backgroundItem) return QPen();
Michal Klocek
Adds PIMPL to qchart
r740 return d_ptr->m_backgroundItem->pen();
Michal Klocek
Adds force option to chartTheme...
r645 }
Marek Rosa
Added some documentation to QChart and QChartView
r274 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Sets the chart \a title. The description text that is drawn above the chart.
*/
Michal Klocek
Adds force option to chartTheme...
r645 void QChart::setTitle(const QString& title)
Michal Klocek
Add background to chart...
r69 {
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->createChartTitleItem();
d_ptr->m_titleItem->setText(title);
d_ptr->updateLayout();
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 }
/*!
Michal Klocek
Adds PIMPL to qchart
r740 Returns the chart title. The description text that is drawn above the chart.
*/
Michal Klocek
Adds force option to chartTheme...
r645 QString QChart::title() const
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 {
Michal Klocek
Polishing qchart class
r742 if (d_ptr->m_titleItem)
Michal Klocek
Adds PIMPL to qchart
r740 return d_ptr->m_titleItem->text();
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 else
return QString();
Michal Klocek
Adds font handling for chart's titile...
r192 }
Marek Rosa
Added some documentation to QChart and QChartView
r274 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Sets the \a font that is used for rendering the description text that is rendered above the chart.
*/
Michal Klocek
Adds force option to chartTheme...
r645 void QChart::setTitleFont(const QFont& font)
Michal Klocek
Adds font handling for chart's titile...
r192 {
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->createChartTitleItem();
d_ptr->m_titleItem->setFont(font);
d_ptr->updateLayout();
Michal Klocek
Add background to chart...
r69 }
Tero Ahola
Chart title font color
r495 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Sets the \a brush used for rendering the title text.
*/
Michal Klocek
Adds force option to chartTheme...
r645 void QChart::setTitleBrush(const QBrush &brush)
Tero Ahola
Chart title font color
r495 {
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->createChartTitleItem();
d_ptr->m_titleItem->setBrush(brush);
d_ptr->updateLayout();
Tero Ahola
Chart title font color
r495 }
/*!
Michal Klocek
Adds PIMPL to qchart
r740 Returns the brush used for rendering the title text.
*/
Michal Klocek
Adds force option to chartTheme...
r645 QBrush QChart::titleBrush() const
Tero Ahola
Chart title font color
r495 {
Michal Klocek
Polishing qchart class
r742 if (!d_ptr->m_titleItem) return QBrush();
Michal Klocek
Adds PIMPL to qchart
r740 return d_ptr->m_titleItem->brush();
Michal Klocek
Refactors axis handling...
r223 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Sets the \a theme used by the chart for rendering the graphical representation of the data
\sa ChartTheme, chartTheme()
*/
void QChart::setTheme(QChart::ChartTheme theme)
Tero Ahola
Draft implementation for setting color themes for a chart
r64 {
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_presenter->setTheme(theme);
Tero Ahola
Draft implementation for setting color themes for a chart
r64 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Returns the theme enum used by the chart.
\sa ChartTheme, setChartTheme()
*/
QChart::ChartTheme QChart::theme() const
Tero Ahola
Proof-of-concept for QML api...
r120 {
Michal Klocek
Adds PIMPL to qchart
r740 return d_ptr->m_presenter->theme();
Tero Ahola
Proof-of-concept for QML api...
r120 }
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Zooms in the view by a factor of 2
*/
Michal Klocek
Refactors axis handling...
r223 void QChart::zoomIn()
Michal Klocek
Add zoom support...
r67 {
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_presenter->zoomIn();
Michal Klocek
Add zoom support...
r67 }
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Zooms in the view to a maximum level at which \a rect is still fully visible.
*/
Michal Klocek
Refactors axis handling...
r223 void QChart::zoomIn(const QRectF& rect)
Michal Klocek
Add zoom support...
r67 {
Michal Klocek
Polishing qchart class
r742 if (!rect.isValid()) return;
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_presenter->zoomIn(rect);
Michal Klocek
Add zoom support...
r67 }
Marek Rosa
else clause added to QChartView mousePressEvent. Added some more docs to QChart and QChartView
r285 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Restores the view zoom level to the previous one.
*/
Michal Klocek
Add zoom support...
r67 void QChart::zoomOut()
{
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_presenter->zoomOut();
Michal Klocek
Add zoom support...
r67 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Returns the pointer to the x axis object of the chart
*/
Michal Klocek
Refactors axis handling...
r223 QChartAxis* QChart::axisX() const
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Adds PIMPL to qchart
r740 return d_ptr->m_dataset->axisX();
Michal Klocek
Adds more axis handling...
r176 }
Marek Rosa
Added some more documentation to QChart and QChartView
r277 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Returns the pointer to the y axis object of the chart
*/
Michal Klocek
Refactors axis handling...
r223 QChartAxis* QChart::axisY() const
Michal Klocek
Adds more axis handling...
r176 {
Michal Klocek
Adds PIMPL to qchart
r740 return d_ptr->m_dataset->axisY();
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 }
sauimone
framework for legend
r524 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Returns the legend object of the chart. Ownership stays in chart.
*/
sauimone
improved legend layout
r783 QLegend* QChart::legend() const
sauimone
framework for legend
r524 {
sauimone
improved legend layout
r783 return d_ptr->m_legend;
sauimone
framework for legend
r524 }
Michal Klocek
Fix padding to be int, update unit test
r804 QRect QChart::padding() const
sauimone
legend pos to theme example, legend padding
r803 {
return d_ptr->m_padding;
}
Marek Rosa
QChart and QChartView now has some description for all the functions
r287 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Resizes and updates the chart area using the \a event data
*/
Michal Klocek
Adds layout support for charts....
r115 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
{
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize());
d_ptr->updateLayout();
Michal Klocek
Removes obsolate methods from qchart
r117 QGraphicsWidget::resizeEvent(event);
Michal Klocek
Adds layout support for charts....
r115 update();
}
Michal Klocek
Adds animation settings handling
r298 /*!
Michal Klocek
Adds PIMPL to qchart
r740 Sets animation \a options for the chart
*/
Michal Klocek
Adds animation settings handling
r298 void QChart::setAnimationOptions(AnimationOptions options)
{
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_presenter->setAnimationOptions(options);
Michal Klocek
Adds animation settings handling
r298 }
/*!
Michal Klocek
Adds PIMPL to qchart
r740 Returns animation options for the chart
*/
Michal Klocek
Adds animation settings handling
r298 QChart::AnimationOptions QChart::animationOptions() const
{
Michal Klocek
Adds PIMPL to qchart
r740 return d_ptr->m_presenter->animationOptions();
Michal Klocek
Adds animation settings handling
r298 }
Michal Klocek
Refcator scrol() to scrollLeft,Right,Up,Down
r600 void QChart::scrollLeft()
{
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_presenter->scroll(-d_ptr->m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
Michal Klocek
Refcator scrol() to scrollLeft,Right,Up,Down
r600 }
void QChart::scrollRight()
{
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_presenter->scroll(d_ptr->m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
Michal Klocek
Refcator scrol() to scrollLeft,Right,Up,Down
r600 }
Michal Klocek
Adds PIMPL to qchart
r740
Michal Klocek
Refcator scrol() to scrollLeft,Right,Up,Down
r600 void QChart::scrollUp()
{
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->geometry().width()/(axisY()->ticksCount()-1));
Michal Klocek
Refcator scrol() to scrollLeft,Right,Up,Down
r600 }
Michal Klocek
Adds PIMPL to qchart
r740
Michal Klocek
Refcator scrol() to scrollLeft,Right,Up,Down
r600 void QChart::scrollDown()
{
Michal Klocek
Adds PIMPL to qchart
r740 d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->geometry().width()/(axisY()->ticksCount()-1));
Michal Klocek
Adds scroll support...
r531 }
Michal Klocek
Adds PIMPL to qchart
r740 void QChart::setBackgroundVisible(bool visible)
{
d_ptr->createChartBackgroundItem();
d_ptr->m_backgroundItem->setVisible(visible);
}
sauimone
Scrolling logic to legend
r716
Michal Klocek
Adds PIMPL to qchart
r740 bool QChart::isBackgroundVisible() const
{
Michal Klocek
Polishing qchart class
r742 if (!d_ptr->m_backgroundItem) return false;
Michal Klocek
Adds PIMPL to qchart
r740 return d_ptr->m_backgroundItem->isVisible();
sauimone
Scrolling logic to legend
r716 }
Michal Klocek
Adds PIMPL to qchart
r740 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Michal Klocek
Changes background item...
r639
Michal Klocek
Adds PIMPL to qchart
r740 QChartPrivate::QChartPrivate(QChart *parent):
q_ptr(parent),
m_backgroundItem(0),
m_titleItem(0),
m_legend(0),
m_dataset(0),
sauimone
legend pos to theme example, legend padding
r803 m_presenter(0),
Michal Klocek
Fix padding to be int, update unit test
r804 m_padding(QRect(50,50,0,0))
Michal Klocek
Changes background item...
r639 {
Michal Klocek
Adds PIMPL to qchart
r740
Michal Klocek
Changes background item...
r639 }
Michal Klocek
Adds PIMPL to qchart
r740 QChartPrivate::~QChartPrivate()
Michal Klocek
Changes background item...
r639 {
Michal Klocek
Adds PIMPL to qchart
r740
Michal Klocek
Changes background item...
r639 }
Michal Klocek
Adds PIMPL to qchart
r740 void QChartPrivate::createChartBackgroundItem()
Michal Klocek
Changes background item...
r639 {
Michal Klocek
Polishing qchart class
r742 if (!m_backgroundItem) {
Michal Klocek
Adds PIMPL to qchart
r740 m_backgroundItem = new ChartBackground(q_ptr);
m_backgroundItem->setPen(Qt::NoPen);
m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue);
Michal Klocek
Changes background item...
r639 }
}
Michal Klocek
Adds PIMPL to qchart
r740 void QChartPrivate::createChartTitleItem()
Michal Klocek
Changes background item...
r639 {
Michal Klocek
Polishing qchart class
r742 if (!m_titleItem) {
Michal Klocek
Adds PIMPL to qchart
r740 m_titleItem = new QGraphicsSimpleTextItem(q_ptr);
m_titleItem->setZValue(ChartPresenter::BackgroundZValue);
}
Michal Klocek
Changes background item...
r639 }
Michal Klocek
Adds PIMPL to qchart
r740 void QChartPrivate::updateLegendLayout()
Michal Klocek
Adds force option to chartTheme...
r645 {
sauimone
legend pos to theme example, legend padding
r803 //int legendPadding = m_chart->legend()->padding();
int legendPadding = 30;
QRectF rect = m_rect;
if ((m_legend->attachedToChart()) && (m_legend->isVisible())) {
// Reserve some space for legend
switch (m_legend->alignment()) {
case QLegend::AlignmentTop: {
rect.adjust(m_padding.left(),
m_padding.top() + legendPadding,
-m_padding.right(),
-m_padding.bottom());
break;
}
case QLegend::AlignmentBottom: {
rect.adjust(m_padding.left(),
m_padding.top(),
-m_padding.right(),
-m_padding.bottom() - legendPadding);
break;
}
case QLegend::AlignmentLeft: {
rect.adjust(m_padding.left() + legendPadding,
m_padding.top(),
-m_padding.right(),
-m_padding.bottom());
break;
}
case QLegend::AlignmentRight: {
rect.adjust(m_padding.left(),
m_padding.top(),
-m_padding.right() - legendPadding,
-m_padding.bottom());
break;
}
default: {
rect.adjust(m_padding.left(),
m_padding.top(),
-m_padding.right(),
-m_padding.bottom());
break;
}
}
} else {
rect.adjust(m_padding.left(),
m_padding.top(),
-m_padding.right(),
-m_padding.bottom());
}
QRectF plotRect = m_rect.adjusted(m_padding.left()
,m_padding.top()
,-m_padding.right()
,-m_padding.bottom());
Michal Klocek
Adds PIMPL to qchart
r740 QRectF legendRect;
sauimone
legend pos to theme example, legend padding
r803 int padding = 0; // TODO: fix this
sauimone
legend fixes
r766 switch (m_legend->alignment())
Michal Klocek
Adds PIMPL to qchart
r740 {
sauimone
legend layout with padding
r799 case QLegend::AlignmentTop: {
sauimone
solid brush for all legend markers
r800 legendRect = m_rect.adjusted(0,padding,0,-padding - plotRect.height());
Michal Klocek
Adds PIMPL to qchart
r740 break;
}
sauimone
legend layout with padding
r799 case QLegend::AlignmentBottom: {
legendRect = m_rect.adjusted(padding,padding + plotRect.height(),-padding,0);
Michal Klocek
Adds PIMPL to qchart
r740 break;
}
sauimone
legend layout with padding
r799 case QLegend::AlignmentLeft: {
legendRect = m_rect.adjusted(0,padding,-padding - plotRect.width(),-padding);
Michal Klocek
Adds PIMPL to qchart
r740 break;
}
sauimone
legend layout with padding
r799 case QLegend::AlignmentRight: {
legendRect = m_rect.adjusted(padding + plotRect.width(),padding,0,-padding);
Michal Klocek
Adds PIMPL to qchart
r740 break;
}
default: {
legendRect = plotRect;
break;
}
}
m_legend->setMaximumSize(legendRect.size());
sauimone
improved legend layout
r783
qreal width = legendRect.width() - m_legend->size().width();
qreal height = legendRect.height() - m_legend->size().height();
QPointF pos = legendRect.topLeft();
if (width > 0) {
pos.setX(pos.x() + width/2);
}
if (height > 0) {
pos.setY(pos.y() + height/2);
}
sauimone
legend layout with padding
r799
sauimone
improved legend layout
r783 m_legend->setPos(pos);
Michal Klocek
Adds force option to chartTheme...
r645 }
Michal Klocek
Adds PIMPL to qchart
r740 void QChartPrivate::updateLayout()
Michal Klocek
Adds force option to chartTheme...
r645 {
Michal Klocek
Polishing qchart class
r742 if (!m_rect.isValid()) return;
sauimone
legend pos to theme example, legend padding
r803 int padding = m_padding.top();
Michal Klocek
Polishing qchart class
r742 int backgroundPadding = m_presenter->backgroundPadding();
Michal Klocek
Adds PIMPL to qchart
r740
// recalculate title position
if (m_titleItem) {
QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
Michal Klocek
Polishing qchart class
r742 m_titleItem->setPos(center.x(),m_rect.top()/2 + padding/2);
Michal Klocek
Adds PIMPL to qchart
r740 }
//recalculate background gradient
if (m_backgroundItem) {
Michal Klocek
Polishing qchart class
r742 m_backgroundItem->setRect(m_rect.adjusted(backgroundPadding,backgroundPadding, -backgroundPadding, -backgroundPadding));
Michal Klocek
Adds PIMPL to qchart
r740 }
Michal Klocek
Adds force option to chartTheme...
r645
Michal Klocek
Adds PIMPL to qchart
r740 // recalculate legend position
if (m_legend) {
sauimone
legend layout with padding
r799 if ((m_legend->attachedToChart()) && (m_legend->parentObject() == q_ptr)) {
Michal Klocek
Adds PIMPL to qchart
r740 updateLegendLayout();
}
}
}
Michal Klocek
Adds force option to chartTheme...
r645
Tero Ahola
Draft implementation for setting color themes for a chart
r64 #include "moc_qchart.cpp"
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48
Tero Ahola
Renamed to QtCommercialChart
r30 QTCOMMERCIALCHART_END_NAMESPACE