The table always displays the formatted value of the cell, regardless of 
what the actual value is.  When you use a formatter, it sets the formatted 
value of every cell in the chosen column.  If you update the value of the 
cell, but not the formatted value, it will still display the original 
formatted value.  The formatters also won't change an already-formatted 
value, so you have to clear the formatted value first, and then call the 
formatter again:

data.setValue(0,1,200);
data.setFormattedValue(0, 1, null);
// reformat column 1
formatter_percentage.format(data, 1);

On Monday, November 19, 2012 8:08:01 PM UTC-5, Ambientson wrote:
>
> Hi,
>
> It took me a long time to finally that my values would not get updated on 
> my table even though the underlying data table was changed because of 
> formatters.
>
> I might be doing something wrong but it sure looks like there is an issue. 
> See following code to run in Google Code Playground (modified Table 
> example):
>
> function drawVisualization() {
>   // Create and populate the data table.
>   var data = google.visualization.arrayToDataTable([
>     ['Name', 'Height', 'Smokes'],
>     ['Tong Ning mu', 174, true],
>     ['Huang Ang fa', 523, false],
>     ['Teng nu', 86, true]
>   ]);
>   
>   var formatter_percentage = new google.visualization.NumberFormat({suffix
> :'%'});
>   formatter_percentage.format(data, 1);
>
>   // Create and draw the visualization.
>   var table= new google.visualization.Table(document.getElementById(
> 'table'));
>   var tableView = new google.visualization.DataView(data);
>   table.draw(tableView, {showRowNumber: false});
>
>   data.setValue(0,1,200);
>   table.draw(tableView, {showRowNumber: false});
> }
>
> If we leave as is, the value in row 0, column 1 will never show as 200 in 
> the table. If we comment ou the two formatter lines, it works.
>
> Any ideas why?
>
> Am I using the formatters in a bad way? Is there a work around (other than 
> me formatting the values through custom code)?
>
> Many thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/--uQ-L50GtUJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to