gpt4 book ai didi

javascript - 如何在 Chart.js Laravel 中将起始值设置为 “0”

转载 作者:行者123 更新时间:2023-11-30 19:34:59 24 4
gpt4 key购买 nike

我在我的 Laravel 项目中使用 Chart.js,但我不知道如何将我的图表设置为零。

$chartjs = app()->chartjs
->name('lineChartTest')
->type('bar')
->size(['width' => 400, 'height' => 200])
->labels(['02', '03', '04', '05', '06', '07', '08', '09', '10', '11'])
->datasets([
[
'label' => 'My Second Dataset',
'backgroundColor' => 'rgba(138, 22, 54, 0.31)',
'borderColor' => 'rgba(138, 125, 154, 0.7)',
'pointBorderColor' => 'rgba(38, 285, 14, 0.7)',
'pointBackgroundColor' => 'rgba(38, 185, 154, 0.7)',
'pointHoverBackgroundColor' => '#fff',
'pointHoverBorderColor' => 'rgba(120,20,220,1)',
'data' => [
$articles['02']->count(), $articles['03']->count(), $articles['04']->count(), $articles['05']->count(),
$articles['06']->count(), $articles['07']->count(), $articles['08']->count(), $articles['09']->count(),
$articles['10']->count(), $articles['11']->count()
],
'borderWidth' => 3,
]

])
->options([]);

最佳答案

您必须设置 beginAtZero 选项:

$chartOptions = [
'scales' => [
'yAxes' => [
[
'ticks' => [
'beginAtZero' => true,
],
],
],
],
];

->options($chartOptions);

关于javascript - 如何在 Chart.js Laravel 中将起始值设置为 “0”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56039079/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com