You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

FusionChart新手求助:自定义数据点Tooltip内容不显示问题

FusionCharts自定义Tooltip无法渲染自定义字段的解决方法

问题核心

在FusionCharts中直接用$example这种格式引用data数组里的自定义字段,不会被自动解析,所以Tooltip里只会显示$example文本而非对应的值。

解决方法

将plottooltext中的$example替换为$dataValue[example],这是FusionCharts调用数据点自定义属性的标准语法。

修改后的完整代码示例

dataSource: {
  "chart": {
    "theme": "fusion",
    "caption": "lorem ipsum",
    "subCaption": "lorum ipsum",
    "xAxisName": "Date",
    "yAxisName": "time",
    "labelDisplay": "Rotate",
    "reversalPercentage": "0",
    "axisLineAlpha": "40",
    "rallythickness": "3",
    "declinethickness": "3",
    "showToolTip": "1",
    "plottooltext": "$label <hr> lorum ipsum <b>$value</b> $dataValue[example]",
  },
  "data": [{
      "label": "date",
      "value": "time",
      "example": "more info"
    },
    // 其他数据点
  ]
}

进阶自定义方案

如果需要更灵活的Tooltip内容,可以使用tooltipCustomFn配置项绑定自定义函数,完全控制Tooltip的输出:

// 数据源配置
dataSource: {
  "chart": {
    "theme": "fusion",
    "caption": "lorem ipsum",
    "subCaption": "lorum ipsum",
    "xAxisName": "Date",
    "yAxisName": "time",
    "labelDisplay": "Rotate",
    "reversalPercentage": "0",
    "axisLineAlpha": "40",
    "rallythickness": "3",
    "declinethickness": "3",
    "showToolTip": "1",
    "tooltipCustomFn": "generateCustomTooltip"
  },
  "data": [{
      "label": "date",
      "value": "time",
      "example": "more info"
    },
    // 其他数据点
  ]
}

// 自定义Tooltip生成函数
function generateCustomTooltip(dataPoint) {
  return `${dataPoint.label} <hr> lorum ipsum <b>${dataPoint.value}</b> ${dataPoint.example}`;
}

内容的提问来源于stack exchange,提问作者Joost_informatica

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 05:13:30