1

I'm trying to set a stripes filling for a graph created with CorePlot. I've found an example on internet:

CPColor *firstStripesColor = [CPColor colorWithComponentRed:1.0 green:1.0 blue:1.0 alpha:0.0];
                CPColor *secondStripesColor = [CPColor colorWithComponentRed:1.0 green:1.0 blue:1.0 alpha:0.6];
                CPFill *areaStripesFill = [CPFill fillWithFirstColor:firstStripesColor secondColor:secondStripesColor stripeWidth:2];
                scatterPlot.areaFill = areaStripesFill;

I think this code is using an old version of the CorePlot library (I'm using 1.0). I just changed CPColor with CPTColor and CPFill with CPTFill but no method called fillWithFirstColor:secondColor: is present. I would like to create a filling like the one in the iPhone Stocks app.

Any idea?

thanks a lot

Claus

Kdeveloper
  • 13,679
  • 11
  • 41
  • 49
Claus
  • 5,662
  • 10
  • 77
  • 118

1 Answers1

2

Here's the code that makes the background fill for the stocks theme:

CPTGradient *stocksBackgroundGradient = [[[CPTGradient alloc] init] autorelease];

stocksBackgroundGradient = [stocksBackgroundGradient addColorStop:[CPTColor colorWithComponentRed:0.21569 green:0.28627 blue:0.44706 alpha:1.0] atPosition:0.0];
stocksBackgroundGradient = [stocksBackgroundGradient addColorStop:[CPTColor colorWithComponentRed:0.09412 green:0.17255 blue:0.36078 alpha:1.0] atPosition:0.5];
stocksBackgroundGradient = [stocksBackgroundGradient addColorStop:[CPTColor colorWithComponentRed:0.05882 green:0.13333 blue:0.33333 alpha:1.0] atPosition:0.5];
stocksBackgroundGradient = [stocksBackgroundGradient addColorStop:[CPTColor colorWithComponentRed:0.05882 green:0.13333 blue:0.33333 alpha:1.0] atPosition:1.0];
stocksBackgroundGradient.angle = 270.0;
plotAreaFrame.fill = [CPTFill fillWithGradient:stocksBackgroundGradient];
Eric Skroch
  • 27,381
  • 3
  • 29
  • 36
  • Is it possible to make the pattern repeat? E.g. having the gradient every second unit and the flat color every other second unit? – Setomidor Aug 23 '12 at 06:31
  • Set the `alternatingBandFills` on the axis. See the Plot Gallery example app for sample code. – Eric Skroch Aug 23 '12 at 22:28
  • 1
    Thanks! Tried that but it didn't quite do what I intended. I ended up using a tiled PNG with transparent element instead (as per your suggestion in another thread) :) – Setomidor Aug 24 '12 at 07:46