Class QAccelPlot::Axis¶
ClassList > QAccelPlot > Axis
A visual axis item that maps a data-space range to pixel coordinates and renders tick marks and labels. More...
#include <Axis.hpp>
Inherits the following classes: QQuickPaintedItem
Inheritance diagram¶
flowchart TB
classQAccelPlot_1_1Axis["QAccelPlot::Axis"]
external_base_classQAccelPlot_1_1Axis_1["QQuickPaintedItem"]
external_base_classQAccelPlot_1_1Axis_1 --> classQAccelPlot_1_1Axis
Public Types¶
| Type | Name |
|---|---|
| enum | Side Side of the plot on which the axis is positioned. |
Public Properties¶
| Type | Name |
|---|---|
| property bool | autoRescale Whether the viewport follows the data range. Default: false . |
| property QColor | baselineColor Color of the axis baseline. Default: Colors.dark.axisLine . |
| property qreal | baselinePadding Pixels of padding between the plot area edge and the baseline. Default: 0. |
| property qreal | baselineWidth Width in pixels of the axis baseline. Default: 2. |
| property qreal | dataMax Maximum data value of the series bound to this axis. Default: 1. Computed like dataMin . |
| property qreal | dataMin Minimum data value of the series bound to this axis. Default: 0. |
| property QColor | hoverColor Tick and label color applied when the axis is hovered. Default: Colors.dark.hover . |
| property bool | hovered Read-only: true while the mouse cursor is over the axis widget. |
| property QString | label Optional axis label displayed alongside the axis line. |
| property QColor | labelColor Optional axis-label color. When invalid, the baselineColor is used. |
| property QFont | labelFont Font used to render the axis label text. Default: application default font. |
| property qreal | labelPadding Pixels of padding between the baseline and the axis label. Default: 30. |
| property qreal | layoutSize Layout thickness in pixels: width for vertical axes and height for horizontal axes. Default: 50. |
| property bool | logScale Whether the axis uses a base-10 logarithmic scale. Default: false . |
| property Qt::Orientation | orientation Axis orientation: Qt.Horizontal orQt.Vertical . |
| property Side | side Side of the plot on which the axis is drawn: Left, Top, Right, or Bottom. Assigned automatically for xAxis, yAxis, x2Axis, and y2Axis; set explicitly for an axis placed in extraAxes. |
| property AxisTicker * | ticker Read-only constant: tick appearance configuration object. |
| property qreal | viewportMax Upper bound of the visible range. Default: 1. |
| property qreal | viewportMin Lower bound of the visible range. Default: 0. |
| property qreal | zoomScaleFactor Fraction by which the visible range is multiplied on each inward mouse-wheel step. Must be in (0, 1). Default: 0.9. |
Public Signals¶
| Type | Name |
|---|---|
| signal void | autoRescaleChanged Emitted when the autoRescale property changes. |
| signal void | baselineColorChanged Emitted when the baselineColor property changes. |
| signal void | baselinePaddingChanged Emitted when the baselinePadding property changes. |
| signal void | baselineWidthChanged Emitted when the baselineWidth property changes. |
| signal void | dataMaxChanged Emitted when the dataMax property changes. |
| signal void | dataMinChanged Emitted when the dataMin property changes. |
| signal void | doubleClicked Emitted when the user double-clicks the axis widget. |
| signal void | hoverColorChanged Emitted when the hoverColor property changes. |
| signal void | hoveredChanged Emitted when the hovered property changes. |
| signal void | labelChanged Emitted when the label property changes. |
| signal void | labelColorChanged Emitted when the labelColor property changes. |
| signal void | labelFontChanged Emitted when the labelFont property changes. |
| signal void | labelPaddingChanged Emitted when the labelPadding property changes. |
| signal void | layoutSizeChanged Emitted when the layoutSize property changes. |
| signal void | logScaleChanged Emitted when the logScale property changes. |
| signal void | orientationChanged Emitted when the orientation property changes. |
| signal void | rangeChanged Emitted when either viewportMin or viewportMax changes. |
| signal void | sideChanged Emitted when the side property changes. |
| signal void | viewportMaxChanged Emitted when the viewportMax property changes. |
| signal void | viewportMinChanged Emitted when the viewportMin property changes. |
| signal void | zoomScaleFactorChanged Emitted when the zoomScaleFactor property changes. |
Public Functions¶
| Type | Name |
|---|---|
| Axis (QQuickItem * parent=nullptr, Side side=Bottom) Constructs an Axis with the given__parent and initial__side . |
|
| bool | autoRescale () const Returns true when the viewport follows the data range. |
| QColor | baselineColor () const Returns the axis baseline color. |
| qreal | baselinePadding () const Returns the padding between the plot area edge and the baseline in pixels. |
| qreal | baselineWidth () const Returns the axis baseline width in pixels. |
| Q_INVOKABLE qreal | coordToPixel (qreal value, qreal length) const Maps a data-space value to a pixel position along an axis of__length pixels. |
| qreal | dataMax () const Returns the maximum data value of the bound series, computing it if their data changed. |
| qreal | dataMin () const Returns the minimum data value of the bound series, computing it if their data changed. |
| Q_INVOKABLE QString | formatValue (qreal value, qreal length) const Formats value for a readout on an axis of__length pixels. |
| QColor | hoverColor () const Returns the hovered tick/label color. |
| bool | hovered () const Returns true if the mouse is currently over the axis widget. |
| qreal | inwardTickOverlap () const Returns the inward tick overlap beyond baselinePadding , used byPlotView to size the plot area. |
| QString | label () const Returns the axis label string. |
| QColor | labelColor () const Returns the axis-label color, or an invalid color when it follows baselineColor. |
| QFont | labelFont () const Returns the axis label font. |
| qreal | labelOverflow () const Returns extra width/height needed to accommodate edge tick labels that extend beyond the axis bounds. |
| qreal | labelPadding () const Returns the padding between the baseline and the axis label in pixels. |
| qreal | layoutSize () const Returns the layout thickness in pixels. |
| bool | logScale () const Returns true when log scale is active. |
| AxisMapping | mapping () const Returns a snapshot of the current viewport mapping. |
| Qt::Orientation | orientation () const Returns the axis orientation. |
| void | paint (QPainter * painter) override Paints the axis widget (tick marks, labels, label text, background). |
| Q_INVOKABLE qreal | pixelToCoord (qreal pos, qreal length) const Maps a pixel pos along an axis of__length pixels back to a data-space value. |
| Q_INVOKABLE void | rescaleToData () Sets viewportMin andviewportMax to the currentdataMin /dataMax range. |
| void | setAutoRescale (bool on) Sets whether the viewport follows the data range to on . Enabling it rescales to the current data range. |
| void | setBaselineColor (const QColor & c) Sets the axis baseline color to c . |
| void | setBaselinePadding (qreal padding) Sets the padding between the plot area edge and the baseline to padding pixels. |
| void | setBaselineWidth (qreal width) Sets the axis baseline width to width pixels. Negative values are clamped to zero. |
| void | setDataMax (qreal m) Sets the data maximum to m until a bound series with data changes its records. |
| void | setDataMin (qreal m) Sets the data minimum to m until a bound series with data changes its records. |
| Q_INVOKABLE void | setDataRange (qreal min, qreal max) Sets the data range to [ min _,_max ] until a bound series with data changes its records. |
| void | setHoverColor (const QColor & c) Sets the hovered color to c . |
| void | setLabel (const QString & t) Sets the axis label to t . |
| void | setLabelColor (const QColor & c) Sets the axis-label color to c . An invalid color restores the baselineColor fallback. |
| void | setLabelFont (const QFont & f) Sets the axis label font to f . |
| void | setLabelPadding (qreal padding) Sets the padding between the baseline and the axis label to padding pixels. |
| void | setLayoutSize (qreal size) Sets the layout thickness to size pixels. Negative values are clamped to zero. |
| void | setLogScale (bool on) Sets log-scale mode to on . |
| void | setOrientation (Qt::Orientation o) Sets the axis orientation to o . |
| void | setSide (Side s) Sets the axis side to s . |
| void | setViewportMax (qreal m) Sets the upper bound of the visible range to m . |
| void | setViewportMin (qreal m) Sets the lower bound of the visible range to m . |
| void | setZoomScaleFactor (qreal factor) Sets the zoom scale factor to factor (clamped to the range (0, 1)). |
| Side | side () const Returns the axis side. |
| AxisTicker * | ticker () const Returns the tick configuration object. |
| Q_INVOKABLE void | toggleLogScale () Toggles the log-scale mode on or off. |
| qreal | viewportMax () const Returns the upper bound of the visible range. |
| qreal | viewportMin () const Returns the lower bound of the visible range. |
| qreal | zoomScaleFactor () const Returns the zoom scale factor. |
Protected Functions¶
| Type | Name |
|---|---|
| void | componentComplete () override |
| void | hoverEnterEvent (QHoverEvent * event) override |
| void | hoverLeaveEvent (QHoverEvent * event) override |
| void | keyPressEvent (QKeyEvent * event) override |
| void | mouseDoubleClickEvent (QMouseEvent * event) override |
| void | mouseMoveEvent (QMouseEvent * event) override |
| void | mousePressEvent (QMouseEvent * event) override |
| void | mouseReleaseEvent (QMouseEvent * event) override |
| void | updatePolish () override Recomputes the visible tick values and formats their labels on the GUI thread, ahead of paint() . |
Detailed Description¶
Assign an Axis to the corresponding property of PlotView (xAxis, yAxis, etc.) to connect it to the plot. Tick appearance is configured via the ticker property. Supports linear and logarithmic scaling, mouse-driven pan/zoom, and custom label formatters. Set the inherited visible property to false to hide the axis and reclaim its layout space while preserving its range, coordinate mapping, and plot-wide navigation behavior.
See also: PlotView, AxisTicker, TickLabelFormatter
Public Types Documentation¶
enum Side¶
Side of the plot on which the axis is positioned.
Public Properties Documentation¶
property autoRescale¶
Whether the viewport follows the data range. Default: false .
While true, every data update of a bound series sets the viewport as rescaleToData() does, replacing a viewport set by panning, zooming, or viewportMin / viewportMax. Each update scans the series' records unless they were given data bounds. The viewport is kept when the last series on the axis clears its data.
property baselineColor¶
Color of the axis baseline. Default: Colors.dark.axisLine .
property baselinePadding¶
Pixels of padding between the plot area edge and the baseline. Default: 0.
property baselineWidth¶
Width in pixels of the axis baseline. Default: 2.
property dataMax¶
Maximum data value of the series bound to this axis. Default: 1. Computed like dataMin .
property dataMin¶
Minimum data value of the series bound to this axis. Default: 0.
Computed from the series when read after a data update, which scans their records unless they were given data bounds. A value set here is used until a bound series with data changes its records. dataMinChanged() also announces a data update whose new minimum has not been computed yet.
property hoverColor¶
Tick and label color applied when the axis is hovered. Default: Colors.dark.hover .
property hovered¶
Read-only: true while the mouse cursor is over the axis widget.
property label¶
Optional axis label displayed alongside the axis line.
property labelColor¶
Optional axis-label color. When invalid, the baselineColor is used.
property labelFont¶
Font used to render the axis label text. Default: application default font.
property labelPadding¶
Pixels of padding between the baseline and the axis label. Default: 30.
property layoutSize¶
Layout thickness in pixels: width for vertical axes and height for horizontal axes. Default: 50.
property logScale¶
Whether the axis uses a base-10 logarithmic scale. Default: false .
property orientation¶
Axis orientation:Qt.Horizontal orQt.Vertical .
property side¶
Side of the plot on which the axis is drawn: Left, Top, Right, or Bottom. Assigned automatically for xAxis, yAxis, x2Axis, and y2Axis; set explicitly for an axis placed in extraAxes.
property ticker¶
Read-only constant: tick appearance configuration object.
property viewportMax¶
Upper bound of the visible range. Default: 1.
property viewportMin¶
Lower bound of the visible range. Default: 0.
property zoomScaleFactor¶
Fraction by which the visible range is multiplied on each inward mouse-wheel step. Must be in (0, 1). Default: 0.9.
On a zoom-in step the range is multiplied by this value; on zoom-out by its reciprocal. Decrease the factor (e.g. 0.5) to zoom faster; increase it toward 1.0 (e.g. 0.95) to zoom more slowly.
Public Signals Documentation¶
signal autoRescaleChanged¶
Emitted when the autoRescale property changes.
signal baselineColorChanged¶
Emitted when the baselineColor property changes.
signal baselinePaddingChanged¶
Emitted when the baselinePadding property changes.
signal baselineWidthChanged¶
Emitted when the baselineWidth property changes.
signal dataMaxChanged¶
Emitted when the dataMax property changes.
signal dataMinChanged¶
Emitted when the dataMin property changes.
signal doubleClicked¶
Emitted when the user double-clicks the axis widget.
signal hoverColorChanged¶
Emitted when the hoverColor property changes.
signal hoveredChanged¶
Emitted when the hovered property changes.
signal labelChanged¶
Emitted when the label property changes.
signal labelColorChanged¶
Emitted when the labelColor property changes.
signal labelFontChanged¶
Emitted when the labelFont property changes.
signal labelPaddingChanged¶
Emitted when the labelPadding property changes.
signal layoutSizeChanged¶
Emitted when the layoutSize property changes.
signal logScaleChanged¶
Emitted when the logScale property changes.
signal orientationChanged¶
Emitted when the orientation property changes.
signal rangeChanged¶
Emitted when either viewportMin or viewportMax changes.
signal sideChanged¶
Emitted when the side property changes.
signal viewportMaxChanged¶
Emitted when the viewportMax property changes.
signal viewportMinChanged¶
Emitted when the viewportMin property changes.
signal zoomScaleFactorChanged¶
Emitted when the zoomScaleFactor property changes.
Public Functions Documentation¶
function Axis¶
Constructs an Axis with the given__parent and initial__side .
function autoRescale¶
Returns true when the viewport follows the data range.
function baselineColor¶
Returns the axis baseline color.
function baselinePadding¶
Returns the padding between the plot area edge and the baseline in pixels.
function baselineWidth¶
Returns the axis baseline width in pixels.
function coordToPixel¶
Maps a data-space value to a pixel position along an axis of__length pixels.
function dataMax¶
Returns the maximum data value of the bound series, computing it if their data changed.
function dataMin¶
Returns the minimum data value of the bound series, computing it if their data changed.
function formatValue¶
Formats value for a readout on an axis of__length pixels.
Uses the tick label formatter with a precision one decimal digit finer than a pixel, so the text follows the zoom level instead of the tick spacing. Returns an empty string for a nonfinite value.
function hoverColor¶
Returns the hovered tick/label color.
function hovered¶
Returns true if the mouse is currently over the axis widget.
function inwardTickOverlap¶
Returns the inward tick overlap beyond baselinePadding , used byPlotView to size the plot area.
function label¶
Returns the axis label string.
function labelColor¶
Returns the axis-label color, or an invalid color when it follows baselineColor.
function labelFont¶
Returns the axis label font.
function labelOverflow¶
Returns extra width/height needed to accommodate edge tick labels that extend beyond the axis bounds.
function labelPadding¶
Returns the padding between the baseline and the axis label in pixels.
function layoutSize¶
Returns the layout thickness in pixels.
function logScale¶
Returns true when log scale is active.
function mapping¶
Returns a snapshot of the current viewport mapping.
function orientation¶
Returns the axis orientation.
function paint¶
Paints the axis widget (tick marks, labels, label text, background).
Draws the ticks and labels computed in updatePolish(); with the threaded render loop this runs on the render thread.
function pixelToCoord¶
Maps a pixel pos along an axis of__length pixels back to a data-space value.
function rescaleToData¶
Sets viewportMin andviewportMax to the currentdataMin /dataMax range.
Emits rangeChanged() once.
function setAutoRescale¶
Sets whether the viewport follows the data range to on . Enabling it rescales to the current data range.
function setBaselineColor¶
Sets the axis baseline color to c .
function setBaselinePadding¶
Sets the padding between the plot area edge and the baseline to padding pixels.
function setBaselineWidth¶
Sets the axis baseline width to width pixels. Negative values are clamped to zero.
function setDataMax¶
Sets the data maximum to m until a bound series with data changes its records.
function setDataMin¶
Sets the data minimum to m until a bound series with data changes its records.
function setDataRange¶
Sets the data range to [ min _,_max ] until a bound series with data changes its records.
Unlike setDataMin() and setDataMax(), this never computes the range from the series.
function setHoverColor¶
Sets the hovered color to c .
function setLabel¶
Sets the axis label to t .
function setLabelColor¶
Sets the axis-label color to c . An invalid color restores the baselineColor fallback.
function setLabelFont¶
Sets the axis label font to f .
function setLabelPadding¶
Sets the padding between the baseline and the axis label to padding pixels.
function setLayoutSize¶
Sets the layout thickness to size pixels. Negative values are clamped to zero.
function setLogScale¶
Sets log-scale mode to on .
function setOrientation¶
Sets the axis orientation to o .
function setSide¶
Sets the axis side to s .
function setViewportMax¶
Sets the upper bound of the visible range to m .
function setViewportMin¶
Sets the lower bound of the visible range to m .
function setZoomScaleFactor¶
Sets the zoom scale factor to factor (clamped to the range (0, 1)).
Smaller values (e.g. 0.5) produce faster zooming; values closer to 1.0 (e.g. 0.95) produce slower zooming.
function side¶
Returns the axis side.
function ticker¶
Returns the tick configuration object.
function toggleLogScale¶
Toggles the log-scale mode on or off.
function viewportMax¶
Returns the upper bound of the visible range.
function viewportMin¶
Returns the lower bound of the visible range.
function zoomScaleFactor¶
Returns the zoom scale factor.
Protected Functions Documentation¶
function componentComplete¶
function hoverEnterEvent¶
function hoverLeaveEvent¶
function keyPressEvent¶
function mouseDoubleClickEvent¶
function mouseMoveEvent¶
function mousePressEvent¶
function mouseReleaseEvent¶
function updatePolish¶
Recomputes the visible tick values and formats their labels on the GUI thread, ahead of paint() .
The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/axis/Axis.hpp