Wt::Chart::WPieChart Class Reference
[Chart library]

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)
 Create a new pie chart.
void setLabelsColumn (int column)
 Change the model column that holds the labels.
int labelsColumn () const
 Returns the model column used for the labels.
void setDataColumn (int modelColumn)
 Change 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)
 Change 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)
 Change the angle of the first segment.
double startAngle () const
 Returns the angle of the first segment.
void setDisplayLabels (int options)
 Configure if and how labels should be displayed.
int 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)
 Paint the widget.

Private Member Functions

virtual void modelChanged ()
 Method called whenever the entire model was changed.
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().

ChartWPieChart-1.png

Example of a pie chart

See also:
WCartesianChart

Member Function Documentation

void Wt::Chart::WPieChart::setLabelsColumn ( int  column  ) 

Change 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)

int Wt::Chart::WPieChart::labelsColumn (  )  const [inline]

Returns the model column used for the labels.

See also:
setLabelsColumn(int)

void Wt::Chart::WPieChart::setDataColumn ( int  modelColumn  ) 

Change 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)

int Wt::Chart::WPieChart::dataColumn (  )  const [inline]

Returns the model column used for the data.

See also:
setDataColumn(int)

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 *)

WBrush Wt::Chart::WPieChart::brush ( int  modelRow  )  const

Returns the brush used for a pie segment.

See also:
setBrush(int, const WBrush&)

void Wt::Chart::WPieChart::setExplode ( int  modelRow,
double  factor 
)

Change 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.

double Wt::Chart::WPieChart::explode ( int  modelRow  )  const

Returns the explosion factor for a segment.

See also:
setExplode(int, double)

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.

bool Wt::Chart::WPieChart::isPerspectiveEnabled (  )  const [inline]

Returns whether a 3D effect is enabled.

See also:
setPerspectiveEnabled(bool, double)

void Wt::Chart::WPieChart::setStartAngle ( double  degrees  ) 

Change 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.

See also:
setStartAngle(double)

void Wt::Chart::WPieChart::setDisplayLabels ( int  options  ) 

Configure 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.

int Wt::Chart::WPieChart::displayLabels (  )  const [inline]

Returns options set for displaying labels.

See also:
setDisplayLabels(int)

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]

Paint 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::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::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::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.


Generated on Mon Jan 26 14:14:13 2009 for Wt by doxygen 1.5.6