go-chart icon indicating copy to clipboard operation
go-chart copied to clipboard

Add a function to generate prettier ticks

Open beevee opened this issue 5 years ago • 0 comments

Current default algorithm that generates ticks is quite simple, but not ideal. Even the most basic examples produce weirdly complicated tick values:

weird ticks

I propose to add an optional algorithm that generates pretty and human-readable ticks, based on a paper by Justin Talbot et.al.

pretty ticks

I chose not to replace the default algoritm with this one, because of two major drawbacks:

  1. 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.
  2. 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.

beevee avatar May 23 '19 08:05 beevee