Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Timeseries scale type #4189

Closed
benmccann opened this issue Apr 27, 2017 · 3 comments
Closed

[FEATURE] Timeseries scale type #4189

benmccann opened this issue Apr 27, 2017 · 3 comments

Comments

@benmccann
Copy link
Contributor

benmccann commented Apr 27, 2017

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 #2006, #2415, #3107, #3263, #3277, #3297, #3780, #4185, #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 #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.

@etimberg
Copy link
Member

@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

@etimberg etimberg added this to the Version 2.7 milestone Apr 27, 2017
@benmccann
Copy link
Contributor Author

benmccann commented Apr 28, 2017

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

IlyaBeliaev added a commit to IlyaBeliaev/Chart.js that referenced this issue May 22, 2017
IlyaBeliaev added a commit to IlyaBeliaev/Chart.js that referenced this issue Jun 6, 2017
IlyaBeliaev added a commit to IlyaBeliaev/Chart.js that referenced this issue Jun 12, 2017
IlyaBeliaev added a commit to IlyaBeliaev/Chart.js that referenced this issue Jun 12, 2017
IlyaBeliaev added a commit to IlyaBeliaev/Chart.js that referenced this issue Jun 23, 2017
IlyaBeliaev added a commit to IlyaBeliaev/Chart.js that referenced this issue Jun 28, 2017
IlyaBeliaev added a commit to IlyaBeliaev/Chart.js that referenced this issue Jul 3, 2017
IlyaBeliaev added a commit to IlyaBeliaev/Chart.js that referenced this issue Jul 9, 2017
@benmccann
Copy link
Contributor Author

Implemented in #4507

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants