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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -