Class WCartesianChart


public class WCartesianChart
extends WAbstractChart
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 WAbstractChart#setModel(), set the model column that holds the X data using setXSeriesColumn(), and add one or more series using addSeries(). Each series corresponds to one data column that holds Y data.

A cartesian chart is either a ChartType.CategoryChart or a ChartType.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 AxisScale.CategoryScale.

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 AxisScale.LinearScale, but this may be changed to a AxisScale.DateScale when the X series contains dates (of type WDate) to create a time series chart, or to a AxisScale.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().

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:

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

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

CSS

Styling through CSS is not applicable.

Client-side interaction

WCartesianChart has several features that allow interaction with the chart without server roundtrips. These features include zoom, pan, crosshair and follow curve functionality.

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

Note: 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.
  • WAxis#setBreak() is incompatible with interactive mode
See Also:
WDataSeries, WAxis, WPieChart