Max
Max

Reputation: 755

Non-scaling / absolute gradient for scatter plots in CorePlot?

I've added a gradient to my scatter plot in the usual manner:

CPTFill areaGradientFill = [CPTFill fillWithGradient:areaGradient1];
boundLinePlot.areaFill = areaGradientFill;
boundLinePlot.areaBaseValue = 0;

Setting the minimum for the gradient is easy to do with the areaBaseValue property. However, the gradient will always stretch such that the entire range of color defined by areaGradient1 appears below the line plot.

What I'd like to do is set an absolute y-axis range (e.g., 0 to 100) and have the gradient always be set to that range. So if my line is at y=50, only the bottom 50% of the gradient would be rendered below the line. I thought setting boundLinePlot.areaBaseValue2 = 100; would do this, but it doesn't have any effect.

Does CorePlot support this? If not, what's the 'right' way to go about implementing it?

(This is my first question so apologies if I'm not clear. Be gentle. :) )

Upvotes: 2

Views: 210

Answers (2)

Mike Lischke
Mike Lischke

Reputation: 53347

While there's no direct way to make this happen you could use a trick. Make your horizontal global range wider than what you would show normally and do not make the graph horizontally scrollable. Add a value to the graph in the hidden area that is always your maximum value. This will be filled with the full gradient. Other parts however will only get a partial gradient, depending on their height.

I found this trick by accident while looking at one of my graphs. Look:

enter image description here

The overview at the top shows where the big graph is currently (the green limit band). Now compare this with another part:

enter image description here

You can clearly see that the tip of the large value has a different gradient value as the tip of the smaller one.

Upvotes: 1

Eric Skroch
Eric Skroch

Reputation: 27381

You can use a "background limit band" to draw a fill at a certain size behind the plots, but that won't be clipped to the plot line.

Upvotes: 0

Related Questions