KD Chart 2  [rev.2.7]
KDChartWidget.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef __KDCHARTWIDGET_H__
24 #define __KDCHARTWIDGET_H__
25 
26 #include "KDChartGlobal.h"
27 
28 #include <QWidget>
29 
30 #include "KDChartEnums.h"
31 #include "KDChartHeaderFooter.h"
32 
33 QT_BEGIN_NAMESPACE
34 template <typename T> class QVector;
35 template <typename T1, typename T2> struct QPair;
36 QT_END_NAMESPACE
37 
38 namespace KDChart {
39 
40  // some forward declarations
41  class AbstractDiagram;
42  class Chart;
43  class AbstractCoordinatePlane;
44  class TableModel;
45  class BarDiagram;
46  class LineDiagram;
47  class Plotter;
48  class PieDiagram;
49  class RingDiagram;
50  class PolarDiagram;
51  class Legend;
52  class Position;
53 
60  class KDCHART_EXPORT Widget : public QWidget
61  {
62  Q_OBJECT
63 
64  Q_DISABLE_COPY( Widget )
66 
67  public:
75  explicit Widget( QWidget* parent = 0 );
76 
78  ~Widget() override;
80  void setDataset( int column, const QVector< qreal > & data, const QString& title = QString() );
83  void setDataset( int column, const QVector< QPair< qreal, qreal > > & data, const QString& title = QString() );
85  void setDataCell( int row, int column, qreal data );
87  void setDataCell( int row, int column, QPair< qreal, qreal > data );
89  void resetData();
90 
91  public Q_SLOTS:
93  void setGlobalLeading( int left, int top, int right, int bottom );
95  void setGlobalLeadingLeft( int leading );
97  void setGlobalLeadingTop( int leading );
99  void setGlobalLeadingRight( int leading );
101  void setGlobalLeadingBottom( int leading );
102 
103  public:
105  int globalLeadingLeft() const;
107  int globalLeadingTop() const;
109  int globalLeadingRight() const;
111  int globalLeadingBottom() const;
112 
114  HeaderFooter* firstHeaderFooter();
116  QList<HeaderFooter*> allHeadersFooters();
117 
119  void addHeaderFooter( const QString& text,
121  Position position );
122 
127  void addHeaderFooter( HeaderFooter* header );
128 
146  void replaceHeaderFooter( HeaderFooter* header,
147  HeaderFooter* oldHeader = 0 );
148 
156  void takeHeaderFooter( HeaderFooter* header );
157 
159  Legend* legend();
161  QList<Legend*> allLegends();
162 
164  void addLegend( Position position );
166  void addLegend (Legend* legend );
167 
168  void replaceLegend( Legend* legend, Legend* oldLegend = 0 );
169  void takeLegend( Legend* legend );
170 
171 
173  AbstractDiagram* diagram();
174 
178  BarDiagram* barDiagram();
182  LineDiagram* lineDiagram();
190  Plotter* plotter();
194  PieDiagram* pieDiagram();
198  RingDiagram* ringDiagram();
202  PolarDiagram* polarDiagram();
203 
205  AbstractCoordinatePlane* coordinatePlane();
206 
207 
208  enum ChartType { NoType, Bar, Line, Plot, Pie, Ring, Polar };
209 
211  ChartType type() const;
212 
214  enum SubType { Normal, Stacked, Percent, Rows };
215 
217  SubType subType() const;
218 
219  public Q_SLOTS:
221  void setType( ChartType chartType, SubType subType=Normal );
232  void setSubType( SubType subType );
233 
234  private:
236  void justifyModelSize( int rows, int columns );
238  bool checkDatasetWidth( int width );
239  };
240 }
241 
242 #endif // KDChartWidget_H
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
SubType
Sub type values, matching the values defines for the respective Diagram classes.
Definition of global enums.
#define KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET(X)
Definition: KDChartGlobal.h:93
PolarDiagram defines a common polar diagram.
BarDiagram defines a common bar diagram.
Plotter defines a diagram type plotting two-dimensional data.
AbstractDiagram defines the interface for diagram classes.
Legend defines the interface for the legend drawing class.
Definition: KDChartLegend.h:55
LineDiagram defines a common line diagram.
The KD Chart widget for usage without Model/View.
Definition: KDChartWidget.h:60
Defines a position, using compass terminology.
PieDiagram defines a common pie diagram.
Class only listed here to document inheritance of some KDChart classes.
RingDiagram defines a common ring diagram.

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/