##// END OF EJS Templates
Added HTML support for various text items...
Added HTML support for various text items - HTML tags can now be used in chart titles, legends, and labels - '\n' does no longer cause line break in multi-line text items. HTML tag <br/> can be used for line break now. - Setting pen for axis titles and labels is deprecated - When setting brush for titles and labels, only the color is relevant - Logic for identifying label format specifiers was improved, so adding additional information to labels via label format string is now more viable. Task-number: QTRD-1912 Change-Id: I8fa56df56fd656e2a3e427eff4abf3481435eec7 Reviewed-by: Mika Salmela <mika.salmela@digia.com>

File last commit:

r2516:567bb8091928
r2539:74f3dbde7a75
Show More
qsplineseries.cpp
153 lines | 4.4 KiB | text/x-c | CppLexer
/****************************************************************************
**
** Copyright (C) 2013 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$
**
****************************************************************************/
#include "qsplineseries.h"
#include "qsplineseries_p.h"
#include "splinechartitem_p.h"
#include "chartdataset_p.h"
#include "charttheme_p.h"
#include "splineanimation_p.h"
#include "qchart_p.h"
/*!
\class QSplineSeries
\brief Series type used to store data needed to draw a spline.
QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline
Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn.
\image examples_splinechart.png
Creating basic spline chart is simple:
\code
QSplineSeries* series = new QSplineSeries();
series->append(0, 6);
series->append(2, 4);
...
chart->addSeries(series);
\endcode
*/
/*!
\qmlclass SplineSeries QSplineSeries
\inherits XYSeries
The following QML shows how to create a simple spline chart:
\snippet ../demos/qmlchart/qml/qmlchart/View3.qml 1
\beginfloatleft
\image demos_qmlchart3.png
\endfloat
\clearfloat
*/
/*!
\fn QSeriesType QSplineSeries::type() const
Returns the type of the series
*/
/*!
\qmlproperty real SplineSeries::width
The width of the line. By default the width is 2.0.
*/
/*!
\qmlproperty Qt::PenStyle SplineSeries::style
Controls the style of the line. Set to one of Qt.NoPen, Qt.SolidLine, Qt.DashLine, Qt.DotLine,
Qt.DashDotLine or Qt.DashDotDotLine. Using Qt.CustomDashLine is not supported in the QML API.
By default the style is Qt.SolidLine.
*/
/*!
\qmlproperty Qt::PenCapStyle SplineSeries::capStyle
Controls the cap style of the line. Set to one of Qt.FlatCap, Qt.SquareCap or Qt.RoundCap. By
default the cap style is Qt.SquareCap.
*/
QTCOMMERCIALCHART_BEGIN_NAMESPACE
/*!
Constructs empty series object which is a child of \a parent.
When series object is added to a QChart instance then the ownerships is transferred.
*/
QSplineSeries::QSplineSeries(QObject *parent)
: QLineSeries(*new QSplineSeriesPrivate(this), parent)
{
}
/*!
Destroys the object.
*/
QSplineSeries::~QSplineSeries()
{
Q_D(QSplineSeries);
if (d->m_chart)
d->m_chart->removeSeries(this);
}
QAbstractSeries::SeriesType QSplineSeries::type() const
{
return QAbstractSeries::SeriesTypeSpline;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QSplineSeriesPrivate::QSplineSeriesPrivate(QSplineSeries *q)
: QLineSeriesPrivate(q)
{
}
void QSplineSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
{
Q_Q(QSplineSeries);
SplineChartItem *spline = new SplineChartItem(q,parent);
m_item.reset(spline);
QAbstractSeriesPrivate::initializeGraphics(parent);
}
void QSplineSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced)
{
Q_Q(QSplineSeries);
const QList<QColor> colors = theme->seriesColors();
if (forced || QChartPrivate::defaultPen() == m_pen) {
QPen pen;
pen.setColor(colors.at(index % colors.size()));
pen.setWidthF(2);
q->setPen(pen);
}
}
void QSplineSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options)
{
SplineChartItem *item = static_cast<SplineChartItem *>(m_item.data());
Q_ASSERT(item);
if (options.testFlag(QChart::SeriesAnimations)) {
item->setAnimation(new SplineAnimation(item));
}else{
item->setAnimation(0);
}
QAbstractSeriesPrivate::initializeAnimations(options);
}
#include "moc_qsplineseries.cpp"
#include "moc_qsplineseries_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE