Class which represents an axis of a cartesian chart. More...
#include <Wt/Chart/WAxis>
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 | 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 | setBreak (double minimum, double maximum) |
Specify 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. |
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(bool) to change the visibility of an axis, setGridLinesEnabled(bool) 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 "dd/MM/yyyy" (for DateScale). The format may be customized using setLabelFormat(). The angle of the label text may be changed using setLabelAngle(double). By default, all labels are printed horizontally.
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().
WCartesianChart* Wt::Chart::WAxis::chart | ( | ) | const [inline] |
Returns the chart to which this axis belongs.
const WPen& Wt::Chart::WAxis::gridLinesPen | ( | ) | const [inline] |
Returns the pen used for rendering the grid lines.
Axis Wt::Chart::WAxis::id | ( | ) | const [inline] |
Returns the axis id.
bool Wt::Chart::WAxis::isGridLinesEnabled | ( | ) | const [inline] |
Returns whether gridlines are displayed for this axis.
bool Wt::Chart::WAxis::isVisible | ( | ) | const [inline] |
Returns whether this axis is visible.
double Wt::Chart::WAxis::labelAngle | ( | ) | const [inline] |
Returns the label angle.
const WFont& Wt::Chart::WAxis::labelFont | ( | ) | const [inline] |
Returns the axis label font.
const WString& Wt::Chart::WAxis::labelFormat | ( | ) | const [inline] |
Returns the label format string.
double Wt::Chart::WAxis::labelInterval | ( | ) | const [inline] |
Returns the label interval.
AxisValue Wt::Chart::WAxis::location | ( | ) | const [inline] |
Returns the axis location.
int Wt::Chart::WAxis::margin | ( | ) | const [inline] |
Returns the margin between the axis and the plot area.
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 maximum.
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 minimum.
const WPen& Wt::Chart::WAxis::pen | ( | ) | const [inline] |
Returns the pen used for rendering the axis and ticks.
AxisScale Wt::Chart::WAxis::scale | ( | ) | const [inline] |
Returns the scale of the axis.
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 | |||
) |
Specify 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(bool).
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.
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 ("horizontal text").
void Wt::Chart::WAxis::setLabelFont | ( | const WFont & | labelFont | ) |
Sets the axis label font.
The default label font is a 10 point Sans Serif font.
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(Axis, bool)).
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(const WString&), to format a date. If the format string is an empty string, "dd/MM/yyyy", "MMM yy" or "yyyy" is used depending on the situation.
The default value is an empty string ("").
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.
void Wt::Chart::WAxis::setLocation | ( | AxisValue | value | ) |
Sets the axis location.
Configures the location of the axis, relative to values on the other values (i.e. Y values for the X axis, and X values for the Y axis).
The default value is Chart::MinimumValue.
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.
void Wt::Chart::WAxis::setMaximum | ( | double | maximum | ) |
Sets the maximum value for the axis displayed on the axis.
Specify the maximum value to be displayed on the axis. By default, the minimum and maximum values are determined automatically so that all the data can be displayed.
void Wt::Chart::WAxis::setMinimum | ( | double | minimum | ) |
Sets the minimum value displayed on the axis.
Specify the minimum value to be displayed on the axis. By default, the minimum and maximum values are determined automatically so that all the data can be displayed.
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.
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.
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.
void Wt::Chart::WAxis::setTitle | ( | const WString & | 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.
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(bool).
The default value is true for the X axis and first Y axis, but false for the second Y axis.
const WString& Wt::Chart::WAxis::title | ( | ) | const [inline] |
Returns the axis title.
const WFont& Wt::Chart::WAxis::titleFont | ( | ) | const [inline] |
Returns the axis title font.
const double Wt::Chart::WAxis::AUTO_MAXIMUM = -DBL_MAX [static] |
Constant which indicates automatic maximum calculation.
const double Wt::Chart::WAxis::AUTO_MINIMUM = DBL_MAX [static] |
Constant which indicates automatic minimum calculation.