pub struct PriceScale { /* private fields */ }Expand description
One price axis: options and the visible range in scale units, fitted to the data until the user scales it by hand.
Implementations§
Source§impl PriceScale
impl PriceScale
Sourcepub fn new(options: PriceScaleOptions) -> Self
pub fn new(options: PriceScaleOptions) -> Self
Creates an auto-scaled price scale.
Sourcepub fn set_price_precision(&mut self, decimals: Option<u8>)
pub fn set_price_precision(&mut self, decimals: Option<u8>)
Sets the decimals used by price ticks and tags. None derives them from the tick step.
Sourcepub fn set_bar_ratio_locked(
&mut self,
locked: bool,
bar_spacing: f32,
height: f32,
)
pub fn set_bar_ratio_locked( &mut self, locked: bool, bar_spacing: f32, height: f32, )
Locks scale units per bar at the current bar spacing and pane height. Invalid dimensions leave the scale unlocked. Unlocking keeps the current manual range.
Sourcepub fn set_bar_ratio(&mut self, ratio: Option<f64>)
pub fn set_bar_ratio(&mut self, ratio: Option<f64>)
Set scale units per bar; None unlocks. Invalid ratios leave the scale unchanged.
The next update_bar_ratio applies it about the range centre.
Sourcepub fn bar_ratio_locked(&self) -> bool
pub fn bar_ratio_locked(&self) -> bool
Whether horizontal zoom and pane resizing preserve scale units per bar.
Sourcepub fn update_bar_ratio(&mut self, bar_spacing: f32, height: f32)
pub fn update_bar_ratio(&mut self, bar_spacing: f32, height: f32)
Preserves the locked ratio about the range centre after horizontal zoom or pane resize.
Sourcepub fn options(&self) -> &PriceScaleOptions
pub fn options(&self) -> &PriceScaleOptions
Returns the options.
Sourcepub fn options_mut(&mut self) -> &mut PriceScaleOptions
pub fn options_mut(&mut self) -> &mut PriceScaleOptions
Returns the options for changing the mode, inversion or margins.
The range is in scale units, so after changing the mode call
reset to fit the data in the new units.
Sourcepub fn range(&self) -> PriceRange
pub fn range(&self) -> PriceRange
Returns the visible range in scale units.
Sourcepub fn autoscale(&mut self, min: f64, max: f64)
pub fn autoscale(&mut self, min: f64, max: f64)
Fits min..max (scale units) plus margins unless the user scaled by hand.
Non-finite bounds (no drawable data) and a fit that overflows keep the current range.
Sourcepub fn set_range(&mut self, min: f64, max: f64)
pub fn set_range(&mut self, min: f64, max: f64)
Shows min..max and switches to manual.
The bounds are in the units of the transform the last fit returned
(ChartState::fit_price_scale).
Non-finite, equal or reversed bounds, or an overflowing span, leave the scale unchanged.
Sourcepub fn zoom(&mut self, factor: f64, anchor: f64)
pub fn zoom(&mut self, factor: f64, anchor: f64)
Scales the range by factor (above 1 zooms out) around the scale value
anchor, which keeps its position on screen, and switches to manual.
anchor is in the units of the transform the last fit returned.
One call changes the span by at most 20 times either way. Zooming in stops at a millionth of the price level: 1e-6 log units on a logarithmic scale, 1e-4 percentage or index points in the relative modes, and for prices 1e-6 of the larger magnitude of the data at the last fit or of the range. A result that is not finite leaves the range unchanged.
Trait Implementations§
Source§impl Clone for PriceScale
impl Clone for PriceScale
Source§fn clone(&self) -> PriceScale
fn clone(&self) -> PriceScale
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PriceScale
impl Debug for PriceScale
Source§impl<'de> Deserialize<'de> for PriceScale
impl<'de> Deserialize<'de> for PriceScale
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PriceScale
impl RefUnwindSafe for PriceScale
impl Send for PriceScale
impl Sync for PriceScale
impl Unpin for PriceScale
impl UnsafeUnpin for PriceScale
impl UnwindSafe for PriceScale
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more