Wt: Wt::Chart::WAxis Class Reference

Wt 3.3.0

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

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Attributes
Wt::Chart::WAxis Class Reference
Charts (Wt::Chart)

Class which represents an axis of a cartesian chart. More...

`#include <Wt/Chart/WAxis>`

List of all members.

## Public Member Functions
Axis | id () const
| Returns the axis id.
void | setVisible (bool visible)
| Sets whether this axis is visible.
bool | isVisible () const
| Returns whether this axis is visible.
void | setLocation (AxisValue value)
| Sets the axis location.
AxisValue | location () const
| Returns the axis location.
void | setScale (AxisScale scale)
| Sets the scale of the axis.
AxisScale | scale () const
| Returns the scale of the axis.
void | setMinimum (double minimum)
| Sets the minimum value displayed on the axis.
double | minimum () const
| Returns the minimum value displayed on the axis.
void | setMaximum (double maximum)
| Sets the maximum value for the axis displayed on the axis.
double | maximum () const
| Returns the maximum value displayed on the axis.
void | setRange (double minimum, double maximum)
| Sets the axis range (minimum and maximum values) manually.
void | setResolution (double resolution)
| Sets the axis resolution.
double | resolution () const
| Returns the axis resolution.
void | setAutoLimits (WFlags< AxisValue > locations)
| Let the minimum and/or maximum be calculated from the data.
WFlags< AxisValue > | autoLimits () const
| Returns the limits that are calculated automatically.
void | setRoundLimits (WFlags< AxisValue > locations)
| Specifies whether limits should be rounded.
WFlags< AxisValue > | roundLimits () const
| Returns whether limits should be rounded.
void | setBreak (double minimum, double maximum)
| Specifies a range that needs to be omitted from the axis.
void | setLabelInterval (double labelInterval)
| Sets the label interval.
double | labelInterval () const
| Returns the label interval.
void | setLabelFormat (const WString &format)
| Sets the label format.
const WString & | labelFormat () const
| Returns the label format string.
void | setLabelAngle (double angle)
| Sets the label angle.
double | labelAngle () const
| Returns the label angle.
void | setGridLinesEnabled (bool enabled)
| Sets whether gridlines are displayed for this axis.
bool | isGridLinesEnabled () const
| Returns whether gridlines are displayed for this axis.
void | setPen (const WPen &pen)
| Changes the pen used for rendering the axis and ticks.
const WPen & | pen () const
| Returns the pen used for rendering the axis and ticks.
void | setGridLinesPen (const WPen &pen)
| Changes the pen used for rendering the grid lines.
const WPen & | gridLinesPen () const
| Returns the pen used for rendering the grid lines.
void | setMargin (int pixels)
| Sets the margin between the axis and the plot area.
int | margin () const
| Returns the margin between the axis and the plot area.
void | setTitle (const WString &title)
| Sets the axis title.
const WString & | title () const
| Returns the axis title.
void | setTitleFont (const WFont &titleFont)
| Sets the axis title font.
const WFont & | titleFont () const
| Returns the axis title font.
void | setLabelFont (const WFont &labelFont)
| Sets the axis label font.
const WFont & | labelFont () const
| Returns the axis label font.
WCartesianChart * | chart () const
| Returns the chart to which this axis belongs.
## Static Public Attributes
static const double | AUTO_MINIMUM = -DBL_MAX
| Constant which indicates automatic minimum calculation.
static const double | AUTO_MAXIMUM = DBL_MAX
| Constant which indicates automatic maximum calculation.

## Detailed Description

Class which represents an axis of a cartesian chart.

A cartesian chart has two or three axes: an X axis (XAxis), a Y axis (YAxis) and optionally a second Y axis (Y2Axis). Each of the up to three axes in a cartesian chart has a unique id() that identifies which of these three axes it is in the enclosing chart().

Use setVisible() to change the visibility of an axis, setGridLinesEnabled() to show grid lines for an axis. The pen styles for rendering the axis or grid lines may be changed using setPen() and setGridLinesPen(). A margin between the axis and the main plot area may be configured using setMargin().

By default, the axis will automatically adjust its range so that all data will be visible. You may manually specify a range using setMinimum(), setMaximum or setRange(). The interval between labels is by default automatically adjusted depending on the axis length and the range, but may be manually specified using setLabelInterval().

The axis has support for being "broken", to support displaying data with a few outliers which would otherwise swamp the chart. This is not done automatically, but instead you need to use setBreak() to specify the value range that needs to be omitted from the axis. The omission is rendered in the axis and in bars that cross the break.

The labels are shown using a "%.4g" format string for numbers, and a suitable format for DateScale or DateTimeScale formats, which uses heuristics to choose a suitable format. The format may be customized using setLabelFormat(). The angle of the label text may be changed using setLabelAngle(). By default, all labels are printed horizontally.

See also:
  WCartesianChart

## Member Function Documentation

WFlags< AxisValue > Wt::Chart::WAxis::autoLimits | ( |  | ) | const

Returns the limits that are calculated automatically.

This returns the limits (Chart::MinimumValue and/or Chart::MaximumValue) that are calculated automatically from the data, rather than being specified manually using setMinimum() and/or setMaximum().

See also:
  setAutoLimits()

WCartesianChart* Wt::Chart::WAxis::chart | ( |  | ) | const

Returns the chart to which this axis belongs.

See also:
  WCartesianChart::axis()

const WPen& Wt::Chart::WAxis::gridLinesPen | ( |  | ) | const

Returns the pen used for rendering the grid lines.

See also:
  setGridLinesPen()

Axis Wt::Chart::WAxis::id | ( |  | ) | const

Returns the axis id.

See also:
  chart(), WCartesianChart::axis()

bool Wt::Chart::WAxis::isGridLinesEnabled | ( |  | ) | const

Returns whether gridlines are displayed for this axis.

See also:
  setGridLinesEnabled()

bool Wt::Chart::WAxis::isVisible | ( |  | ) | const

Returns whether this axis is visible.

See also:
  setVisible()

double Wt::Chart::WAxis::labelAngle | ( |  | ) | const

Returns the label angle.

See also:
  setLabelAngle()

const WFont& Wt::Chart::WAxis::labelFont | ( |  | ) | const

Returns the axis label font.

See also:
  setLabelFont()

const WString& Wt::Chart::WAxis::labelFormat | ( |  | ) | const

Returns the label format string.

See also:
  setLabelFormat()

double Wt::Chart::WAxis::labelInterval | ( |  | ) | const

Returns the label interval.

See also:
  setLabelInterval()

AxisValue Wt::Chart::WAxis::location | ( |  | ) | const

Returns the axis location.

See also:
  setLocation()

int Wt::Chart::WAxis::margin | ( |  | ) | const

Returns the margin between the axis and the plot area.

See also:
  setMargin()

double Wt::Chart::WAxis::maximum | ( |  | ) | const

Returns the maximum value displayed on the axis.

This returned the maximum value that was set using setMaximum(), or otherwise the automatically calculated (and rounded) maximum.

The numerical value corresponding to a data point is defined by it's AxisScale type.

See also:
  setMaximum(), setAutoLimits(), setRoundLimits()

double Wt::Chart::WAxis::minimum | ( |  | ) | const

Returns the minimum value displayed on the axis.

This returned the minimum value that was set using setMinimum(), or otherwise the automatically calculated (and rounded) minimum.

The numerical value corresponding to a data point is defined by it's AxisScale type.

See also:
  setMinimum(), setAutoLimits(), setRoundLimits()

const WPen& Wt::Chart::WAxis::pen | ( |  | ) | const

Returns the pen used for rendering the axis and ticks.

See also:
  setPen()

double Wt::Chart::WAxis::resolution | ( |  | ) | const

Returns the axis resolution.

See also:
  setResolution()

WFlags<AxisValue> Wt::Chart::WAxis::roundLimits | ( |  | ) | const

Returns whether limits should be rounded.

See also:
  setRoundLimits()

AxisScale Wt::Chart::WAxis::scale | ( |  | ) | const

Returns the scale of the axis.

See also:
  setScale()

void Wt::Chart::WAxis::setAutoLimits | ( | WFlags< AxisValue > | locations | ) |

Let the minimum and/or maximum be calculated from the data.

Using this method, you can indicate that you want to have automatic limits, rather than limits set manually using setMinimum() or setMaximum().

`locations` can be Chart::MinimumValue and/or Chart::MaximumValue.

The default value is Chart::MinimumValue | Chart::MaximumValue.

void Wt::Chart::WAxis::setBreak | ( | double | minimum,
|  | double | maximum
| ) |  |

Specifies a range that needs to be omitted from the axis.

This is useful to display data with a few outliers which would otherwise swamp the chart. This is not done automatically, but instead you need to use setBreak() to specify the value range that needs to be omitted from the axis. The omission is rendered in the axis and in BarSeries that cross the break.

void Wt::Chart::WAxis::setGridLinesEnabled | ( | bool | enabled | ) |

Sets whether gridlines are displayed for this axis.

When enabled, gird lines are drawn for each tick on this axis, using the gridLinesPen().

Unlike all other visual aspects of an axis, rendering of the gridlines is not controlled by setDisplayEnabled().

See also:
  setGridLinesPen(), isGridLinesEnabled()

void Wt::Chart::WAxis::setGridLinesPen | ( | const WPen & | pen | ) |

Changes the pen used for rendering the grid lines.

The default value is a gray pen of 0 width.

See also:
  setPen(), gridLinesPen().

void Wt::Chart::WAxis::setLabelAngle | ( | double | angle | ) |

Sets the label angle.

Sets the angle used for displaying the labels (in degrees). A 0 angle corresponds to horizontal text. Note that this option is only supported by the InlineSvgVml renderers, but not by HtmlCanvas.

The default value is 0.0.

See also:
  labelAngle()

void Wt::Chart::WAxis::setLabelFont | ( | const WFont & | labelFont | ) |

Sets the axis label font.

The default label font is a 10 point Sans Serif font.

See also:
  labelFont()

void Wt::Chart::WAxis::setLabelFormat | ( | const WString & | format | ) |

Sets the label format.

Sets a format string which is used to format values, both for the axis labels as well as data series values (see WDataSeries::setLabelsEnabled()).

For an axis with a LinearScale or LogScale scale, the format string must be a format string that is accepted by snprintf() and which formats one double. If the format string is an empty string, "%.4g" is used.

For an axis with a DateScale scale, the format string must be a format string accepted by WDate::toString(), to format a date. If the format string is an empty string, a suitable format is chosen based on heuristics.

For an axis with a DateTimeScale scale, the format string must be a format string accepted by WDateTime::toString(), to format a date. If the format string is an empty string, a suitable format is chosen based on heuristics.

The default value is an empty string ("").

See also:
  labelFormat()

void Wt::Chart::WAxis::setLabelInterval | ( | double | labelInterval | ) |

Sets the label interval.

Specifies the interval for displaying labels (and ticks) on the axis. The default value is 0.0, and indicates that the interval should be computed automatically.

See also:
  setLabelFormat()

void Wt::Chart::WAxis::setLocation | ( | AxisValue | value | ) |

Sets the axis location.

Configures the location of the axis, relative to values on the other axis (i.e. Y values for the X axis, and X values for the Y axis).

The default value is Chart::MinimumValue.

See also:
  location()

void Wt::Chart::WAxis::setMargin | ( | int | pixels | ) |

Sets the margin between the axis and the plot area.

The margin is defined in pixels.

The default value is 0.

See also:
  margin()

void Wt::Chart::WAxis::setMaximum | ( | double | maximum | ) |

Sets the maximum value for the axis displayed on the axis.

By default, the minimum and maximum values are determined automatically so that all the data can be displayed.

The numerical value corresponding to a data point is defined by it's AxisScale type.

See also:
  setMinimum(), setAutoLimits()

void Wt::Chart::WAxis::setMinimum | ( | double | minimum | ) |

Sets the minimum value displayed on the axis.

By default, the minimum and maximum values are determined automatically so that all the data can be displayed.

The numerical value corresponding to a data point is defined by it's AxisScale type.

See also:
  setMaximum(), setAutoLimits()

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

Changes the pen used for rendering the axis and ticks.

The default value is a black pen of 0 width.

See also:
  setGridLinesPen().

void Wt::Chart::WAxis::setRange | ( | double | minimum,
|  | double | maximum
| ) |  |

Sets the axis range (minimum and maximum values) manually.

Specifies both minimum and maximum value for the axis. This automatically disables automatic range calculation.

The numerical value corresponding to a data point is defined by it's AxisScale type.

See also:
  setMinimum(), setMaximum()

void Wt::Chart::WAxis::setResolution | ( | double | resolution | ) |

Sets the axis resolution.

Specifies the axis resolution, in case maximum-minimum < resolution minimum and maximum are modified so the maximum - minimum = resolution

The default resolution is 0, which uses a built-in epsilon.

See also:
  resolution()

void Wt::Chart::WAxis::setRoundLimits | ( | WFlags< AxisValue > | locations | ) |

Specifies whether limits should be rounded.

When enabling rounding, this has the effect of rounding down the minimum value, or rounding up the maximum value, to the nearest label interval.

By default, rounding is enabled for an auto-calculated limited, and disabled for a manually specifed limit.

See also:
  setAutoLimits()

void Wt::Chart::WAxis::setScale | ( | AxisScale | scale | ) |

Sets the scale of the axis.

For the X scale in a CategoryChart, the scale should be left unchanged to CategoryScale.

For all other axes, the default value is LinearScale, but this may be changed to LogScale or DateScale. DateScale is only useful for the X axis in a ScatterPlot which contains WDate values.

See also:
  scale()

void Wt::Chart::WAxis::setTitle | ( | const WString & | title | ) |

Sets the axis title.

The default title is empty.

See also:
  title()

void Wt::Chart::WAxis::setTitleFont | ( | const WFont & | titleFont | ) |

Sets the axis title font.

The default title font is a 12 point Sans Serif font.

See also:
  titleFont()

void Wt::Chart::WAxis::setVisible | ( | bool | visible | ) |

Sets whether this axis is visible.

Changes whether the axis is displayed, including ticks and labels. The rendering of the grid lines is controlled seperately by setGridLinesEnabled().

The default value is true for the X axis and first Y axis, but false for the second Y axis.

See also:
  setGridLinesEnabled().

const WString& Wt::Chart::WAxis::title | ( |  | ) | const

Returns the axis title.

See also:
  setTitle()

const WFont& Wt::Chart::WAxis::titleFont | ( |  | ) | const

Returns the axis title font.

See also:
  setTitleFont()

## Member Data Documentation

const double Wt::Chart::WAxis::AUTO_MAXIMUM = DBL_MAX`[static]`

Constant which indicates automatic maximum calculation.

See also:
  setMaximum()

const double Wt::Chart::WAxis::AUTO_MINIMUM = -DBL_MAX`[static]`

Constant which indicates automatic minimum calculation.

See also:
  setMinimum()

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator