【问题标题】:How do I hide interval on canvasjs charts?如何在 canvasjs 图表上隐藏间隔?
【发布时间】:2019-04-29 14:36:27
【问题描述】:

我有一个带有 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】:

    您可以通过将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>

    【讨论】:

    • 完美,正是我想要的,感谢您链接到更多信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多