json - Javascript - Stingify : formatting numbers for Google charts -


i trying understand why 2 below code not produce same output. data in datatable formatted: 11254 shows 11,254.

view.setcolumns([1, {     calc: "stringify",     sourcecolumn: 1,     type: "string",     role: "annotation" }]); 

the above creates 2 column. 1 original column 1 datatable. second 1 string annotation of chart. numbers end being formatted: 11,254.

view.setcolumns([1,{     role: "annotation",     type: "string",     calc: function (dt, row) {         if dt.getvalue(row, 1) == 0) {             return "";         }         else {             return json.stringify(dt.getvalue(row, 1));         }     } }]); 

in case numbers converted string not formatted anymore: 11254 instead of 11,254. 2 stringify function not same?

the "stringify" function not documented, based on observation, returns formatted value of cell. second function returning string based on value, not formatted value, of cell. if want make them equivalent, need this:

view.setcolumns([1,{     role: "annotation",     type: "string",     calc: function (dt, row) {         if dt.getvalue(row, 1) == 0) {             return "";         }         else {             return json.stringify(dt.getformattedvalue(row, 1));         }     } }]); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -