The DataTable doesn't have any method of telling you whether or not a 
column was formatted.  You may have luck checking the contents of a column 
against their formatted values, but that won't necessarily tell you 
anything useful, eg:

var formatted = [];
for (var col = 0; col < data.getNumberOfColumns(); col++) {
    formatted.push(false);
    for (var row = 0; row < data.getNumberOfRows(); row++) {
        if ((data.getValue(row, col) == null && data.getFormattedValue(row, 
col) != '') || data.getValue(row, col).toString() !== 
data.getFormattedValue(row, col)) {
            formatted[col] = true;
            break;
        }
    }
}

That will iterate over all columns in the table and check to see if any of 
the cells' formatted values differ from the string-transform of the actual 
value.  This will fail to work with Dates and fail to detect any formatting 
where the format doesn't change from the default given the set of data, ex:

var data = new google.visualization.DataTable();
data.addColumn('number', 'foo');
data.addRow([3]);
var formatter = new google.visualization.NumberFormat({pattern: 
'#,###.##'});
formatter.format(data, 0);
data.getValue(0, 0).toString() === data.getFormattedValue(0, 0); // true, 
even though I applied a formatter

so it's not perfect.  I would suggest tracking your formatting externally 
rather than trying to detect it.

On Monday, May 26, 2014 7:36:14 AM UTC-4, Amir Bashan wrote:
>
> Hi,
> I created this number formatter:
> *var formatter = new google.visualization.NumberFormat({pattern: 
> '#,###.##'});*
>
> and I want to apply this formatter to columns that don't have formatters 
> applied to them - a "default" formatter.
> I couldn't find any method that tells you if a column was formatted.
> How can I do this?
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to