8

Possible Duplicate:
How to change tooltip text for google chart api?

I am using Google Charts to create a line chart: http://code.google.com/apis/chart/interactive/docs/gallery/linechart.html

I would like to control the text displayed when the user clicks or hovers over a datapoint. Currently the hover only shows the dataset name and value (same a Y-axis). I would like to display additional meta-data. Is this possible? Does someone have an example?

Community
  • 1
  • 1
Chris Willmore
  • 133
  • 1
  • 1
  • 8

2 Answers2

4

You could use "tooltip" in the dataTable roles:

 data.addColumn('number', 'Abscisses');
 data.addColumn('number', 'Warior');
 data.addColumn({type:'number', role:'tooltip'});
 data.addColumn({type:'string', role:'tooltip'});

 data.addRow([2,3,4,'a']);
 data.addRow([3,4,2,'b']);

Refers to:DataTable roles

Michael
  • 41
  • 3
  • However I have not figured out a way to add labels to the tooltip, like I want to show "battle:4 name: a"in the tooltip. I appreciate if Someone who worked out the way could help. – Michael Mar 12 '12 at 21:32
  • 1
    Linecharts only allow one column with the role `tooltip`. Also to get the title you could always do this: `data.addRow([2,3,'Battle: 4\n Name: a']);` If you are for-eaching over your data it would be easy to manipulate the string you wanted to go to the tooltip. – Aust Nov 28 '12 at 18:26
2

Yes you do this by using the following code -

<code>
data.setFormattedValue(<your custom hover lable>);
</code>

Refer here:

http://code.google.com/apis/chart/interactive/docs/reference.html#DataTable_setFormattedValue