Data series with timestamps #36
Replies: 2 comments
-
Ok, after a day of struggling found out: import "chartjs-adapter-date-fns"; to force registering the DateAdapter and adding a typescript ignore comment just to allow to provide date objects instead of numbers. // @ts-ignore I get now a chart with dates on the x-axis :-) |
Beta Was this translation helpful? Give feedback.
-
So, the type definition seems not accurate enough to allow any json style and using the "parsing" functionality of chart.js |
Beta Was this translation helpful? Give feedback.
-
Hi,
Using vue3.
package.json includes:
"vue-chart-3": "^0.5.8",
"date-fns":"^2.25.0",
"chartjs-adapter-date-fns":"^2.0.0"
It seems there is no default date adapter set. Documentation says the "moment"library is the default?
I get this error:
This method is not implemented: Check that a complete date adapter is provided
I included the chartjs-adapter-date-fns via an import statement. But no result.
How should I setup the date adapter in vue3 + typescript?
Second question:
How do I provide timestamps in String format for the x-axis ?
It seems the type only allows "ScatteredDataPoint" which only includes x: y: numbers
const testData = computed<ChartData<"line">>(() => ({
labels: ["Paris", "Nîmes"],
datasets: [
{
xAxisID: "timeScale",
data: [
{ x: "a stringformat somehow??", y: 6 },
{ x: new Date().getTime(), y: 7 },
],
},
],
}));
Regards, Bert.
Beta Was this translation helpful? Give feedback.
All reactions