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.
Question
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>"
}
Solution
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.
OTHER TIPS
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>"
}