作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的 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/
我是一名优秀的程序员,十分优秀!