CanvasJS 值为 0 未显示在图表中
CanvasJS value is 0 not showing in chart
我第一次使用 CanvasJs 制作我的图表,但我注意到每次值为零时图表都不会显示它。我使用的图表结合了折线图和条形图,因此这对于显示两个值之间是否存在零变化很重要。折线图的代码如下:
{
type: "line",
name: "Cumulatief",
showInLegend: true,
yValueFormatString: "€#",
dataPoints: [
{ x: new Date(dateValue1) , y: 0 }
]
}
我希望有人能帮助我,以便我可以在折线图上显示零值。
Y 值 0 正在呈现,无论图表类型是线还是列,并且似乎工作正常。
但是,当您将 yValueFormatString 设置为“€#”时,工具提示中未显示值 0。在这种情况下,将其更改为“€0”即可正常工作。检查下面的工作代码:
var chart = new CanvasJS.Chart("chartContainer", {
data: [{
type: "line",
name: "Cumulatief",
showInLegend: true,
yValueFormatString: "€0",
dataPoints: [
{ x: new Date(2018,03,19) , y: 0 }
]
}]
});
chart.render();
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 260px; width: 100%;"></div>
我第一次使用 CanvasJs 制作我的图表,但我注意到每次值为零时图表都不会显示它。我使用的图表结合了折线图和条形图,因此这对于显示两个值之间是否存在零变化很重要。折线图的代码如下:
{
type: "line",
name: "Cumulatief",
showInLegend: true,
yValueFormatString: "€#",
dataPoints: [
{ x: new Date(dateValue1) , y: 0 }
]
}
我希望有人能帮助我,以便我可以在折线图上显示零值。
Y 值 0 正在呈现,无论图表类型是线还是列,并且似乎工作正常。
但是,当您将 yValueFormatString 设置为“€#”时,工具提示中未显示值 0。在这种情况下,将其更改为“€0”即可正常工作。检查下面的工作代码:
var chart = new CanvasJS.Chart("chartContainer", {
data: [{
type: "line",
name: "Cumulatief",
showInLegend: true,
yValueFormatString: "€0",
dataPoints: [
{ x: new Date(2018,03,19) , y: 0 }
]
}]
});
chart.render();
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 260px; width: 100%;"></div>