Claus
Claus

Reputation: 5722

iOS CorePlot: wrong bar plotting positioning

I have a graph created with CorePlot. The user can switch between scatter chart:

enter image description here

and bar chart:

enter image description here

As you can see in the bar chart case the graph gets moved on the right till the point the second bar is not visible anymore. This does't happen when more than 5 elements get displayed:

enter image description here enter image description here

it looks like the automatic positioning places wrongly some padding but I'm not sure how to avoid this problem.

Any idea?

Upvotes: 1

Views: 168

Answers (1)

Claus
Claus

Reputation: 5722

I think I've found a possible solution, extending the plot space X-axis range in order to include all the elements and leaving a small margin on the right:

// X-Axis spacing
plotSpace.xRange = [CPTPlotRange
                    plotRangeWithLocation:CPTDecimalFromFloat(0.0)
                    length:CPTDecimalFromFloat([graphData count] - 0.7)];

enter image description here

I will wait to set this as optimal solution, just in case somebody comes with something better.

Upvotes: 1

Related Questions