java - MPAndroidChart. Display value in one row of the grid background with XAxis -


i not know how accurately describe problem. displayed this: https://i.stack.imgur.com/ww5w8.png

values , xaxis in barchart not in center of row. need this: https://i.stack.imgur.com/v0au2.png

how achieve this?

  public void setdataforchart() {              barchart.setdrawbarshadow(false);             barchart.setdrawvalueabovebar(true);             barchart.setmaxvisiblevaluecount(50);             barchart.setpinchzoom(false);             barchart.setdrawgridbackground(true);             barchart.setextraoffsets(0, 0, 0, 20);             barchart.setdescription(description);   arraylist<barentry> barentries = new arraylist<>();         barentries.add(new barentry(1, 41f));         barentries.add(new barentry(2, 42f));         barentries.add(new barentry(3, 43f));         barentries.add(new barentry(4, 44f));         barentries.add(new barentry(5, 45f));         barentries.add(new barentry(6, 46f));         barentries.add(new barentry(7, 47f));         barentries.add(new barentry(8, 48f));         barentries.add(new barentry(9, 49f));         barentries.add(new barentry(10, 50f));         barentries.add(new barentry(11, 51f));         barentries.add(new barentry(12, 52f));              bardataset bardataset = new bardataset(barentries, "data set1");             bardataset.setcolors(colortemplate.colorful_colors);              bardata data1 = new bardata(bardataset);             data1.setbarwidth(0.7f);              barchart.setdata(data1);             barchart.notifydatasetchanged();              string[] months = new string[]{"Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"};              xaxis xaxis = barchart.getxaxis();             xaxis.setvalueformatter(new myxaxisvalueformatter(months));             xaxis.setposition(xaxis.xaxisposition.top);             xaxis.setgranularity(1);             xaxis.setcenteraxislabels(true);             xaxis.setlabelcount(12);              yaxis yaxis = barchart.getaxisleft();             yaxis.setenabled(false);         }          public class myxaxisvalueformatter implements iaxisvalueformatter {              public string[] values;              public myxaxisvalueformatter(string[] values) {                 this.values = values;             }              @override             public string getformattedvalue(float value, axisbase axis) {                 if (values.length > (int) value) {                     return values[(int) value];                 } else {                     return "";                 }              }         } 

can please check after remove or set 0 in place of 20 in below line.

barchart.setextraoffsets(0, 0, 0, 20);  

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -