Wt  3.3.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Protected Member Functions
Wt::Chart::WCartesianChart Class Reference

A cartesian chart. More...

#include <Wt/Chart/WCartesianChart>

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

List of all members.

Public Member Functions

 WCartesianChart (WContainerWidget *parent=0)
 Creates a new cartesian chart.
 WCartesianChart (ChartType type, WContainerWidget *parent=0)
 Creates a new cartesian chart.
void setType (ChartType type)
 Sets the chart type.
ChartType type () const
 Returns the chart type.
void setOrientation (Orientation orientation)
 Sets the chart orientation.
Orientation orientation () const
 Returns the chart orientation.
void setXSeriesColumn (int modelColumn)
 Sets the the model column for the X series.
void setTextPen (const WPen &pen)
 set the pen used to render the labels
int XSeriesColumn () const
 Returns the model column for the X series.
void addSeries (const WDataSeries &series)
 Adds a data series.
void removeSeries (int modelColumn)
 Removes a data series.
void setSeries (const std::vector< WDataSeries > &series)
 Sets all data series.
WDataSeriesseries (int modelColumn)
 Returns a data series corresponding to a data column.
const WDataSeriesseries (int modelColumn) const
 Returns a data series corresponding to a data column.
const std::vector< WDataSeries > & series () const
 Returns a list with the current data series.
WAxisaxis (Axis axis)
 Returns a chart axis.
const WAxisaxis (Axis axis) const
 Accesses a chart axis.
void setAxis (WAxis *waxis, Axis axis)
 Sets an axis.
void setBarMargin (double margin)
 Sets the margin between bars of different series.
double barMargin () const
 Returns the margin between bars of different series.
void setLegendEnabled (bool enabled)
 Enables the legend.
bool isLegendEnabled () const
 Returns whether the legend is enabled.
void setLegendLocation (LegendLocation location, Side side, AlignmentFlag alignment)
 Configures the legend location.
void setLegendStyle (const WFont &font, const WPen &border, const WBrush &background)
 Configures the legend decoration.
LegendLocation legendLocation () const
 Returns the legend location.
Side legendSide () const
 Returns the legend side.
AlignmentFlag legendAlignment () const
 Returns the legend alignment.
int legendColumns () const
 Returns the legend columns.
WLength legendColumnWidth () const
 Returns the legend column width.
WFont legendFont () const
 Returns the legend font.
WPen legendBorder () const
 Returns the legend border pen.
WBrush legendBackground () const
 Returns the legend background brush.
void setLegendColumns (int columns, const WLength &width)
 Configures multiple legend columns.
virtual void paint (WPainter &painter, const WRectF &rectangle=WRectF()) const WT_CXX11ONLY(override)
 Paint the chart in a rectangle of the given painter.
virtual void drawMarker (const WDataSeries &series, WPainterPath &result) const
 Draws the marker for a given data series.
virtual void renderLegendIcon (WPainter &painter, const WPointF &pos, const WDataSeries &series) const
 Renders the legend icon for a given data series.
virtual void renderLegendItem (WPainter &painter, const WPointF &pos, const WDataSeries &series) const
 Renders the legend item for a given data series.
WPointF mapFromDevice (const WPointF &point, Axis ordinateAxis=OrdinateAxis) const
 Maps from device coordinates to model coordinates.
WPointF mapToDevice (const boost::any &xValue, const boost::any &yValue, Axis axis=OrdinateAxis, int xSegment=0, int ySegment=0) const
 Maps model values onto chart coordinates.
bool initLayout (const WRectF &rectangle=WRectF(), WPaintDevice *device=0) const
 Initializes the chart layout.
WWidgetcreateLegendItemWidget (int index)
 Creates a widget which renders the a legend item.
virtual void addDataPointArea (const WDataSeries &series, const WModelIndex &xIndex, WAbstractArea *area)
 Adds a data point area (used for displaying e.g. tooltips).
void setAxisPadding (int axisPadding)
 Sets the padding between the chart area and the axes.
int axisPadding () const
 Returns the padding between the chart area and the axes.
void setBorderPen (const WPen &pen)
 Sets the pen of the border to be drawn around the chart area.
const WPenborderPen () const
 Returns the pen used to draw the border around the chart area.
Client side interaction

These methods allow to activate the client side interactive features of a WCartesianChart.

Note:
Client side interaction is only available if the chart is drawn on an HTML canvas. This is the default rendering method on modern browsers, see WPaintedWidget::setPreferredMethod()
Some features are currently not supported in interactive mode:
  • Axes set at ZeroValue position will not always be drawn correctly. They may be clipped off outside of the chart area, and when zooming, the axis ticks will change size.
void setZoomEnabled (bool zoom=true)
 Enables zoom functionality.
bool zoomEnabled () const
 Returns whether zoom is enabled.
void setPanEnabled (bool pan=true)
 Enables pan functionality.
bool panEnabled () const
 Returns whether pan is enabled.
void setCrosshairEnabled (bool crosshair=true)
 Enables the crosshair functionality.
bool crosshairEnabled () const
 Returns whether the crosshair is enabled.
void setFollowCurve (int modelColumn)
 Enables the follow curve functionality for a data series.
void disableFollowCurve ()
 Disable the follow curve functionality.
int followCurve () const
 Returns the curve that is to be followed.
void setRubberBandEffectEnabled (bool rubberBand=true)
 Enables/disables the inertial scrolling and rubberband effect.
bool rubberBandEffectEnabled () const
 Checks whether the rubberband effect is enabled.
void setWheelActions (WheelActions wheelActions)
 Sets the mapping of mouse wheel actions for interactive charts.
WheelActions wheelActions () const
 Returns the current mouse wheel actions for interactive charts.
void setSoftLabelClipping (bool enabled)
 Enables or disables soft label clipping on all axes.

Protected Member Functions

virtual void modelColumnsInserted (const WModelIndex &parent, int start, int end) WT_CXX11ONLY(override)
 Method called when colums have been inserted in the model.
virtual void modelColumnsRemoved (const WModelIndex &parent, int start, int end) WT_CXX11ONLY(override)
 Method called when colums have been removed from the model.
virtual void modelRowsInserted (const WModelIndex &parent, int start, int end) WT_CXX11ONLY(override)
 Method called when rows have been inserted from the model.
virtual void modelRowsRemoved (const WModelIndex &parent, int start, int end) WT_CXX11ONLY(override)
 Method called when rows have been removed from the model.
virtual void modelDataChanged (const WModelIndex &topLeft, const WModelIndex &bottomRight) WT_CXX11ONLY(override)
 Method called when data has been changed in the model.
virtual void modelHeaderDataChanged (Orientation orientation, int start, int end) WT_CXX11ONLY(override)
 Method called when header data has been changed in the model.
virtual void modelChanged () WT_CXX11ONLY(override)
 Method called whenever the entire model was changed.
virtual void modelReset () WT_CXX11ONLY(override)
 Method called whenever the entire model was reset.
virtual void render (WFlags< RenderFlag > flags) WT_CXX11ONLY(override)
 Renders the widget.
Rendering logic
virtual void paintEvent (WPaintDevice *paintDevice) WT_CXX11ONLY(override)
 Paints the widget.
virtual void render (WPainter &painter, const WRectF &rectangle) const
 Renders the chart.
virtual WPointF map (double xValue, double yValue, Axis yAxis=OrdinateAxis, int currentXSegment=0, int currentYSegment=0) const
 Map (x, y) value pair to chart coordinates coordinates.
virtual void renderLabel (WPainter &painter, const WString &text, const WPointF &pos, WFlags< AlignmentFlag > flags, double angle, int margin) const
 Utility function for rendering text.
WPointF hv (double x, double y) const
 Conversion between chart and painter coordinates.
WPointF hv (const WPointF &f) const
 Conversion between chart and painter coordinates.
WRectF hv (const WRectF &f) const
 Conversion between chart and painter coordinates.
WRectF chartSegmentArea (WAxis yAxis, int xSegment, int ySegment) const
 Returns the segment area for a combination of X and Y segments.
virtual void calcChartArea () const
 Calculates the chart area.
virtual bool prepareAxes () const
 Prepares the axes for rendering.
virtual void renderBackground (WPainter &painter) const
 Renders the background.
virtual void renderAxes (WPainter &painter, WFlags< AxisProperty > properties) const
 Renders one or more properties of the axes.
virtual void renderBorder (WPainter &painter) const
 Renders the border of the chart area.
virtual void renderSeries (WPainter &painter) const
 Renders all series data, including value labels.
virtual void renderLegend (WPainter &painter) const
 Renders the (default) legend and chart titles.
virtual void renderAxis (WPainter &painter, const WAxis &axis, WFlags< AxisProperty > properties) const
 Renders properties of one axis.
virtual void renderGrid (WPainter &painter, const WAxis &axis) const
 Renders grid lines along the ticks of the given axis.
int calcNumBarGroups ()
 Calculates the total number of bar groups.

Detailed Description

A cartesian chart.

A cartesian chart is a chart that uses X and Y axes. It can display one or multiple data series, which each may be rendered using bars, lines, areas, or points.

To use a cartesian chart, the minimum you need to do is set a model using setModel(), set the model column that holds the X data using setXSeriesColumn(int modelColumn), and add one or more series using addSeries(const WDataSeries&). Each series corresponds to one data column that holds Y data.

A cartesian chart is either a CategoryChart or a ScatterPlot.

In a CategoryChart, the X series represent different categories, which are listed consecutively in model row order. The X axis scale is set to CategoryScale.

ChartWCartesianChart-1.png
A category chart with bar series

Each series may be rendered differently, and this is configured in the data series (see WDataSeries for more information).

In a ScatterPlot, the X series data are interpreted as numbers on a numerical scale. The scale for the X axis defaults to a LinearScale, but this may be changed to a DateScale when the X series contains dates (of type WDate) to create a time series chart, or to a LogScale. A ScatterPlot supports the same types of data series as a CategoryChart, but does not support stacking. In a scatter plot, the X series do not need to be ordered in increasing values, and may be set differently for each dataseries using WDataSeries::setXSeriesColumn(int modelColumn).

ChartWCartesianChart-2.png
A time series scatter plot with line series

Missing data in a model series Y values is interpreted as a break. For curve-like series, this breaks the curve (or line).

The cartesian chart has support for dual Y axes. Each data series may be bound to one of the two Y axes. By default, only the first Y axis is displayed. To show the second Y axis you will need to call:

 chart->axis(Y2Axis).setVisible(true);

By default a chart has a horizontal X axis and a vertical Y axis, which corresponds to a Vertical orientation. The orientation may be changed to Horizontal using setOrientation().

The styling of the series data are dictated by a palette which may be set using setPalette(WChartPalette *), but may be overridden by settings in each data series.

CSS

Styling through CSS is not applicable.

See also:
WDataSeries, WAxis
WPieChart

Constructor & Destructor Documentation

Creates a new cartesian chart.

Creates a cartesian chart of type CategoryChart.

Creates a new cartesian chart.

Creates a cartesian chart of the indicated type.


Member Function Documentation

