symfony/ux-chartjs
Symfony UX Chart.js is a Symfony bundle that integrates Chart.js into Symfony apps. Part of the Symfony UX initiative, it helps you build and render interactive charts with modern UX tooling. Documentation and issues are managed in the main symfony/ux repo.
composer why symfony/ux-chartjs
config/packages/framework.yaml).use statements for components).component() function (now uses use syntax).autoconfigure changes).chartjs-plugin-datalabels@2.x).{{ dump(component('chartjs_chart')) }} to debug.symfony/ux-live-component)?symfony/ux-live-component for real-time updates).composer require symfony/*:^7.0
composer require symfony/ux
composer require symfony/ux-chartjs:^2.35
{# Before (UX 2.x) #}
{{ component('chartjs_chart', { ... }) }}
{# After (UX 3.x) #}
{# templates/components/chartjs_chart.html.twig #}
{% use 'chartjs_chart.html.twig' %}
chart.js is in package.json and resolved in webpack.config.js.vite.config.js:
import { defineConfig } from 'vite';
export default defineConfig({
optimizeDeps: {
include: ['chart.js']
}
});
use Symfony\Component\Serializer\Annotation\Context;
use ApiPlatform\Metadata\Operation;
#[Operation(
method: 'GET',
path: '/sales',
serializationContext: [new Context(['groups' => ['chart_data']])]
)]
yarn add chart.js --dev
{# app/templates/chart.html.twig #}
{% use 'chartjs_chart.html.twig' with {
type: 'pie',
data: salesData|json_encode
} %}
^4.3) to avoid breaking changes.composer why-not symfony/ux-chartjs to check for updates.{# templates/components/chartjs_chart.html.twig #}
{% extends '@SymfonyUxChartjs/chartjs_chart.html.twig' %}
{% block chart_options %}{{ parent() }}<script>console.log('Custom JS');</script>{% endblock %}
bin/console debug:ux to inspect components.symfony7, symfony-ux-3, chartjs.How can I help you explore Laravel packages today?