- What is symfony/ux-chartjs used for?
- It is a Symfony UX bundle that integrates Chart.js into Symfony applications. You define chart data and options in PHP or Twig and render interactive charts through a Twig component and Stimulus controller, avoiding custom JavaScript for standard charts.
- Does symfony/ux-chartjs work with Laravel?
- No, it is built for Symfony, not Laravel. It relies on Symfony bundles, Twig components, and the Symfony UX Stimulus bridge, so it will not drop into a Laravel app without significant custom work. Laravel developers should evaluate Laravel-specific Chart.js wrappers or integrate Chart.js manually.
- How do I install symfony/ux-chartjs?
- Install it with Composer using a version constraint such as symfony/ux-chartjs:^3.6, then follow the Symfony UX setup for your asset pipeline. With AssetMapper, ensure symfony/asset-mapper 8.2 or later to pick up the #3919 compatibility fix. The README now uses an X.Y.Z placeholder, so pin an explicit version in your install docs.
- Which Symfony and PHP versions does symfony/ux-chartjs 3.6 support?
- The 3.x line aligns with Symfony UX 3.x, Symfony 7.4+/8.x, and PHP 8.4+ based on the release assessment. Verify the bundle's composer.json constraints before committing to Symfony 8.x, because the tested matrix may be broader than the 7.4+ framing. The older 2.x line targets previous Symfony stacks.
- Do I need Node.js or Webpack Encore to use symfony/ux-chartjs?
- Not necessarily. As of v3.6.0, the AssetMapper conflict fix (#3919) makes AssetMapper and importmap a viable first-class path with no Node dependency, provided symfony/asset-mapper is 8.2 or later. Vite and Webpack Encore remain supported options, though Encore is legacy-track for Symfony 7.x and 8.x.
- How do I render a chart from PHP with symfony/ux-chartjs?
- Use the Twig component, for example <twig:Chart>, with data and options defined in a controller or template. You can pass datasets, labels, and Chart.js options as PHP arrays, and the Stimulus controller initializes Chart.js client-side. Standard chart types such as line, bar, pie, doughnut, and radar need no custom JavaScript.
- Does symfony/ux-chartjs support Chart.js 4 plugins like datalabels or zoom?
- It targets Chart.js 4.x, so plugins must be v4-compatible, such as chartjs-plugin-datalabels 2.x and chartjs-plugin-zoom 2.x or later. With Vite, add plugins to optimizeDeps.include to avoid dependency optimization issues. Plugin drift remains a frontend risk, so pin plugin versions and smoke-test your charts.
- Can I use symfony/ux-chartjs with Symfony Live Components for reactive charts?
- Yes, the chartjs:view-value-change re-render behavior supports Live Components, so chart updates can happen without SPA complexity. The 3.6.0 release does not affect this behavior. You still provide data server-side and let the Stimulus bridge handle re-rendering.
- How should I test and deploy symfony/ux-chartjs in production?
- Branch first, run composer update --with-dependencies, check composer why-not symfony/asset-mapper, and smoke-test one chart end-to-end. In production, watch server-render TTFB, pin Chart.js and plugin versions, and confirm your asset pipeline configuration for AssetMapper, Vite, or Encore. Renamed Stimulus events and missing Vite optimizeDeps entries are common failure points.
- What alternatives should Laravel or Symfony developers consider to symfony/ux-chartjs?
- For Symfony, alternatives include rendering Chart.js manually, using other UX bundles, or serving chart data to an API-driven frontend. For Laravel, look at Laravel Chart.js packages or a custom Blade plus Chart.js integration, since symfony/ux-chartjs is Symfony-specific. Evaluate maintenance, Chart.js version support, and asset pipeline fit before choosing.