Skip to content

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.

enum QAccelPlot::Axis::Side {
    Left,
    Top,
    Right,
    Bottom
};


Public Properties Documentation

property autoRescale

Whether the viewport follows the data range. Default: false .

bool QAccelPlot::Axis::autoRescale;

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 .

QColor QAccelPlot::Axis::baselineColor;


property baselinePadding

Pixels of padding between the plot area edge and the baseline. Default: 0.

qreal QAccelPlot::Axis::baselinePadding;


property baselineWidth

Width in pixels of the axis baseline. Default: 2.

qreal QAccelPlot::Axis::baselineWidth;


property dataMax

Maximum data value of the series bound to this axis. Default: 1. Computed like dataMin .

qreal QAccelPlot::Axis::dataMax;


property dataMin

Minimum data value of the series bound to this axis. Default: 0.

qreal QAccelPlot::Axis::dataMin;

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 .

QColor QAccelPlot::Axis::hoverColor;


property hovered

Read-only: true while the mouse cursor is over the axis widget.

bool QAccelPlot::Axis::hovered;


property label

Optional axis label displayed alongside the axis line.

QString QAccelPlot::Axis::label;


property labelColor

Optional axis-label color. When invalid, the baselineColor is used.

QColor QAccelPlot::Axis::labelColor;


property labelFont

Font used to render the axis label text. Default: application default font.

QFont QAccelPlot::Axis::labelFont;


property labelPadding

Pixels of padding between the baseline and the axis label. Default: 30.

qreal QAccelPlot::Axis::labelPadding;


property layoutSize

Layout thickness in pixels: width for vertical axes and height for horizontal axes. Default: 50.

qreal QAccelPlot::Axis::layoutSize;


property logScale

Whether the axis uses a base-10 logarithmic scale. Default: false .

bool QAccelPlot::Axis::logScale;


property orientation

Axis orientation:Qt.Horizontal orQt.Vertical .

Qt::Orientation QAccelPlot::Axis::orientation;


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.

Side QAccelPlot::Axis::side;


property ticker

Read-only constant: tick appearance configuration object.

AxisTicker* QAccelPlot::Axis::ticker;


property viewportMax

Upper bound of the visible range. Default: 1.

qreal QAccelPlot::Axis::viewportMax;


property viewportMin

Lower bound of the visible range. Default: 0.

qreal QAccelPlot::Axis::viewportMin;


property zoomScaleFactor

Fraction by which the visible range is multiplied on each inward mouse-wheel step. Must be in (0, 1). Default: 0.9.

qreal QAccelPlot::Axis::zoomScaleFactor;

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.

void QAccelPlot::Axis::autoRescaleChanged;


signal baselineColorChanged

Emitted when the baselineColor property changes.

void QAccelPlot::Axis::baselineColorChanged;


signal baselinePaddingChanged

Emitted when the baselinePadding property changes.

void QAccelPlot::Axis::baselinePaddingChanged;


signal baselineWidthChanged

Emitted when the baselineWidth property changes.

void QAccelPlot::Axis::baselineWidthChanged;


signal dataMaxChanged

Emitted when the dataMax property changes.

void QAccelPlot::Axis::dataMaxChanged;


signal dataMinChanged

Emitted when the dataMin property changes.

void QAccelPlot::Axis::dataMinChanged;


signal doubleClicked

Emitted when the user double-clicks the axis widget.

void QAccelPlot::Axis::doubleClicked;


signal hoverColorChanged

Emitted when the hoverColor property changes.

void QAccelPlot::Axis::hoverColorChanged;


signal hoveredChanged

Emitted when the hovered property changes.

void QAccelPlot::Axis::hoveredChanged;


signal labelChanged

Emitted when the label property changes.

void QAccelPlot::Axis::labelChanged;


signal labelColorChanged

Emitted when the labelColor property changes.

void QAccelPlot::Axis::labelColorChanged;


signal labelFontChanged

Emitted when the labelFont property changes.

void QAccelPlot::Axis::labelFontChanged;


signal labelPaddingChanged

Emitted when the labelPadding property changes.

void QAccelPlot::Axis::labelPaddingChanged;


signal layoutSizeChanged

Emitted when the layoutSize property changes.

void QAccelPlot::Axis::layoutSizeChanged;


signal logScaleChanged

Emitted when the logScale property changes.

void QAccelPlot::Axis::logScaleChanged;


signal orientationChanged

Emitted when the orientation property changes.

void QAccelPlot::Axis::orientationChanged;


signal rangeChanged

Emitted when either viewportMin or viewportMax changes.

void QAccelPlot::Axis::rangeChanged;


signal sideChanged

Emitted when the side property changes.

void QAccelPlot::Axis::sideChanged;


signal viewportMaxChanged

Emitted when the viewportMax property changes.

void QAccelPlot::Axis::viewportMaxChanged;


signal viewportMinChanged

Emitted when the viewportMin property changes.

void QAccelPlot::Axis::viewportMinChanged;


signal zoomScaleFactorChanged

Emitted when the zoomScaleFactor property changes.

void QAccelPlot::Axis::zoomScaleFactorChanged;


Public Functions Documentation

function Axis

Constructs an Axis with the given__parent and initial__side .

explicit QAccelPlot::Axis::Axis (
    QQuickItem * parent=nullptr,
    Side side=Bottom
) 


function autoRescale

Returns true when the viewport follows the data range.

bool QAccelPlot::Axis::autoRescale () const


function baselineColor

Returns the axis baseline color.

QColor QAccelPlot::Axis::baselineColor () const


function baselinePadding

Returns the padding between the plot area edge and the baseline in pixels.

qreal QAccelPlot::Axis::baselinePadding () const


function baselineWidth

Returns the axis baseline width in pixels.

qreal QAccelPlot::Axis::baselineWidth () const


function coordToPixel

Maps a data-space value to a pixel position along an axis of__length pixels.

Q_INVOKABLE qreal QAccelPlot::Axis::coordToPixel (
    qreal value,
    qreal length
) const


function dataMax

Returns the maximum data value of the bound series, computing it if their data changed.

qreal QAccelPlot::Axis::dataMax () const


function dataMin

Returns the minimum data value of the bound series, computing it if their data changed.

qreal QAccelPlot::Axis::dataMin () const


function formatValue

Formats value for a readout on an axis of__length pixels.

Q_INVOKABLE QString QAccelPlot::Axis::formatValue (
    qreal value,
    qreal length
) const

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.

QColor QAccelPlot::Axis::hoverColor () const


function hovered

Returns true if the mouse is currently over the axis widget.

bool QAccelPlot::Axis::hovered () const


function inwardTickOverlap

Returns the inward tick overlap beyond baselinePadding , used byPlotView to size the plot area.

qreal QAccelPlot::Axis::inwardTickOverlap () const


function label

Returns the axis label string.

QString QAccelPlot::Axis::label () const


function labelColor

Returns the axis-label color, or an invalid color when it follows baselineColor.

QColor QAccelPlot::Axis::labelColor () const


function labelFont

Returns the axis label font.

QFont QAccelPlot::Axis::labelFont () const


function labelOverflow

Returns extra width/height needed to accommodate edge tick labels that extend beyond the axis bounds.

qreal QAccelPlot::Axis::labelOverflow () const


function labelPadding

Returns the padding between the baseline and the axis label in pixels.

qreal QAccelPlot::Axis::labelPadding () const


function layoutSize

Returns the layout thickness in pixels.

qreal QAccelPlot::Axis::layoutSize () const


function logScale

Returns true when log scale is active.

bool QAccelPlot::Axis::logScale () const


function mapping

Returns a snapshot of the current viewport mapping.

AxisMapping QAccelPlot::Axis::mapping () const


function orientation

Returns the axis orientation.

Qt::Orientation QAccelPlot::Axis::orientation () const


function paint

Paints the axis widget (tick marks, labels, label text, background).

void QAccelPlot::Axis::paint (
    QPainter * painter
) override

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.

Q_INVOKABLE qreal QAccelPlot::Axis::pixelToCoord (
    qreal pos,
    qreal length
) const


function rescaleToData

Sets viewportMin andviewportMax to the currentdataMin /dataMax range.

Q_INVOKABLE void QAccelPlot::Axis::rescaleToData () 

Emits rangeChanged() once.


function setAutoRescale

Sets whether the viewport follows the data range to on . Enabling it rescales to the current data range.

void QAccelPlot::Axis::setAutoRescale (
    bool on
) 


function setBaselineColor

Sets the axis baseline color to c .

void QAccelPlot::Axis::setBaselineColor (
    const QColor & c
) 


function setBaselinePadding

Sets the padding between the plot area edge and the baseline to padding pixels.

void QAccelPlot::Axis::setBaselinePadding (
    qreal padding
) 


function setBaselineWidth

Sets the axis baseline width to width pixels. Negative values are clamped to zero.

void QAccelPlot::Axis::setBaselineWidth (
    qreal width
) 


function setDataMax

Sets the data maximum to m until a bound series with data changes its records.

void QAccelPlot::Axis::setDataMax (
    qreal m
) 


function setDataMin

Sets the data minimum to m until a bound series with data changes its records.

void QAccelPlot::Axis::setDataMin (
    qreal m
) 


function setDataRange

Sets the data range to [ min _,_max ] until a bound series with data changes its records.

Q_INVOKABLE void QAccelPlot::Axis::setDataRange (
    qreal min,
    qreal max
) 

Unlike setDataMin() and setDataMax(), this never computes the range from the series.


function setHoverColor

Sets the hovered color to c .

void QAccelPlot::Axis::setHoverColor (
    const QColor & c
) 


function setLabel

Sets the axis label to t .

void QAccelPlot::Axis::setLabel (
    const QString & t
) 


function setLabelColor

Sets the axis-label color to c . An invalid color restores the baselineColor fallback.

void QAccelPlot::Axis::setLabelColor (
    const QColor & c
) 


function setLabelFont

Sets the axis label font to f .

void QAccelPlot::Axis::setLabelFont (
    const QFont & f
) 


function setLabelPadding

Sets the padding between the baseline and the axis label to padding pixels.

void QAccelPlot::Axis::setLabelPadding (
    qreal padding
) 


function setLayoutSize

Sets the layout thickness to size pixels. Negative values are clamped to zero.

void QAccelPlot::Axis::setLayoutSize (
    qreal size
) 


function setLogScale

Sets log-scale mode to on .

void QAccelPlot::Axis::setLogScale (
    bool on
) 


function setOrientation

Sets the axis orientation to o .

void QAccelPlot::Axis::setOrientation (
    Qt::Orientation o
) 


function setSide

Sets the axis side to s .

void QAccelPlot::Axis::setSide (
    Side s
) 


function setViewportMax

Sets the upper bound of the visible range to m .

void QAccelPlot::Axis::setViewportMax (
    qreal m
) 


function setViewportMin

Sets the lower bound of the visible range to m .

void QAccelPlot::Axis::setViewportMin (
    qreal m
) 


function setZoomScaleFactor

Sets the zoom scale factor to factor (clamped to the range (0, 1)).

void QAccelPlot::Axis::setZoomScaleFactor (
    qreal factor
) 

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.

Side QAccelPlot::Axis::side () const


function ticker

Returns the tick configuration object.

AxisTicker * QAccelPlot::Axis::ticker () const


function toggleLogScale

Toggles the log-scale mode on or off.

Q_INVOKABLE void QAccelPlot::Axis::toggleLogScale () 


function viewportMax

Returns the upper bound of the visible range.

qreal QAccelPlot::Axis::viewportMax () const


function viewportMin

Returns the lower bound of the visible range.

qreal QAccelPlot::Axis::viewportMin () const


function zoomScaleFactor

Returns the zoom scale factor.

qreal QAccelPlot::Axis::zoomScaleFactor () const


Protected Functions Documentation

function componentComplete

void QAccelPlot::Axis::componentComplete () override

function hoverEnterEvent

void QAccelPlot::Axis::hoverEnterEvent (
    QHoverEvent * event
) override

function hoverLeaveEvent

void QAccelPlot::Axis::hoverLeaveEvent (
    QHoverEvent * event
) override

function keyPressEvent

void QAccelPlot::Axis::keyPressEvent (
    QKeyEvent * event
) override

function mouseDoubleClickEvent

void QAccelPlot::Axis::mouseDoubleClickEvent (
    QMouseEvent * event
) override

function mouseMoveEvent

void QAccelPlot::Axis::mouseMoveEvent (
    QMouseEvent * event
) override

function mousePressEvent

void QAccelPlot::Axis::mousePressEvent (
    QMouseEvent * event
) override

function mouseReleaseEvent

void QAccelPlot::Axis::mouseReleaseEvent (
    QMouseEvent * event
) override

function updatePolish

Recomputes the visible tick values and formats their labels on the GUI thread, ahead of paint() .

void QAccelPlot::Axis::updatePolish () override



The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/axis/Axis.hpp