Google visualization graph: add a total to a tooltip

I am using the goi visualization api to create a chart by area. When the user hovers over a point inside the diagram, I want it to show the total added sum of points in this place, as well as the values โ€‹โ€‹of these points.

The second point that I can easily reach by specifying the focusTarget: 'category' option. I would like to have an extra line in the appearance in the tooltip for total .

I tried to achieve this by adding an extra column called total , which will have a value of 0, but the tooltip is equal to the sum. This, however, adds an empty line to both the legend and the diagram itself, which is not visually appealing.

It seems to me something that should be available out of the box, but I can not find a solution to this problem.

If anyone knows of a good way to fix this, answer. Thanks in advance.

+4
source share
1 answer

Since you already have a summary column, you can make the row disappear and remove the total from the legend using the series option:

 series: { <series index of the total>: { lineWidth: 0, pointSize: 0, visibleInlegend: false } } 

I would recommend making the resulting column your first series of data (column index 1, series index 0), as this puts it at the bottom of the chart where it will not interfere with your other series.

+6
source

Source: https://habr.com/ru/post/1501307/


All Articles