Wt
3.3.5
|
Class which represents an axis of a cartesian chart. More...
#include <Wt/Chart/WAxis>
Classes | |
struct | TickLabel |
Represents a label/tick on the axis. More... | |
Public Member Functions | |
virtual | ~WAxis () |
Destructor. | |
Axis | id () const |
Returns the axis id. More... | |
void | setVisible (bool visible) |
Sets whether this axis is visible. More... | |
bool | isVisible () const |
Returns whether this axis is visible. More... | |
void | setLocation (AxisValue value) |
Sets the axis location. More... | |
AxisValue | location () const |
Returns the axis location. More... | |
void | setScale (AxisScale scale) |
Sets the scale of the axis. More... | |
AxisScale | scale () const |
Returns the scale of the axis. More... | |
void | setMinimum (double minimum) |
Sets the minimum value displayed on the axis. More... | |
double | minimum () const |
Returns the minimum value displayed on the axis. More... | |
void | setMaximum (double maximum) |
Sets the maximum value for the axis displayed on the axis. More... | |
double | maximum () const |
Returns the maximum value displayed on the axis. More... | |
void | setRange (double minimum, double maximum) |
Sets the axis range (minimum and maximum values) manually. More... | |
void | setResolution (double resolution) |
Sets the axis resolution. More... | |
double | resolution () const |
Returns the axis resolution. More... | |
void | setAutoLimits (WFlags< AxisValue > locations) |
Let the minimum and/or maximum be calculated from the data. More... | |
WFlags< AxisValue > | autoLimits () const |
Returns the limits that are calculated automatically. More... | |
void | setRoundLimits (WFlags< AxisValue > locations) |
Specifies whether limits should be rounded. More... | |
WFlags< AxisValue > | roundLimits () const |
Returns whether limits should be rounded. More... | |
void | setBreak (double minimum, double maximum) |
Specifies a range that needs to be omitted from the axis. More... | |
void | setLabelInterval (double labelInterval) |
Sets the label interval. More... | |
double | labelInterval () const |
Returns the label interval. More... | |
void | setLabelBasePoint (double point) |
Sets a point to be included as one of the labels (if possible). More... | |
double | labelBasePoint () const |
Returns the base point for labels. More... | |
void | setLabelFormat (const WString &format) |
Sets the label format. More... | |
WString | labelFormat () const |
Returns the label format string. More... | |
void | setLabelAngle (double angle) |
Sets the label angle. More... | |
double | labelAngle () const |
Returns the label angle. More... | |
void | setTitleOrientation (const Orientation &orientation) |
Sets the title orientation. More... | |
const Orientation & | titleOrientation () const |
Returns the title orientation. More... | |
void | setGridLinesEnabled (bool enabled) |
Sets whether gridlines are displayed for this axis. More... | |
bool | isGridLinesEnabled () const |
Returns whether gridlines are displayed for this axis. More... | |
void | setPen (const WPen &pen) |
Changes the pen used for rendering the axis and ticks. More... | |
const WPen & | pen () const |
Returns the pen used for rendering the axis and ticks. More... | |
void | setTextPen (const WPen &pen) |
Changes the pen used for rendering labels for this axis. More... | |
const WPen & | textPen () const |
Returns the pen used for rendering labels for this axis. More... | |
void | setGridLinesPen (const WPen &pen) |
Changes the pen used for rendering the grid lines. More... | |
const WPen & | gridLinesPen () const |
Returns the pen used for rendering the grid lines. More... | |
void | setMargin (int pixels) |
Sets the margin between the axis and the plot area. More... | |
int | margin () const |
Returns the margin between the axis and the plot area. More... | |
void | setTitle (const WString &title) |
Sets the axis title. More... | |
const WString & | title () const |
Returns the axis title. More... | |
void | setTitleFont (const WFont &titleFont) |
Sets the axis title font. More... | |
const WFont & | titleFont () const |
Returns the axis title font. More... | |
void | setTitleOffset (double offset) |
Sets the offset from the axis for the title label. | |
double | titleOffset () const |
Returns the title offset. | |
void | setLabelFont (const WFont &labelFont) |
Sets the axis label font. More... | |
const WFont & | labelFont () const |
Returns the axis label font. More... | |
virtual WString | label (double u) const |
Returns the label for a value. More... | |
void | setZoom (double zoom) |
Sets the zoom level for this axis. More... | |
double | zoom () const |
Get the zoom level for this axis. More... | |
void | setMaxZoom (double maxZoom) |
Sets the maximum zoom level for this axis. More... | |
double | maxZoom () const |
Get the maximum zoom level for this axis. More... | |
void | setPan (double pan) |
Sets the value to pan to for this axis. More... | |
double | pan () const |
Get the value to pan to for this axis, when pan is enabled on the chart. More... | |
void | setPadding (int padding) |
Sets the padding between the chart area and this axis. More... | |
int | padding () const |
Returns the padding between the chart area and this axis. More... | |
void | setTickDirection (TickDirection direction) |
Sets the direction that the axis ticks should point to. More... | |
TickDirection | tickDirection () const |
Gets the direction that the axis ticks point to. More... | |
void | setSoftLabelClipping (bool enabled) |
Enables soft clipping of axis labels. More... | |
bool | softLabelClipping () const |
Returns whether soft lable clipping is enabled. More... | |
virtual std::vector< double > | gridLinePositions () const |
Returns the positions for grid lines on this axis. More... | |
Static Public Attributes | |
static const double | AUTO_MINIMUM = -DBL_MAX |
Constant which indicates automatic minimum calculation. More... | |
static const double | AUTO_MAXIMUM = DBL_MAX |
Constant which indicates automatic maximum calculation. More... | |
Protected Types | |
enum | DateTimeUnit |
Represents a Date time unit. | |
Protected Member Functions | |
virtual void | getLabelTicks (std::vector< TickLabel > &ticks, int segment, int zoomLevel) const |
Returns the label (and ticks) information for this axis. | |
virtual WString | autoDateFormat (const WDateTime &dt, DateTimeUnit unit, bool atTick) const |
Returns the Date format. | |
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 scales, based on heuristics. 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.
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().
|
virtual |
Returns the positions for grid lines on this axis.
This returns a list of logical values at which a grid line should be drawn on this axis.
const WPen& Wt::Chart::WAxis::gridLinesPen | ( | ) | const |
Returns the pen used for rendering the grid lines.
Axis Wt::Chart::WAxis::id | ( | ) | const |
Returns the axis id.
bool Wt::Chart::WAxis::isGridLinesEnabled | ( | ) | const |
Returns whether gridlines are displayed for this axis.
bool Wt::Chart::WAxis::isVisible | ( | ) | const |
Returns whether this axis is visible.
|
virtual |
Returns the label for a value.
This returns the label text that corresponds to a given value.
The default implementation uses the labelFormat() to properly represent the value.
double Wt::Chart::WAxis::labelAngle | ( | ) | const |
Returns the label angle.
double Wt::Chart::WAxis::labelBasePoint | ( | ) | const |
Returns the base point for labels.
const WFont& Wt::Chart::WAxis::labelFont | ( | ) | const |
Returns the axis label font.
WString Wt::Chart::WAxis::labelFormat | ( | ) | const |
Returns the label format string.
double Wt::Chart::WAxis::labelInterval | ( | ) | const |
Returns the label interval.
AxisValue Wt::Chart::WAxis::location | ( | ) | const |
Returns the axis location.
int Wt::Chart::WAxis::margin | ( | ) | const |
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 (and rounded) maximum.
The numerical value corresponding to a data point is defined by it's AxisScale type.
double Wt::Chart::WAxis::maxZoom | ( | ) | const |
Get the maximum zoom level for this axis.
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.
int Wt::Chart::WAxis::padding | ( | ) | const |
Returns the padding between the chart area and this axis.
double Wt::Chart::WAxis::pan | ( | ) | const |
const WPen& Wt::Chart::WAxis::pen | ( | ) | const |
Returns the pen used for rendering the axis and ticks.
double Wt::Chart::WAxis::resolution | ( | ) | const |
Returns the axis resolution.
WFlags<AxisValue> Wt::Chart::WAxis::roundLimits | ( | ) | const |
Returns whether limits should be rounded.
AxisScale Wt::Chart::WAxis::scale | ( | ) | const |
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 | ||
) |
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().
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.
void Wt::Chart::WAxis::setLabelBasePoint | ( | double | point | ) |
Sets a point to be included as one of the labels (if possible).
The given point will be included as one of the labels, by adjusting the minimum value on the axis, if that minimum is auto-computed. This is only applicable to a Linear scale axis.
The default value is 0.0.
void Wt::Chart::WAxis::setLabelFont | ( | const WFont & | 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, then WLocale::toString() 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 "%.4g" for a numeric axis, and a suitable format for date(time) scales based on a heuristic taking into account the current axis range.
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.
The unit for the label interval is in logical units (i.e. the same as minimum or maximum).
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.
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.
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.
void Wt::Chart::WAxis::setMaxZoom | ( | double | maxZoom | ) |
Sets the maximum zoom level for this axis.
Only applies to a WCartesianChart in interactive mode. The zoom level should be >= 1 (no zoom).
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.
void Wt::Chart::WAxis::setPadding | ( | int | padding | ) |
Sets the padding between the chart area and this axis.
void Wt::Chart::WAxis::setPan | ( | double | pan | ) |
Sets the value to pan to for this axis.
This sets the leftmost (horizontal axis) or bottom (vertical axis) value to be displayed on the chart.
Note that if this would cause the chart to go out of bounds, the panning of the chart will be automatically adjusted.
Only applies to a WCartesianChart in interactive mode.
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.
The numerical value corresponding to a data point is defined by it's AxisScale type.
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.
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.
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::setSoftLabelClipping | ( | bool | enabled | ) |
Enables soft clipping of axis labels.
This is set to false
by for a 3D chart and to true
for a 2D chart.
This setting determines how labels should be clipped in case not the entire axis is visible due to clipping. "Hard" clipping is done by the paint device and may truncate labels. "Soft" clipping will determine if the corresponding tick is visible, and draw the label (unclipped), preventing labels from being truncated. For a 2D chart, this feature is only relevant when zoom is enabled on a WCartesianChart.
![]()
Soft clipping enabled (slower). | ![]()
Soft clipping disabled (faster). |
void Wt::Chart::WAxis::setTextPen | ( | const WPen & | pen | ) |
Changes the pen used for rendering labels for this axis.
The default value is a black pen of 0 width.
void Wt::Chart::WAxis::setTickDirection | ( | TickDirection | direction | ) |
Sets the direction that the axis ticks should point to.
If set to Outwards, the axis ticks will point outside of the chart, and the labels will be on the outside.
If set to Inwards, the axis ticks will point inside of the chart, and the labels will be on the inside. Also, the padding() will be set to 25.
void Wt::Chart::WAxis::setTitle | ( | const WString & | title | ) |
void Wt::Chart::WAxis::setTitleFont | ( | const WFont & | titleFont | ) |
void Wt::Chart::WAxis::setTitleOrientation | ( | const Orientation & | orientation | ) |
Sets the title orientation.
Sets the orientation used for displaying the title.
The default value is Horizontal
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.
void Wt::Chart::WAxis::setZoom | ( | double | zoom | ) |
Sets the zoom level for this axis.
Only applies to a WCartesianChart in interactive mode. The zoom level should be >= 1 and smaller than maxZoom()
bool Wt::Chart::WAxis::softLabelClipping | ( | ) | const |
Returns whether soft lable clipping is enabled.
const WPen& Wt::Chart::WAxis::textPen | ( | ) | const |
Returns the pen used for rendering labels for this axis.
TickDirection Wt::Chart::WAxis::tickDirection | ( | ) | const |
Gets the direction that the axis ticks point to.
const WString& Wt::Chart::WAxis::title | ( | ) | const |
Returns the axis title.
const WFont& Wt::Chart::WAxis::titleFont | ( | ) | const |
Returns the axis title font.
const Orientation& Wt::Chart::WAxis::titleOrientation | ( | ) | const |
Returns the title orientation.
double Wt::Chart::WAxis::zoom | ( | ) | const |
Get the zoom level for this axis.
|
static |
Constant which indicates automatic maximum calculation.
|
static |
Constant which indicates automatic minimum calculation.