Hyperlinks with Array Tables

31 views
Skip to first unread message

Tday

unread,
Oct 11, 2011, 4:09:13 PM10/11/11
to Google Visualization API
I'd like to turn data entries inside my table into hyperlinks. This
is all part of a dashboard for displaying data. The table below is
similar to what I have/want.

var data = google.visualization.arrayToDataTable([
['Col A Hyper', 'Col B'],
['Link A',12],
['Link B', 62]
]);

I tried simply putting the <a href=...></a> around my entries, but
that didn't work.

Dinga Bogdan

unread,
Oct 12, 2011, 2:00:12 AM10/12/11
to Google Visualization API
It should work.
Put the '<a href="#">Link A</a>' as a value

But make a var option, if you don`t have it, or put a extra option in
the draw(data, { ... }) what ever is your case this:

'allowHtml': true

I have the same thing done in a Table generated by Google API, for me
the data is query from a PHP/json.
Also this work with <img> tag . I got a column with green/red bullets
witch are .PNG

:)

Tday

unread,
Oct 12, 2011, 9:55:55 AM10/12/11
to Google Visualization API
I'm not entirely sure what the issue was.

draw(data,{'allowHtml':true})

right?

Tday

unread,
Oct 12, 2011, 10:16:29 AM10/12/11
to Google Visualization API
Got it working, set is as an option of the ChartWrapper. Just needed
to try harder I guess.

Thanks!

Tday

unread,
Oct 12, 2011, 10:26:13 AM10/12/11
to Google Visualization API
I spoke too soon, I just noticed that the pie chart linked to the same
data doesn't display text as hyperlinks, rather the full HTML code.
IE, the legend says <a href=#>blah</a> as opposed to just blah.

Apparently piecharts don't have allowHtml as an option? Or is there a
work around? There doesn't have to be a hyperlink on the pie chart,
but I do want the legend to say blue is whatever (makes it nice and
pretty, you know?).

~.~

asgallant

unread,
Oct 12, 2011, 11:45:29 AM10/12/11
to google-visua...@googlegroups.com
You can't put links in them, but you can create an event listener to hook the 'select' event, which is fired whenever someone clicks on the pie slices or legend.  You can then use javascript to simulate clicking on a link (example: https://groups.google.com/d/msg/google-visualization-api/4T4LrI5mC_Q/oFeBqfQzlZkJ).
Reply all
Reply to author
Forward
0 new messages