Skip to content

Commit 86b1b8f

Browse files
[Chart.js] Add a small example how to set options
1 parent 9324888 commit 86b1b8f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Chartjs/Model/Chart.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ public function setData(array $data): self
4949
}
5050

5151
/**
52+
* Sets Chart.js options.
53+
*
54+
* @see https://www.chartjs.org/docs/latest/
55+
*
56+
* <code>
57+
* $chart->setOptions([
58+
* 'scales' => [
59+
* 'yAxes' => [
60+
* ['ticks' => ['min' => 0, 'max' => 100]],
61+
* ]
62+
* ]
63+
* ]);
64+
* </code>
65+
*
5266
* @return $this
5367
*/
5468
public function setOptions(array $options): self

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)