in bar chart creating first , last rows consistently being cut in half (even if add additional bars). causes values above bars out of place. inflating within fragment.
the axis increasing 0.9 instead of 1. fix need implement axisvalueformatter interface?
image:
code: .java
chart = (barchart) view.findviewbyid(r.id.chart1); // chart settings chart.setdrawgridbackground(false); chart.sethighlightfullbarenabled(true); chart.setdrawbarshadow(false); chart.setdrawvalueabovebar(true); chart.setdescription(""); // settings x-axis xaxis xaxis = chart.getxaxis(); xaxis.setdrawgridlines(false); xaxis.setenabled(true); xaxis.setdrawlabels(true); xaxis.setposition(xaxisposition.bottom); // settings y-axis yaxis leftaxis = chart.getaxisleft(); yaxis rightaxis = chart.getaxisright(); leftaxis.setaxisminvalue(0f); rightaxis.setaxisminvalue(0f); barentry = new arraylist<>(); barentrylabels = new arraylist<string>(); barentry.add(new barentry(2f, 1)); barentry.add(new barentry(3f, 2)); barentry.add(new barentry(4f, 3)); barentry.add(new barentry(5f, 4)); barentry.add(new barentry(6f, 5)); bardataset = new bardataset(barentry, "projects"); bardataset.setcolors(colortemplate.colorful_colors); bardata = new bardata(bardataset); chart.setdata(bardata); chart.invalidate(); // refresh chart.animatey(1500); return view;
to answer questions:
in order show bars need fit bars, (don't ask me why it's not enabled default):
chart.setfitbars(true)
you can find more information in
barchart
javadocs:setfitbars(boolean enabled)
: adds half of bar width each side of x-axis range in order allow bars of barchart displayed.if have
combinedchart
usesetspacemin()
,setspacemax()
add additional spacing on both ends of axis:xaxis xaxis = chart.getxaxis(); xaxis.setspacemin(bardata.getbarwidth() / 2f); xaxis.setspacemax(bardata.getbarwidth() / 2f);
it impossible infuence value positions rendered on axis. creating
valueformatter
changes displayed text, not actual position of label.
Comments
Post a Comment