MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Highlighting central element of the bar data on the bar chart

Open fockeRR opened this issue 7 years ago • 2 comments

Summary Hello, I'm using the BarChart to show the BarData basing on BarDataSet. I disabled all highlighting features on BarChart

    mChart.setDoubleTapToZoomEnabled(false);
    mChart.setHighlightPerTapEnabled(false);
    mChart.setHighlightFullBarEnabled(false);
    mChart.setHighlightPerDragEnabled(false);

on BarDataSet

    barDataSet.setHighLightAlpha(0);
    barDataSet.setHighLightColor(Color.TRANSPARENT);
    barDataSet.setHighlightEnabled(false);

on BarData

barData.setHighlightEnabled(false);

But (only) central element of the bar chart is still clickable and highlights after tapping it. Did I forget about some flags or methods to disable highlighting or it is a bug? Screenshot_20190527-130747 Expected Behavior All the bars should be non-clickable and not highlighted.

Device:

  • Device: Google Nexus 6
  • Android Version 7.0
  • Library Version 3.1.0

fockeRR avatar May 27 '19 11:05 fockeRR

I'm attempting the opposite, but have the same results. I'm trying to allow tapping on any bar segment in the chart to highlight, but the only item that will ever highlight is the center entry.

I am also using a HorizontalBarChart. I have stacked BarEntry values.

Adding an OnChartValueSelectedListener', I can see that onNothingSelected` is fired almost every time I tap on the chart, other than over the middle bar entry.

Barryrowe avatar Jul 01 '19 21:07 Barryrowe

For anyone that happens upon this and has the same issue I did with only the center item highlighting:

If your entries are rendering in reversed order, reverse your data set BEFORE building the BarEntry list. The way the highlighting algorithm works, it expects Entry[0].x <= Entry[1].x <= Entry[2].x and so on. During the process it's doing a binary search to find the closest value, and if your X values are in reversed order, that search will fail except for the center value.

Barryrowe avatar Jul 02 '19 20:07 Barryrowe