MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Tooltip not showing on Horizontal or Vertical Bar chart when all values are negatives.

Open checoalejandro opened this issue 7 years ago • 3 comments

Hi, it seems like for Horizontal or Vertical Bar Chart, marker views are not being drawn when all values are negatives, it doesn't reach the refreshContent method of the marker view. If you change all values to positive and negative, it will load refreshContent method and also the marker view.

I just checked that inside Chart, the method drawMarkers is doing a validation of checking if is in bounds and every iteration goes to continue in this validation so it never calls refreshContent or draw of the markerView.

checoalejandro avatar Aug 21 '17 16:08 checoalejandro

This is what I have: `horizontalBarChart = findViewById(R.id.horizontalBar); horizontalBarChart.setMarker(new CustomMarkerView(this, R.layout.custom_marker_view_layout));

    List<BarEntry> entries = new ArrayList<>();
    entries.add(new BarEntry(0f, -30f));
    entries.add(new BarEntry(1f, -80f));
    entries.add(new BarEntry(2f, -60f));
    entries.add(new BarEntry(3f, -50f));
    // gap of 2f
    entries.add(new BarEntry(5f, -70f));
    entries.add(new BarEntry(6f, -60f));

    BarDataSet set = new BarDataSet(entries, "BarDataSet");
    BarData data = new BarData(set);
    data.setBarWidth(0.9f); // set custom bar width
    horizontalBarChart.setData(data);
    horizontalBarChart.setFitBars(true); // make the x-axis fit exactly all bars
    horizontalBarChart.invalidate(); // refresh`

checoalejandro avatar Aug 21 '17 16:08 checoalejandro

Any solution on this? , see i am too facing a similar issue: https://stackoverflow.com/questions/59541099/set-the-negative-values-to-the-left-of-the-bars-in-horizontal-bar-chart

suvDev avatar Dec 31 '19 14:12 suvDev

have you find the solution for it ?

omkarshisode avatar Aug 10 '23 12:08 omkarshisode