pub struct PnlLabel { /* private fields */ }Expand description
Auto-colored profit/loss label.
Colors text with the theme’s success or error colour by the value’s sign, and zero in the normal text colour.
PnlLabel::currency(1234.5, &CurrencyFormatter::usd()).show(ui); // "+$1,234.50" in green
PnlLabel::currency(-50.0, &CurrencyFormatter::usd()).show(ui); // "-$50.00" in red
PnlLabel::percent(5.34).show(ui); // "+5.34%" in green
PnlLabel::value(-10.0, "custom").show(ui); // "custom" in redImplementations§
Source§impl PnlLabel
impl PnlLabel
Sourcepub fn currency(value: f64, formatter: &CurrencyFormatter) -> Self
pub fn currency(value: f64, formatter: &CurrencyFormatter) -> Self
Display a P&L value using the instrument currency and precision supplied by the host.
Sourcepub fn percent(value: f64) -> Self
pub fn percent(value: f64) -> Self
Display a percentage P&L value given in percent units (5.34 shows “+5.34%”)
Auto Trait Implementations§
impl Freeze for PnlLabel
impl RefUnwindSafe for PnlLabel
impl Send for PnlLabel
impl Sync for PnlLabel
impl Unpin for PnlLabel
impl UnsafeUnpin for PnlLabel
impl UnwindSafe for PnlLabel
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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