我已经用 ChartJS 玩了两天了,我似乎无法摆脱浅灰色的轴线(垂直和水平)。
因为它是一个 Laravel 项目,所以我正在使用 ConsoleTV 的 Charts 包。图表代码如下:
$this->options([
'legend' => [
'display' => false
],
'scales' => [
'xAxes' => [
'gridLines'=> [
'drawOnChartArea' => 'false',
'display' => 'false',
],
'display' => 'false',
],
],
'elements' => [
'line' => [
'backgroundColor' => 'rgba(71, 15, 244, 0.2)',
'borderColor' => '#470ff4'
],
],
'title' => [
'display' => false,
]
]);
...呈现为...(一行):
options: {"maintainAspectRatio":false,"scales":{"xAxes":{"gridLines":{"drawOnChartArea":"false","display":"false"},"display":"false"},"yAxes":[{"ticks":{"beginAtZero":true}}]},"legend":{"display":false},"elements":{"line":{"backgroundColor":"rgba(71, 15, 244, 0.2)","borderColor":"#470ff4"}},"title":{"display":false}}
我尝试对其进行格式化以提高可读性:
options:
{"maintainAspectRatio":false,
"scales":{
"xAxes":{
"gridLines": {
"drawOnChartArea":"false",
"display":"false"
},
"display":"false"
},
"yAxes":
[{"ticks":{
"beginAtZero":true
}}
]},
"legend":{"display":false},"elements":{"line":{"backgroundColor":"rgba(71, 15, 244, 0.2)","borderColor":"#470ff4"}},"title":{"display":false}}
如您所见,我尝试将几个显示值设置为false
。任何帮助,将不胜感激!
提前致谢。
编辑 到目前为止没有帮助的是添加这一行,尽管我完全相信它应该工作。这没有意义。我也看过其他解决方案,但是,给出的答案不起作用。
加载脚本的顺序: Head: 1. ChartJS Body: 1. 图表画布, 2. 图表配置
$this->options([
'scales' => [
'xAxes' => [
'gridLines'=> [
'lineWidth' => 0
]
],
'yAxes' => [
'gridLines'=> [
'lineWidth' => 0
]
],
],
]);