1

我正在使用react-google-charts构建一个 AreaChart,并在我的图表中的两个不同区域添加自定义工具提示。我的数据数组的格式为:

['X', 'NegativeY', 'PositiveY', { role: "tooltip", type: "string", p: {html: true}}]

我的数据条目是结果格式:

[x, y, null, 'X: ' + x ". Y: " + Y] // if y > 0
[x, null, y, 'X: ' + x ". Y: " + Y] //if y < 0

在选项字典中,我添加了以下内容:

tooltip: { isHtml: true, trigger: "visible" }

目前,自定义工具提示仅针对负 Y 区域显示,默认 Google 工具提示针对正区域显示。我希望自定义工具提示也能显示在正区域。这可能吗?

4

1 回答 1

1

您将需要一个额外的工具提示列。
每个tooltip都关联一个series,
如果你有两个series',就需要两个tooltip,
并且tooltip列应该跟在数据表中的series列之后。

您将需要按如下方式添加一列...

['X', 'NegativeY', { role: "tooltip", type: "string", p: {html: true}}, 'PositiveY', { role: "tooltip", type: "string", p: {html: true}}]

[x, y, 'X: ' + x ". Y: " + Y, null, null] // if y > 0
[x, null, null, y, 'X: ' + x ". Y: " + Y] //if y < 0
于 2021-10-01T19:33:40.850 回答