'Am I missing a chart.js component or helper?
I experimented with my code on the chartjs website (using their editor on one of their samples pages) and it works perfectly. When I copy and paste it into my page, the chart won't even render. When I delete the line "type: 'time'," the chart renders fine, but not with the intended x axis (which makes me think the rest of my code is OK). When I delete the entire 'scales' section, it also renders. It's something in that section that is tanking my chart. Am I missing a component or helper that is required for the 'time' type to function? I have the latest version of chart.js installed (3.7.0), but that's the only external script I have linked.
scales: {
x: {
type: 'time',
time: {
unit:'month',
},
title: {
display: true,
text: 'Date'
}
},
}
Solution 1:[1]
OK, so yes I figured out I was missing some files: Luxon 1.0, and the Luxon adapter (chartjs-adapter-luxon), available on GitHub (https://github.com/chartjs/chartjs-adapter-luxon). I struggle with GitHub sometimes, plus I didn't want to link to any non-local files. I managed to find and view each file in a browser window, and then just saved each page's source as a plain text doc, which I named appropriately. Stashed those in the same local directory as my chart's HTML page and then linked each file to my chart's page in its HTML. My chart sprang to life and all is well. I take it there's a better way to get a file off of GitHub, but I couldn't figure that out. Apologies for the knumbskullery, but it worked...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mark G |
