Mpandroidchart: Data set values on Horizontal Bar chart disappear on zooming along y-axis

Created on 3 Jul 2018  路  9Comments  路  Source: PhilJay/MPAndroidChart

The values next to the bar in horizontal bar graph disappear on scaling along y-axis. It reappears when scrolled to far left

bug

Most helpful comment

I'm using version v3.1.0 and seeing a very similar issue. But it is happening in the vertical version of the Bar chart. A few columns disappear in a given zoom level and drag position. Very weird.

Maybe it's related?

All 9 comments

I am having the same issue...

Could one of you please explain this issue further, perhaps with a video if you can?

Starting from this initially and zooming just a bit till zero/start goes off the chart makes the values on top of the bars disappear (as seen here). While zoomed in, any time the start appears in the chart again, the values also reappear.

Deleting the useless parts, the minimal dummy code below can still reproduce the issue:

HorizontalBarChart horizontalBarChart;                
List<BarEntry> barEntries = new ArrayList<>();
barEntries.add(new BarEntry(1, 1));
barEntries.add(new BarEntry(2, 2));
barEntries.add(new BarEntry(3, 3));
BarDataSet dataSet = new BarDataSet(barEntries, "Label");
YAxis yAxisLeft = horizontalBarChart.getAxisLeft();
yAxisLeft.setAxisMinimum(0);
BarData barData = new BarData(dataSet);
horizontalBarChart.setData(barData);
int chartHeightDp = 10 + 30 * entries.length;
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
horizontalBarChart.setMinimumHeight((int) (chartHeightDp * (metrics.densityDpi / 160f)));
horizontalBarChart.invalidate();

Upon investigating it quickly, it seems like this block of code is triggered:

if (!mViewPortHandler.isInBoundsX(buffer.buffer[j]))
  continue;

and the drawing of the values is skipped.

Yeah that definitely looks like the cause. It should check the Y-value on horizontal bar charts instead of the X-value. I'll fix this soon.

I'm using version v3.1.0 and seeing a very similar issue. But it is happening in the vertical version of the Bar chart. A few columns disappear in a given zoom level and drag position. Very weird.

Maybe it's related?

I have this problem too.
I did a video.
Android Emulator - Pixel_2_API_26_5554 2020-03-31 16-34-32.zip

I found the problem seen in the video posted some minutes ago.

The BarEntry values must be added ordered (ascendent) by "X" value.
This code will generate the issue:

ArrayList<BarEntry> binClassEntries = new ArrayList<BarEntry>(); for(int i = 0; i <20; i++) binClassEntries.add(new BarEntry((float)20-i,(float)new Random().nextInt(2000)));
This code works:

ArrayList<BarEntry> binClassEntries = new ArrayList<BarEntry>(); for(int i = 0; i <20; i++) binClassEntries.add(new BarEntry((float)i,(float)new Random().nextInt(2000)));

Any update or resolution?

I'm using version v3.1.0 and seeing a very similar issue. But it is happening in the vertical version of the Bar chart. A few columns disappear in a given zoom level and drag position. Very weird.

Maybe it's related?

You can resolve it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rohitkumarbhagat picture rohitkumarbhagat  路  3Comments

Giammaofwar picture Giammaofwar  路  3Comments

botondbutuza picture botondbutuza  路  3Comments

manucheri picture manucheri  路  3Comments

tsengvn picture tsengvn  路  3Comments