Custom background color for Scatterchart


#1

I know we can set the background colour of the plot area by using

[chartsetPlotAreaBackgroundColor:[UIColordarkGrayColor]];
 
 However, what I want to accomplish is to have the background colour change depending on the xaxis. The data I want to show will be in a scatter series with all Y values being within the X value range 0-6. I want the background from x=0 to x=1 to be light gray, then a darker gray from x=1 to x=2, then back to lighter etc. Is this possible?

#2

an addendum -> can we set an image to be the either or both of the chartbackground or plotbackground?


#3

Hi Victor,

Currently, ShinobiCharts only supports a solid colour as a background. If you want vertical stripes on your chart, I would look at adding annotations to your chart. Specfically, the method +verticalBandAtPosition:andMaxX:withXAxis:andYAxis:withColor: is what you are looking for!

To have it appear as though an image is the charts background, you could set the charts background to be [UIColor clearColor] and then place an image behind the chart. You can get the frame of the chart or plot area (to use as your UIImageView’s frame) like so:

// Chart frame.
CGRect chartFrame = myChart.frame;
// Plot area frame.
CGRect plotAreaFrame = myChart.canvas.glView.frame;

Jan


#4

Jan I will try to implement this later today, but it appears to be exactly what I was looking for! Thanks a lot for your reply :slight_smile:


#5

No problem! Glad I could help.  :laughing: