Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何删除chart.js上的网格_Javascript_Chart.js - Fatal编程技术网

Javascript 如何删除chart.js上的网格

Javascript 如何删除chart.js上的网格,javascript,chart.js,Javascript,Chart.js,我正在使用Chart.js进行测试,并试图删除网格。我的代码: function grafica(){ var chartData = { labels: [" ", " ", " "], datasets: [ { fillColor: "#79D1CF", strokeColor: "#79D1CF",//marges data: [

我正在使用Chart.js进行测试,并试图删除网格。我的代码:

function grafica(){
    var chartData = {
        labels: [" ", " ", " "],
        datasets: [
            {
                fillColor: "#79D1CF",
                strokeColor: "#79D1CF",//marges
                data: [30, 40, 45]
            }, {
                fillColor: "rgb(210,27,71)",
                strokeColor: "rgb(210,27,71)",//marges
                data: [56, 55, 40]
            }, {
                fillColor: "rgba(210,27,71,0)",
                strokeColor: "rgba(210,27,71,0)",//marges
                data: [0, 0, 0]
            }
        ]
    };
    var ctx = document.getElementById("myChart").getContext("2d");
    var myBar = new Chart(ctx).Bar(chartData, {
        showTooltips: false,
        onAnimationComplete: function () {
            var ctx = this.chart.ctx;
            ctx.font = this.scale.font;
            ctx.fillStyle = this.scale.textColor;
            ctx.textAlign = "center";
            ctx.textBaseline = "bottom";
        }
    });
}
我怎么做?我尝试了添加“ctx.gridLines=false”和“ctx.ticks=false”之类的内容,但目前一切都正常

编辑: 我按照你的指示做了一些更改,但我不知道为什么会有任何效果。 我使用的版本是2.0.0-alpha

试一下:

xAxis: {
    gridLineWidth: 0                
},
yAxis: {
    gridLineWidth: 0,
    minorTickInterval: null
}

将此添加到图表数据中,

我现在使用的是2.0Alpha版本,与您相同

下面是一个没有网格线的简单条形图示例

您需要在options对象的y键和xAxis键上设置“gridLines”键

window.onload=function(){
var ctx=document.getElementById(“画布”).getContext(“2d”);
var barChartData={
标签:[“一月”、“二月”、“三月”、“四月”、“五月”、“六月”、“七月”],
数据集:[{
标签:“数据集1”,
背景色:“rgba(151187205,0.5)”,
数据:[100,99,98,97,96,95,94]
}]
};
window.myBar=新图表(ctx).Bar({
数据:barChartData,
选项:{
回答:是的,
比例:{
xAxes:[{
网格线:{
秀:真的
}
}],
雅克斯:[{
网格线:{
节目:假
}
}]
}
}
});
}

将v3()上的更改为

options: {
  scales: {
    x: {
      grid: {
        display: false
      }
    },
    y: {
      grid: {
        display: false
      }
    }
  },
}
我使用的是v2.9.3,它是“display:false”而不是“show:false”。