我已经在ChartJS上玩了两天了,我似乎无法摆脱浅灰色的轴线(垂直的和水平的)。
Screenshot of my chart, indication the lines I'd like to remove
因为这是一个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,
]
]);
...which被渲染成...(一行):
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
]
],
],
]);
发布于 2018-06-26 13:45:33
我找到了一种方法来禁用Laravel Charts(由ConsoleTV) ChartJS上的轴。包本身有两个方法可以做到这一点。
在图表的template类中,我添加了这两个函数:
public function __construct()
{
parent::__construct();
// ...
$this->displayAxes(false);
$this->minimalist(true);
// ...
}
https://stackoverflow.com/questions/51000938
复制相似问题