Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling hover label of data point in Google Chart [duplicate]

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?

like image 643
Chris Willmore Avatar asked Oct 05 '11 06:10

Chris Willmore


People also ask

How do you add data labels to only certain points in Google Sheets?

Layout > Labels > Data Labels > More Data Label Options. You can now apply specific label type to selected point only. points you want labeled?

How do I change the hover text in an Excel chart?

In Chart Properties, click Hover Text Settings. Enter the desired text in the Text field. You can insert macros here by clicking the "+" button and selecting the desired macro. For more information about macros, see Hover text macros.


2 Answers

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

like image 152
Michael Avatar answered Sep 27 '22 20:09

Michael


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

like image 33
user1057283 Avatar answered Sep 27 '22 19:09

user1057283