Correct ChartOptions types for a Line chart with Time scale
See original GitHub issueDocumentation Is:
- Missing or needed
- Confusing
- Not Sure?
Please Explain in Detail…
I want to get the correct types for a Line
chart which has Time
scale. From documentation I found that I can pass "line"
to the ChartOptions
type.
const chartOptions = ChartOptions<'line'> = {
scales: {
x: {
time: {
unit: 'day'
}
}
}
}
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 following
this.chartOptions.scales.x.time.unit = 'hour';
VSCode shows that,
Property 'time' does not exist on type '_DeepPartialObject<{ type: "linear"; } ...........
How can I use the proper types for Time
scale on a Line
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
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
A Complete Guide to Line Charts | Tutorial by Chartio
Line charts are a fundamental chart type generally used to show change in values across time. Learn how to best use this chart...
Read more >Time Cartesian Axis - Chart.js
Time Cartesian Axis. The time scale is used to display times and dates. Data are spread according to the amount of time between...
Read more >How to Create a Date or Time Chart in Excel | Pryor Learning
To adjust how the x-axis time-scale is displayed: Click on the chart to open the Format Chart Area Pane. Click on Chart Options...
Read more >Line Chart - Google Developers
Draws the chart inside an inline frame. (Note that on IE8, this option is ignored; all IE8 charts are drawn in i-frames.) Type:...
Read more >Line chart options | Looker - Google Cloud
Charts with an Ordinal x-axis scale type. Click the Add Trend Line button to add trend lines in your chart. Click it as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
After adding this (time) correct format with Chart.js v3 , I am getting Error: “time” is not a registered scale. Any suggestions ?