Align scatter points with columns


#1

Hi everyone,

I am using a combination of SChartColumnSeries and SChartScatterSeries to make this chart.

Is there a way to center the points with the respective column ?

Thx for any help.


#2

Hello Moonlace,

What I would suggest doing is offsetting the datapoints on your X axis to account for the offset of the bars. You could do this in a number of ways:

  1. If your chart is always going to be two columns, it might be easiest for you to find a hard coded value to offset your green & orange datapoints.
  2. Use the our bar spacing equation to do this dynamically.

( (minSpacing * (1 - interSeriesSetPadding) ) / numColSeries) * (1 - interSetPadding)

Unforunately, you can’t set your scatter points at an offset to your bars whilst they are on a category axis, so you have two options again here:

  1. Add another X axis to your chart and hide it, have the range of your second X axis as the same as the range of your category axis. (A category axis’ range & padding is still numerica, based of the index of the category.)
  2. Change your main axis to an SChartNumber axis and assign an NSNumber formatter subclass that returns the correct category names for the integers that your datapoints are at. Or simply change the numbers to the category names in the alterTickLabel: delegate method (although you may have label length/truncation issues when using the delegate method).

I hope the above has helped.

Thanks,
Jan


#3

I was able to solve the problem by adding a second chart on top of the column chart.

But i will try your solution otherwise i will have problems managing the pans / zooms since the chart that is on top will eat all the gestures.

If i manage to use your solution i will say something.

Thx very much for the help :slight_smile:


#4

Glad I could help!