For example,I use the these codes and it works well and the tooltip show the decimal number like "2.152".

  tooltip: {
    visible: true,
    template: "<table style='color:red'><tr><td> #= value #</td></tr></table>"
   }

Now I want to use Math.round() function for the value of the tooltip,I use like these,but it do not work.It just show the "Math.round(2.152)" string,but I just want show "2".

  tooltip: {
    visible: true,
    template: "<table style='color:red'><tr><td>Math.round(#=value#)</td></tr></table>"
   }
有帮助吗?

解决方案

If you want to evaluate JS code and print the result, you need to surround the full expression with the delimiters:

#= Math.round(value) #

Everything outside of that is simply treated as a string.

其他提示

According to the document here,if you use javascript,you shuld use #..#,try the code again.

 tooltip: {
visible: true,
template: "<table style='color:red'><tr><td># Math.round(#=value#) #</td></tr></table>"

}

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top