KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
KDChartLegend.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Chart library.
4**
5** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
11#ifndef KDCHARTLEGEND_H
12#define KDCHARTLEGEND_H
13
16#include "KDChartPosition.h"
17
18class QTextTable;
19
20namespace KDChart {
21
22class AbstractDiagram;
25
43class KDCHART_EXPORT Legend : public AbstractAreaWidget
44{
45 Q_OBJECT
46
47 Q_DISABLE_COPY(Legend)
49
50public:
51 explicit Legend(QWidget *parent = nullptr);
52 explicit Legend(KDChart::AbstractDiagram *diagram, QWidget *parent = nullptr);
53 ~Legend() override;
54
56 {
57 MarkersOnly = 0,
58 LinesOnly = 1,
59 MarkersAndLines = 2
60 };
61
62 void setLegendStyle(LegendStyle style);
63 LegendStyle legendStyle() const;
64
65 virtual Legend *clone() const;
66
70 bool compare(const Legend *other) const;
71
72 void resizeEvent(QResizeEvent *event) override; // TODO: should be protected
73
74 void paint(QPainter *painter) override;
75 void setVisible(bool visible) override;
76
92 void setReferenceArea(const QWidget *area);
100 const QWidget *referenceArea() const;
101
108 KDChart::AbstractDiagram *diagram() const;
109
116 DiagramList diagrams() const;
117
121 ConstDiagramList constDiagrams() const;
122
129 void addDiagram(KDChart::AbstractDiagram *newDiagram);
130
136 void removeDiagram(KDChart::AbstractDiagram *oldDiagram);
137
143 void removeDiagrams();
144
159 void replaceDiagram(KDChart::AbstractDiagram *newDiagram,
160 KDChart::AbstractDiagram *oldDiagram = nullptr);
161
166 uint dataSetOffset(KDChart::AbstractDiagram *diagram);
167
176 void setDiagram(KDChart::AbstractDiagram *newDiagram);
177
186 void setPosition(Position position);
187
192 Position position() const;
193
202 void setAlignment(Qt::Alignment);
203
208 Qt::Alignment alignment() const;
209
215 void setTextAlignment(Qt::Alignment);
216
222 Qt::Alignment textAlignment() const;
223
230 void setLegendSymbolAlignment(Qt::Alignment);
231
238 Qt::Alignment legendSymbolAlignment() const;
239
284 void setFloatingPosition(const RelativePosition &relativePosition);
285
290 const RelativePosition floatingPosition() const;
291
292 void setOrientation(Qt::Orientation orientation);
293 Qt::Orientation orientation() const;
294
295 void setSortOrder(Qt::SortOrder order);
296 Qt::SortOrder sortOrder() const;
297
298 void setShowLines(bool legendShowLines);
299 bool showLines() const;
300
301 void resetTexts();
302 void setText(uint dataset, const QString &text);
303 QString text(uint dataset) const;
304 const QMap<uint, QString> texts() const;
305
313 void setHiddenDatasets(const QList<uint> &hiddenDatasets);
314 const QList<uint> hiddenDatasets() const;
315 void setDatasetHidden(uint dataset, bool hidden);
316 bool datasetIsHidden(uint dataset) const;
317
318 uint datasetCount() const;
319
320 void setDefaultColors();
321 void setRainbowColors();
322 void setSubduedColors(bool ordered = false);
323
324 void setBrushesFromDiagram(KDChart::AbstractDiagram *diagram);
325
331 void setColor(uint dataset, const QColor &color);
332
333 void setBrush(uint dataset, const QBrush &brush);
334 QBrush brush(uint dataset) const;
335 const QMap<uint, QBrush> brushes() const;
336
337 void setPen(uint dataset, const QPen &pen);
338 QPen pen(uint dataset) const;
339 const QMap<uint, QPen> pens() const;
340
346 void setMarkerAttributes(uint dataset, const MarkerAttributes &);
347 MarkerAttributes markerAttributes(uint dataset) const;
348 const QMap<uint, MarkerAttributes> markerAttributes() const;
349
357 void setUseAutomaticMarkerSize(bool useAutomaticMarkerSize);
358 bool useAutomaticMarkerSize() const;
359
360 void setTextAttributes(const TextAttributes &a);
361 TextAttributes textAttributes() const;
362
363 void setTitleText(const QString &text);
364 QString titleText() const;
365
366 void setTitleTextAttributes(const TextAttributes &a);
367 TextAttributes titleTextAttributes() const;
368
369 void setSpacing(uint space);
370 uint spacing() const;
371
372 // called internally by KDChart::Chart, when painting into a custom QPainter
373 void forceRebuild() override;
374
375 QSize minimumSizeHint() const override;
376 QSize sizeHint() const override;
377 bool hasHeightForWidth() const override;
378 int heightForWidth(int width) const override;
379 void needSizeHint() override;
380 void resizeLayout(const QSize &size) override;
381
382Q_SIGNALS:
386
387private Q_SLOTS:
388 void emitPositionChanged();
389 void resetDiagram(AbstractDiagram *);
390 void activateTheLayout();
391 void setNeedRebuild();
392 void buildLegend();
393}; // End of class Legend
394}
395
396#endif // KDCHARTLEGEND_H
#define KDCHART_DECLARE_PRIVATE_DERIVED_QWIDGET(X)
An area in the chart with a background, a frame, etc.
AbstractDiagram defines the interface for diagram classes.
Legend defines the interface for the legend drawing class.
void propertiesChanged()
void destroyedLegend(Legend *)
A set of attributes controlling the appearance of data set markers.
Defines a position, using compass terminology.
Defines relative position information: reference area, position in this area (reference position),...
A set of text attributes.
QList< const AbstractDiagram * > ConstDiagramList
QList< AbstractDiagram * > DiagramList
typedef Alignment
Orientation
SortOrder

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated on Wed May 1 2024 00:01:10 for KD Chart API Documentation by doxygen 1.9.8