Re: how to format data in DataView

409 views
Skip to first unread message

asgallant

unread,
Jul 9, 2012, 12:23:30 PM7/9/12
to google-visua...@googlegroups.com
You have to apply the format yourself and return it in the calculated column, like this:

var view new google.visualization.DataView(data);
view.setColumns([012{
    type'number',
    label'Average',
    calcfunction (dtrow{
        var avg (dt.getValue(row1dt.getValue(row2)2;
        return {vavgfavg ' ms'};
    }
}]);

The returned object has two properties: "v" for the value and "f" for the formatted value.

On Sunday, July 8, 2012 12:52:59 PM UTC-4, luka wrote:
I have a DataTable displaying some numeric data, lets say there's 2 series. I want to display the average of these 2 series, so I created a DataView which calculates the average using a custom "calc" function inside "setColumns".

On my columns inside the original DataTable I have applied a DataFormatter, but this doesn't work on a DataView. So my question is how do I format this calculated data? I just want to add a simple suffix like " ms".

Regards,
Luka
Reply all
Reply to author
Forward
0 new messages