I want to add a custom tooltip to my charts by using the default one and for example just append some text to it.
Is this even possible, or to i have to create it all by myself with html?
data= google.visualization.arrayToDataTable([
["Element", "Duration ", { role: "style" }, { role: 'tooltip' }],
["Count", 23515, "orange", ???],
]);
How it is (Default Tooltip):
How i want it:
Append the duration as readable time, but still keep the default tooltip
it's not possible to add content to the default tooltip via standard functionality
to do so requires manipulating the tooltip directly when it is shown
the following working snippet listens for the
'onmouseover'
event on the chartthen modifies the tooltip (if found)
using the row # passed as a property of the event argument
keep in mind, the style (
font-size
) will change according to the size of the chartthe snippet copies the style from the existing lines
to add content to the tooltip using standard functionality requires replacing the tooltip altogether
the best result will be using html tooltips
to use html tooltips, two things must be in place
first, need
html
column property on tooltip column{role: 'tooltip', type: 'string', p: {html: true}}
next, need
tooltip.isHtml: true
in the config optionsthe tooltip can be provided directly in the data,
or add dynamically, as in the following snippet...