#label #axis #values #ideal #generate #array #positioning

axis-ticks

Generates an array of nicely rounded values between two numbers for which are ideal for positioning axis labels and grid-lines

1 unstable release

0.1.0 Sep 24, 2020

#7 in #ideal


Used in bare-metrics-gui

MIT license

9KB
175 lines

axis-ticks

A port of d3-ticks, part of the JavaScript D3 plotting library.

Generates an array of nicely rounded values between two numbers for which are ideal for positioning axis labels and grid-lines.

let ticks = axis_ticks::ticks(-0.125, 0.25, 10);

assert_eq!(
    ticks,
    [-0.15, -0.1, -0.05, 0.0, 0.05, 0.1, 0.15, 0.2, 0.25]
);

lib.rs:

A port of d3-ticks, part of the JavaScript D3 plotting library.

Generates an array of nicely rounded values between two numbers for which are ideal for positioning axis labels and grid-lines.

let ticks = axis_ticks::ticks(-0.125, 0.25, 10);

assert_eq!(
ticks,
[-0.15, -0.1, -0.05, 0.0, 0.05, 0.1, 0.15, 0.2, 0.25]
);

Dependencies

~155KB