We currently have a time scale. This is a continuous scale. It also would be nice to have a time scale (which I'm calling a "timeseries scale"), which handles discrete time values similar to a category scale.
We've gotten numerous requests for this or similar things. E.g. see https://github.com/chartjs/Chart.js/issues/2006, https://github.com/chartjs/Chart.js/issues/2415, https://github.com/chartjs/Chart.js/issues/3107, https://github.com/chartjs/Chart.js/issues/3263, https://github.com/chartjs/Chart.js/issues/3277, https://github.com/chartjs/Chart.js/issues/3297, https://github.com/chartjs/Chart.js/issues/3780, https://github.com/chartjs/Chart.js/issues/4185, https://github.com/chartjs/Chart.js/issues/4343, etc. In particular, it's currently difficult to utilize bar charts with the time scale.
I'd like this for another use case, which is candlestick charts for stocks. Candlestick charts are essentially bar charts where the bottom of each bar may be greater than 0. For stock charts, we typically specify the days to include on the chart since stocks are not traded on weekends, holidays, etc. and we don't want empty gaps in the chart. However, I believe this scale should be incorporated into the core library rather than chartjs-chart-financial because it is useful in so many other scenarios like the examples above.
The reason I propose a new scale type rather than using category is that it's still nice for the scale to have an understanding that you're working with times. E.g. you cannot have a scale which draws grid lines only on the first of each day, week, month, etc. without a knowledge of time. See https://github.com/chartjs/Chart.js/issues/4187 for a more full description of that feature including screenshots.
There should be a lot of code that can be shared between the "time" and "timeseries" scales.
@benmccann this is a really great way to solve the bar+time issues!! If I understand correctly, the timeseries scale would behave like a category scale using labels to generate the ticks, but would use it's knowledge of time data to render things like the grid lines at better locations than a raw category axis.
I'm happy to look at a PR adding the new scale. If you do create one, please include some new samples / docs 馃憤 . I'm tagging this for v2.7 since it's a bit risky for a v2.6 which we're trying to release soonish
There's a rough version of this in the financial chart repo. Its code can be ported into this repo, but we'll have to fix the code duplication and test a bit.
https://github.com/chartjs/chartjs-chart-financial/blob/master/src/scale.timeseries.js
Implemented in https://github.com/chartjs/Chart.js/pull/4507
Most helpful comment
There's a rough version of this in the financial chart repo. Its code can be ported into this repo, but we'll have to fix the code duplication and test a bit.
https://github.com/chartjs/chartjs-chart-financial/blob/master/src/scale.timeseries.js