Php 仅当存在时,highcharts才会在工具提示中显示arearange的最小/最大值
我有两个系列的数据 平均值:[时间戳,度量] 范围:[时间戳,最小值,最大值] 我想使用上给出的arearange+折线图Php 仅当存在时,highcharts才会在工具提示中显示arearange的最小/最大值,php,highcharts,tooltip,Php,Highcharts,Tooltip,我有两个系列的数据 平均值:[时间戳,度量] 范围:[时间戳,最小值,最大值] 我想使用上给出的arearange+折线图 。。。 选项。工具提示={ 分享:是的, //valueSuffix:' //十字准星:[对,对], 格式化程序:函数(){ var text=''+Highcharts.dateFormat('%A%e%B%Yá%H:%M:%S',this.x)+''; text+='区域:'; text+=':'+此.points[0].y+''; console.dir(this);
。。。
选项。工具提示={
分享:是的,
//valueSuffix:'
//十字准星:[对,对],
格式化程序:函数(){
var text=''+Highcharts.dateFormat('%A%e%B%Yá%H:%M:%S',this.x)+'';
text+='
区域:';
text+='
:'+此.points[0].y+'';
console.dir(this);
text+='
最小值:'+this.points[1].point.low+'';
text+='
最大值:'+this.points[1].point.high+'';
返回文本;
}
};
这很有效。但是,在某些情况下,“最小值”和“最大值”设置为NULL,我不想在工具提示上显示“最小值/最大值”。然后我收到一条错误消息“UncaughtTypeError:无法读取未定义的属性'point'”
我不知道如何避免显示错误消息以及我应该进行哪些测试
谢谢你类似于
if(type of this.points[1]!=“undefined”)text+='
Min:'+this.points[1].point.low+''代码>?请用fiddle重新创建您的示例,因为提供的示例没有此问题。所以用这个bug粘贴你的部分数据。
...
options.tooltip = {
shared: true,
//valueSuffix: '<?php echo $sonde_unite;?>'
//crosshairs: [true, true],
formatter: function() {
var text = '<b>'+ Highcharts.dateFormat('%A %e %B %Y à %H:%M:%S', this.x) +'</b>';
text += '<br/><b> Zone: <?php echo $sonde_zone;?></b>';
text += '<br/> <?php echo $sonde_grandeur;?>: '+ this.points[0].y +' <?php echo $sonde_unite;?>';
console.dir (this);
text += '<br/> Min: '+ this.points[1].point.low +' <?php echo $sonde_unite;?>';
text += '<br/> Max: '+ this.points[1].point.high +' <?php echo $sonde_unite;?>';
return text;
}
};