PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.53k stars 9.01k forks source link

barchart width issue #2209

Open levianye opened 8 years ago

levianye commented 8 years ago

@PhilJay thank your awsome chart project! recently I am studying your project in order to apply some features in my project,I meet some problems, it makes me confused. ①:whether barchart support set max scale? it seems barchart can be scaled infinite, ②:can I set a fixed bar width? as the first question ③:I want to display bar start from Y axis edge,so I modified the demo project BarChartActivity,original in the demo the code in function setData

float mult = (range + 1); float val = (float) (Math.random() * mult); yVals1.add(new BarEntry(i+1f, val));

I just modified to

float mult = (range + 1); float val = (float) (Math.random() * mult); yVals1.add(new BarEntry(i, val));

here is comparison result s60830-163754 1 s60830-163802 1 s60830-163624 1 s60830-163633 1

We can clearly see that if let bar display from Y axis edge(yVals1.add(new BarEntry(i, val)); ) ,the first bar seems only display half of itself,so what is this problem? is there some more attribute need to set?I would be grateful if you can answer me!

ghost commented 8 years ago

http://stackoverflow.com/questions/38838362/mpandroidchart-first-and-last-bars-not-rendering-correctly

try this.

chart.setFitBars(true)

levianye commented 8 years ago

@BottleTasteApp but I have already set it! because I tried various ways,but not working,so I raised the issue,I don't konw how to make it working!

levianye commented 8 years ago

fuck! finally I found a perfect way to solve this issue! just setAxisMinimum and setAxisMaximum it work perfectly! mChart.getXAxis().setAxisMinimum(-data.getBarWidth()/2); mChart.getXAxis().setAxisMaximum(count-data.getBarWidth()/2); remember you must set it after BarData instantiation to let it work!

BongJaeChoi commented 7 years ago

horizontal bar same issue

galaxi76 commented 5 years ago

fuck! finally I found a perfect way to solve this issue! just setAxisMinimum and setAxisMaximum it work perfectly! mChart.getXAxis().setAxisMinimum(-data.getBarWidth()/2); mChart.getXAxis().setAxisMaximum(count-data.getBarWidth()/2); remember you must set it after BarData instantiation to let it work!

This is also useful if you have less bars than the expected, but still want them to have a set width, instead of the bars spreading across the original chart width

rahulpahuja commented 4 years ago

@PhilJay i think if this is resolved with the previous comment shall we close this issue?