symfony / ux

Symfony UX initiative: a JavaScript ecosystem for Symfony
https://ux.symfony.com/
MIT License
781 stars 274 forks source link

[ChartJS] Using chartjs/auto + importmap is not compatible with date adapters #1695

Open simondaigre opened 2 months ago

simondaigre commented 2 months ago

Following this thread on Symfony Slack : https://symfony-devs.slack.com/archives/C01FN4EQNLX/p1709732205012939

The workaround seems hacky IMHO. Maybe we should require chartjs only ?

smnandre commented 2 months ago

Could you resume the problem and suggested workaround here ? As the Symfony Slack does not keep messages very long

simondaigre commented 2 months ago

Symfony UX requires chartjs/auto while Chart JS plugins require chartjs. This is causing issues with assetmapper.

Workaround:

Almost got it, just need some advise how to resolve it properly.What I did:

    forced /auto  version to be 4.4.1
    in app.js I've just added import 'chartjs-adapter-date-fns'
    in app/assets/vendor/chartjs-adapter-date-fns/chartjs-adapter-date-fns.index.js

 there was import{_adapters as e}from"chart.js" which I've changed to import{_adapters as e}from"chart.js/auto"

But it requires to edit a vendor file...

I see this is duplicate of https://github.com/symfony/ux/issues/1474#issuecomment-1933959076 so we can close this issue.

smnandre commented 2 months ago

I realise i stated something : https://github.com/symfony/ux/pull/1263

simondaigre commented 2 months ago

@smnandre I just checked on my project, #1263 solves my issue.

smnandre commented 2 months ago

@simondaigre I'm having difficulties to clean / finalize the PR #1263 in question.. would you take a look and see if you can help there.. ? :)

I think we're almost there but i'm fighting with CI errors / Chartjs 3.9.1