1
votes

I have a question that is connected to implementation scroll in Core Plot graph object.

I use CPTGraphHostingView and CPTGraph for display my plots.

I have a problem when I have a lot of plots in my graph view, because they are stretched to the current rect.

I need to have ability make an interval (for example 50 points between each plot) and if total width of plots bigger than rect then make graph view scrollable.

I added this code for create range between to points

plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(xMin) length:CPTDecimalFromFloat(xMax)];

But this is just abstract range that will be recalculated for the current width of graph view. I want range that will be corresponded to the next data:

starts from: 0

end point: xMax * 50 + offset (so for example xMax = 10 * 50 point + 15 point offset per each plot)

1

1 Answers

2
votes

All plots are drawn in the plot area layer. After building the graph and adding it to the hosting view, call -layoutIfNeeded on it to update all of the graph layers. Use the size of the plot area layer to decide how many plot points you want visible. Set the length of the xRange to show that many points. Set allowsUserInteraction to YES on the plot space to enable scrolling if needed.