Sorting Table broken when using a bar formatter

44 views
Skip to first unread message

NA

unread,
Jan 18, 2012, 3:26:31 PM1/18/12
to Google Visualization API
Hi,

I have Tables displaying data from a DataTable that is updated
periodically. In my table options, I have:

wrap.setOptions({
allowHtml:true
,sortColumn:1
,sortAscending:false
,page:'disable'
});

The sort works fine, and when the data in the DataTable is updated and
the MyWrapper.draw() method called, the Table updates properly,
maintaining correct sort order.

But if I add a bar formatter to column 1, the sorting works when the
table is initially displayed but does not work after updates to the
table are made. Even resetting the options using:

wrap.setOption('sortAscending',false);
wrap.setOption('sortColumn',1);

didn't work. It seems as if the sort method is looking at the data in
the bars, not at the actual values.

Furthermore, the bar formatter isn't applied to rows added to the
table.

In fact, I ran a few other tests and it seems as if the bar formatter
just doesn't work properly when the underlying DataTable is updates.

Can someone confirm? I'm not sure if this is a new bug or not, as I
just began testing this feature a few minutes ago...

asgallant

unread,
Jan 19, 2012, 9:56:13 AM1/19/12
to google-visua...@googlegroups.com
I believe that you need to call the #format method every time you update the DataTable, before you call the #draw method.

NA

unread,
Jan 19, 2012, 10:18:52 AM1/19/12
to Google Visualization API
No, that doesn't work. 2 things go wrong in that case:

- Bars appear for all entries, but their sizes aren't correct. It
looks like entries whose value wasn't changed kept their old bar
size. This isn't the correct behavior; they need to be resized to
take into account other values in their column.

- Sorting is still broken. The data is not sorted according to what
was specified in setOptions. It's sort of scrambled; I didn't see the
pattern to how it appeared.

:(

NA

unread,
Jan 19, 2012, 10:24:19 AM1/19/12
to Google Visualization API
In fact, even clearing the formatters for every entry in the column
with "setFormattedValue(i,1,null);" before re-applying them at each
draw() still doesn't work, same behavior as before.

Any GVIZ team have any ideas what I need to do, and if this behavior
is somehow desirable?

NA

unread,
Jan 22, 2012, 7:29:18 PM1/22/12
to Google Visualization API
Anyone from the GVIZ team to comment on this?

I'd love to use the formatters with this table as it updates, but this
is preventing me from doing so.

asgallant

unread,
Jan 23, 2012, 9:34:47 AM1/23/12
to google-visua...@googlegroups.com
It works fine when I tried it: http://jsfiddle.net/9Lg2L/

NA

unread,
Jan 23, 2012, 10:34:30 AM1/23/12
to Google Visualization API
Thanks very much for creating an example :) I was meaning to do that
to perhaps get more responses.

I've modified your example so that it shows the odd behavior.

Take a look at:

http://jsfiddle.net/LvZRa/2/

In this example, after clicking on the button, the sorting looks
correct but the value being displayed isn't updated.

Is there something going on here with setValue vs setCell? I don't
see anything wrong with my use of setValue.

I'm more confused than before. Any ideas what's happening?

asgallant

unread,
Jan 23, 2012, 11:36:47 AM1/23/12
to google-visua...@googlegroups.com
Ok, I see what you mean.  Looking into this, there seem to be (at least) two things bugged here:

1) the DataTable#setValue method does not clear the formatted value, as the documentation says it is supposed to
2) the formatter redraws bars correctly, but keeps the old cell values for labels (the stored '_bar_format_old_value' property never changes), even when the formatted value is cleared.

You can work around this problem in the meantime by using the #setCell and #setProperty methods to set the cell value, clear the formatted value, and set the '_bar_format_old_value' property to the new cell value: http://jsfiddle.net/LvZRa/5/

NA

unread,
Jan 23, 2012, 12:19:56 PM1/23/12
to Google Visualization API
Impressive effort to get to the _bar_format_old property! This is a
nice workaround, but I don't think it's going to generalize to the
cases that I have (each of my tables can be updated by more than one
method, and the formatters for a column won't/shouldn't be known by
those methods). I am starting to wonder if the other formatters are
broken in the same way...

It looks like we have a good working example of the problem, though.

Can we get a GVIZ person to confirm? Perhaps some inside perspective
on this? I know I can make a bug ticket, but I'd like to hear
confirmation from the dev team on this to get an idea of whether it
will be addressed soon. Hopefully the fix is straightforward.

For me, one of the key features of the Visualization API is the Table
and it's formatters, and I'd love to see this working.

thanks,

ChartMan

unread,
Jan 23, 2012, 12:42:56 PM1/23/12
to google-visua...@googlegroups.com

Thanks for reporting I will look into this.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

NA

unread,
Jan 30, 2012, 9:02:11 AM1/30/12
to Google Visualization API
Hi ChartMan,

Were you able to find more about this, perhaps even a workaround until
a fix is ready? I really like the look of charts with the bar
formatter, and want to apply it to my charts that update in real time.

thanks,

Reply all
Reply to author
Forward
0 new messages