Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 自定义Highcharts工具提示_Javascript_Highcharts - Fatal编程技术网

Javascript 自定义Highcharts工具提示

Javascript 自定义Highcharts工具提示,javascript,highcharts,Javascript,Highcharts,我正在自定义Highcharts工具提示: tooltip: { headerFormat: '<b>{series.name}</b><br>', pointFormat: 'round {point.x-9} to {point.x} avg: {point.y}' } 工具提示:{ headerFormat:“{series.name}”, pointFormat:'将{point.x-9}取整为{point.x}平均值:{point.

我正在自定义Highcharts工具提示:

tooltip: {
    headerFormat: '<b>{series.name}</b><br>',
    pointFormat: 'round {point.x-9} to {point.x} avg: {point.y}'
}
工具提示:{
headerFormat:“{series.name}
”, pointFormat:'将{point.x-9}取整为{point.x}平均值:{point.y}' }
但是,
{point.x-10}
无法计算,我没有得到
第0到9轮平均值:0.1
,而是
第9轮平均值:0.1

我怎么修理它


Highcharts不允许您在花括号中执行JS代码。在API中,我们可以阅读:

点格式:字符串:工具提示中点的线的HTML。变量用花括号括起来。可用的变量有point.x、point.y和series。名称和series.color以及同一表单上的其他属性

您应该使用格式化程序属性:

tooltip: {
  headerFormat: '<b>{series.name}</b><br>',
  formatter: function() {
    return 'round ' + (this.x - 9) + ' to ' + this.x + ' avg: ' + this.y
  }
}
工具提示:{
headerFormat:“{series.name}
”, 格式化程序:函数(){ 将'round'+(this.x-9)+'返回到'+this.x+'平均值:'+this.y } }
现场演示:


API:

Highcharts不允许您在花括号中执行JS代码。在API中,我们可以阅读:

点格式:字符串:工具提示中点的线的HTML。变量用花括号括起来。可用的变量有point.x、point.y和series。名称和series.color以及同一表单上的其他属性

您应该使用格式化程序属性:

tooltip: {
  headerFormat: '<b>{series.name}</b><br>',
  formatter: function() {
    return 'round ' + (this.x - 9) + ' to ' + this.x + ' avg: ' + this.y
  }
}
工具提示:{
headerFormat:“{series.name}
”, 格式化程序:函数(){ 将'round'+(this.x-9)+'返回到'+this.x+'平均值:'+this.y } }
现场演示:


API:

我认为您应该使用格式化程序选项我认为您应该使用格式化程序选项