st
somehow-ticks
npm i somehow-ticks
st

somehow-ticks

calculate the best breakpoints between two numbers

by Spencer Kelly

0.0.3 (see all)License:MITTypeScript:Not Found
npm i somehow-ticks
Readme
somehow-ticks

work in progress

calculate some sensible break-points between two numbers

npm i somehow-ticks

const somehowTicks = require('somehow-ticks')

let ticks = somehowTicks(0, 5000, 5)
/*
[ { label: '1k', number: 1000, value: 0.2 },
  { label: '2k', number: 2000, value: 0.4 },
  { label: '3k', number: 3000, value: 0.6 },
  { label: '4k', number: 4000, value: 0.8 } ]
*/

This library has some opinions:

  • ticks should always be spaced evenly, even if this means less ticks
  • a tick should appear x.0 or x.5
  • they don't need to begin or end at the start and end.
  • less ticks are better than too-many ticks

it was built for labelling an x-axis in a space-limited way, but you can use it for whatever weird stuff.

See also:

MIT

Downloads/wk

7

GitHub Stars

0
No data available

LAST COMMIT

NaNyrs ago

MAINTAINERS

1

CONTRIBUTORS

0

OPEN ISSUES

0

OPEN PRs

0
No data available
VersionTagPublished
0.0.3
latest
3yrs ago
No alternatives found
No tutorials found
Add a tutorial