Problems with Pattern Formatter (to create a link)

233 views
Skip to first unread message

Maha Istanbouly

unread,
Jul 19, 2012, 12:18:09 PM7/19/12
to google-visua...@googlegroups.com
Hey there,

I'm having some issues with the Pattern Formatters. I have attached a snippet of my table for your reference, and here is my script;

function drawVisualization() {
    var options = {'sortColumn': 0, 'sortAscending': false, 'allowHtml': true};
          visualization = new google.visualization.Table(document.getElementById('feed'));
    var formatter_medium = new google.visualization.DateFormat({formatType: 'medium'});
    formatter_medium.format(listObject,0);
    var formatterurl = new google.visualization.PatternFormat('<a href="{4}">{3}</a>');
  formatterurl.format(listObject, [3, 4]); 
      visualization.draw(listObject, options);
    }

Now for some reason, the script thinks I'm trying to access a column outside of the applicable range [0-4], but there are most definitely 5 columns in my table...
Here is the error message I get;

Uncaught Error: Invalid column index undefined. Should be an integer in the range [0-4].

I have been stuck on this for quite some time now and I was hoping someone could shed some light on the error...

Thanks in advance
Screen Shot 2012-07-19 at 6.10.22 PM.png

asgallant

unread,
Jul 19, 2012, 1:25:23 PM7/19/12
to google-visua...@googlegroups.com
The problem is that by using "3" and "4" in the pattern, the API expects you to pass at least 5 columns in the #format call, as the numbers in the pattern reference the index positions in the format's source column indices parameter, not the data table.  What you wanted was this:

var formatterurl new google.visualization.PatternFormat('<a href="{1}">{0}</a>'); 

Maha Istanbouly

unread,
Jul 20, 2012, 7:43:36 AM7/20/12
to google-visua...@googlegroups.com
Ahhhh ok, clearly a novice mistake! Thanks for your help :)
Reply all
Reply to author
Forward
0 new messages