12 #include "KDChartLineDiagram_p.h"
17 #include "KDChartPainterSaver_p.h"
20 #include <KDABLibFakes>
22 #include "KDChartNormalLineDiagram_p.h"
23 #include "KDChartPercentLineDiagram_p.h"
24 #include "KDChartStackedLineDiagram_p.h"
28 #include <QPainterPath>
35 LineDiagram::Private::Private()
39 LineDiagram::Private::~Private()
51 void LineDiagram::init()
53 d->normalDiagram =
new NormalLineDiagram(
this);
54 d->stackedDiagram =
new StackedLineDiagram(
this);
55 d->percentDiagram =
new PercentLineDiagram(
this);
56 d->implementor =
d->normalDiagram;
57 d->centerDataPoints =
false;
58 d->reverseDatasetOrder =
false;
63 delete d->normalDiagram;
64 delete d->stackedDiagram;
65 delete d->percentDiagram;
74 newDiagram->setType(
type());
97 if (
d->implementor->type() ==
type)
100 Q_ASSERT_X(
false,
"setType()",
101 "This line chart type can't be used with multi-dimensional data.");
106 d->implementor =
d->normalDiagram;
109 d->implementor =
d->stackedDiagram;
112 d->implementor =
d->percentDiagram;
115 Q_ASSERT_X(
false,
"LineDiagram::setType",
"unknown diagram subtype");
119 Q_ASSERT(
d->implementor->type() ==
type);
133 return d->implementor->type();
138 if (
d->centerDataPoints == center) {
142 d->centerDataPoints = center;
153 return d->centerDataPoints;
158 d->reverseDatasetOrder = reverse;
163 return d->reverseDatasetOrder;
171 d->attributesModel->setModelData(
172 QVariant::fromValue(la),
201 const QModelIndex &index,
204 d->attributesModel->setData(
205 d->attributesModel->mapFromSource(index),
206 QVariant::fromValue(la),
216 d->attributesModel->resetData(
244 const QModelIndex &index)
const
246 return d->attributesModel->data(
247 d->attributesModel->mapFromSource(index),
259 d->attributesModel->setModelData(
260 QVariant::fromValue(la),
281 const QModelIndex &index,
285 d->attributesModel->setData(
286 d->attributesModel->mapFromSource(index),
287 QVariant::fromValue(la),
316 return d->attributesModel->data(
317 d->attributesModel->mapFromSource(index),
338 d->attributesModel->setData(
d->attributesModel->mapFromSource(index),
339 QVariant::fromValue(va),
348 const QModelIndex &index)
const
350 return d->attributesModel->data(
351 d->attributesModel->mapFromSource(index),
366 d->tension = tension;
376 d->compressor.setResolution(
static_cast<int>(this->size().width() *
coordinatePlane()->zoomFactorX()),
377 static_cast<int>(this->size().height() *
coordinatePlane()->zoomFactorY()));
380 return QPair<QPointF, QPointF>(QPointF(0, 0), QPointF(0, 0));
387 return d->implementor->calculateDataBoundaries();
392 QPainter painter(viewport());
407 const PainterSaver p(ctx->
painter());
408 if (model()->rowCount(rootIndex()) == 0 || model()->columnCount(rootIndex()) == 0)
415 d->implementor->paint(ctx);
422 d->compressor.setResolution(
static_cast<int>(size.width() *
coordinatePlane()->zoomFactorX()),
425 QAbstractItemView::resize(size.toSize());
428 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && defined(Q_COMPILER_MANGLES_RETURN_TYPE)
437 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && defined(Q_COMPILER_MANGLES_RETURN_TYPE)
Base class for diagrams based on a cartesian coordianate system.
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...
virtual AbstractCoordinatePlane * sharedAxisMasterPlane(QPainter *p=nullptr)
virtual bool checkInvariants(bool justReturnTheStatus=false) const
void layoutChanged(AbstractDiagram *)
QModelIndex attributesModelRootIndex() const
returns a QModelIndex pointing into the AttributesModel that corresponds to the root index of the dia...
const QPair< QPointF, QPointF > dataBoundaries() const
Return the bottom left and top right data point, that the diagram will display (unless the grid adjus...
AbstractCoordinatePlane * coordinatePlane() const
void setDataBoundariesDirty() const
Q_DECL_DEPRECATED void setPercentMode(bool percent)
Deprecated method that turns the percent mode of this diagram on or off.
int datasetDimension() const
static bool isBoundariesValid(const QRectF &r)
Cartesian coordinate plane.
Set of attributes for changing the appearance of line charts.
LineDiagram defines a common line diagram.
void setType(const LineType type)
LineAttributes lineAttributes() const
void resizeEvent(QResizeEvent *) override
bool centerDataPoints() const
void setLineAttributes(const LineAttributes &a)
void setLineTension(qreal tenson)
LineDiagram(QWidget *parent=nullptr, CartesianCoordinatePlane *plane=nullptr)
int numberOfAbscissaSegments() const override
void paintEvent(QPaintEvent *) override
void setCenterDataPoints(bool center)
void setValueTrackerAttributes(const QModelIndex &index, const ValueTrackerAttributes &a)
qreal threeDItemDepth(const QModelIndex &index) const override
void setThreeDLineAttributes(const ThreeDLineAttributes &a)
qreal lineTension() const
virtual LineDiagram * clone() const
void resize(const QSizeF &area) override
ThreeDLineAttributes threeDLineAttributes() const
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
void resetLineAttributes(int column)
void setReverseDatasetOrder(bool reverse)
void paint(PaintContext *paintContext) override
ValueTrackerAttributes valueTrackerAttributes(const QModelIndex &index) const
bool reverseDatasetOrder() const
int numberOfOrdinateSegments() const override
bool compare(const LineDiagram *other) const
Stores information about painting diagrams.
void setPainter(QPainter *painter)
void setCoordinatePlane(AbstractCoordinatePlane *plane)
void setRectangle(const QRectF &rect)
AbstractCoordinatePlane * coordinatePlane() const
QPainter * painter() const
A set of 3D line attributes.
Cell-specific attributes regarding value tracking.
@ ThreeDLineAttributesRole
@ ValueTrackerAttributesRole