Wt: Wt::Chart::WDataSeries Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions
Wt::Chart::WDataSeries Class Reference
Charts (Wt::Chart)

A single data series in a cartesian chart. More...

`#include <Wt/Chart/WDataSeries>`

List of all members.

## Public Types
enum | CustomFlag { CustomPen = 0x1, CustomBrush = 0x2, CustomMarkerPen = 0x4, CustomMarkerBrush = 0x8, CustomLabelColor = 0x10 }
| Enumeration that indicates an aspect of the look. More...
## Public Member Functions
| WDataSeries (int modelColumn, SeriesType seriesType=PointSeries, Axis axis=Y1Axis)
| Constructs a new data series.
void | setBarWidth (const double width)
| Sets the bar width.
double | barWidth () const
| Returns the bar width.
void | setType (SeriesType t)
| Sets the series type.
SeriesType | type () const
| Returns the series type.
void | setModelColumn (int modelColumn)
| Sets the model column.
int | modelColumn () const
| Returns the model column.
void | setXSeriesColumn (int modelColumn)
| Sets the X series column.
int | XSeriesColumn () const
| Returns the X series column.
void | setStacked (bool stacked)
| Sets whether this series is stacked on top of the preceding series.
bool | isStacked () const
| Returns whether this series is stacked on top of the preceding series.
void | bindToAxis (Axis axis)
| Binds this series to a chart axis.
Axis | axis () const
| Returns the chart axis used for this series.
void | setCustomFlags (WFlags< CustomFlag > customFlags)
| Sets which aspects of the look are overriden.
WFlags< CustomFlag > | customFlags () const
| Returns which aspects of the look are overriden.
void | setPen (const WPen &pen)
| Overrides the pen used for drawing lines for this series.
WPen | pen () const
| Returns the pen used for drawing lines for this series.
void | setBrush (const WBrush &brush)
| Overrides the brush used for filling areas for this series.
WBrush | brush () const
| Returns the brush used for filling areas for this series.
void | setShadow (const WShadow &shadow)
| Sets a shadow used for stroking lines for this series.
const WShadow & | shadow () const
| Returns the shadow used for stroking lines for this series.
void | setFillRange (FillRangeType fillRange)
| Sets the fill range for line or curve series.
FillRangeType | fillRange () const
| Returns the fill range (for line, curve and bar series).
void | setMarker (MarkerType marker)
| Sets the data point marker.
void | setCustomMarker (const WPainterPath &path)
| Sets the custom marker.
WPainterPath | customMarker () const
| Returns the custom marker.
MarkerType | marker () const
| Returns the data point marker.
void | setMarkerSize (double size)
| Sets the marker size.
double | markerSize () const
| Returns the marker size.
void | setMarkerPen (const WPen &pen)
| Sets the marker pen.
WPen | markerPen () const
| Returns the marker pen.
void | setMarkerBrush (const WBrush &brush)
| Sets the marker brush.
WBrush | markerBrush () const
| Returns the marker brush.
void | setLegendEnabled (bool enabled)
| Enables the entry for this series in the legend.
bool | isLegendEnabled () const
| Returns whether this series has an entry in the legend.
void | setLabelsEnabled (Axis axis, bool enabled=true)
| Enables a label that is shown at the series data points.
bool | isLabelsEnabled (Axis axis) const
| Returns whether labels are enabled for the given axis.
void | setLabelColor (const WColor &color)
| Sets the label color.
WColor | labelColor () const
| Returns the label color.
void | setHidden (bool hidden)
| Hide/unhide this series.
bool | isHidden () const
| Return whether the series is hidden.
WPointF | mapFromDevice (const WPointF &deviceCoordinates) const
| Maps from device coordinates to model coordinates.
WPointF | mapToDevice (const boost::any &xValue, const boost::any &yValue, int segment=0) const
| Maps from model values to device coordinates.

## Detailed Description

A single data series in a cartesian chart.

