2

I have an issue with the BalloonMarker I used for my graph as it won't display the marker for all the chart elements, but only for one of them.

I used the BalloonMarker from the ChartsDemo project for a bar chart. The marker gets displayed, but only for one of the bars from the charts. I don't know if it is a coincidence or not, but it gets displayed for the bar from the middle.

I can't see what I am missing here. Is there any mistake or any other setting I can add in order to make the marker display properly?

This is the code I used to create the BallonMarker for the chart:

BalloonMarker *balloonMarker = [[BalloonMarker alloc]
                         initWithColor: [UIColor colorWithWhite:180/255. alpha:0.9]
                         font: [UIFont systemFontOfSize:10.0]
                         textColor: UIColor.whiteColor
                         insets: UIEdgeInsetsMake(8.0, 8.0, 20.0, 8.0)];
balloonMarker.chartView = barChartOrdersView;
balloonMarker.minimumSize = CGSizeMake(40.f, 20.f);

I added the marker to the chart using this code:

barChartOrdersView.drawMarkers = YES;
barChartOrdersView.marker = balloonMarker;

The properties for the bar chart are:

barChartOrdersView.gridBackgroundColor = [UIColor whiteColor];
barChartOrdersView.backgroundColor = [UIColor whiteColor];

barChartOrdersView.drawBarShadowEnabled = NO;
barChartOrdersView.drawValueAboveBarEnabled = YES;
barChartOrdersView.chartDescription.enabled = NO;
barChartOrdersView.dragEnabled = NO;
[barChartOrdersView setScaleEnabled:NO];
barChartOrdersView.pinchZoomEnabled = NO;

barChartOrdersView.rightAxis.enabled = NO;

barChartOrdersView.leftAxis.drawGridLinesEnabled = YES;
barChartOrdersView.leftAxis.drawLabelsEnabled = YES;
barChartOrdersView.leftAxis.labelFont = [UIFont systemFontOfSize:10.f];
barChartOrdersView.leftAxis.labelPosition = YAxisLabelPositionOutsideChart;
barChartOrdersView.leftAxis.spaceTop = 0.15;
barChartOrdersView.leftAxis.axisMinimum = 0.0;

barChartOrdersView.xAxis.labelPosition = XAxisLabelPositionBottom;
barChartOrdersView.xAxis.drawGridLinesEnabled = NO;
barChartOrdersView.xAxis.axisMinimum = 0.0;
barChartOrdersView.xAxis.granularity = 1.0;
barChartOrdersView.xAxis.labelFont = [UIFont systemFontOfSize:10.f];
barChartOrdersView.xAxis.drawGridLinesEnabled = NO;
barChartOrdersView.xAxis.granularity = 1.0;
barChartOrdersView.xAxis.labelCount = 7;
barChartOrdersView.xAxis.valueFormatter = [DayAxisValueFormatter new];

barChartOrdersView.legend.enabled = YES;
barChartOrdersView.legend.horizontalAlignment = ChartLegendHorizontalAlignmentLeft;
barChartOrdersView.legend.verticalAlignment = ChartLegendVerticalAlignmentBottom;
barChartOrdersView.legend.orientation = ChartLegendOrientationHorizontal;
barChartOrdersView.legend.drawInside = NO;
barChartOrdersView.legend.form = ChartLegendFormSquare;
barChartOrdersView.legend.formSize = 9.0;
barChartOrdersView.legend.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:11.f];
barChartOrdersView.legend.xEntrySpace = 4.0;
Alina
  • 142
  • 2
  • 13
  • 1
    BallonMarker from ChartsDemo will be displayed when you click on the bar. And it shows only for the clicked bar. – Vini App Sep 07 '17 at 06:58

1 Answers1

0

Make sure the entries you passed in is sorted by ascending order of x value.

Unordered entries could result in unexpected behavior such as dataset flashing or marker not tappable as you mentioned.

Sam
  • 125
  • 2
  • 5