KD Chart API Documentation  3.1
Public Types | Public Slots | Public Member Functions | List of all members
KDChart::Widget Class Reference

The KD Chart widget for usage without Model/View. More...

#include <KDChartWidget.h>

Inheritance diagram for KDChart::Widget:

Public Types

enum  ChartType {
  NoType , Bar , Line , Plot ,
  Pie , Ring , Polar
}
 
enum  SubType { Normal , Stacked , Percent , Rows }
 

Public Slots

void setGlobalLeading (int left, int top, int right, int bottom)
 
void setGlobalLeadingBottom (int leading)
 
void setGlobalLeadingLeft (int leading)
 
void setGlobalLeadingRight (int leading)
 
void setGlobalLeadingTop (int leading)
 
void setSubType (SubType subType)
 Sets the type of the chart without changing the main type. More...
 
void setType (ChartType chartType, SubType subType=Normal)
 

Public Member Functions

 Widget (QWidget *parent=nullptr)
 
 ~Widget () override
 
void addHeaderFooter (const QString &text, HeaderFooter::HeaderFooterType type, Position position)
 
void addHeaderFooter (HeaderFooter *header)
 
void addLegend (Legend *legend)
 
void addLegend (Position position)
 
QList< HeaderFooter * > allHeadersFooters ()
 
QList< Legend * > allLegends ()
 
BarDiagrambarDiagram ()
 
AbstractCoordinatePlanecoordinatePlane ()
 
AbstractDiagramdiagram ()
 
HeaderFooterfirstHeaderFooter ()
 
int globalLeadingBottom () const
 
int globalLeadingLeft () const
 
int globalLeadingRight () const
 
int globalLeadingTop () const
 
Legendlegend ()
 
LineDiagramlineDiagram ()
 
PieDiagrampieDiagram ()
 
Plotterplotter ()
 
PolarDiagrampolarDiagram ()
 
void replaceHeaderFooter (HeaderFooter *header, HeaderFooter *oldHeader=nullptr)
 
void replaceLegend (Legend *legend, Legend *oldLegend=nullptr)
 
void resetData ()
 
RingDiagramringDiagram ()
 
void setDataCell (int row, int column, QPair< qreal, qreal > data)
 
void setDataCell (int row, int column, qreal data)
 
void setDataset (int column, const QVector< QPair< qreal, qreal >> &data, const QString &title=QString())
 
void setDataset (int column, const QVector< qreal > &data, const QString &title=QString())
 
SubType subType () const
 
void takeHeaderFooter (HeaderFooter *header)
 
void takeLegend (Legend *legend)
 
ChartType type () const
 

Detailed Description

The KD Chart widget for usage without Model/View.

If you want to use KD Chart with Model/View, use KDChart::Chart instead.

Definition at line 44 of file KDChartWidget.h.

Member Enumeration Documentation

◆ ChartType

Enumerator
NoType 
Bar 
Line 
Plot 
Pie 
Ring 
Polar 

Definition at line 190 of file KDChartWidget.h.

◆ SubType

Sub type values, matching the values defines for the respective Diagram classes.

Enumerator
Normal 
Stacked 
Percent 
Rows 

Definition at line 205 of file KDChartWidget.h.

Constructor & Destructor Documentation

◆ Widget()

Widget::Widget ( QWidget *  parent = nullptr)
explicit

Standard Qt-style Constructor

Creates a new widget with all data initialized empty.

Parameters
parentthe widget parent; passed on to QWidget

Constructor. Creates a new widget with all data initialized empty.

Parameters
parentthe widget parent; passed on to QWidget

Definition at line 65 of file KDChartWidget.cpp.

References Line, and setType().

◆ ~Widget()

Widget::~Widget ( )
override

Destructor.

Definition at line 77 of file KDChartWidget.cpp.

Member Function Documentation

◆ addHeaderFooter() [1/2]

void Widget::addHeaderFooter ( const QString &  text,
HeaderFooter::HeaderFooterType  type,
Position  position 
)

Adds a new header/footer with the given text to the position.

Definition at line 254 of file KDChartWidget.cpp.

References d, and type().

◆ addHeaderFooter() [2/2]

void Widget::addHeaderFooter ( HeaderFooter header)

Adds the existing header / footer object header.

See also
replaceHeaderFooter, takeHeaderFooter

Adds an existing header / footer object.

Definition at line 268 of file KDChartWidget.cpp.

References d, and KDChart::HeaderFooter::setParent().

◆ addLegend() [1/2]

void Widget::addLegend ( Legend legend)

Adds a new, already existing, legend.

Definition at line 314 of file KDChartWidget.cpp.

