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
Correct ChartOptions types for a Line chart with Time scale #9085
Comments
You need to add const chartOptions = ChartOptions<'line'> = {
scales: {
x: {
type: 'time',
time: {
unit: 'day'
}
}
}
} |
This is mentioned in the docs in https://www.chartjs.org/docs/latest/axes/ |
Thanks for the snippet. I was unaware of the
|
I tried to reproduce this issue but could not. #9091 |
After adding this (time) correct format with Chart.js v3 , I am getting Error: "time" is not a registered scale. Any suggestions ? |
Chart.js is treeshakable so you will have to import and register the timescale, https://www.chartjs.org/docs/master/getting-started/integration.html#bundlers-webpack-rollup-etc |
Closing as stale since there is no test case |
I had the same error as @mycodedig, to get it working I had to register the
Then, I got this error:
So, I added
If there is a more correct way, I'd love to know. |
@JBaczuk do you have a reproducable sample for this, because when I try to do it it works fine: |
This example doesn't run for me: Here's my reproduction: |
I just realized, the type definition is in UPDATE: Apparently,
|
Update: Once I added
and
The confusing part is this error gave no indication that those other 2 lines needed additional type casting:
|
Documentation Is:
Please Explain in Detail...
I want to get the correct types for a
Line
chart which hasTime
scale. From documentation I found that I can pass"line"
to theChartOptions
type.But the problem is I can't find any way to specify that I want to use the
Time
scale. As a result when I try to do the followingVSCode shows that,
How can I use the proper types for
Time
scale on aLine
chart so that I get the correct type checks? I could not find any documentation for this anywhere so any pointers is appreciated.Your Proposal for Changes
Example
The text was updated successfully, but these errors were encountered: