I have spend a lot of time trying to find a title that explain my question, but not easy. Feel free to suggest.
Code is as follow: I am creating annotation for my chart using google visualisation. The annotation column uses a custom function. This is allowed by google, and the function will received 2 parameters: dt and row. The question is: what should (dt, row, i) in the below be so that I get the default dt, row that the function normally receives and my additional parameter i?
view = new google.visualization.DataView(chartData);
var arr = [0];
for (var i = 1; i < chartData.getNumberOfColumns() ; i++)
{
arr.push(i);
arr.push({role: "annotation", type: "string", calc: (function (dt, row,i) {
if (typeof (dt.getValue(row,i)) == "number" && dt.getValue(row,i) == 0)
{
return "";
}
else
{
return dt.getValue(row, i).toString;
}
})(dt, row, i)
});
}
view.setColumns(arr);
chartData = view.toDataTable();