如何在 canvasjs 图表上隐藏间隔?
How do I hide interval on canvasjs charts?
我有一个带有 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();
您可以通过设置gridThickness and tickLength to 0 respectively. If you like to hide axis labels along with removing grids and tick, you can use 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>
我有一个带有 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();
您可以通过设置gridThickness and tickLength to 0 respectively. If you like to hide axis labels along with removing grids and tick, you can use 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>