piaoyongren / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

When bars in CPBarPlot have a barOffset, the corresponding bar labels are not positioned correctly #142

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a CPBarPlot
2. Give the barOffset property a value other than zero
3. Make sure a label is generated for each bar by returning nil in the
datasource protocol method -(CPTextLayer *)barLabelForBarPlot:(CPBarPlot
*)plot recordIndex:(NSUInteger)index

Positioning of the labels should be above the offsetted bars. Instead the
labels are positioned without any offset.

FIX: CPBarPlot.m - addLabelLayers

Add the following lines of code in the main for-loop after the
initialization of the local variables tipPoint and basePoint:

        CGFloat viewOffset = self.barOffset * self.barWidth;
        if ( self.barsAreHorizontal ) {
            basePoint.y += viewOffset;
            tipPoint.y += viewOffset;
        }
        else {
            basePoint.x += viewOffset;
            tipPoint.x += viewOffset;
        }

Original issue reported on code.google.com by robin....@gmail.com on 18 May 2010 at 7:58

GoogleCodeExporter commented 9 years ago

Original comment by drewmcco...@mac.com on 18 May 2010 at 8:00

GoogleCodeExporter commented 9 years ago
Fixed in 14c1d04abf9c

Original comment by drewmcco...@mac.com on 18 May 2010 at 8:14