【发布时间】:2021-04-19 08:51:15
【问题描述】:
假设我从服务器端获得了图表配置:
let chartConfig = {
chart: {
type: "bar"
},
tooltip: {
formatter: `function () {
return this.point.name + ':' +this.y;
}`
},
};
所以格式化程序函数需要是一个字符串,以便可以将其保存为 JSON 字符串。 它不能作为字符串工作。
我将 react 与 highchart-react-officail 库一起使用。
我试过这个:
useEffect(() => {
chartConfig.tooltip.formatter = tooltipsFormat;
}, [])
const tooltipsFormat = () => {
return this.key + '<br/>'
}
将函数重新分配给格式化程序,但很明显,这里的“this”与配置中的不一样。
我应该怎么做才能让它工作?
【问题讨论】:
标签: highcharts react-highcharts