我正在向highcharts工具提示中添加一个链接,我需要在链接中添加变量{point.key},但我无法访问它。当我将它从标记中取出时,我可以很好地访问它。
有问题的代码行:
`<a href="/events/discover?${chart.aggregation}={point.key}"/>View</a>`,
整个程式码片段:
options.series = allSeriesState.map((seriesState) => {
return {
seriesId: seriesState.seriesId,
name: seriesState.name,
tooltip: {
headerFormat: `<table><tr><th>${chart.xTitle}: {point.key:%Y-%m-%d}</th></tr>`,
pointFormat:
`<tr><td><b>{point.y} </b><span style="color: {series.color}">{series.name}</span> Events</td></tr>` +
`<tr><td><a href="/admin/portfolio/miniApp/events/discover?event_type={series.name}&index=${seriesState.index}&timeFrame=${chart.timeFrame}&${chart.aggregation}={point.key}"/>View in Discover</a></td></tr>`,
footerFormat: '</table>'},
type: seriesState.type,
color: seriesState.color,
data: seriesState.color && seriesState.type ? allSeriesData?.[seriesState.seriesId] || [] : []
}
});
2条答案
按热度按时间pdtvr36n1#
pointFormat
不支持多个嵌套级别。请使用pointFormatter
函数,该函数具有更大的灵活性。演示:https://jsfiddle.net/BlackLabel/oqvh8yx1/
API参考:
https://api.highcharts.com/highcharts/tooltip.pointFormat
https://api.highcharts.com/highcharts/tooltip.pointFormatter
bhmjp9jg2#
从该点添加属性的唯一解决方案是创建一个自定义工具提示组件,如下所示:
组成部分: