MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / log_formatter

Function log_formatter

src/ticks.rs:59–70  ·  view source on GitHub ↗

A simple formatter for logarithmic ticks with an arbitrary base. Expects positive `tick.value` and renders labels as `b^n`, where `b` is the provided base.

(mark: Tick, base: f64)

Source from the content-addressed store, hash-verified

57 if log_step >= 0.0 {
58 format!("{:.0}", mark.value)
59 } else {
60 let decimal_places = (-log_step).ceil() as usize;
61 format!("{:.*}", decimal_places, mark.value)
62 }
63}
64
65/// A simple formatter for logarithmic ticks with an arbitrary base.
66///
67/// Expects positive `tick.value` and renders labels as `b^n`, where `b` is the provided base.
68pub fn log_formatter(mark: Tick, base: f64) -> String {
69 if !mark.value.is_finite() || mark.value <= 0.0 {
70 return String::new();
71 }
72 let exp = mark.value.log(base).round() as i32;
73

Callers 1

newFunction · 0.85

Calls 2

logMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected