Reputation: 1173
I've been trying to setup the gradient under the plot:
//add gradient to line
CPTColor *underLineGradientStartColor = [CPTColor colorWithComponentRed:CPTFloat(0.0) green:CPTFloat(1.0) blue:CPTFloat(0.0) alpha:CPTFloat(1.0)];
CPTColor *underLineGradientEndColor = [CPTColor colorWithComponentRed:CPTFloat(1.0) green:CPTFloat(0.0) blue:CPTFloat(0.0) alpha:CPTFloat(1.0)];
CPTGradient *underLineGradient = [CPTGradient gradientWithBeginningColor:underLineGradientStartColor endingColor:underLineGradientEndColor];
underLineGradient.angle = -90.0;
CPTFill *underLineGradientFill = [CPTFill fillWithGradient:underLineGradient];
dataSourceLinePlot.areaFill = underLineGradientFill;
I've also set up the areaBaseValues:
dataSourceLinePlot.areaBaseValue = @0;
dataSourceLinePlot.areaBaseValue2 = @255;
The values I am going to plot are in the range 0-255 (range of plot is set to be constant). Sometimes, however, I receive invalid values (e.g. 1000). Incorrect values are not shown as they are out of range. The gradients, however, want to fill them and in the result the gradient is not visible (only the lowest part of it is on the screen - not full range). How can I change it?
EDIT:
This is how it looks now:
I want to have gradient from 0 to 255 (values above 255 can be solid green).
Upvotes: 0
Views: 164
Reputation: 27381
Have the datasource clip the invalid data points to a value that is just outside the maximum value of the plot range. For example, if the plot range will never go above 255, have the datasource return a y-value of 255.1 for any invalid data point. It doesn't matter what the fill above 255 is since it's outside the plot area and you'll never see it.
Upvotes: 1