Highcharts: 基于多次检查图表是否为钻取而进行条件提示

huangapple go评论80阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年4月10日 20:51:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75977296.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定