|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WWidget
eu.webtoolkit.jwt.WWebWidget
eu.webtoolkit.jwt.WInteractWidget
eu.webtoolkit.jwt.WPaintedWidget
eu.webtoolkit.jwt.chart.WAbstractChart
eu.webtoolkit.jwt.chart.WPieChart
public class WPieChart
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
WAbstractChart#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
WCartesianChart| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WPaintedWidget |
|---|
WPaintedWidget.Method |
| Constructor Summary | |
|---|---|
WPieChart()
Creates a new pie chart. |
|
WPieChart(WContainerWidget parent)
Creates a new pie chart. |
|
| Method Summary | |
|---|---|
void |
addDataPointArea(WModelIndex index,
WAbstractArea area)
Adds a data point area (used for displaying e.g. |
WWidget |
createLegendItemWidget(int index,
java.util.EnumSet<LabelOption> options)
Creates a widget which renders the a legend item. |
WWidget |
createLegendItemWidget(int index,
LabelOption option,
LabelOption... options)
Creates a widget which renders the a legend item. |
double |
getAvoidLabelRendering()
Returns the percentage to avoid label rendering. |
WBrush |
getBrush(int modelRow)
Returns the brush used for a pie segment. |
int |
getDataColumn()
Returns the model column used for the data. |
java.util.EnumSet<LabelOption> |
getDisplayLabels()
Returns options set for displaying labels. |
double |
getExplode(int modelRow)
Returns the explosion factor for a segment. |
int |
getLabelsColumn()
Returns the model column used for the labels. |
double |
getStartAngle()
Returns the angle of the first segment. |
boolean |
isPerspectiveEnabled()
Returns whether a 3D effect is enabled. |
boolean |
isShadowEnabled()
Returns whether a shadow effect is enabled. |
protected void |
modelChanged()
Method called whenever the entire model was changed. |
protected void |
modelColumnsInserted(WModelIndex parent,
int start,
int end)
Method called when colums have been inserted in the model. |
protected void |
modelColumnsRemoved(WModelIndex parent,
int start,
int end)
Method called when colums have been removed from the model. |
protected void |
modelDataChanged(WModelIndex topLeft,
WModelIndex bottomRight)
Method called when data has been changed in the model. |
protected void |
modelReset()
Method called whenever the entire model was reset. |
protected void |
modelRowsInserted(WModelIndex parent,
int start,
int end)
Method called when rows have been inserted from the model. |
protected void |
modelRowsRemoved(WModelIndex parent,
int start,
int end)
Method called when rows have been removed from the model. |
void |
paint(WPainter painter,
WRectF rectangle)
Paint the chart in a rectangle of the given painter. |
protected void |
paintEvent(WPaintDevice paintDevice)
Paints the widget. |
void |
setAvoidLabelRendering(double avoidLabelRendering)
Sets the percentage value to avoid rendering of label texts. |
void |
setBrush(int modelRow,
WBrush brush)
Customizes the brush used for a pie segment. |
void |
setDataColumn(int modelColumn)
Sets the model column that holds the data. |
void |
setDisplayLabels(java.util.EnumSet<LabelOption> options)
Configures if and how labels should be displayed. |
void |
setDisplayLabels(LabelOption option,
LabelOption... options)
Configures if and how labels should be displayed. |
void |
setExplode(int modelRow,
double factor)
Sets the explosion factor for a pie segment. |
void |
setLabelsColumn(int modelColumn)
Sets the model column that holds the labels. |
void |
setPerspectiveEnabled(boolean enabled)
Enables a 3D perspective effect on the pie. |
void |
setPerspectiveEnabled(boolean enabled,
double height)
Enables a 3D perspective effect on the pie. |
void |
setShadowEnabled(boolean enabled)
Enables a shadow effect. |
void |
setStartAngle(double startAngle)
Sets the angle of the first segment. |
| Methods inherited from class eu.webtoolkit.jwt.chart.WAbstractChart |
|---|
getBackground, getModel, getPalette, getPlotAreaPadding, getTitle, getTitleFont, paint, remove, setBackground, setModel, setPalette, setPlotAreaPadding, setPlotAreaPadding, setPlotAreaPadding, setTitle, setTitleFont |
| Methods inherited from class eu.webtoolkit.jwt.WPaintedWidget |
|---|
addArea, enableAjax, getArea, getAreas, getMethod, getPreferredMethod, insertArea, layoutSizeChanged, removeArea, resize, setPreferredMethod, update, update, update |
| Methods inherited from class eu.webtoolkit.jwt.WInteractWidget |
|---|
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, propagateSetEnabled, setDraggable, setDraggable, setDraggable, setDraggable, touchEnded, touchMoved, touchStarted |
| Methods inherited from class eu.webtoolkit.jwt.WWidget |
|---|
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getObjectName, setObjectName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WPieChart(WContainerWidget parent)
public WPieChart()
Calls this((WContainerWidget)null)
| Method Detail |
|---|
public void setLabelsColumn(int modelColumn)
The labels are used only when
setDisplayLabels() is
called with the TextLabel option.
The default value is -1 (not defined).
WAbstractChart.setModel(WAbstractItemModel model),
setDisplayLabels(EnumSet options),
setDataColumn(int modelColumn)public int getLabelsColumn()
setLabelsColumn(int modelColumn)public void setDataColumn(int modelColumn)
The data column should contain data that can be converted to a number,
but should not necessarily be of a number type, see also
StringUtils.asNumber(Object).
The default value is -1 (not defined).
WAbstractChart.setModel(WAbstractItemModel model),
setLabelsColumn(int modelColumn)public int getDataColumn()
setDataColumn(int modelColumn)
public void setBrush(int modelRow,
WBrush brush)
By default, the brush is taken from the
WAbstractChart#getPalette(). You can
use this method to override the palette's brush for a particular
modelRow.
WAbstractChart.setPalette(WChartPalette palette)public WBrush getBrush(int modelRow)
setBrush(int modelRow, WBrush brush)
public void setExplode(int modelRow,
double factor)
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.
public double getExplode(int modelRow)
setExplode(int modelRow, double factor)
public void setPerspectiveEnabled(boolean enabled,
double height)
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.
public final void setPerspectiveEnabled(boolean enabled)
Calls setPerspectiveEnabled(enabled, 1.0)
public boolean isPerspectiveEnabled()
setPerspectiveEnabled(boolean enabled, double height)public void setShadowEnabled(boolean enabled)
A soft shadow effect is added.
The default value is false.
public boolean isShadowEnabled()
setShadowEnabled(boolean enabled)public void setStartAngle(double startAngle)
The default value is 45 degrees.
public double getStartAngle()
setStartAngle(double startAngle)public void setAvoidLabelRendering(double avoidLabelRendering)
The default value is 0 percent.
public double getAvoidLabelRendering()
setAvoidLabelRendering(double avoidLabelRendering)public void setDisplayLabels(java.util.EnumSet<LabelOption> options)
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.
public final void setDisplayLabels(LabelOption option,
LabelOption... options)
Calls setDisplayLabels(EnumSet.of(option, options))
public java.util.EnumSet<LabelOption> getDisplayLabels()
setDisplayLabels(EnumSet options)
public WWidget createLegendItemWidget(int index,
java.util.EnumSet<LabelOption> options)
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.
public final WWidget createLegendItemWidget(int index,
LabelOption option,
LabelOption... options)
Returns createLegendItemWidget(index, EnumSet.of(option, options))
public void addDataPointArea(WModelIndex index,
WAbstractArea area)
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.
public void paint(WPainter painter,
WRectF rectangle)
WAbstractChart
Paints the chart inside the painter, in the area indicated by
rectangle. When rectangle is a null rectangle, the entire
painter window is used.
paint in class WAbstractChartprotected void paintEvent(WPaintDevice paintDevice)
WPaintedWidgetYou should reimplement this method to paint the contents of the widget, using the given paintDevice.
paintEvent in class WPaintedWidgetprotected void modelChanged()
WAbstractChart
modelChanged in class WAbstractChartWAbstractChart.setModel(WAbstractItemModel model)protected void modelReset()
WAbstractChart
Bound to the WAbstractItemModel#modelReset() and
WAbstractItemModel#layoutChanged() signals.
modelReset in class WAbstractChart
protected void modelColumnsInserted(WModelIndex parent,
int start,
int end)
WAbstractChart
modelColumnsInserted in class WAbstractChartWAbstractItemModel.columnsInserted()
protected void modelColumnsRemoved(WModelIndex parent,
int start,
int end)
WAbstractChart
modelColumnsRemoved in class WAbstractChartWAbstractItemModel.columnsRemoved()
protected void modelRowsInserted(WModelIndex parent,
int start,
int end)
WAbstractChart
modelRowsInserted in class WAbstractChartWAbstractItemModel.rowsInserted()
protected void modelRowsRemoved(WModelIndex parent,
int start,
int end)
WAbstractChart
modelRowsRemoved in class WAbstractChartWAbstractItemModel.rowsRemoved()
protected void modelDataChanged(WModelIndex topLeft,
WModelIndex bottomRight)
WAbstractChart
modelDataChanged in class WAbstractChartWAbstractItemModel.dataChanged()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||