formatting - How to remove negative symbol on values Google Charts? -


i have column chart , work fine, want allways show positive number, force negative number "divide" bars on top , bottom.

he example:

example

here code

google.load('visualization','1.1',{packages:['corechart']}); google.setonloadcallback(function(){ var googlechart=new google.visualization.columnchart(document.getelementbyid( 'chart' ));    var data = google.visualization.arraytodatatable([     ["age","male","female"],     ["<15",{"v":0,"f":"0%"},{"v":0,"f":"0%"}],     ["15-20",{"v":8.3333333333333,"f":"8,3333333333333%"},{"v":0,"f":"0%"}],     ["20-25",{"v":75,"f":"75%"},{"v":-8.3333333333333,"f":"8,3333333333333%"}],     ["25-30",{"v":0,"f":"0%"},{"v":0,"f":"0%"}],     ["30-35",{"v":0,"f":"0%"},{"v":0,"f":"0%"}],     ["35-40",{"v":0,"f":"0%"},{"v":0,"f":"0%"}],     ["40-45",{"v":8.3333333333333,"f":"8,3333333333333%"},{"v":0,"f":"0%"}],     ["45-50",{"v":0,"f":"0%"},{"v":0,"f":"0%"}],     ["50-55",{"v":0,"f":"0%"},{"v":0,"f":"0%"}],     ["55-60",{"v":0,"f":"0%"},{"v":0,"f":"0%"}],     [">60",{"v":0,"f":"0%"},{"v":0,"f":"0%"}] ]); new google.visualization.numberformat({"pattern":"#,##%"}).format(data, 1);  new google.visualization.numberformat({"pattern":"#,##%"}).format(data, 2);  var options ={     "isstacked":true,     "haxis":{         "title":"age"     },     "vaxis":{         "title":"percentage",         "format":"#,##%",         "viewwindowmode":"explicit",         "viewwindow":{             "min":-100,             "max":100         }     } }; googlechart.draw(data, options); 

i dont know how remove negative symbol("-"). thanks

p.s: google charts 1.1

the google visualization pattern format subset of icu pattern set. can specify subpatterns both positive , negative numbers avoid minus sign (because if negative subpattern not specified, minus prefix default) :

format: "#,##%;#,##%" 

unfortunetaly not work in visualization - complains "too many percent/permills" - since % nothing "multiply 100 , show percentage" - can add ,00% string suffix instead :

vaxis:{    format:"#,##',00%';#,##',00%'",    ... } 
new google.visualization.numberformat({"pattern":"#,##',00%';#,##',00%'"}).format(data, 1);  new google.visualization.numberformat({"pattern":"#,##',00%';#,##',00%'"}).format(data, 2);  

minus sign removed both vaxis , tooltips.

demo -> http://jsfiddle.net/pcvtf7q9/


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -