HTML tooltip not working in columnChart

1,052 views
Skip to first unread message

Tim Johnson

unread,
Nov 10, 2013, 5:42:50 PM11/10/13
to google-visua...@googlegroups.com
I paste this into the Playground and I get raw text "<div>my text</div>", not the HTML version I was expecting. What am I doing wrong?

function drawVisualization() {
  // Create and populate the data table.
  var data = google.visualization.arrayToDataTable([
    ['Year', 'Austria', 'Bulgaria', 'Denmark', 'Tooltip'],
    ['2003',  1400360,    1400361,    1400362,   '<div>THIS IS IT</div>'],
  ]);

  data.setColumnProperty(4, 'role', 'tooltip');
  data.setColumnProperty(4, 'p', {'html': true});

  // Create and draw the visualization.
  new google.visualization.ColumnChart(document.getElementById('visualization')).
      draw(data,
           {title:"Yearly Coffee Consumption by Country",
            tooltip: {isHtml: true},
            width:600, height:400, legend:{position: "none"},
            vAxis: {title: "Year"},
            hAxis: {title: "Cups"}}
      );
}

asgallant

unread,
Nov 10, 2013, 8:37:30 PM11/10/13
to google-visua...@googlegroups.com
In order to use the custom tooltips, you have to set the proper column role for the tooltip column.  Given your code as-is, add these lines after creating the DataTable but before drawing the chart:

data.setColumnProperty(4, 'role', 'tooltip');
data.setColumnProperty(4, 'html', true);

Tim Johnson

unread,
Nov 10, 2013, 10:47:45 PM11/10/13
to google-visua...@googlegroups.com
Thanks for providing the correct syntax on the 2nd line (I already had the first line). Virtually all the other examples and documentation talk about setting the "p" property to {'html': true}, which is clearly not accurate.


--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/mnWmVkYkBVY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.



--
Tim

asgallant

unread,
Nov 11, 2013, 10:25:51 AM11/11/13
to google-visua...@googlegroups.com
When constructing the column using the standard DataTable constructor, the "p" stands for properties, so you are not supposed to set the p.html property.
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsub...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.



--
Tim

Tim Johnson

unread,
Nov 11, 2013, 12:01:13 PM11/11/13
to google-visua...@googlegroups.com

Ahh, got it now, thanks!

To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages