Charts: Bars not rendering or disappearing while and after dragging

I’ve created a bar chart using BarChartView. The view displays work hours per day. Unfortunately, some bars are not rendered at all - and others are disappearing while the whole chart is dragged.

Before the chart is shown the first time, it’s zoomed to show only 7 bars at a time:

barChart.zoom(scaleX:ceil(CGFloat(dataSet.xMax - dataSet.xMin) / 7), scaleY: 1, x: 0, y: 0)

Then the view is animated, so the latest day is shown first:

barChart.moveViewToAnimated(xValue: dataSet.xMax, yValue: dataSet.yMin, axis: barChart.rightAxis.axisDependency, duration: 0.8, easingOption: .easeInOutSine)

This leads to the following result - so far, so good:

img_2071

As soon as I drag the chart to the right, bars begin to disappear - only the value remains visible (notice the bar of Mo. 6th - it’s gone):

img_2072

Also all bars which are further left and therefore not visible immediately (because of the zoom) are not rendered at all. What I’ doing wrong?

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 32 (10 by maintainers)

Most upvoted comments

I have the same issue with 3.0.2 in a CombinedChartView with stacked bar BarChartData(). When zooming and dragging the most right data entry outside the visible view the bars disappear, the data labels are there. Further I don’t restrict .setVisibleXRangeMaximum() or move the left side via .moveViewToX() at all.

Another strange behavior is that I cannot select all bars via .highlightPerTapEnabled(), only the center bar in a set of e.g. 13 is selectable. Not sure if this is related at all.

solved: The issue was that the data entries where in reverse order. Ordering the data entries by increasing x values solved the issue.