如何在canvasjs图表上隐藏间隔?

问题描述 投票:0回答:1

我有一个带有X和Y轴的canvasjs折线图。在canvasjs中,Y轴上的间隔是自动计算的,除非我指定。我该如何删除它?我不希望间隔线显示。

例:

var chart = new CanvasJS.Chart("chartContainer", {
    animationEnabled: true,
    theme: "light2",
    title:{
        text: "Simple Line Chart"
    },
    axisY:{
        interval: 10 < I want to hide this
    },
    data: [{        
            type: "line",       
            dataPoints: [
                { y: 450 },
                { y: 414 },
                { y: 510 }
            ]
        }]
    });
chart.render();
javascript canvasjs
1个回答
1
投票

您可以通过将gridThicknesstickLength分别设置为0来隐藏网格和刻度。如果你想隐藏轴标签以及删除网格和勾选,你可以使用labelFormatter。下面是工作代码,它隐藏了axisY上的网格,刻度和标签:

var chart = new CanvasJS.Chart("chartContainer", {
    animationEnabled: true,
    theme: "light2",
    title:{
        text: "Simple Line Chart"
    },
    axisY:{
      gridThickness: 0,
      tickLength: 0,
      labelFormatter: function(e) {
        return "";
      }
    },
    data: [{        
            type: "line",       
            dataPoints: [
                { y: 450 },
                { y: 414 },
                { y: 510 }
            ]
        }]
    });
chart.render();
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="width: 100%; height: 200px"></div>
© www.soinside.com 2019 - 2024. All rights reserved.