References d, diagram(), legend(), and KDChart::Legend::setDiagram().

◆ addLegend() [2/2]

void Widget::addLegend ( Position  position)

Adds an empty legend on the given position.

Definition at line 304 of file KDChartWidget.cpp.

References d, diagram(), legend(), and KDChart::Legend::setPosition().

◆ allHeadersFooters()

QList< KDChart::HeaderFooter * > Widget::allHeadersFooters ( )

Returns a list with all headers.

Definition at line 246 of file KDChartWidget.cpp.

References d.

◆ allLegends()

QList< KDChart::Legend * > Widget::allLegends ( )

Returns a list with all legends.

Definition at line 296 of file KDChartWidget.cpp.

References d.

◆ barDiagram()

BarDiagram * Widget::barDiagram ( )

If the current diagram is a BarDiagram, it is returned; otherwise 0 is returned. This function provides type-safe casting.

Definition at line 341 of file KDChartWidget.cpp.

References diagram().

◆ coordinatePlane()

AbstractCoordinatePlane * Widget::coordinatePlane ( )

Returns a pointer to the current coordinate plane.

Definition at line 366 of file KDChartWidget.cpp.

References d.

Referenced by diagram(), and setType().

◆ diagram()

AbstractDiagram * Widget::diagram ( )

◆ firstHeaderFooter()

KDChart::HeaderFooter * Widget::firstHeaderFooter ( )

Returns the first of all headers.

Definition at line 238 of file KDChartWidget.cpp.

References d.

◆ globalLeadingBottom()

int Widget::globalLeadingBottom ( ) const

Returns the bottom leading (border).

Definition at line 230 of file KDChartWidget.cpp.

References d.

◆ globalLeadingLeft()

int Widget::globalLeadingLeft ( ) const

Returns the left leading (border).

Definition at line 182 of file KDChartWidget.cpp.

References d.

◆ globalLeadingRight()

int Widget::globalLeadingRight ( ) const

Returns the right leading (border).

Definition at line 214 of file KDChartWidget.cpp.

References d.

◆ globalLeadingTop()

int Widget::globalLeadingTop ( ) const

Returns the top leading (border).

Definition at line 198 of file KDChartWidget.cpp.

References d.

◆ legend()

KDChart::Legend * Widget::legend ( )

Returns the first of all legends.

Definition at line 288 of file KDChartWidget.cpp.

References d.

Referenced by addLegend(), replaceLegend(), and takeLegend().

◆ lineDiagram()

LineDiagram * Widget::lineDiagram ( )

If the current diagram is a LineDiagram, it is returned; otherwise 0 is returned. This function provides type-safe casting.

Definition at line 345 of file KDChartWidget.cpp.

References diagram().

◆ pieDiagram()

PieDiagram * Widget::pieDiagram ( )

If the current diagram is a Plotter, it is returned; otherwise 0 is returned. This function provides type-safe casting.

Definition at line 353 of file KDChartWidget.cpp.

References diagram().

◆ plotter()

Plotter * Widget::plotter ( )

If the current diagram is a LineDiagram, it is returned; otherwise 0 is returned. This function provides type-safe casting.

Note
Do not use lineDiagram for multi-dimensional diagrams, but use plotter instead
See also
plotter

Definition at line 349 of file KDChartWidget.cpp.

References diagram().

◆ polarDiagram()

PolarDiagram * Widget::polarDiagram ( )

If the current diagram is a PolarDiagram, it is returned; otherwise 0 is returned. This function provides type-safe casting.

Definition at line 361 of file KDChartWidget.cpp.

References diagram().

◆ replaceHeaderFooter()

void Widget::replaceHeaderFooter ( HeaderFooter header,
HeaderFooter oldHeader = nullptr 
)

Replaces the old header (or footer, resp.), or appends the new header or footer, it there is none yet.

Parameters
headerThe header or footer to be used instead of the old one. This parameter must not be zero, or the method will do nothing.
oldHeaderThe header or footer to be removed by the new one. This header or footer will be deleted automatically. If the parameter is omitted, the very first header or footer will be replaced. In case, there was no header and no footer yet, the new header or footer will just be added.
Note
If you want to re-use the old header or footer, call takeHeaderFooter and addHeaderFooter, instead of using replaceHeaderFooter.
See also
addHeaderFooter, takeHeaderFooter

Definition at line 274 of file KDChartWidget.cpp.

References d, and KDChart::HeaderFooter::setParent().

◆ replaceLegend()

void Widget::replaceLegend ( Legend legend,
Legend oldLegend = nullptr 
)

Definition at line 321 of file KDChartWidget.cpp.

References d, diagram(), legend(), and KDChart::Legend::setDiagram().

◆ resetData()

void Widget::resetData ( )

Resets all data.

Definition at line 157 of file KDChartWidget.cpp.

References d.

◆ ringDiagram()

RingDiagram * Widget::ringDiagram ( )

If the current diagram is a RingDiagram, it is returned; otherwise 0 is returned. This function provides type-safe casting.

Definition at line 357 of file KDChartWidget.cpp.

References diagram().

◆ setDataCell() [1/2]

void Widget::setDataCell ( int  row,
int  column,
QPair< qreal, qreal >  data 
)

Sets the data for a given column using an (X, Y) QPair of qreals.

Definition at line 138 of file KDChartWidget.cpp.

References d.

◆ setDataCell() [2/2]

void Widget::setDataCell ( int  row,
int  column,
qreal  data 
)

Sets the Y value data for a given cell.

Definition at line 125 of file KDChartWidget.cpp.

References d.

◆ setDataset() [1/2]

void Widget::setDataset ( int  column,
const QVector< QPair< qreal, qreal >> &  data,
const QString &  title = QString() 
)

Sets the data in the given column using a QVector of QPairs of qreal for the (X, Y) values.

Definition at line 104 of file KDChartWidget.cpp.

References d.

◆ setDataset() [2/2]

void Widget::setDataset ( int  column,
const QVector< qreal > &  data,
const QString &  title = QString() 
)

Sets the data in the given column using a QVector of qreal for the Y values.

Definition at line 87 of file KDChartWidget.cpp.

References d.

◆ setGlobalLeading

void Widget::setGlobalLeading ( int  left,
int  top,
int  right,
int  bottom 
)
slot

Sets all global leadings (borders).

Definition at line 166 of file KDChartWidget.cpp.

References d.

◆ setGlobalLeadingBottom

void Widget::setGlobalLeadingBottom ( int  leading)
slot

Sets the bottom leading (border).

Definition at line 222 of file KDChartWidget.cpp.

References d.

◆ setGlobalLeadingLeft

void Widget::setGlobalLeadingLeft ( int  leading)
slot

Sets the left leading (border).

Definition at line 174 of file KDChartWidget.cpp.

References d.

◆ setGlobalLeadingRight

void Widget::setGlobalLeadingRight ( int  leading)
slot

Sets the right leading (border).

Definition at line 206 of file KDChartWidget.cpp.

References d.

◆ setGlobalLeadingTop

void Widget::setGlobalLeadingTop ( int  leading)
slot

Sets the top leading (border).

Definition at line 190 of file KDChartWidget.cpp.

References d.

◆ setSubType

void Widget::setSubType ( SubType  subType)
slot

Sets the type of the chart without changing the main type.

Make sure to use a sub-type that matches the main type, so e.g. setting sub-type Rows makes sense for Bar charts only, and it will be ignored for all other chart types.

See also
KDChartBarDiagram::BarType, KDChartLineDiagram::LineType
KDChartPieDiagram::PieType, KDChartRingDiagram::RingType
KDChartPolarDiagram::PolarType

Definition at line 469 of file KDChartWidget.cpp.

References diagram(), KDChart::BarDiagram::Normal, KDChart::LineDiagram::Normal, KDChart::Plotter::Normal, Normal, KDChart::BarDiagram::Percent, KDChart::LineDiagram::Percent, KDChart::Plotter::Percent, Percent, Rows, KDChart::BarDiagram::Stacked, KDChart::LineDiagram::Stacked, Stacked, and subType().

Referenced by setType().

◆ setType

void Widget::setType ( ChartType  chartType,
SubType  subType = Normal 
)
slot

◆ subType()

Widget::SubType Widget::subType ( ) const

◆ takeHeaderFooter()

void Widget::takeHeaderFooter ( HeaderFooter header)

Remove the header (or footer, resp.) from the widget, without deleting it. The chart no longer owns the header or footer, so it is the caller's responsibility to delete the header or footer.

See also
addHeaderFooter, replaceHeaderFooter

Definition at line 280 of file KDChartWidget.cpp.

References d.

◆ takeLegend()

void Widget::takeLegend ( Legend legend)

Definition at line 328 of file KDChartWidget.cpp.

References d, and legend().

◆ type()

Widget::ChartType Widget::type ( ) const

Returns the type of the chart.

Definition at line 502 of file KDChartWidget.cpp.

References Bar, diagram(), Line, NoType, Pie, Plot, Polar, and Ring.

Referenced by addHeaderFooter(), setType(), and subType().


The documentation for this class was generated from the following files:

© 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 by doxygen 1.9.1