带后缀的十进制格式的 canvasjs 无法正常工作

canvasjs in decimal format with suffix is not working properly

我使用 canvasJS 制作折线图报告,现在的问题是使用 yValueFormatString.

它没有在工具提示中正确显示

我的目标是显示值:

{
    type:"stepLine",
    name: "title",
    showInLegend: true,
    connectNullData: true,
    yValueFormatString: "##.## %",
    dataPoints: [     
       { x: new Date(2019, 1, 20), y: 12.78 },
          { x: new Date(2019, 1, 19), y: 12.79 },
          { x: new Date(2019, 1, 18), y: 12.80 },
       ]
}

在工具提示中,它显示

1278 %
1279 %
1280 %

我觉得有问题,我想这样显示:

12.78 %
12.79 %
12.80 %

有什么想法吗?

根据documentation,“%”将数字乘以 100,即 12.78("##.## %") => 1278%。在这种情况下,设置 yValueFormatString to "##.#0 '%'" 应该可以正常工作。

这是一个例子:

var chart = new CanvasJS.Chart("chartContainer", {
  data: [{
    type:"stepLine",
    name: "title",
    showInLegend: true,
    connectNullData: true,
    yValueFormatString: "##.#0 '%'",
    dataPoints: [     
      { x: new Date(2019, 1, 20), y: 12.78 },
      { x: new Date(2019, 1, 19), y: 12.79 },
      { x: new Date(2019, 1, 18), y: 12.80 },
    ]
  }]
});
chart.render();
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="width: 100%; height: 260px"></div>