Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
use super::funejson::Value; ← the fune runtime: the JSON value the test vectors use; fune build keeps it only where a signature takes one
use super::charts_axis_axis_from_ticks::{axis_from_value, axis_line, check_orient, line_to_value}; ← axisFromTicks, another function of this group · built into the same file, even by a slim install
/// One gridline per tick, from the axis line across the plot: up from a bottom
/// axis, down from a top one, right from a left axis and left from a right one.
///
/// # Panics
/// Panics on an unknown orient or a negative or non-finite length.
pub fn grid_lines(axis: &Axis, length: f64) -> Vec<Line> {
check_orient(&axis.orient);
if !length.is_finite() || length < 0.0 {
panic!("length must be a finite number of zero or more, received {}", length);
}
let pos = axis.position;
axis.ticks
.iter()
.map(|t| {
let p = t.position;
match axis.orient.as_str() {
"bottom" => axis_line(p, pos, p, pos - length),
"top" => axis_line(p, pos, p, pos + length),
"left" => axis_line(pos, p, pos + length, p),
_ => axis_line(pos, p, pos - length, p),
}
})
.collect()
}
pub fn fune_vector(args: &[Value]) -> Value {
Value::Arr(grid_lines(&axis_from_value(&args[0]), args[1].as_f64()).iter().map(line_to_value).collect())
}