Javascript Amcharts:如何在函数中传递标题?

Javascript Amcharts:如何在函数中传递标题?,javascript,amcharts,amstock,Javascript,Amcharts,Amstock,我想在传递之前格式化数据,它将显示为工具提示。为此,我使用了气球函数和比较气球函数 "stockGraphs": [ { "id": "g1", "valueField": "value", "comparable": true, "compareField": "value", "balloonFunction": this.ballonR

我想在传递之前格式化数据,它将显示为工具提示。为此,我使用了
气球函数
比较气球函数

        "stockGraphs": [
          {
            "id": "g1",
            "valueField": "value",
            "comparable": true,
            "compareField": "value",
            "balloonFunction": this.ballonRender,
            "compareGraphBalloonFunction": this.ballonRender,
            // This is works
            //"balloonText": [[title]]
            //"compareGraphBalloonText": [[title]]
          }]
但是,当我将标题作为参数发送到我的ballonRender函数时,我在
title
对象中找不到显示图形名称的属性

  ballonRender(title) {
    let sign = (title["percents"]["value"]>0) ? "+" : "-";
    let values = (title["values"]["value"]).toFixed(4)
    let percentage =  (title["percents"]["value"]).toFixed(2)
    let newTitle = 'Product <b>%s</b> (%s %s%)'.format(values, sign, percentage)
    return newTitle
  },
我不明白为什么
ballodtext
中的
[[title]]
工作正常,但是当我将此参数传递给函数时,我无法检索图形标题

另外,我对
ballonFunction
中的输入参数也有点困惑。如果你能分享一个有解释和最佳实践的资源,那就太好了。

标题来自。在股票图表中,图表继承了
数据集
的标题,但填充了相同的属性。要获取标题数据,您只需访问作为第二个参数传递给的graph对象,而函数中目前没有该对象:

    "balloonFunction": function(graphDataItem, graph) {  
      return "<u>" + graph.title + "</u>: <b>" + graphDataItem.values.value + "</b>";
    },
    "compareGraphBalloonFunction": function(graphDataItem, graph) {  
      return "<u>" + graph.title + "</u>: <b>" + graphDataItem.values.value + "</b>";
    }
“BalloodFunction”:函数(graphDataItem,graph){
返回“+graph.title+”:“+graphDataItem.values.value+”;
},
“CompareGraphBallodFunction”:函数(graphDataItem,graph){
返回“+graph.title+”:“+graphDataItem.values.value+”;
}

标题来源于主题本身。在股票图表中,图表继承了
数据集
的标题,但填充了相同的属性。要获取标题数据,您只需访问作为第二个参数传递给的graph对象,而函数中目前没有该对象:

    "balloonFunction": function(graphDataItem, graph) {  
      return "<u>" + graph.title + "</u>: <b>" + graphDataItem.values.value + "</b>";
    },
    "compareGraphBalloonFunction": function(graphDataItem, graph) {  
      return "<u>" + graph.title + "</u>: <b>" + graphDataItem.values.value + "</b>";
    }
“BalloodFunction”:函数(graphDataItem,graph){
返回“+graph.title+”:“+graphDataItem.values.value+”;
},
“CompareGraphBallodFunction”:函数(graphDataItem,graph){
返回“+graph.title+”:“+graphDataItem.values.value+”;
}