openskope / skope-interface

The new SKOPE web portal interface.
https://www.openskope.org
4 stars 2 forks source link

Chart x-axis tics are mis-aligned #205

Open Zodiase opened 6 years ago

Zodiase commented 6 years ago

From @kintigh:

In graph view, the vertical line that gives the date and the value does not line up correctly with the tic marks and labels on the x axis. This can be seen in graphs for relatively short time periods (e.g. 100 years).

Zodiase commented 6 years ago

image image

Zodiase commented 6 years ago

Not sure what's causing this yet.

Zodiase commented 6 years ago

Looks like whenever I use precise x-axis ticks (by giving a count or a list of x values), the mis-alignment happens. My guess is the problem is caused by rounding precise date values to years, e.g. the position of the tick is April 20th, 1200 but the label displayed is 1200 (due to the format).

Zodiase commented 6 years ago

To deal with this we'd need some complex algorithm that carefully picks x values, instead of simply dividing range by tick count. This algorithm needs to handle ranges over 1k years, 100 years, 10 years, within 1 year (with monthly data) and maybe even smaller ranges.

An edge case the algorithm needs to handle:

If there are 6 years in the range, and there is only space for 5 labeled tick marks, which one does it through away?