0

我已经用 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
              ]
            ],
          ],
        ]);
4

1 回答 1

0

我找到了一种方法来禁用 Laravel Charts(由 ConsoleTV)ChartJS 上的轴。包本身有两种方法可以做到这一点。

在图表的模板类中,我添加了这两个函数:

public function __construct()
     {
       parent::__construct();
       // ...

       $this->displayAxes(false);
       $this->minimalist(true);

       // ...
     }
于 2018-06-26T05:45:32.583 回答