gujjula / core-plot

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

Ranges for barPlots #337

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In relation to fixes of issue 329 
(http://code.google.com/p/core-plot/issues/detail?id=329), I have a few more 
suggestions, but I am not sure if they are applicable throughout the framework:

- first, an edge case when, for example, all bars are of the same height (say 
50), the method plotRangeForField: returns nil, whereas I guess a range with 
location 50 and length 0 would be more appropriate (unless there are place 
where this causes division by 0). Could be simply fixed by non-strict checking 
of min and max (e.g. replace max > min with max >= min and the same with 
decimals)

- also, when one wants to adjust the plot ranges accordingly, I would suggest 
the bar plots should show the full range from the base to the maximum of the 
tips (or from the minimum of the base if they vary) and horizontally take the 
bar width into account (e.g. a bar plot with bars at 0, 1 and 2 and bar width 
0.7 should have range from -0.35 to 2.35 instead of from 0 to 2) so that the 
plot fits completely in the plot area

For example in CPTBarPlot
-(CPTPlotRange *)plotRangeForField:(NSUInteger)fieldEnum {

    CPTPlotRange *range = [super plotRangeForField:fieldEnum];

    if (fieldEnum == CPTBarPlotFieldBarTip) {
        if (self.barBasesVary) {
            // handle varying bases
        }
        else {
            range.length = CPTDecimalAdd(CPTDecimalSubtract(range.location, self.baseValue), range.length);
            range.location = self.baseValue;
        }
    }
    else if (fieldEnum == CPTBarPlotFieldBarLocation) {
        range.location = CPTDecimalSubtract(range.location, CPTDecimalDivide(self.barWidth, CPTDecimalFromInt(2)));
        range.length = CPTDecimalAdd(range.length, self.barWidth);
    }

    return range;
}

Original issue reported on code.google.com by sergiy.p...@gmail.com on 2 Oct 2011 at 10:24

GoogleCodeExporter commented 9 years ago
I agree on part 1. Good point on checking for division by zero elsewhere in 
Core Plot.

This is really two separate issues. I added issue 338 to track comments and 
action on the enhancement described in part 2.

Original comment by eskr...@mac.com on 3 Oct 2011 at 1:36

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 1017bc3914f9.

Original comment by eskr...@mac.com on 21 Oct 2011 at 2:07