Skip to content

Commit eda1445

Browse files
Nyholmnicolas-grekas
authored andcommitted
[Chart] Add a small example how to set options
1 parent bb79ba1 commit eda1445

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Chartjs/Model/Chart.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ public function setData(array $data)
4343
$this->data = $data;
4444
}
4545

46+
/**
47+
* Sets Chart.js options.
48+
*
49+
* @see https://www.chartjs.org/docs/latest/
50+
*
51+
* <code>
52+
* $chart->setOptions([
53+
* 'scales' => [
54+
* 'yAxes' => [
55+
* ['ticks' => ['min' => 0, 'max' => 100]],
56+
* ]
57+
* ]
58+
* ]);
59+
* </code>
60+
*/
4661
public function setOptions(array $options)
4762
{
4863
$this->options = $options;

src/Chartjs/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ class HomeController extends AbstractController
4747
],
4848
]);
4949

50-
$chart->setOptions([/* ... */]);
50+
$chart->setOptions([
51+
'scales' => [
52+
'yAxes' => [
53+
['ticks' => ['min' => 0, 'max' => 100]],
54+
],
55+
],
56+
]);
5157

5258
return $this->render('home/index.html.twig', [
5359
'chart' => $chart,

0 commit comments

Comments
 (0)