void Wt::Chart::WCartesianChart::addDataPointArea ( const WDataSeries series,
const WModelIndex xIndex,
WAbstractArea area 
) [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 Wt::ToolTipRole data at the data point is not empty.

Adds a data series.

A single chart may display one or more data series. Each data series displays data from a single model column in the chart. Series are plotted in the order that they have been added to the chart.

The series column is reset to -1 when the model is set (or changed). Thus you need to set a model before configuring the series.

See also:
removeSeries(), setSeries()

Returns a chart axis.

Returns a reference to the specified axis.

const WAxis & Wt::Chart::WCartesianChart::axis ( Axis  axis) const

Accesses a chart axis.

Returns a const reference to the specified axis.

Returns the padding between the chart area and the axes.

This number may not reflect the actual padding of the individual axes, if another padding has been applied on the individual axes.

See also:
setAxisPadding()

Returns the margin between bars of different series.

See also:
setBarMargin(double)

Returns the pen used to draw the border around the chart area.

Defaults to NoPen.

See also:
setBorderPen()
void Wt::Chart::WCartesianChart::calcChartArea ( ) const [protected, virtual]

Calculates the chart area.

This calculates the chartArea(), which is the rectangle (in chart coordinates) that bounds the actual chart (thus excluding axes, labels, titles, legend, etc...).

See also:
plotAreaPadding()
WRectF Wt::Chart::WCartesianChart::chartSegmentArea ( WAxis  yAxis,
int  xSegment,
int  ySegment 
) const [protected]

Returns the segment area for a combination of X and Y segments.

This segment area is used for clipping when rendering in a particular segment.

Creates a widget which renders the a legend item.

The legend item widget will contain a text and a WPaintedWidget which draws the series' symbol.

Returns whether the crosshair is enabled.

See also:
setCrosshairEnabled()

Disable the follow curve functionality.

See also:
setFollowCurve()
void Wt::Chart::WCartesianChart::drawMarker ( const WDataSeries series,
WPainterPath result 
) const [virtual]

Draws the marker for a given data series.

Draws the marker for the indicated series in the result. This method is called while painting the chart, and you may want to reimplement this method if you wish to provide a custom marker for a particular data series.

See also:
setLegendEnabled()

Returns the curve that is to be followed.

If follow curve functionality is not enabled, returns -1.

See also:
setFollowCurve()
WPointF Wt::Chart::WCartesianChart::hv ( double  x,
double  y 
) const [protected]

Conversion between chart and painter coordinates.

Converts from chart coordinates to painter coordinates, taking into account the chart orientation.

WPointF Wt::Chart::WCartesianChart::hv ( const WPointF f) const [protected]

Conversion between chart and painter coordinates.

Converts from chart coordinates to painter coordinates, taking into account the chart orientation.

WRectF Wt::Chart::WCartesianChart::hv ( const WRectF f) const [protected]

Conversion between chart and painter coordinates.

Converts from chart coordinates to painter coordinates, taking into account the chart orientation.

bool Wt::Chart::WCartesianChart::initLayout ( const WRectF rectangle = WRectF(),
WPaintDevice device = 0 
) const

Initializes the chart layout.

The mapping between model and device coordinates is only established after a rendering phase, or after calling initLayout manually.

You need a layout in order to use the mapFromDevice() and mapToDevice() methods.

Unless a specific chart rectangle is specified, the entire widget area is assumed.

Returns whether the legend is enabled.

See also:
setLegendEnabled()

Returns the legend alignment.

See also:
setLegendLocation()

Returns the legend background brush.

See also:
setLegendStyle()

Returns the legend border pen.

See also:
setLegendStyle()

Returns the legend columns.

See also:
setLegendColumns()

Returns the legend column width.

See also:
setLegendColumns()

Returns the legend font.

See also:
setLegendStyle()

Returns the legend location.

See also:
setLegendLocation()

Returns the legend side.

See also:
setLegendLocation()
WPointF Wt::Chart::WCartesianChart::map ( double  xValue,
double  yValue,
Axis  yAxis = OrdinateAxis,
int  currentXSegment = 0,
int  currentYSegment = 0 
) const [protected, virtual]

Map (x, y) value pair to chart coordinates coordinates.

The result needs further transformation using hv() to painter coordinates.

WPointF Wt::Chart::WCartesianChart::mapFromDevice ( const WPointF point,
Axis  ordinateAxis = OrdinateAxis 
) const

Maps from device coordinates to model coordinates.

Maps a position in the chart back to model coordinates.

This 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 initLayout() first.

See also:
mapToDevice()
WPointF Wt::Chart::WCartesianChart::mapToDevice ( const boost::any &  xValue,
const boost::any &  yValue,
Axis  axis = OrdinateAxis,
int  xSegment = 0,
int  ySegment = 0 
) const

Maps model values onto chart coordinates.

This returns the chart device coordinates for a (x,y) pair of model values.

This 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 initLayout() first.

The xSegment and ySegment arguments are relevant only when the corresponding axis is broken using WAxis::setBreak(). Then, its possible values may be 0 (below the break) or 1 (above the break).

See also:
mapFromDevice()
void Wt::Chart::WCartesianChart::modelChanged ( ) [override, protected, virtual]

Method called whenever the entire model was changed.

See also:
setModel(WAbstractItemModel *)

Reimplemented from Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelColumnsInserted ( const WModelIndex parent,
int  start,
int  end 
) [override, protected, virtual]

Method called when colums have been inserted in the model.

See also:
WAbstractItemModel::columnsInserted

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelColumnsRemoved ( const WModelIndex parent,
int  start,
int  end 
) [override, protected, virtual]

Method called when colums have been removed from the model.

See also:
WAbstractItemModel::columnsRemoved

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelDataChanged ( const WModelIndex topLeft,
const WModelIndex bottomRight 
) [override, protected, virtual]

Method called when data has been changed in the model.

See also:
WAbstractItemModel::dataChanged

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelHeaderDataChanged ( Orientation  orientation,
int  start,
int  end 
) [override, protected, virtual]

Method called when header data has been changed in the model.

See also:
WAbstractItemModel::headerDataChanged

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelReset ( ) [override, protected, 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::WCartesianChart::modelRowsInserted ( const WModelIndex parent,
int  start,
int  end 
) [override, protected, virtual]

Method called when rows have been inserted from the model.

See also:
WAbstractItemModel::rowsInserted

Implements Wt::Chart::WAbstractChart.

void Wt::Chart::WCartesianChart::modelRowsRemoved ( const WModelIndex parent,
int  start,
int  end 
) [override, protected, virtual]

Method called when rows have been removed from the model.

See also:
WAbstractItemModel::rowsRemoved

Implements Wt::Chart::WAbstractChart.

Returns the chart orientation.

See also:
setOrientation()
void Wt::Chart::WCartesianChart::paint ( WPainter painter,
const WRectF rectangle = WRectF() 
) const [override, 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::WCartesianChart::paintEvent ( WPaintDevice paintDevice) [override, protected, virtual]

Paints the widget.

This calls render() to paint on the paint device.

Implements Wt::WPaintedWidget.

Returns whether pan is enabled.

See also:
setPanEnabled()
bool Wt::Chart::WCartesianChart::prepareAxes ( ) const [protected, virtual]

Prepares the axes for rendering.

Computes axis properties such as the range (if not manually specified), label interval (if not manually specified) and axis locations. These properties are stored within the axes.

See also:
initLayout()
void Wt::Chart::WCartesianChart::removeSeries ( int  modelColumn)

Removes a data series.

This removes the first data series which plots the given modelColumn.

See also:
addSeries(), setSeries()
void Wt::Chart::WCartesianChart::render ( WPainter painter,
const WRectF rectangle 
) const [protected, virtual]

Renders the chart.

Renders the chart within the given rectangle. To accomodate both rendering of horizontal and vertically oriented charts, all rendering logic assumes horizontal. This "chart coordinates" space is transformed to painter coordinates using hv().

The default implementation looks like:

 painter.save();
 painter.translate(rectangle.topLeft());

 if (initLayout(rectangle)) {
   renderBackground(painter);
   renderGrid(painter, axis(XAxis));
   renderGrid(painter, axis(Y1Axis));
   renderGrid(painter, axis(Y2Axis));
   renderSeries(painter);
   renderAxes(painter, Line | Labels);
   renderBorder(painter);
   renderLegend(painter);
 }

 painter.restore();
void Wt::Chart::WCartesianChart::render ( WFlags< RenderFlag flags) [override, protected, virtual]

Renders the widget.

This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().

The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.

Reimplemented from Wt::WPaintedWidget.

void Wt::Chart::WCartesianChart::renderAxes ( WPainter painter,
WFlags< AxisProperty properties 
) const [protected, virtual]

Renders one or more properties of the axes.

This calls renderAxis() for each axis.

See also:
render()
void Wt::Chart::WCartesianChart::renderAxis ( WPainter painter,
const WAxis axis,
WFlags< AxisProperty properties 
) const [protected, virtual]

Renders properties of one axis.

See also:
renderAxes()
void Wt::Chart::WCartesianChart::renderBackground ( WPainter painter) const [protected, virtual]

Renders the background.

See also:
render()
void Wt::Chart::WCartesianChart::renderBorder ( WPainter painter) const [protected, virtual]

Renders the border of the chart area.

See also:
render()
setBorderPen()
void Wt::Chart::WCartesianChart::renderGrid ( WPainter painter,
const WAxis axis 
) const [protected, virtual]

Renders grid lines along the ticks of the given axis.

See also:
render()
void Wt::Chart::WCartesianChart::renderLabel ( WPainter painter,
const WString text,
const WPointF pos,
WFlags< AlignmentFlag flags,
double  angle,
int  margin 
) const [protected, virtual]

Utility function for rendering text.

This method renders text on the chart position pos, with a particular alignment flags. These are both specified in chart coordinates. The position is converted to painter coordinates using hv(), and the alignment flags are changed accordingly. The rotation, indicated by angle is specified in painter coordinates and thus an angle of 0 always indicates horizontal text, regardless of the chart orientation.

void Wt::Chart::WCartesianChart::renderLegend ( WPainter painter) const [protected, virtual]

Renders the (default) legend and chart titles.

See also:
render()
void Wt::Chart::WCartesianChart::renderLegendIcon ( WPainter painter,
const WPointF pos,
const WDataSeries series 
) const [virtual]

Renders the legend icon for a given data series.

Renders the legend icon for the indicated series in the painter at position pos.

This method is called while rendering a legend item, and you may want to reimplement this method if you wish to provide a custom legend icon for a particular data series.

See also:
renderLegendItem()
void Wt::Chart::WCartesianChart::renderLegendItem ( WPainter painter,
const WPointF pos,
const WDataSeries series 
) const [virtual]

Renders the legend item for a given data series.

Renders the legend item for the indicated series in the painter at position pos. The default implementation draws the marker, and the series description to the right. The series description is taken from the model's header data for that series' data column.

This method is called while painting the chart, and you may want to reimplement this method if you wish to provide a custom marker for a particular data series.

See also:
setLegendEnabled()
void Wt::Chart::WCartesianChart::renderSeries ( WPainter painter) const [protected, virtual]

Renders all series data, including value labels.

See also:
render()

Checks whether the rubberband effect is enabled.

See also:
setRubberBandEffect()

Returns a data series corresponding to a data column.

Returns a reference to the first data series that plots data from modelColumn.

const WDataSeries & Wt::Chart::WCartesianChart::series ( int  modelColumn) const

Returns a data series corresponding to a data column.

Returns a const reference to the first data series that plots data from modelColumn.

const std::vector<WDataSeries>& Wt::Chart::WCartesianChart::series ( ) const

Returns a list with the current data series.

Returns the complete list of current data series.

See also:
setSeries(const std::vector<WDataSeries>&)
void Wt::Chart::WCartesianChart::setAxis ( WAxis waxis,
Axis  axis 
)

Sets an axis.

Ownership is transferred and a previously set (default) axis is deleted first.

See also:
axis(Axis axis)
void Wt::Chart::WCartesianChart::setAxisPadding ( int  axisPadding)

Sets the padding between the chart area and the axes.

This calls WAxes::setPadding() on all axes.

See also:
axisPadding()

Sets the margin between bars of different series.

Use this method to change the margin that is set between bars of different series. The margin is specified as a fraction of the width. For example, a value of 0.1 adds a 10% margin between bars of each series. Negative values are also allowed. For example, use a margin of -1 to plot the bars of different series on top of each other.

The default value is 0.

Sets the pen of the border to be drawn around the chart area.

See also:
borderPen()
void Wt::Chart::WCartesianChart::setCrosshairEnabled ( bool  crosshair = true)

Enables the crosshair functionality.

When enabled, the crosshair will follow mouse movement, and show in the top right corner the coordinate (according to X axis and the first Y axis) corresponding to this position.

When using touch, the crosshair can be moved with a drag. If both panning and the crosshair are enabled, the crosshair will be moved when dragging close to the crosshair. Otherwise, the chart will pan.

void Wt::Chart::WCartesianChart::setFollowCurve ( int  modelColumn)

Enables the follow curve functionality for a data series.

This enables follow curve functionality for the data series corresponding to the given column.

If the data series is of type LineSeries or CurveSeries, the crosshair can only be moved in the x direction. The y position of the crosshair will be determined by the value of the data series. The crosshair will snap to the nearest point that is defined in the data series.

When using the mouse, the x position will change on mouseover. When using touch, the x position can be moved with a drag. The follow curve functionality has priority over the crosshair functionality.

Use column index -1 or disableFollowCurve() to disable the follow curve feature.

Note:
The follow curve functionality requires that the X axis values of the data series are monotonically increasing or decreasing.
void Wt::Chart::WCartesianChart::setLegendColumns ( int  columns,
const WLength width 
)

Configures multiple legend columns.

Multiple columns are typically useful when placing the legend at the top or at the bottom of the chart.

The default value is a single column, 100 pixels wide.

When automatic chart layout is enabled, then the legend column width is computed automatically, and this setting is ignored.

See also:
setAutoLayoutEnabled()

Enables the legend.

The location of the legend can be configured using setLegendLocation(). Only series for which the legend is enabled are included in this legend.

The default value is false.

See also:
see WDataSeries::isLegendEnabled(), setLegendLocation()

Configures the legend location.

The legend can be renderd either inside or outside of the chart area. When location is Chart::LegendInside, the legend will be rendered inside the chart. When location is Chart::Legendoutside, the legend is rendered outside the chart, in the chart padding area.

The provided side can either be Wt::Left, Wt::Right, Wt::Top, Wt::Bottom and configures the side of the chart at which the legend is displayed.

The alignment specifies how the legend is aligned. This can be a horizontal alignment flag (Wt::AlignLeft, Wt::AlignCenter, or Wt::AlignRight), when the side is Bottom or Top, or a vertical alignment flag (Wt::AlignTop, Wt::AlignMiddle, or Wt::AlignBottom) when the side is Left or Right.

The default location is Chart::LegendOutside, Wt::Right and Wt::AlignMiddle.

To have more control over the legend, you could reimplement the renderLegendItem() method to customize how one item in the legend is rendered, or, alternatively you can disable the legend generated by the chart itself, and reimplement the paint() method in which you use the renderLegendItem() method repeatedly to render a customized legend.

See also:
WDataSeries::setLegendEnabled()
void Wt::Chart::WCartesianChart::setLegendStyle ( const WFont font,
const WPen border,
const WBrush background 
)

Configures the legend decoration.

This configures the font, border and background for the legend.

The default font is a 10pt sans serif font (the same as the default axis label font), the default border is NoPen and the default background is NoBrush.

See also:
setLegendEnabled()

Sets the chart orientation.

Sets the chart orientation, which corresponds to the orientation of the Y axis: a Wt::Vertical orientation corresponds to the conventional way of a horizontal X axis and vertical Y axis. A Wt::Horizontal orientation is the other way around.

The default orientation is Wt::Vertical.

See also:
orientation()
void Wt::Chart::WCartesianChart::setPanEnabled ( bool  pan = true)

Enables pan functionality.

When using the mouse, you can click and drag to pan the chart (if zoomed in), or use the scrollwheel.

When using touch, you can drag to pan the chart. If the rubberband effect is enabled, this is intertial (it will keep scrolling after you let go) and there is an overscroll and bounce back effect on the sides.

The default value is false.

See also:
panEnabled()

Enables/disables the inertial scrolling and rubberband effect.

See also:
setPanEnabled()
void Wt::Chart::WCartesianChart::setSeries ( const std::vector< WDataSeries > &  series)

Sets all data series.

Replaces the current list of series with the new list.

See also:
series(), addSeries(), removeSeries()

Enables or disables soft label clipping on all axes.

See also:
WAxis::setSoftLabelClipping()

set the pen used to render the labels

This method overwrites the pen for all axes

See also:
WAxis::setTextPen()

Sets the chart type.

The chart type determines how (x,y) data are interpreted. In a CategoryChart, the X values are categories, and these are plotted consecutively, evenly spaced, and in row order. In a ScatterPlot, the X values are interpreted numerically (as for Y values).

The default chart type is a CategoryChart.

See also:
type()
WAxis::setScale(), axis(Axis)

Sets the mapping of mouse wheel actions for interactive charts.

See also:
wheelActions()

Sets the the model column for the X series.

Use this method to specify the default data for the X series. For a ScatterPlot this is mandatory if an X series is not specified for every WDataSeries. For a CategoryChart, if not specified, an increasing series of integer numbers will be used (1, 2, ...).

Scatterplot dataseries may each individually be given its own X series data using WDataSeries::setXSeriesColumn(int modelColumn)

The default value is -1 (not specified).

The series column is reset to -1 when the model is set (or changed). Thus you need to set a model before configuring the series.

See also:
XSeriesColumn()
void Wt::Chart::WCartesianChart::setZoomEnabled ( bool  zoom = true)

Enables zoom functionality.

When using the mouse, press the ctrl key while scrolling to zoom in/out a specific point on the chart. If you press shift+ctrl, it will only zoom vertically. If you press alt+ctrl, it will only zoom horizontally. To change these default mappings, use setWheelActions().

When using touch, you can use a pinch gesture to zoom in/out. If the pinch gesture is vertical/horizontal, it will zoom only vertically/horizontally, otherwise it will zoom both axes equally.

The default value is false.

See also:
zoomEnabled()
setWheelActions(WheelActions)

Returns the chart type.

See also:
setType()

Returns the current mouse wheel actions for interactive charts.

See also:
setWheelActions()

Returns the model column for the X series.

See also:
setXSeriesColumn()

Returns whether zoom is enabled.

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

Generated on Tue Mar 22 2016 for the C++ Web Toolkit (Wt) by doxygen 1.7.6.1