This class configures all aspects for rendering a single data series in a cartesian chart. A data series renders Y data from a single model column against the X series configured for the chart.

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

Multiple series of different types may be combined on a single chart.

Different styles of data series

For a category chart, series may be stacked on top of each other. This is controlled by setStacked() for a series, which if enabled, will stack that series on top of the preceding data series. This works regardless of whether they are of the same type, but obviously works visually best if these series are of the same type. When not stacked, bar series are rendered next to each other. The margin between bars of different data series is controlled using WCartesianChart::setBarMargin().

The line and color type are by default based on the chart palette, but may be overridden for a series using setPen(), setBrush(), etc...

See also:
  WCartesianChart::addSeries()

## Member Enumeration Documentation

enum Wt::Chart::WDataSeries::CustomFlag

Enumeration that indicates an aspect of the look.

These flags are used to keep track of which aspects of the look that are overridden from the values provided by the chart palette, using one of the methods in this class.

See also:
  setPen(), setBrush(), setMarkerPen(), setMarkerBrush(), setLabelColor()

Enumerator:

  CustomPen | A custom pen is set.
  CustomBrush | A custom brush is set.
  CustomMarkerPen | A custom marker pen is set.
  CustomMarkerBrush | A custom marker brush is set.
  CustomLabelColor | A custom label color is set.

## Constructor & Destructor Documentation

Wt::Chart::WDataSeries::WDataSeries | ( | int | modelColumn,
|  | SeriesType | seriesType = `PointSeries`,
|  | Axis | axis = `Y1Axis`
| ) |  |

Constructs a new data series.

Creates a new data series which plots the Y values from the model column modelColumn, with the indicated seriesType. The Y values are mapped to the indicated axis, which should correspond to one of the two Y axes.

See also:
  WCartesianChart::addSeries()

## Member Function Documentation

Axis Wt::Chart::WDataSeries::axis | ( |  | ) | const

Returns the chart axis used for this series.

See also:
  bindToAxis()

double Wt::Chart::WDataSeries::barWidth | ( |  | ) | const

Returns the bar width.

See also:
  setBarWidth()

void Wt::Chart::WDataSeries::bindToAxis | ( | Axis | axis | ) |

Binds this series to a chart axis.

A data series may be bound to either the first or second Y axis. Note that the second Y axis is by default not displayed.

The default value is the first Y axis.

See also:
  WAxis::setVisible()

WBrush Wt::Chart::WDataSeries::brush | ( |  | ) | const

Returns the brush used for filling areas for this series.

See also:
  setBrush()

WFlags<CustomFlag> Wt::Chart::WDataSeries::customFlags | ( |  | ) | const

Returns which aspects of the look are overriden.

See also:
  setCustomFlags()

WPainterPath Wt::Chart::WDataSeries::customMarker | ( |  | ) | const

Returns the custom marker.

See also:
  setCustomMarker()

FillRangeType Wt::Chart::WDataSeries::fillRange | ( |  | ) | const

Returns the fill range (for line, curve and bar series).

See also:
  setFillRange()

bool Wt::Chart::WDataSeries::isHidden | ( |  | ) | const

Return whether the series is hidden.

See also:
  setHidden()

bool Wt::Chart::WDataSeries::isLabelsEnabled | ( | Axis | axis | ) | const

Returns whether labels are enabled for the given axis.

See also:
  setLabelsEnabled()

bool Wt::Chart::WDataSeries::isLegendEnabled | ( |  | ) | const

Returns whether this series has an entry in the legend.

See also:
  setLegendEnabled()

bool Wt::Chart::WDataSeries::isStacked | ( |  | ) | const

Returns whether this series is stacked on top of the preceding series.

See also:
  setStacked()

WColor Wt::Chart::WDataSeries::labelColor | ( |  | ) | const

Returns the label color.

See also:
  setLabelColor()

WPointF Wt::Chart::WDataSeries::mapFromDevice | ( | const WPointF & | deviceCoordinates | ) | const

Maps from device coordinates to model coordinates.

