-
-
Notifications
You must be signed in to change notification settings - Fork 401
Closed
Labels
BugBug FixBug FixChartjsStatus: Waiting feedbackNeeds feedback from the authorNeeds feedback from the author
Description
Hi
I'm using ux-chartjs and there is no way to render any charts.
No error in the console.
I'm using Symfony 7.2.2 and PHP 8.3.
I followed the document and the examples. Noway.
The rendering is blank.
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\UX\Chartjs\Builder\ChartBuilderInterface;
use Symfony\UX\Chartjs\Model\Chart;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
final class ChartController extends AbstractController
{
#[Route('/chart', name: 'app_chart')]
public function index(ChartBuilderInterface $chartBuilder): Response
{
$chart = $chartBuilder->createChart(Chart::TYPE_LINE);
$chart->setData([
'labels' => ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
'datasets' => [
[
'label' => 'My First dataset',
'backgroundColor' => 'rgb(255, 99, 132)',
'borderColor' => 'rgb(255, 99, 132)',
'data' => [0, 10, 5, 2, 20, 30, 45],
],
],
]);
$chart->setOptions([
'scales' => [
'y' => [
'suggestedMin' => 0,
'suggestedMax' => 100,
],
],
]);
return $this->render('chart/index.html.twig', [
'chart' => $chart,
]);
}
}
{% extends 'base.html.twig' %}
{% block body %}
<div style="height: 300px;">
{{ render_chart(chart) }}
</div>
{% endblock %}
Metadata
Metadata
Assignees
Labels
BugBug FixBug FixChartjsStatus: Waiting feedbackNeeds feedback from the authorNeeds feedback from the author