Javascript AmCharts:如何访问图例中显示的值
我试图在使用ChartCursor将鼠标悬停在图表上时操作图例中显示的值(我已为其连接了侦听器函数,但似乎无法找到每个对象如何显示图例中的每个当前值): 我已尝试使用valueText访问Javascript AmCharts:如何访问图例中显示的值,javascript,charts,amcharts,Javascript,Charts,Amcharts,我试图在使用ChartCursor将鼠标悬停在图表上时操作图例中显示的值(我已为其连接了侦听器函数,但似乎无法找到每个对象如何显示图例中的每个当前值): 我已尝试使用valueText访问 chart.legend.valueText 但是,如果替换valueText,图例中的每个对象都会出现值集。我希望能够接触到图例中的每个对象,并能够操纵每个对象的valueText 侦听器在chartCursor中实现: "chartCursor": { "categoryBalloon
chart.legend.valueText
但是,如果替换valueText,图例中的每个对象都会出现值集。我希望能够接触到图例中的每个对象,并能够操纵每个对象的valueText
侦听器在chartCursor中实现:
"chartCursor": {
"categoryBalloonEnabled": false,
"listeners": [{
"event": "changed",
"method": cursorChanged
}]
},
有人知道如何做到这一点吗
谢谢 要访问图例值,必须在图例对象内部创建一个:
"legend": {
// ...
"valueFunction": function(graphDataItem, valueText) {
//check if valueText is empty.
//this only occurs when you're not currently hovered over a value
//and if you don't have a periodValueText set.
if (valueText !== " ") {
//access the current graph's value through the graph.valueField
//inside the graphDataItem parameter,
//or the string version of the value in valueText and manipulate it accordingly
return graphDataItem.dataContext[graphDataItem.graph.valueField]; //current hovered value
} else {
return valueText;
}
}
},
为每个具有可见图例标记的图形对象调用valueFunction
要访问图例值,必须在图例对象内部创建一个:
"legend": {
// ...
"valueFunction": function(graphDataItem, valueText) {
//check if valueText is empty.
//this only occurs when you're not currently hovered over a value
//and if you don't have a periodValueText set.
if (valueText !== " ") {
//access the current graph's value through the graph.valueField
//inside the graphDataItem parameter,
//or the string version of the value in valueText and manipulate it accordingly
return graphDataItem.dataContext[graphDataItem.graph.valueField]; //current hovered value
} else {
return valueText;
}
}
},
为每个具有可见图例标记的图形对象调用valueFunction