Open ankraft opened 7 years ago
PNbarChart.m :: setXLabels instead of label.center = CGPointMake(labelXPosition, self.frame.size.height - _chartMarginTop + label.frame.size.height /2.0 + _labelMarginTop);
->
label.center = CGPointMake(labelXPosition, self.frame.size.height - (_chartMarginTop + label.frame.size.height /2.0) + _labelMarginTop);
This should be changed to:
label.center = CGPointMake(labelXPosition, self.frame.size.height - _chartMarginBottom + label.frame.size.height /2.0 + _labelMarginTop);
label.center = CGPointMake(labelXPosition, self.frame.size.height - _chartMarginBottom + label.frame.size.height /2.0 + _labelMarginTop);
This doesn't work for me. This pushes the label way down below the chart. I think that at least you need to subtract half of the label height, not add it.
label.center = CGPointMake(labelXPosition, self.frame.size.height - (_chartMarginBottom + label.frame.size.height /2.0) + _labelMarginTop);
Hi, Since a long time the offset calculations for labels etc are broken (sometimes overly complicated) so that labels are drawn at wrong positions in the view. The latest patches didn't improve this. The following calculations work for me.
PNbarChart.m :: __addYCoordinateLabelsValues instead of
label.frame = (CGRect){0, sectionHeight * i + _chartMarginTop - kYLabelHeight/2.0 + kXLabelHeight + _labelMarginTop, _yChartLabelWidth, kYLabelHeight};
->
label.frame = (CGRect){0, sectionHeight * i + _chartMarginTop - kYLabelHeight/2.0 , _yChartLabelWidth, kYLabelHeight};
PNbarChart.m :: setXLabels instead of
label.center = CGPointMake(labelXPosition, self.frame.size.height - _chartMarginTop + label.frame.size.height /2.0 + _labelMarginTop);
->
label.center = CGPointMake(labelXPosition, self.frame.size.height - (_chartMarginTop + label.frame.size.height /2.0) + _labelMarginTop);
PNbarChart.m :: updateBar instead of
bar = [[PNBar alloc] initWithFrame:CGRectMake(barXPosition, self.frame.size.height - chartCavanHeight - kXLabelHeight - _chartMarginBottom + _chartMarginTop ,barWidth, self.showLevelLine ? chartCavanHeight/2.0:chartCavanHeight)];
->
bar = [[PNBar alloc] initWithFrame:CGRectMake(barXPosition, _chartMarginTop, barWidth, self.showLevelLine ? chartCavanHeight/2.0:chartCavanHeight)];
I hope this will help others as well.