删除图表js折线图中的垂直线 [英] Remove the vertical line in the chart js line chart

查看:173
本文介绍了删除图表js折线图中的垂直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Chart.js生成地图,并在很大程度上对其进行了自定义.但是无论如何,我都无法删除垂直网格线.有人遇到过这样的情况吗?帮助非常感谢.

I am using Chart.js to generate maps and have customised it to a good extent. But I am not able to remove the vertical grid line no matter what. Has anyone come across a situation like this? Help much appreciated.

JavaScript

var ChartDataHome = {
        labels: ["",
            "NOV", "DEC", "JAN", "FEB",
        ],
        datasets: [{
            strokeColor: "rgba(255.255,255,1)",
            pointColor: "rgba(159,209,154,1)",
            pointStrokeColor: "rgba(255,255,255,1.00)",
            data: [4.5, 8.8, 7.5, 9.5, 7.8, 9]
        }, ]
    };

    var step = 2;
    var max = 10;
    var start = 0;
    ChartOptionsHome = {
        scaleLabel: "<%= value + ' K ' %>",
        pointDot: false,
        bezierCurve: false,
        scaleOverride: true,
        scaleSteps: 10,
        // scaleStepWidth: Math.ceil(4/2),
        scaleSteps: Math.ceil((max - start) / step),
        scaleStepWidth: step,
        scaleStartValue: start,
        scaleShowGridLines: true,
        scaleGridLineWidth: 0,
        scaleGridLineColor: "rgba(0,0,0,0.1)",
        datasetFill: false,
        animation: true,
        animationSteps: 60,
        scaleFontColor: "#ffffff",
        scaleFontSize: 14,
        scaleLineColor: "rgba(255,255,255,1)",
        datasetStrokeWidth: 6,
        responsive: true,

    }
    ChartOptions = {

    }

    if ($("#chartHome")[0]) {
        DrawTheChart(ChartDataHome, ChartOptionsHome, "chartHome", "Line");
    }

推荐答案

以下内容适用于Chart.js 2.*.

The following applies to Chart.js 2.*.

如果只有一个x轴,则由options.scales.xAxes[0].gridLines.display的布尔值指定是否显示(与该x轴相关的)垂直网格线.更准确地说,以下图表选项会禁用单个x轴情况下的垂直网格线显示.

If you only have one x-axis, whether the vertical grid lines (that are related to this x-axis) are displayed or not, is specified by the boolean value of options.scales.xAxes[0].gridLines.display. To be more precise, the following chart options disable the display of vertical grid lines for the single x-axis case.

options : {
    scales : {
        xAxes : [ {
            gridLines : {
                display : false
            }
        } ]
    }
}

这篇关于删除图表js折线图中的垂直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