英文:
Highcharts: Conditional tooltip based on multiple checking chart is drilldown or not
问题
Here are the translated code parts without the comments:
tooltip: {
formatter: function() {
return (this.hasOwnProperty("drilldown") ? '用户数量' : '数字数量' + this.point.y);
}
},
events: {
drilldown: function(e) {
this.xAxis[0].setTitle({
text: '账户'
});
},
drillup: function(e) {
this.xAxis[0].setTitle({
text: '来源'
});
}
}
英文:
formatter: function() {
return (this.hasOwnProperty("drilldown") ? 'Count of user' : 'count of number' + this.point.y);
}
},
I just want to change tooltip text based on drilldown condition.
I have set Xaxis name by add event in chart and it's working So what should i do for tooltip ??
events: {drilldown: function(e) {
this.xAxis[0].setTitle({
text: 'Accounts'
});
},
drillup: function(e) {
this.xAxis[0].setTitle({
text: 'Source'
});
}
}
答案1
得分: 1
你可以在 tooltip 的 formatter 中检查 ddDupes
图表的属性。例如:
tooltip: {
formatter: function() {
const chart = this.series.chart;
if (chart.ddDupes && chart.ddDupes.length) {
return '已钻取';
}
return '未钻取';
}
}
在线演示: https://jsfiddle.net/BlackLabel/7abL0en4/
API 参考: https://api.highcharts.com/highcharts/tooltip.formatter
英文:
You can check ddDupes
chart's property in tooltip's formatter. For example:
tooltip: {
formatter: function() {
const chart = this.series.chart;
if (chart.ddDupes && chart.ddDupes.length) {
return 'Drilled down';
}
return 'Not drilled down';
}
}
Live demo: https://jsfiddle.net/BlackLabel/7abL0en4/
API Reference: https://api.highcharts.com/highcharts/tooltip.formatter
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论