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.56k stars 9.01k forks source link

BarChart, Bar Scrolling issue in ViewPager #4420

Open masheransari opened 5 years ago

masheransari commented 5 years ago

Scrolling issue in barchart

bar scolling is not smooth in app. Code are also attached.

barChart.setDescription(""); barChart.setPinchZoom(true); barChart.setDrawBarShadow(false); barChart.setDrawValueAboveBar(true); YAxis yLabels = barChart.getAxisLeft(); yLabels.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART); yLabels.setValueFormatter(new MyYValueFormatter()); barChart.getAxisRight().setValueFormatter(new MyYValueFormatter()); barChart.getAxisRight().setDrawGridLines(false); YAxis yl = barChart.getAxisLeft(); yl.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART); yl.setDrawGridLines(true); yl.setEnabled(true); yl.setAxisMinValue(0f); barChart.getAxisRight().setEnabled(false); XAxis xAxis = barChart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); xAxis.setTypeface(Constant.getRegularTypeface(context)); xAxis.setDrawGridLines(false); xAxis.setSpaceBetweenLabels(2); xAxis.setXOffset(5f); xAxis.setYOffset(5f); xAxis.setTextSize(8f); xAxis.setLabelRotationAngle(-45); FormatterType.YAxisFormatter custom = new FormatterType.YAxisFormatter(yAxis_unit); YAxis leftAxis = barChart.getAxisLeft(); leftAxis.setValueFormatter(custom); barChart.getLegend().setEnabled(false);

//Data Setting process.

BarDataSet set1 = new BarDataSet(values, ""); set1.setBarSpacePercent(35f); set1.setColors(colors); set1.setDrawValues(true); BarChartCustomRendererImage barChartCustomRenderer = new BarChartCustomRendererImage(barChart, barChart.getAnimator(), barChart.getViewPortHandler(), bitmaps); barChart.setRenderer(barChartCustomRenderer); barChart.setRenderer(barChartCustomRenderer); ArrayList dataSets = new ArrayList<>(); dataSets.add(set1); BarData data = new BarData(xVals, dataSets); data.setValueTextSize(9f); data.setValueTypeface(Constant.getRegularTypeface(context)); barChart.setData(data);

Sorry for bad english.

b880de2d-471d-412b-b29d-f4942cf7d3f6

thomasponzo commented 5 years ago

I have the same problem How to fix this. Found this but dont know how to implement it https://github.com/PhilJay/MPAndroidChart/issues/1885#issuecomment-267568663