Margin for scatter points in scatter series


#1

Is there a way to ensure there’s a margin in the plot area when using a scatter series. At present, my min and max points are being sliced in half by the edge of the plot area.

I am allowing the axis to range automatically and would just like to specify a margin in pixels so that points at the edge aren’t truncated.


#2

Hi,

You can specify a padding on the range at both the high and low ends of your axes. This should give you the effect you’re looking for. The properties you will need are specified on the SChartAxis class. I’ve pasted in the relevant section of the API header comments for more information:

/** In data terms, the amount by which the lower limit of the axis range will be lowered past the range of the data.
 
 By default, this is set to 0. */
@property (nonatomic, retain) id rangePaddingLow;

/** In data terms, the amount by which the upper limit of the axis range will be raised past the range of the data.
 
 By default, this is set to 0. */
@property (nonatomic, retain) id rangePaddingHigh;

Hope that helps,

Dan


#3

Thanks for responding Dan, however I’m not sure this helps.

The range specified is in raw units, but the margin is for visual effect and should be specified in pixels. If you can show me how I can easily calculate the units to pixel ratio then I can specify the rangePadding as an alternative?

Thanks


#4

Hi,

Thank you for clarifying this. I guess one way you could get a ratio of units to pixels would be to use the pixelValueForDataValue: method on SChartAxis. If you called this for the max and min values on the axis range, you could then find the difference in pixel coordinates.

One area which could be problematic would be dealing with zooming and panning interactions on the chart. As the axis range changes, you would need to update the padding to reflect this, which would also cause the chart to redraw.

Thanks,

Dan