Reputation: 11
I have a ComboChart with ControlWrapper, I want in my chart only I see the the figure on two decimal places, so I use formatter, this my code
view: {
columns: [
{
//transform the numbers into strings, so the steppedArea series will work
type: "string",
calc: function (dt, row) {
var date = dt.getValue(row, 2);
var formatter = new google.visualization.DateFormat({pattern:"dd/MM/yyyy HH:mm"});
return formatter.formatValue(date);
console.log(calc, typeof (calc));
}
},
{
type:"string",
calc: function (dt, row) {
var number = dt.getValue(row, 2);
var number = dt.getValue(row, 3);
var number = dt.getValue(row, 4);
var formatter = new google.visualization.NumberFormat({fractionDigits:2});
console.log(calc);
return formatter.formatValue(number);
}
},
6,7]
}
but I have this error :
One or more participants failed to draw()×
All series on a given axis must be of the same data type×
could you help me?
Upvotes: 0
Views: 3877
Reputation: 26340
Answered over in the Google Visualization API Discussion Group, but to reprint here for folks with a similar problem:
You are returning a string value when you should be returning a number value. If you want to format the data, you can return it as an object with "v" (value) and "f" (formatted value) properties:
{
type: 'number',
calc: function (dt, row) {
var number = dt.getValue(row, 2);
var formatter = new google.visualization.NumberFormat({fractionDigits:2});
return {
v: number,
f: formatter.formatValue(number)
};
}
}
Upvotes: 1