Maps a position in the chart back to model coordinates, for data in this data series.

This uses WChart::mapFromDevice() passing the axis() to which this series is bound.

This method uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish to already the mapping reflect model changes since the last rendering, you should call WCartesianChart::initLayout() first.

See also:
  mapToDevice()

WPointF Wt::Chart::WDataSeries::mapToDevice | ( | const boost::any & | xValue,
|  | const boost::any & | yValue,
|  | int | segment = `0`
| ) |  | const

Maps from model values to device coordinates.

Maps model values to device coordinates, for data in this data series.

This uses WChart::mapToDevice() passing the axis() to which this series is bound.

This method uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish to already the mapping reflect model changes since the last rendering, you should call WCartesianChart::initLayout() first.

See also:
  mapFromDevice()

MarkerType Wt::Chart::WDataSeries::marker | ( |  | ) | const

Returns the data point marker.

See also:
  setMarker()

WBrush Wt::Chart::WDataSeries::markerBrush | ( |  | ) | const

Returns the marker brush.

See also:
  setMarkerBrush()

WPen Wt::Chart::WDataSeries::markerPen | ( |  | ) | const

Returns the marker pen.

See also:
  setMarkerPen()

double Wt::Chart::WDataSeries::markerSize | ( |  | ) | const

Returns the marker size.

See also:
  setMarkerSize()

int Wt::Chart::WDataSeries::modelColumn | ( |  | ) | const

Returns the model column.

See also:
  setModelColumn()

WPen Wt::Chart::WDataSeries::pen | ( |  | ) | const

Returns the pen used for drawing lines for this series.

See also:
  setPen()

void Wt::Chart::WDataSeries::setBarWidth | ( | const double | width | ) |

Sets the bar width.

The bar width specifies the bar width (in axis dimensions). For category plots, which may have several bars for different series next to each other, you will want to specify the same bar width for each series.

For scatter plots, you may want to set the bar width to a natural size. E.g. if you are plotting weekly measurements, you could set the width to correspond to a week (=7).

The default value is 0.8 (which leaves a 20% margin between bars for different categories in a category chart.

See also:
  WCartesianChart::setBarMargin()

void Wt::Chart::WDataSeries::setBrush | ( | const WBrush & | brush | ) |

Overrides the brush used for filling areas for this series.

Overrides the brush that is used to draw this series which is otherwise provided by the chart palette. For a bar plot, this is the brush used to fill the bars. For a line chart, this is the brush used to fill the area under (or above) the line. Calling this method automatically adds CustomBrush to the custom flags.

See also:
  WChartPalette::brush()

void Wt::Chart::WDataSeries::setCustomFlags | ( | WFlags< CustomFlag > | customFlags | ) |

Sets which aspects of the look are overriden.

Set which aspects of the look, that are by default based on the chart palette, are overridden by custom settings.

The default value is 0 (nothing overridden).

void Wt::Chart::WDataSeries::setCustomMarker | ( | const WPainterPath & | path | ) |

Sets the custom marker.

This will also changes the marker type to CustomMarker.

See also:
  setMarker()

void Wt::Chart::WDataSeries::setFillRange | ( | FillRangeType | fillRange | ) |

Sets the fill range for line or curve series.

Line or curve series may be filled under or above the curve, using the brush(). This setting specifies the range that is filled. The default value for all but BarSeries is NoFill.

Bar series may use MinimumValueFill to configure the chart to render its bars from the data point to the bottom of the chart or MaximumValueFill to render the bars from the data point to the top of the chart. The default value for BarSeries is ZeroValueFill, which render bars from zero to the data value.

void Wt::Chart::WDataSeries::setHidden | ( | bool | hidden | ) |

Hide/unhide this series.

A hidden series will not be show in the chart and legend.

void Wt::Chart::WDataSeries::setLabelColor | ( | const WColor & | color | ) |

Sets the label color.

Specify the color used for the rendering labels at the data points.

See also:
  setLabelsEnabled()

void Wt::Chart::WDataSeries::setLabelsEnabled | ( | Axis | axis,
|  | bool | enabled = `true`
| ) |  |

Enables a label that is shown at the series data points.

You may enable labels for the XAxis, YAxis or both axes. The label that is displayed is the corresponding value on that axis. If both labels are enabled then they are combined in a single text using the format: "<x-value>: <y-value>".

The default values are false for both axes (no labels).

See also:
  isLabelsEnabled()

void Wt::Chart::WDataSeries::setLegendEnabled | ( | bool | enabled | ) |

Enables the entry for this series in the legend.

When enabled, this series is added to the chart legend.

The default value is true.

See also:
  WCartesianChart::setLegendEnabled().

void Wt::Chart::WDataSeries::setMarker | ( | MarkerType | marker | ) |

Sets the data point marker.

Specifies a marker that is displayed at the (X,Y) coordinate for each series data point.

The default value is a CircleMarker for a PointSeries, or NoMarker otherwise.

See also:
  setMarkerPen(), setMarkerBrush(), setCustomMarker()

void Wt::Chart::WDataSeries::setMarkerBrush | ( | const WBrush & | brush | ) |

Sets the marker brush.

Overrides the brush used for filling the marker. By default the marker brush is the same as brush(). Calling this method automatically adds CustomMarkerBrush to the custom flags.

See also:
  setBrush(), setMarkerPen()

void Wt::Chart::WDataSeries::setMarkerPen | ( | const WPen & | pen | ) |

Sets the marker pen.

Overrides the pen used for stroking the marker. By default the marker pen is the same as pen(). Calling this method automatically adds CustomMarkerPen to the custom flags.

See also:
  setPen(), setMarkerBrush()

void Wt::Chart::WDataSeries::setMarkerSize | ( | double | size | ) |

Sets the marker size.

The default marker size is 6 pixels.

void Wt::Chart::WDataSeries::setModelColumn | ( | int | modelColumn | ) |

Sets the model column.

This specifies the model column from which the Y data is retrieved that is plotted by this series.

The data column should contain data that can be converted to a number (but should not necessarily be of a number type).

See also:
  Wt::asNumber()

void Wt::Chart::WDataSeries::setPen | ( | const WPen & | pen | ) |

Overrides the pen used for drawing lines for this series.

Overrides the pen that is used to draw this series. Calling this method automatically adds CustomPen to the custom flags.

The default value is a default WPen().

See also:
  WChartPalette::strokePen(), WChartPalette::borderPen()

void Wt::Chart::WDataSeries::setStacked | ( | bool | stacked | ) |

Sets whether this series is stacked on top of the preceding series.

For category charts, data from different series may be rendered stacked on top of each other. The rendered value is the sum of the value of this series plus the rendered value of the preceding series. For line series, you probably will want to add filling under the curve. A stacked bar series is rendered by a bar on top of the preceding bar series.

The default value is false.

void Wt::Chart::WDataSeries::setType | ( | SeriesType | t | ) |

Sets the series type.

The series type specifies how the data is plotted, i.e. using mere point markers, lines, curves, or bars.

void Wt::Chart::WDataSeries::setXSeriesColumn | ( | int | modelColumn | ) |

Sets the X series column.

By default, the data series uses the X series column configured for the chart. For a scatter plot, each series can have its own matching X data, which is configured here. For other plots, this setting is ignored.

The default value is -1, which indicates that WCartesianChart::XSeriesColumn() is to be used.

See also:
  WCartesianChart::setXSeriesColumn()

const WShadow & Wt::Chart::WDataSeries::shadow | ( |  | ) | const

Returns the shadow used for stroking lines for this series.

See also:
  setShadow()

SeriesType Wt::Chart::WDataSeries::type | ( |  | ) | const

Returns the series type.

See also:
  setType()

int Wt::Chart::WDataSeries::XSeriesColumn | ( |  | ) | const

Returns the X series column.

See also:
  setXSeriesColumn()

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator