QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
QTradingView::LinearScale Class Reference

Linear scale implementation for chart axes. More...

#include <LinearScale.h>

Inheritance diagram for QTradingView::LinearScale:
QTradingView::IScale

Public Member Functions

 LinearScale ()
 Constructs a LinearScale with default domain and range.
 
 LinearScale (double minValue, double maxValue, double minPixel, double maxPixel)
 Constructs a LinearScale with specified domain and range.
 
 ~LinearScale () override=default
 Destructor.
 
double dataToPixel (double value) const override
 Converts a data value to a pixel position.
 
double pixelToData (double pixel) const override
 Converts a pixel position to a data value.
 
void setDomain (double minValue, double maxValue) override
 Sets the data domain for the scale.
 
void setRange (double minPixel, double maxPixel) override
 Sets the pixel range for the scale.
 
std::vector< double > getTicks (int approxCount) const override
 Returns tick positions for the scale.
 
void applyPadding (double &minValue, double &maxValue, double paddingRatio) const override
 Applies padding to the data domain.
 
void zoomDomain (double &minValue, double &maxValue, double zoomFactor, double anchorValue) const override
 Zooms the data domain by a factor around an anchor value.
 
- Public Member Functions inherited from QTradingView::IScale
virtual ~IScale ()=default
 Virtual destructor for IScale.
 
std::vector< double > getTicks () const
 Returns a default vector of tick values (approx. 5).
 

Detailed Description

Linear scale implementation for chart axes.

Provides conversion between data values and pixel positions using a linear scale.

Constructor & Destructor Documentation

◆ LinearScale()

QTradingView::LinearScale::LinearScale ( double  minValue,
double  maxValue,
double  minPixel,
double  maxPixel 
)

Constructs a LinearScale with specified domain and range.

Parameters
minValueMinimum data value.
maxValueMaximum data value.
minPixelMinimum pixel position.
maxPixelMaximum pixel position.

Member Function Documentation

◆ applyPadding()

void QTradingView::LinearScale::applyPadding ( double &  minValue,
double &  maxValue,
double  paddingRatio 
) const
overridevirtual

Applies padding to the data domain.

Parameters
minValueReference to minimum value to pad.
maxValueReference to maximum value to pad.
paddingRatioRatio of padding to apply.

Implements QTradingView::IScale.

◆ dataToPixel()

double QTradingView::LinearScale::dataToPixel ( double  value) const
overridevirtual

Converts a data value to a pixel position.

Parameters
valueThe data value to convert.
Returns
The corresponding pixel position.

Implements QTradingView::IScale.

◆ getTicks()

std::vector< double > QTradingView::LinearScale::getTicks ( int  approxCount) const
overridevirtual

Returns tick positions for the scale.

Parameters
approxCountApproximate number of ticks desired.
Returns
Vector of tick positions in data coordinates.

Implements QTradingView::IScale.

◆ pixelToData()

double QTradingView::LinearScale::pixelToData ( double  pixel) const
overridevirtual

Converts a pixel position to a data value.

Parameters
pixelThe pixel position to convert.
Returns
The corresponding data value.

Implements QTradingView::IScale.

◆ setDomain()

void QTradingView::LinearScale::setDomain ( double  minValue,
double  maxValue 
)
overridevirtual

Sets the data domain for the scale.

Parameters
minValueMinimum data value.
maxValueMaximum data value.

Implements QTradingView::IScale.

◆ setRange()

void QTradingView::LinearScale::setRange ( double  minPixel,
double  maxPixel 
)
overridevirtual

Sets the pixel range for the scale.

Parameters
minPixelMinimum pixel position.
maxPixelMaximum pixel position.

Implements QTradingView::IScale.

◆ zoomDomain()

void QTradingView::LinearScale::zoomDomain ( double &  minValue,
double &  maxValue,
double  zoomFactor,
double  anchorValue 
) const
overridevirtual

Zooms the data domain by a factor around an anchor value.

Parameters
minValueReference to minimum value to zoom.
maxValueReference to maximum value to zoom.
zoomFactorZoom factor to apply.
anchorValueValue to anchor the zoom.

Implements QTradingView::IScale.


The documentation for this class was generated from the following files: