go-chart
go-chart copied to clipboard
Add a function to generate prettier ticks
Current default algorithm that generates ticks is quite simple, but not ideal. Even the most basic examples produce weirdly complicated tick values:
I propose to add an optional algorithm that generates pretty and human-readable ticks, based on a paper by Justin Talbot et.al.
I chose not to replace the default algoritm with this one, because of two major drawbacks:
- Optimal tick placement can generate ticks outside of the default canvasBox for graph. I had to disable this optimization, because it sometimes leads to ugly results. I wasn't able to understand the canvasBox calculations enougn to fix this and not to break something else.
- This algorithm does not work well for timeseries, because pretty intervals for timeseries are different from decimal (1sec, 60sec, 3600sec, ...), and I couldn't invent a decent way to tell apart timeseries ranges from simple numerical ranges deep down inside the ticks-generating function. So I had to make this algoritm optional.