use super::funejson::Value; use super::charts_scale_band_scale::{band_position, band_strings, check_align, check_outer}; use super::charts_scale_linear_scale::floats; use super::math_round_float::round_float; /// The position of a category on an axis of evenly spaced points, as /// d3.scalePoint: a band scale with inner padding 1, so bands have no width. /// /// # Panics /// Panics on an empty or repeating domain, a value not in it, a range without /// two values, or padding or align out of bounds. pub fn point_scale(domain: &[String], range: &[f64], value: &str, padding: f64, align: f64) -> f64 { check_outer(padding, "padding"); check_align(align); round_float(band_position(domain, range, value, 1.0, padding, align).0, 6) } pub fn fune_vector(args: &[Value]) -> Value { Value::Float(point_scale(&band_strings(&args[0]), &floats(&args[1]), args[2].as_str(), args[3].as_f64(), args[4].as_f64())) }