chartjs/chartjs-adapter-moment

TypeError: Cannot read property '_date' of undefined when using Chartjs 3.x.x

esttenorio opened this issue · 4 comments

The import on the index.js seems to fail when using in a typescript project.

image
image

After locally changing from import {Chart} from 'chart.js'; to import * as Chart from 'chart.js'; the extension works again.

https://github.com/chartjs/Chart.js/blob/7ec99c38c1b41b16cf7cad433569af56c2544d63/types/index.esm.d.ts#L25

I checked the charts repo and the adapters are separate. There's no default export of ChartJs so the fix is:

  • update ChartJs ts exports so Chart is the default export
  • on this adapter change the import to import * as Chart from 'chart.js';
    or
  • on this adapter change the import to `import {_adapter} from 'chart.js';

no, that's precisely the package I'm using:

"chartjs-adapter-moment": "^1.0.0-beta.1",

Ah, ok. I thought I had fixed it. Will take another look. Does import {_adapters} from 'chart.js'; work for you?

Thanks for publishing a new version with a fix so quickly 👍