A pie chart. More...
#include <Wt/Chart/WPieChart>
Public Member Functions | |
WPieChart (WContainerWidget *parent=0) | |
Creates a new pie chart. | |
void | setLabelsColumn (int column) |
Sets the model column that holds the labels. | |
int | labelsColumn () const |
Returns the model column used for the labels. | |
void | setDataColumn (int modelColumn) |
Sets the model column that holds the data. | |
int | dataColumn () const |
Returns the model column used for the data. | |
void | setBrush (int modelRow, const WBrush &brush) |
Customizes the brush used for a pie segment. | |
WBrush | brush (int modelRow) const |
Returns the brush used for a pie segment. | |
void | setExplode (int modelRow, double factor) |
Sets the explosion factor for a pie segment. | |
double | explode (int modelRow) const |
Returns the explosion factor for a segment. | |
void | setPerspectiveEnabled (bool enabled, double height=1.0) |
Enables a 3D perspective effect on the pie. | |
bool | isPerspectiveEnabled () const |
Returns whether a 3D effect is enabled. | |
void | setStartAngle (double degrees) |
Sets the angle of the first segment. | |
double | startAngle () const |
Returns the angle of the first segment. | |
void | setDisplayLabels (WFlags< LabelOption > options) |
Configures if and how labels should be displayed. | |
WFlags< LabelOption > | displayLabels () const |
Returns options set for displaying labels. | |
virtual void | paint (WPainter &painter, const WRectF &rectangle=WRectF()) const |
Paint the chart in a rectangle of the given painter. | |
Protected Member Functions | |
void | paintEvent (Wt::WPaintDevice *paintDevice) |
Paints the widget. | |
Private Member Functions | |
virtual void | modelChanged () |
Method called whenever the entire model was changed. | |
virtual void | modelReset () |
Method called whenever the entire model was reset. | |
virtual void | modelColumnsInserted (const WModelIndex &parent, int start, int end) |
Method called when colums have been inserted in the model. | |
virtual void | modelColumnsRemoved (const WModelIndex &parent, int start, int end) |
Method called when colums have been removed from the model. | |
virtual void | modelRowsInserted (const WModelIndex &parent, int start, int end) |
Method called when rows have been inserted from the model. | |
virtual void | modelRowsRemoved (const WModelIndex &parent, int start, int end) |
Method called when rows have been removed from the model. | |
virtual void | modelDataChanged (const WModelIndex &topLeft, const WModelIndex &bottomRight) |
Method called when data has been changed in the model. |
A pie chart.
A pie chart renders a single data series as segments of a circle, so that the area of each segment is proportional to the value in the data series.
To use a pie chart, you need to set a model using setModel(), and use setLabelsColumn() and setDataColumn() to specify the model column that contains the category labels and data.
The pie chart may be customized visually by enabling a 3D effect (setPerspectiveEnabled()), or by specifying the angle of the first segment. One or more segments may be exploded, which seperates the segment from the rest of the pie chart, using setExplode().
The segments may be labeled in various ways using setDisplayLabels().
Styling through CSS is not applicable.
Example of a pie chart
WBrush Wt::Chart::WPieChart::brush | ( | int | modelRow ) | const |
Returns the brush used for a pie segment.
int Wt::Chart::WPieChart::dataColumn | ( | ) | const [inline] |
Returns the model column used for the data.
WFlags<LabelOption> Wt::Chart::WPieChart::displayLabels | ( | ) | const [inline] |
Returns options set for displaying labels.
double Wt::Chart::WPieChart::explode | ( | int | modelRow ) | const |
Returns the explosion factor for a segment.
bool Wt::Chart::WPieChart::isPerspectiveEnabled | ( | ) | const [inline] |
Returns whether a 3D effect is enabled.
int Wt::Chart::WPieChart::labelsColumn | ( | ) | const [inline] |
Returns the model column used for the labels.
void Wt::Chart::WPieChart::modelChanged | ( | ) | [private, virtual] |
Method called whenever the entire model was changed.
Reimplemented from Wt::Chart::WAbstractChart.
void Wt::Chart::WPieChart::modelColumnsInserted | ( | const WModelIndex & | parent, |
int | start, | ||
int | end | ||
) | [private, virtual] |
Method called when colums have been inserted in the model.
Implements Wt::Chart::WAbstractChart.
void Wt::Chart::WPieChart::modelColumnsRemoved | ( | const WModelIndex & | parent, |
int | start, | ||
int | end | ||
) | [private, virtual] |
Method called when colums have been removed from the model.
Implements Wt::Chart::WAbstractChart.
void Wt::Chart::WPieChart::modelDataChanged | ( | const WModelIndex & | topLeft, |
const WModelIndex & | bottomRight | ||
) | [private, virtual] |
Method called when data has been changed in the model.
Implements Wt::Chart::WAbstractChart.
void Wt::Chart::WPieChart::modelReset | ( | ) | [private, virtual] |
Method called whenever the entire model was reset.
Bound to the WAbstractItemModel::modelReset() and WAbstractItemModel::layoutChanged() signals.
Reimplemented from Wt::Chart::WAbstractChart.
void Wt::Chart::WPieChart::modelRowsInserted | ( | const WModelIndex & | parent, |
int | start, | ||
int | end | ||
) | [private, virtual] |
Method called when rows have been inserted from the model.
Implements Wt::Chart::WAbstractChart.
void Wt::Chart::WPieChart::modelRowsRemoved | ( | const WModelIndex & | parent, |
int | start, | ||
int | end | ||
) | [private, virtual] |
Method called when rows have been removed from the model.
Implements Wt::Chart::WAbstractChart.
void Wt::Chart::WPieChart::paint | ( | WPainter & | painter, |
const WRectF & | rectangle = WRectF() |
||
) | const [virtual] |
Paint the chart in a rectangle of the given painter.
Paints the chart inside the painter, in the area indicated by rectangle. When rectangle is a null rectangle, the entire painter window is used.
Implements Wt::Chart::WAbstractChart.
void Wt::Chart::WPieChart::paintEvent | ( | Wt::WPaintDevice * | paintDevice ) | [protected, virtual] |
Paints the widget.
You should reimplement this method to paint the contents of the widget, using the given paintDevice.
Implements Wt::WPaintedWidget.
void Wt::Chart::WPieChart::setBrush | ( | int | modelRow, |
const WBrush & | brush | ||
) |
Customizes the brush used for a pie segment.
By default, the brush is taken from the palette(). You can use this method to override the palette's brush for a particular modelRow.
void Wt::Chart::WPieChart::setDataColumn | ( | int | modelColumn ) |
Sets the model column that holds the data.
The data column should contain data that can be converted to a number, but should not necessarily be of a number type, see also asNumber(const boost::any&).
The default value is -1 (not defined).
void Wt::Chart::WPieChart::setDisplayLabels | ( | WFlags< LabelOption > | options ) |
Configures if and how labels should be displayed.
The options must be the logical OR of a placement option (Inside or Outside) and TextLabel and/or TextPercentage. If both TextLabel and TextPercentage are specified, then these are combined as "<label>: <percentage>".
The default value is NoLabels.
void Wt::Chart::WPieChart::setExplode | ( | int | modelRow, |
double | factor | ||
) |
Sets the explosion factor for a pie segment.
Separates the segment corresponding to model row modelRow from the rest of the pie. The factor is a positive number that represents the distance from the center as a fraction of the pie radius. Thus, 0 corresponds to no separation, and 0.1 to a 10% separation, and 1 to a separation where the segment tip is on the outer perimeter of the pie.
The default value is 0.
void Wt::Chart::WPieChart::setLabelsColumn | ( | int | column ) |
Sets the model column that holds the labels.
The labels are used only when setDisplayLabels() is called with the TextLabel option.
The default value is -1 (not defined).
void Wt::Chart::WPieChart::setPerspectiveEnabled | ( | bool | enabled, |
double | height = 1.0 |
||
) |
Enables a 3D perspective effect on the pie.
A 3D perspective effect is added, which may be customized by specifying the simulated height of the pie. The height is defined as a fraction of the pie radius.
The default value is false.
void Wt::Chart::WPieChart::setStartAngle | ( | double | degrees ) |
Sets the angle of the first segment.
The default value is 45 degrees.
double Wt::Chart::WPieChart::startAngle | ( | ) | const [inline] |
Returns the angle of the first segment.