将HTML代码中的属性用于图例文本

时间:2019-02-11 23:37:27

标签: highcharts

我不熟悉Highcharts,并且尝试创建自定义图例。 我的图例需要有文字和图标。该图标应带有工具提示文本。到目前为止,我已经创建了文本和图标。对于工具提示,我有一个组件,其属性为“ text”。 text属性接受html代码。总的来说,我的代码看起来像这样。

<i class="" meta-comp text='<div> Hello </div>'></i>

meta-comp是工具提示组件,其属性为文本。

当我在图例的标签格式化程序函数中按如下方式返回以上代码时

labelFormatter()
{
  return '<i class="" meta-comp text="<div> Hello </div>"></i>'

它仅显示图标,没有工具提示。请让我知道我要去哪里错了。

代码概述

legend: {
  useHTML: true,
  layout: 'vertical',
  align: 'left',
  itemMarginTop: 10,
  itemMarginBottom: 15,
  title: {
    style: {
      fontSize: "14px",
      fontWeight: "600",
      color: "#404040"
    }
  },
  itemStyle: {
    fontWeight: 'normal',
    color: '#404040',
    fontSize: '14px'
  },
  //x  : 70,
  //y:  110,
  labelFormatter: function () {



    return '<div class="legendtext">' + this.y + '&nbsp;&nbsp;' + this.name +'<span><i class="material-icons help-icon" fam-tooltip tooltip-text="Hello How are you"  tooltip-position="right">info_outline</i></span></div>'

  }
},

fam-tooltip是显示工具提示的自定义组件。

0 个答案:

没有答案