我正在建立一个可以包含多达5种不同类型的数据系列的图表。我将相似的系列放在一起,因此不同的系列会有3个不同的y轴。
我遇到的问题是,我无法更改要说的系列之一的工具提示,On
或者Off
值是否为100
或0
。
当前,我正在使用共享的工具提示,但是每个数据系列都有其自己的工具提示。5只使用4个前缀/后缀上工具提示,前%
,amps
,psig
等。
不幸的是,我无法通过将工具提示更改为“开”或“关”来使其工作。香港专业教育学院尝试过的。
dataSeries.push({
name: currData['name'],
type: 'line', // Type of visual display
width: 0.4,
yAxis: currData['yAxis'],
data: currData['series'],
tooltip: {
pointFormat: '{series.marker} {series.name}: ' + ('{value}' == 100 ? '<b>On</b><br />' : '<b>Off</b><br />')
//valueSuffix: '{value}' === 100 ? 'On' : 'Off'
formatter: function () {
// Cant get any of these to work
return '{value}' == 100 ? 'On' : 'Off';
return this.y == 100 ? 'On' : 'Off';
return this.point.y == 100 ? 'On' : 'Off';
}
}
//zones: currData['seriesZones'],
}
我不想使用全局工具提示格式化程序,因为我将工具提示格式构建为传递传递多个数据系列时在switch语句上关联的每种不同类型。
使用此代码
pointFormatter: function () {
var point = this;
return point.series.name + ': ' + (point.y > 0 ? 'On' : 'Off') + '<br/>'
}
它不会在工具提示上显示标记。
扩展Grzegorz的解决方案以包括显示标记:
tooltip: {
pointFormatter: function() {
var point = this;
return '<span style="color:' + point.color + '">\u25CF</span> ' + point.series.name + ': <b>' + (point.y > 0 ? 'On' : 'off') + '</b><br/>';
}
}
http://jsfiddle.net/0u915g9b/1/
请注意,默认html显示在文档中:http : //api.highcharts.com/highcharts/series%3Cline%3E.tooltip.pointFormatter
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句