Wt 3.1.10
Public Member Functions | Protected Member Functions | Private Member Functions
Wt::Chart::WPieChart Class Reference

A pie chart. More...

#include <Wt/Chart/WPieChart>

Inheritance diagram for Wt::Chart::WPieChart:
Inheritance graph
[legend]

List of all members.

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 setShadowEnabled (bool enabled)
 Enables a shadow effect.
bool isShadowEnabled () const
 Returns whether a shadow 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< LabelOptiondisplayLabels () const
 Returns options set for displaying labels.
WWidgetcreateLegendItemWidget (int index, WFlags< LabelOption > options)
 Creates a widget which renders the a legend item.
virtual void addDataPointArea (const WModelIndex &index, WAbstractArea *area) const
 Adds a data point area (used for displaying e.g. tooltips).
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.

Detailed Description

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().

CSS

Styling through CSS is not applicable.

ChartWPieChart-1.png
Example of a pie chart
See also:
WCartesianChart

Member Function Documentation

void Wt::Chart::WPieChart::addDataPointArea ( const WModelIndex index,
WAbstractArea area 
) const [virtual]

Adds a data point area (used for displaying e.g. tooltips).

You may want to specialize this is if you wish to modify (or delete) the area.

Note:
Currently, an area is only created if the ToolTipRole data at the data point is not empty.
WBrush Wt::Chart::WPieChart::brush ( int  modelRow) const

Returns the brush used for a pie segment.

See also:
setBrush(int, const WBrush&)
WWidget * Wt::Chart::WPieChart::createLegendItemWidget ( int  index,
WFlags< LabelOption options 
)

Creates a widget which renders the a legend item.

Depending on the passed LabelOption flags, the legend item widget, will contain a text (with or without the percentage) and/or a span with the segment's color.

int Wt::Chart::WPieChart::dataColumn ( ) const

Returns the model column used for the data.

See also:
setDataColumn(int)
WFlags<LabelOption> Wt::Chart::WPieChart::displayLabels ( ) const

Returns options set for displaying labels.

See also:
WPieChart::setDisplayLabels()
double Wt::Chart::WPieChart::explode ( int  modelRow) const

Returns the explosion factor for a segment.

See also:
setExplode(int, double)
bool Wt::Chart::WPieChart::isPerspectiveEnabled ( ) const

Returns whether a 3D effect is enabled.

See also:
setPerspectiveEnabled(bool, double)
bool Wt::Chart::WPieChart::isShadowEnabled ( ) const

Returns whether a shadow effect is enabled.

See also:
setShadowEnabled()
int Wt::Chart::WPieChart::labelsColumn ( ) const

Returns the model column used for the labels.

See also:
setLabelsColumn(int)
void Wt::Chart::WPieChart::modelChanged ( ) [private, virtual]

Method called whenever the entire model was changed.

See also:
setModel(WAbstractItemModel *)

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.

See also:
WAbstractItemModel::columnsInserted

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.

See also:
WAbstractItemModel::columnsRemoved

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.

See also:
WAbstractItemModel::dataChanged

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.

See also:
WAbstractItemModel::rowsInserted

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.

See also:
WAbstractItemModel::rowsRemoved

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.

See also:
setPalette(WChartPalette *)
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).

See also:
setModel(WAbstractItemModel *), setLabelsColumn(int)
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).

See also:
setModel(WAbstractItemModel *), setDisplayLabels(), setDataColumn(int)
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::setShadowEnabled ( bool  enabled)

Enables a shadow effect.

A soft shadow effect is added.

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

Returns the angle of the first segment.

See also:
setStartAngle(double)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Generated on Wed Jul 27 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.4