Class WCartesianChart
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.Category
or a ChartType.Scatter
.
In a ChartType.Category
, the X series represent different categories, which are
listed consecutively in model row order. The X axis scale is set to AxisScale.Discrete
.

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 ChartType.Scatter
, the X series data are interpreted as numbers on a
numerical scale. The scale for the X axis defaults to a AxisScale.Linear
, but this may be
changed to a AxisScale.Date
when the X series contains dates (of type WDate
) to create a time series chart, or to a AxisScale.Log
. A ChartType.Scatter
supports the same types of data series as a ChartType.Category
, 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 setPalette(WChartPalette *), 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:
AxisValue.Zero
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new cartesian chart.WCartesianChart
(ChartType type) Creates a new cartesian chart.WCartesianChart
(ChartType type, WContainerWidget parentContainer) Creates a new cartesian chart.WCartesianChart
(WContainerWidget parentContainer) Creates a new cartesian chart. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCurveLabel
(CurveLabel label) Add a curve label.void
addDataPointArea
(WDataSeries series, int xRow, int xColumn, WAbstractArea area) Adds a data point area (used for displaying e.g.void
addSeries
(WDataSeries series) Adds a data series.int
Adds a X axis to this chart.int
Adds a Y axis to this chart.protected void
Calculates the chart area.protected WRectF
chartSegmentArea
(WAxis yAxis, int xSegment, int ySegment) Returns the segment area for a combination of X and Y segments.protected WRectF
chartSegmentArea
(WAxis xAxis, WAxis yAxis, int xSegment, int ySegment) Returns the segment area for a combination of X and Y segments.void
Clear all curve labels.void
Clears all X axes.void
Clears all Y axes.createLegendItemWidget
(int index) Creates a widget which renders the a legend item.void
Disable the follow curve functionality.void
drawMarker
(WDataSeries series, WPainterPath result) Draws the marker for a given data series.Returns a chart axis.int
Returns the padding between the chart area and the axes.double
Returns the margin between bars of different series.Returns the pen used to draw the border around the chart area.protected int
Calculates the total number of bar groups.Returns the crosshair color.int
Returns the X axis to use for the crosshair.int
Returns the Y axis to use for the crosshair.Get all of the registered curve labels.protected void
getDomChanges
(List<DomElement> result, WApplication app) Get DOM changes for this widget.Returns the curve that is to be followed.Returns the legend alignment.Returns the legend background brush.Returns the legend border pen.int
Returns the legend columns.Returns the legend column width.Returns the legend font.Returns the legend location.Returns the legend side.Returns the background brush for the unloaded area.Returns the chart orientation.Get the currently selected curve.Returns a list with the current data series.getSeries
(int modelColumn) Returns a data series corresponding to a data column.getType()
Returns the chart type.Returns the current mouse wheel actions for interactive charts.getXAxes()
Returns a vector of all X axes associated with this chart.getXAxis
(int i) Retrieves the X axis at index i.int
Returns the number of X axes associated with this chart.getYAxes()
Returns a vector of all Y axes associated with this chart.getYAxis
(int i) Retrieves the Y axis at index i.int
Returns the number of Y axes associated with this chart.protected WPointF
hv
(double x, double y) Conversion between chart and painter coordinates.protected WPointF
Conversion between chart and painter coordinates.protected WRectF
Conversion between chart and painter coordinates.final boolean
Initializes the chart layout.final boolean
initLayout
(WRectF rectangle) Initializes the chart layout.boolean
initLayout
(WRectF rectangle, WPaintDevice device) Initializes the chart layout.boolean
Returns whether the crosshair is enabled.boolean
Returns whether curve manipulation is enabled.boolean
Returns whether the legend is enabled.boolean
Returns whether on-demand loading is enabled.boolean
Returns whether pan is enabled.boolean
Checks whether the rubberband effect is enabled.boolean
Returns whether series selection is enabled.boolean
Returns whether zoom is enabled.final void
iterateSeries
(SeriesIterator iterator, WPainter painter) final void
iterateSeries
(SeriesIterator iterator, WPainter painter, boolean reverseStacked) void
iterateSeries
(SeriesIterator iterator, WPainter painter, boolean reverseStacked, boolean extremesOnly) protected final WPointF
map
(double xValue, double yValue) Map (x, y) value pair to chart coordinates coordinates.protected final WPointF
map
(double xValue, double yValue, int yAxis) Map (x, y) value pair to chart coordinates coordinates.protected final WPointF
map
(double xValue, double yValue, int yAxis, int currentXSegment) Map (x, y) value pair to chart coordinates coordinates.protected WPointF
map
(double xValue, double yValue, int yAxis, int currentXSegment, int currentYSegment) Map (x, y) value pair to chart coordinates coordinates.protected final WPointF
Map (x, y) value pair to chart coordinates coordinates.protected final WPointF
Map (x, y) value pair to chart coordinates coordinates.protected WPointF
Map (x, y) value pair to chart coordinates coordinates.protected final WPointF
Map (x, y) value pair to chart coordinates coordinates.protected final WPointF
Map (x, y) value pair to chart coordinates coordinates.protected WPointF
map
(double xValue, double yValue, WAxis xAxis, WAxis yAxis, int currentXSegment, int currentYSegment) Map (x, y) value pair to chart coordinates coordinates.final WPointF
mapFromDevice
(WPointF point) Maps from device coordinates to model coordinates.mapFromDevice
(WPointF point, int ordinateAxis) Maps from device coordinates to model coordinates.mapFromDevice
(WPointF point, Axis ordinateAxis) Maps from device coordinates to model coordinates.mapFromDevice
(WPointF point, WAxis xAxis, WAxis yAxis) Maps from device coordinates to model coordinates.final WPointF
Maps from device coordinates to model coordinates, ignoring the current zoom range.mapFromDeviceWithoutTransform
(WPointF point, int ordinateAxis) Maps from device coordinates to model coordinates, ignoring the current zoom range.mapFromDeviceWithoutTransform
(WPointF point, Axis ordinateAxis) Maps from device coordinates to model coordinates, ignoring the current zoom range.mapFromDeviceWithoutTransform
(WPointF point, WAxis xAxis, WAxis yAxis) Maps from device coordinates to model coordinates, ignoring the current zoom range.final WPointF
mapToDevice
(Object xValue, Object yValue) Maps model values onto chart coordinates.final WPointF
mapToDevice
(Object xValue, Object yValue, int axis) Maps model values onto chart coordinates.final WPointF
mapToDevice
(Object xValue, Object yValue, int axis, int xSegment) Maps model values onto chart coordinates.mapToDevice
(Object xValue, Object yValue, int axis, int xSegment, int ySegment) Maps model values onto chart coordinates.final WPointF
mapToDevice
(Object xValue, Object yValue, Axis axis) Maps model values onto chart coordinates.final WPointF
mapToDevice
(Object xValue, Object yValue, Axis axis, int xSegment) Maps model values onto chart coordinates.mapToDevice
(Object xValue, Object yValue, Axis axis, int xSegment, int ySegment) Maps model values onto chart coordinates.final WPointF
mapToDevice
(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis) Maps model values onto chart coordinates.final WPointF
mapToDevice
(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis, int xSegment) Maps model values onto chart coordinates.mapToDevice
(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis, int xSegment, int ySegment) Maps model values onto chart coordinates.final WPointF
mapToDeviceWithoutTransform
(Object xValue, Object yValue) Maps model values onto chart coordinates, ignoring the current zoom range.final WPointF
mapToDeviceWithoutTransform
(Object xValue, Object yValue, int ordinateAxis) Maps model values onto chart coordinates, ignoring the current zoom range.final WPointF
mapToDeviceWithoutTransform
(Object xValue, Object yValue, int ordinateAxis, int xSegment) Maps model values onto chart coordinates, ignoring the current zoom range.mapToDeviceWithoutTransform
(Object xValue, Object yValue, int ordinateAxis, int xSegment, int ySegment) Maps model values onto chart coordinates, ignoring the current zoom range.final WPointF
mapToDeviceWithoutTransform
(Object xValue, Object yValue, Axis ordinateAxis) Maps model values onto chart coordinates, ignoring the current zoom range.final WPointF
mapToDeviceWithoutTransform
(Object xValue, Object yValue, Axis ordinateAxis, int xSegment) Maps model values onto chart coordinates, ignoring the current zoom range.mapToDeviceWithoutTransform
(Object xValue, Object yValue, Axis ordinateAxis, int xSegment, int ySegment) Maps model values onto chart coordinates, ignoring the current zoom range.final WPointF
mapToDeviceWithoutTransform
(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis) Maps model values onto chart coordinates, ignoring the current zoom range.final WPointF
mapToDeviceWithoutTransform
(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis, int xSegment) Maps model values onto chart coordinates, ignoring the current zoom range.mapToDeviceWithoutTransform
(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis, int xSegment, int ySegment) Maps model values onto chart coordinates, ignoring the current zoom range.protected void
protected void
void
Paint the chart in a rectangle of the given painter.protected void
paintEvent
(WPaintDevice paintDevice) Paints the widget.protected boolean
prepareAxes
(WPaintDevice device) Prepares the axes for rendering.void
remove()
Destructor.removeSeries
(WDataSeries series) Removes a data series.removeXAxis
(int xAxisId) Removes the X axis with the given id.removeYAxis
(int yAxisId) Removes the Y axis with the given id.protected void
Renders the chart.protected void
render
(EnumSet<RenderFlag> flags) Renders the widget.protected final void
renderAxes
(WPainter painter, AxisProperty propertie, AxisProperty... properties) Renders one or more properties of the axes.protected void
renderAxes
(WPainter painter, EnumSet<AxisProperty> properties) Renders one or more properties of the axes.protected final void
renderAxis
(WPainter painter, WAxis axis, AxisProperty propertie, AxisProperty... properties) Renders properties of one axis.protected void
renderAxis
(WPainter painter, WAxis axis, EnumSet<AxisProperty> properties) Renders properties of one axis.protected void
renderBackground
(WPainter painter) Renders the background.protected void
renderBorder
(WPainter painter) Renders the border of the chart area.protected void
renderCurveLabels
(WPainter painter) Renders the curve labels.protected void
renderGrid
(WPainter painter, WAxis ax) Renders grid lines along the ticks of the given axis.protected void
renderLabel
(WPainter painter, CharSequence text, WPointF p, EnumSet<AlignmentFlag> flags, double angle, int margin) Utility function for rendering text.protected void
renderLegend
(WPainter painter) Renders the (default) legend and chart titles.void
renderLegendIcon
(WPainter painter, WPointF pos, WDataSeries series) Renders the legend icon for a given data series.void
renderLegendItem
(WPainter painter, WPointF pos, WDataSeries series) Renders the legend item for a given data series.protected void
renderOther
(WPainter painter) Renders other, user-defined things.protected void
renderSeries
(WPainter painter) Renders all series data, including value labels.A signal that notifies the selection of a new curve.void
Sets an axis.void
setAxisPadding
(int padding) Sets the padding between the chart area and the axes.void
setBarMargin
(double margin) Sets the margin between bars of different series.void
setBorderPen
(WPen pen) Sets the pen of the border to be drawn around the chart area.void
setCrosshairColor
(WColor color) Sets the crosshair color.final void
Enables the crosshair functionality.void
setCrosshairEnabled
(boolean crosshair) Enables the crosshair functionality.void
setCrosshairXAxis
(int xAxis) Sets the X axis to use for the crosshair.void
setCrosshairYAxis
(int yAxis) Sets the Y axis to use for the crosshair.void
setCurveLabels
(List<CurveLabel> labels) Configure all curve labels at once.final void
Enable curve manipulation.void
setCurveManipulationEnabled
(boolean enabled) Enable curve manipulation.void
setFollowCurve
(int followCurve) Deprecated.void
setFollowCurve
(WDataSeries series) Enabled the follow curve funtionality for a data series.protected void
setFormData
(WObject.FormData formData) void
setLegendColumns
(int columns, WLength columnWidth) Configures multiple legend columns.void
setLegendEnabled
(boolean enabled) Enables the legend.void
setLegendLocation
(LegendLocation location, Side side, AlignmentFlag alignment) Configures the legend location.void
setLegendStyle
(WFont font, WPen border, WBrush background) Configures the legend decoration.void
setLoadingBackground
(WBrush brush) Set the background brush for the unloaded area.void
setOnDemandLoadingEnabled
(boolean enabled) Enable on-demand loading.void
setOrientation
(Orientation orientation) Sets the chart orientation.final void
Enables pan functionality.void
setPanEnabled
(boolean panEnabled) Enables pan functionality.final void
Enables/disables the inertial scrolling and rubberband effect.void
setRubberBandEffectEnabled
(boolean rubberBandEnabled) Enables/disables the inertial scrolling and rubberband effect.void
setSelectedSeries
(WDataSeries series) Sets the series that is currently selected.void
setSeries
(List<WDataSeries> series) Sets all data series.final void
Sets whether series selection is enabled.void
setSeriesSelectionEnabled
(boolean enabled) Sets whether series selection is enabled.void
setSoftLabelClipping
(boolean enabled) Enables or disables soft label clipping on all axes.void
setTextPen
(WPen pen) set the pen used to render the labelsvoid
Sets the chart type.void
setWheelActions
(Map<EnumSet<KeyboardModifier>, InteractiveAction> wheelActions) Sets the mapping of mouse wheel actions for interactive charts.void
setXSeriesColumn
(int modelColumn) Sets the the model column for the X series.final void
Enables zoom functionality.void
setZoomEnabled
(boolean zoomEnabled) Enables zoom functionality.int
Returns the model column for the X series.protected final WTransform
Returns the current zoom range transform.protected WTransform
zoomRangeTransform
(int yAxis) Returns the current zoom range transform.protected WTransform
zoomRangeTransform
(WAxis xAxis, WAxis yAxis) Returns the current zoom range transform.Methods inherited from class eu.webtoolkit.jwt.chart.WAbstractChart
getBackground, getItemModel, getModel, getPalette, getPlotAreaPadding, getTitle, getTitleFont, isAutoLayoutEnabled, paint, setAutoLayoutEnabled, setAutoLayoutEnabled, setBackground, setModel, setModel, setPalette, setPlotAreaPadding, setPlotAreaPadding, setPlotAreaPadding, setTitle, setTitleFont
Methods inherited from class eu.webtoolkit.jwt.WPaintedWidget
addArea, createDomElement, createJSBrush, createJSPainterPath, createJSPen, createJSPoint, createJSRect, createJSTransform, enableAjax, getArea, getAreas, getCreatePaintDevice, getMethod, getObjJsRef, getPreferredMethod, getRepaintSlot, insertArea, layoutSizeChanged, removeArea, resize, setPreferredMethod, update, update, update
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, propagateSetEnabled, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isCanReceiveFocus, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, refresh, removeScript, removeStyleClass, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, 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
getObjectName
-
Constructor Details
-
WCartesianChart
Creates a new cartesian chart.Creates a cartesian chart of type
ChartType.Category
. -
WCartesianChart
public WCartesianChart()Creates a new cartesian chart. -
WCartesianChart
Creates a new cartesian chart.Creates a cartesian chart of the indicated
type
. -
WCartesianChart
Creates a new cartesian chart.
-
-
Method Details
-
remove
public void remove()Description copied from class:WAbstractChart
Destructor.- Overrides:
remove
in classWAbstractChart
- See Also:
-
setType
Sets the chart type.The chart type determines how (x,y) data are interpreted. In a
ChartType.Category
, the X values are categories, and these are plotted consecutively, evenly spaced, and in row order. In aChartType.Scatter
, the X values are interpreted numerically (as for Y values).The default chart type is a
ChartType.Category
. -
getType
Returns the chart type.- See Also:
-
setOrientation
Sets the chart orientation.Sets the chart orientation, which corresponds to the orientation of the Y axis: a
Orientation.Vertical
orientation corresponds to the conventional way of a horizontal X axis and vertical Y axis. AOrientation.Horizontal
orientation is the other way around.The default orientation is
Orientation.Vertical
.- See Also:
-
getOrientation
Returns the chart orientation.- See Also:
-
setXSeriesColumn
public void setXSeriesColumn(int modelColumn) Sets the the model column for the X series.Use this method to specify the default data for the X series. For a
ChartType.Scatter
this is mandatory if an X series is not specified for everyWDataSeries
. For aChartType.Category
, 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()
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:
-
setTextPen
set the pen used to render the labelsThis method overwrites the pen for all axes
- See Also:
-
XSeriesColumn
public int XSeriesColumn()Returns the model column for the X series.- See Also:
-
addSeries
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.
-
removeSeries
Removes a data series.This will disassociate the given series from any WAxisSliderWidgets.
-
setSeries
Sets all data series.Replaces the current list of series with the new list.
-
getSeries
Returns a data series corresponding to a data column.Returns a reference to the first data series that plots data from
modelColumn
. -
getSeries
Returns a list with the current data series.Returns the complete list of current data series.
-
getAxis
Returns a chart axis.Returns a reference to the specified
axis
. -
setAxis
Sets an axis.- See Also:
-
getXAxes
Returns a vector of all X axes associated with this chart.This defaults to a vector of one axis.
-
getYAxes
Returns a vector of all Y axes associated with this chart.This defaults to a vector of two axes: the Y1 and Y2 axes. Y1 will be at index 0, and Y2 will be at index 1.
-
getXAxisCount
public int getXAxisCount()Returns the number of X axes associated with this chart. -
getYAxisCount
public int getYAxisCount()Returns the number of Y axes associated with this chart. -
getXAxis
Retrieves the X axis at index i.The following expression is always true:
getAxis(Axis.XAxis) == getXAxis(0)
Note: Precondition: 0 <= i <
getXAxisCount()
-
getYAxis
Retrieves the Y axis at index i.The following expressions are always true:
axis(Y1) == yAxis(0) axis(Y2) == yAxis(1)
Note: Precondition: 0 <= i <
getYAxisCount()
-
addXAxis
Adds a X axis to this chart.The first extra axis will have index 1, the next index 2,...
Returns the index of the added axis.
Note: This transfers ownership of the given
WAxis
to this chart.Note: Precondition: waxis is not null
-
addYAxis
Adds a Y axis to this chart.The first extra axis will have index 2, the next index 3,...
Returns the index of the added axis.
Note: This transfers ownership of the given
WAxis
to this chart.Note: Precondition: waxis is not null
-
removeXAxis
Removes the X axis with the given id.The indices of the axes with an id higher than xAxisId will be decremented.
Any
WDataSeries
associated with the removed axis are also removed.Note: Precondition: 0 <= xAxisId <
getXAxisCount()
-
removeYAxis
Removes the Y axis with the given id.The indices of the axes with an id higher than yAxisId will be decremented.
Any
WDataSeries
associated with the removed axis are also removed.Note: Precondition: 0 <= yAxisId <
getYAxisCount()
-
clearXAxes
public void clearXAxes()Clears all X axes.The effect is the same as repeatedly using
removeYAxis()
until are axes are removed, i.e. anyWDataSeries
will also be removed. -
clearYAxes
public void clearYAxes()Clears all Y axes.The effect is the same as repeatedly using
removeYAxis()
until are axes are removed, i.e. anyWDataSeries
will also be removed. -
setBarMargin
public void setBarMargin(double margin) 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.
-
getBarMargin
public double getBarMargin()Returns the margin between bars of different series.- See Also:
-
setLegendEnabled
public void setLegendEnabled(boolean enabled) 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
. -
isLegendEnabled
public boolean isLegendEnabled()Returns whether the legend is enabled.- See Also:
-
setLegendLocation
Configures the legend location.The legend can be renderd either inside or outside of the chart area. When
location
isLegendLocation.Inside
, the legend will be rendered inside the chart. Whenlocation
isLegendLocation.Outside
, the legend is rendered outside the chart, in the chart padding area.The provided
side
can either beSide.Left
,Side.Right
,Side.Top
,Side.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 (AlignmentFlag.Left
,AlignmentFlag.Center
, orAlignmentFlag.Right
), when theside
isSide.Bottom
orSide.Top
, or a vertical alignment flag (AlignmentFlag.Top
,AlignmentFlag.Middle
, orAlignmentFlag.Bottom
) when theside
isSide.Left
orSide.Right
.The default location is
LegendLocation.Outside
,Side.Right
andAlignmentFlag.Middle
.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 thepaint()
method in which you use therenderLegendItem()
method repeatedly to render a customized legend. -
setLegendStyle
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 PenStyle::None and the defaultbackground
is BrushStyle::None.- See Also:
-
getLegendLocation
Returns the legend location. -
getLegendSide
Returns the legend side. -
getLegendAlignment
Returns the legend alignment. -
getLegendColumns
public int getLegendColumns()Returns the legend columns. -
getLegendColumnWidth
Returns the legend column width. -
getLegendFont
Returns the legend font. -
getLegendBorder
Returns the legend border pen. -
getLegendBackground
Returns the legend background brush. -
setLegendColumns
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.
-
paint
Description copied from class:WAbstractChart
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
WPainter.getWindow()
is used.- Specified by:
paint
in classWAbstractChart
-
drawMarker
Draws the marker for a given data series.Draws the marker for the indicated
series
in theresult
. 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:
-
renderLegendIcon
Renders the legend icon for a given data series.Renders the legend icon for the indicated
series
in thepainter
at positionpos
.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.
-
renderLegendItem
Renders the legend item for a given data series.Renders the legend item for the indicated
series
in thepainter
at positionpos
. 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:
-
mapFromDevice
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 that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.If the chart is interactive, mapFromDevice will correctly take the current zoom range into account.
-
mapFromDevice
Maps from device coordinates to model coordinates. -
mapFromDevice
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 that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.If the chart is interactive, mapFromDevice will correctly take the current zoom range into account.
-
mapFromDeviceWithoutTransform
Maps from device coordinates to model coordinates, ignoring the current zoom range.Maps a position in the chart back to model coordinates, as if the chart was not zoomed in (nor panned).
This uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.This function will not take the current zoom range into account. The mapping will be performed as if
zoomRangeTransform()
is the identity transform. -
mapFromDeviceWithoutTransform
Maps from device coordinates to model coordinates, ignoring the current zoom range. -
mapFromDevice
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 that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.If the chart is interactive, mapFromDevice will correctly take the current zoom range into account.
-
mapFromDeviceWithoutTransform
Maps from device coordinates to model coordinates, ignoring the current zoom range.Maps a position in the chart back to model coordinates, as if the chart was not zoomed in (nor panned).
This uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.This function will not take the current zoom range into account. The mapping will be performed as if
zoomRangeTransform()
is the identity transform. -
mapFromDeviceWithoutTransform
Maps from device coordinates to model coordinates, ignoring the current zoom range.Maps a position in the chart back to model coordinates, as if the chart was not zoomed in (nor panned).
This uses the axis dimensions that are based on the latest chart rendering. If you have not yet rendered the chart, or wish that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.This function will not take the current zoom range into account. The mapping will be performed as if
zoomRangeTransform()
is the identity transform. -
mapToDevice
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 that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.The
xSegment
andySegment
arguments are relevant only when the corresponding axis is broken usingWAxis#setBreak()
. Then, its possible values may be 0 (below the break) or 1 (above the break).If the chart is interactive, mapToDevice will correctly take the current zoom range into account.
-
mapToDevice
Maps model values onto chart coordinates. -
mapToDevice
Maps model values onto chart coordinates. -
mapToDevice
Maps model values onto chart coordinates. -
mapToDevice
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 that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.The
xSegment
andySegment
arguments are relevant only when the corresponding axis is broken usingWAxis#setBreak()
. Then, its possible values may be 0 (below the break) or 1 (above the break).If the chart is interactive, mapToDevice will correctly take the current zoom range into account.
-
mapToDevice
Maps model values onto chart coordinates. -
mapToDevice
Maps model values onto chart coordinates. -
mapToDevice
public WPointF mapToDevice(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis, int xSegment, int ySegment) 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 that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.The
xSegment
andySegment
arguments are relevant only when the corresponding axis is broken usingWAxis#setBreak()
. Then, its possible values may be 0 (below the break) or 1 (above the break).If the chart is interactive, mapToDevice will correctly take the current zoom range into account.
-
mapToDevice
Maps model values onto chart coordinates. -
mapToDevice
public final WPointF mapToDevice(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis, int xSegment) Maps model values onto chart coordinates.Returns
mapToDevice(xValue, yValue, xAxis, yAxis, xSegment, 0)
-
mapToDeviceWithoutTransform
public WPointF mapToDeviceWithoutTransform(Object xValue, Object yValue, Axis ordinateAxis, int xSegment, int ySegment) Maps model values onto chart coordinates, ignoring the current zoom range.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 that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.The
xSegment
andySegment
arguments are relevant only when the corresponding axis is broken usingWAxis#setBreak()
. Then, its possible values may be 0 (below the break) or 1 (above the break).This function will not take the current zoom range into account.The mapping will be performed as if
zoomRangeTransform()
is the identity transform. -
mapToDeviceWithoutTransform
Maps model values onto chart coordinates, ignoring the current zoom range.Returns
mapToDeviceWithoutTransform(xValue, yValue, Axis.Ordinate, 0, 0)
-
mapToDeviceWithoutTransform
Maps model values onto chart coordinates, ignoring the current zoom range.Returns
mapToDeviceWithoutTransform(xValue, yValue, ordinateAxis, 0, 0)
-
mapToDeviceWithoutTransform
public final WPointF mapToDeviceWithoutTransform(Object xValue, Object yValue, Axis ordinateAxis, int xSegment) Maps model values onto chart coordinates, ignoring the current zoom range.Returns
mapToDeviceWithoutTransform(xValue, yValue, ordinateAxis, xSegment, 0)
-
mapToDeviceWithoutTransform
public WPointF mapToDeviceWithoutTransform(Object xValue, Object yValue, int ordinateAxis, int xSegment, int ySegment) Maps model values onto chart coordinates, ignoring the current zoom range.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 that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.The
xSegment
andySegment
arguments are relevant only when the corresponding axis is broken usingWAxis#setBreak()
. Then, its possible values may be 0 (below the break) or 1 (above the break).This function will not take the current zoom range into account.The mapping will be performed as if
zoomRangeTransform()
is the identity transform. -
mapToDeviceWithoutTransform
Maps model values onto chart coordinates, ignoring the current zoom range.Returns
mapToDeviceWithoutTransform(xValue, yValue, ordinateAxis, 0, 0)
-
mapToDeviceWithoutTransform
public final WPointF mapToDeviceWithoutTransform(Object xValue, Object yValue, int ordinateAxis, int xSegment) Maps model values onto chart coordinates, ignoring the current zoom range.Returns
mapToDeviceWithoutTransform(xValue, yValue, ordinateAxis, xSegment, 0)
-
mapToDeviceWithoutTransform
public WPointF mapToDeviceWithoutTransform(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis, int xSegment, int ySegment) Maps model values onto chart coordinates, ignoring the current zoom range.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 that the mapping already reflects model changes since the last rendering, you should call
initLayout()
first.The
xSegment
andySegment
arguments are relevant only when the corresponding axis is broken usingWAxis#setBreak()
. Then, its possible values may be 0 (below the break) or 1 (above the break).This function will not take the current zoom range into account.The mapping will be performed as if
zoomRangeTransform()
is the identity transform. -
mapToDeviceWithoutTransform
public final WPointF mapToDeviceWithoutTransform(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis) Maps model values onto chart coordinates, ignoring the current zoom range.Returns
mapToDeviceWithoutTransform(xValue, yValue, xAxis, yAxis, 0, 0)
-
mapToDeviceWithoutTransform
public final WPointF mapToDeviceWithoutTransform(Object xValue, Object yValue, WAxis xAxis, WAxis yAxis, int xSegment) Maps model values onto chart coordinates, ignoring the current zoom range.Returns
mapToDeviceWithoutTransform(xValue, yValue, xAxis, yAxis, xSegment, 0)
-
initLayout
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()
andmapToDevice()
methods.Unless a specific chart rectangle is specified, the entire widget area is assumed.
-
initLayout
public final boolean initLayout()Initializes the chart layout. -
initLayout
Initializes the chart layout. -
createLegendItemWidget
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. -
addDataPointArea
Adds a data point area (used for displaying e.g. tooltips).You may want to specialize this is if you wish to modify (or ignore) the area.
Note: Currently, an area is only created if the
ItemDataRole.ToolTip
data at the data point is not empty. -
setAxisPadding
public void setAxisPadding(int padding) Sets the padding between the chart area and the axes.This calls WAxes::setPadding() on all axes.
- See Also:
-
getAxisPadding
public int getAxisPadding()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:
-
setBorderPen
Sets the pen of the border to be drawn around the chart area.- See Also:
-
getBorderPen
Returns the pen used to draw the border around the chart area.Defaults to PenStyle::None.
- See Also:
-
addCurveLabel
Add a curve label. -
setCurveLabels
Configure all curve labels at once.- See Also:
-
clearCurveLabels
public void clearCurveLabels()Clear all curve labels.- See Also:
-
getCurveLabels
Get all of the registered curve labels.- See Also:
-
setZoomEnabled
public void setZoomEnabled(boolean zoomEnabled) 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
. -
setZoomEnabled
public final void setZoomEnabled()Enables zoom functionality.Calls
setZoomEnabled(true)
-
isZoomEnabled
public boolean isZoomEnabled()Returns whether zoom is enabled.- See Also:
-
setPanEnabled
public void setPanEnabled(boolean panEnabled) 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:
-
setPanEnabled
public final void setPanEnabled()Enables pan functionality.Calls
setPanEnabled(true)
-
isPanEnabled
public boolean isPanEnabled()Returns whether pan is enabled.- See Also:
-
setCrosshairEnabled
public void setCrosshairEnabled(boolean crosshair) 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.
-
setCrosshairEnabled
public final void setCrosshairEnabled()Enables the crosshair functionality. -
isCrosshairEnabled
public boolean isCrosshairEnabled()Returns whether the crosshair is enabled.- See Also:
-
setCrosshairColor
Sets the crosshair color.The crosshair color is black by default.
- See Also:
-
getCrosshairColor
Returns the crosshair color. -
setCrosshairXAxis
public void setCrosshairXAxis(int xAxis) Sets the X axis to use for the crosshair.Defaults to 0 (first X axis)
-
getCrosshairXAxis
public int getCrosshairXAxis()Returns the X axis to use for the crosshair. -
setCrosshairYAxis
public void setCrosshairYAxis(int yAxis) Sets the Y axis to use for the crosshair.Defaults to 0 (first Y axis)
-
getCrosshairYAxis
public int getCrosshairYAxis()Returns the Y axis to use for the crosshair. -
setFollowCurve
public void setFollowCurve(int followCurve) Deprecated.UsesetFollowCurve()
insteadEnables 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
SeriesType.Line
orSeriesType.Curve
, 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.
-
setFollowCurve
Enabled the follow curve funtionality 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
SeriesType.Line
orSeriesType.Curve
, 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.
Set to null 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.
-
disableFollowCurve
public void disableFollowCurve()Disable the follow curve functionality.- See Also:
-
getFollowCurve
Returns the curve that is to be followed.If follow curve functionality is not enabled, returns -1.
- See Also:
-
setRubberBandEffectEnabled
public void setRubberBandEffectEnabled(boolean rubberBandEnabled) Enables/disables the inertial scrolling and rubberband effect.- See Also:
-
setRubberBandEffectEnabled
public final void setRubberBandEffectEnabled()Enables/disables the inertial scrolling and rubberband effect. -
isRubberBandEffectEnabled
public boolean isRubberBandEffectEnabled()Checks whether the rubberband effect is enabled. -
setWheelActions
Sets the mapping of mouse wheel actions for interactive charts.- See Also:
-
getWheelActions
Returns the current mouse wheel actions for interactive charts.- See Also:
-
setSoftLabelClipping
public void setSoftLabelClipping(boolean enabled) Enables or disables soft label clipping on all axes. -
setSeriesSelectionEnabled
public void setSeriesSelectionEnabled(boolean enabled) Sets whether series selection is enabled.If series selection is enabled, series can be selected with a mouse click or long press. If the selected series is a
SeriesType.Line
orSeriesType.Curve
, it can be manipulated ifcurve manipulation
is enabled. The series that are not selected, will be shown in a lighter color. -
setSeriesSelectionEnabled
public final void setSeriesSelectionEnabled()Sets whether series selection is enabled. -
isSeriesSelectionEnabled
public boolean isSeriesSelectionEnabled()Returns whether series selection is enabled. -
seriesSelected
A signal that notifies the selection of a new curve.This signal is emitted if a series is selected using a mouse click or long press. The first argument is the selected series. The second argument is the point that was selected, in model coordinates.
-
setSelectedSeries
Sets the series that is currently selected.The series with the given model column will be selected. The other series will be shown in a lighter color. The series that is currently selected is the one that can be manipulated if
curve manipulation
is enabled, and it is aSeriesType.Line
orSeriesType.Curve
.The selected series can be changed using a long touch or mouse click.
If the argument provided is null or
series selection
is not enabled, no series will be selected. -
getSelectedSeries
Get the currently selected curve.-1 means that no curve is currently selected.
- See Also:
-
setCurveManipulationEnabled
public void setCurveManipulationEnabled(boolean enabled) Enable curve manipulation.If curve manipulation is enabled, the
scale
andoffset
of theselected curve
can be manipulated interactively using drag, scroll, and pinch. -
setCurveManipulationEnabled
public final void setCurveManipulationEnabled()Enable curve manipulation. -
isCurveManipulationEnabled
public boolean isCurveManipulationEnabled()Returns whether curve manipulation is enabled. -
setOnDemandLoadingEnabled
public void setOnDemandLoadingEnabled(boolean enabled) Enable on-demand loading.By default, when on-demand loading is not enabled, the entire chart area is loaded, regardless of whether it is within the current zoom range of the X axis.
When on-demand loading is enabled only the currently visible area + some margin is loaded. As the visible area changes, different data is loaded. This improves performance for charts with a lot of data if not all of the data needs to be visible at the same time.
This feature is especially useful in combination with
WAxis#setMaximumZoomRange()
orWAxis#setMinZoom()
, which makes it impossible for the user to view all of the data at the same time, because that would incur too much overhead.Note: On-demand loading requires that the X axis data for all data series is sorted in ascending order. This feature is optimized for equidistant X axis data, but that's not a requirement.
Note: If no minimum or maximum are set on the Y axis (or axes), then the chart will still have to scan all data of its data series to automatically determine the minimum and maximum Y axis values. If this performance hit is undesirable and the Y axis range is known or guaranteed to be within a certain range, make sure to
set a range
on the Y axis (or axes).- See Also:
-
isOnDemandLoadingEnabled
public boolean isOnDemandLoadingEnabled()Returns whether on-demand loading is enabled. -
setLoadingBackground
Set the background brush for the unloaded area. -
getLoadingBackground
Returns the background brush for the unloaded area. -
iterateSeries
public void iterateSeries(SeriesIterator iterator, WPainter painter, boolean reverseStacked, boolean extremesOnly) -
iterateSeries
-
iterateSeries
-
getDomChanges
Description copied from class:WWebWidget
Get DOM changes for this widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
getDomChanges
in classWPaintedWidget
-
modelChanged
protected void modelChanged()- Overrides:
modelChanged
in classWAbstractChart
-
modelReset
protected void modelReset()- Overrides:
modelReset
in classWAbstractChart
-
paintEvent
Paints the widget.This calls
render()
to paint on the paint device.- Specified by:
paintEvent
in classWPaintedWidget
-
render
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()
. -
map
protected WPointF map(double xValue, double yValue, Axis yAxis, int currentXSegment, int currentYSegment) Map (x, y) value pair to chart coordinates coordinates.The result needs further transformation using
hv()
to painter coordinates. -
map
Map (x, y) value pair to chart coordinates coordinates. -
map
Map (x, y) value pair to chart coordinates coordinates.Returns
map(xValue, yValue, yAxis, 0, 0)
-
map
Map (x, y) value pair to chart coordinates coordinates. -
map
protected WPointF map(double xValue, double yValue, int yAxis, int currentXSegment, int currentYSegment) Map (x, y) value pair to chart coordinates coordinates.The result needs further transformation using
hv()
to painter coordinates. -
map
Map (x, y) value pair to chart coordinates coordinates.Returns
map(xValue, yValue, yAxis, 0, 0)
-
map
Map (x, y) value pair to chart coordinates coordinates. -
map
protected WPointF map(double xValue, double yValue, WAxis xAxis, WAxis yAxis, int currentXSegment, int currentYSegment) Map (x, y) value pair to chart coordinates coordinates.The result needs further transformation using
hv()
to painter coordinates. -
map
Map (x, y) value pair to chart coordinates coordinates. -
map
protected final WPointF map(double xValue, double yValue, WAxis xAxis, WAxis yAxis, int currentXSegment) Map (x, y) value pair to chart coordinates coordinates.Returns
map(xValue, yValue, xAxis, yAxis, currentXSegment, 0)
-
renderLabel
protected void renderLabel(WPainter painter, CharSequence text, WPointF p, EnumSet<AlignmentFlag> flags, double angle, int margin) 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. -
hv
Conversion between chart and painter coordinates.Converts from chart coordinates to painter coordinates, taking into account the chart orientation.
-
hv
Conversion between chart and painter coordinates.Converts from chart coordinates to painter coordinates, taking into account the chart orientation.
-
hv
Conversion between chart and painter coordinates.Converts from chart coordinates to painter coordinates, taking into account the chart orientation.
-
chartSegmentArea
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.
-
chartSegmentArea
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.
-
calcChartArea
protected void calcChartArea()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...).
-
prepareAxes
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.
-
renderBackground
Renders the background. -
renderAxes
Renders one or more properties of the axes.This calls
renderAxis()
for each axis. -
renderAxes
protected final void renderAxes(WPainter painter, AxisProperty propertie, AxisProperty... properties) Renders one or more properties of the axes.Calls
renderAxes(painter, EnumSet.of(propertie, properties))
-
renderBorder
Renders the border of the chart area. -
renderCurveLabels
Renders the curve labels. -
renderSeries
Renders all series data, including value labels. -
renderLegend
Renders the (default) legend and chart titles. -
renderAxis
Renders properties of one axis. -
renderAxis
protected final void renderAxis(WPainter painter, WAxis axis, AxisProperty propertie, AxisProperty... properties) Renders properties of one axis.Calls
renderAxis(painter, axis, EnumSet.of(propertie, properties))
-
renderGrid
Renders grid lines along the ticks of the given axis. -
renderOther
Renders other, user-defined things.The default implementation sets the painter's
clip path
to the chart area, but does not enable clipping.This method can be overridden to draw extra content onto the chart.
Chart coordinates can be mapped to device coordinates with
mapToDeviceWithoutTransform()
. If these need to move and scale along with the zoom range, those points can be transformed withzoomRangeTransform()
.This method is called last by default. If you want to render other things at some other moment, you can override render(WPainter&, const WRectF&).
-
getCalcNumBarGroups
protected int getCalcNumBarGroups()Calculates the total number of bar groups. -
render
Description copied from class:WWidget
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.
- Overrides:
render
in classWPaintedWidget
-
setFormData
- Overrides:
setFormData
in classWPaintedWidget
-
zoomRangeTransform
Returns the current zoom range transform.This transform maps device coordinates from the fully zoomed out position to the current zoom range.
This transform is a
JavaScript bound
transform if this chart is interactive. Otherwise, this transform is just the identity transform. -
zoomRangeTransform
Returns the current zoom range transform.Returns
zoomRangeTransform(0)
-
zoomRangeTransform
Returns the current zoom range transform.This transform maps device coordinates from the fully zoomed out position to the current zoom range.
This transform is a
JavaScript bound
transform if this chart is interactive. Otherwise, this transform is just the identity transform.
-
setFollowCurve()
instead