https://github.com/spencermountain/somehow-ticks
generate nice axis-markings between two arbitrary numbers
https://github.com/spencermountain/somehow-ticks
Last synced: about 1 month ago
JSON representation
generate nice axis-markings between two arbitrary numbers
- Host: GitHub
- URL: https://github.com/spencermountain/somehow-ticks
- Owner: spencermountain
- Created: 2019-02-21T14:17:30.000Z (about 6 years ago)
- Default Branch: gh-pages
- Last Pushed: 2019-05-04T23:38:57.000Z (almost 6 years ago)
- Last Synced: 2025-01-26T03:27:46.517Z (3 months ago)
- Language: JavaScript
- Homepage: https://spencermounta.in/somehow-ticks/
- Size: 169 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**work in progress**
calculate some sensible break-points between two numbers
`npm i somehow-ticks`
```js
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 ticksit was built for labelling an x-axis in a space-limited way, but you can use it for whatever weird stuff.
## See also:
- [somehow](https://github.com/spencermountain/somehow) - sneaky infographics library
- [spacetime-ticks](https://github.com/spencermountain/spacetime-ticks) - same api, but for datesMIT