0
votes

I try to add two graphs in a window in an OSX application. I have two custom views each hosting one graph. Additionally I have a viewController that refers to both views as outlets and implements the protocol CPTPlotDataSource.

Each of the two graphs has 3 plots which all refer to the viewController as dataSource.

Everything works fine (both graphs are shown at startup) until I try to actually plot data into both graphs. Just the first one plots its data and just the identifiers of the plots of the first graph show up in the numberForPlot-method of the viewController.

Now my question: Is it a problem for a CPTPlotDataSource to provide data to plots belonging to different graph objects?

Thanks a lot for your help!!

1

1 Answers

0
votes

That should work fine. For example, the Composite Plot demo in the Plot Gallery example app shows three graph hosting views, each with a separate graph in one master view. All three graphs use the same controller as the datasource.

Make sure you have a unique way to identify each plot that the datasource will service. If the plots are different types, you can check the class of the plot object. If some of them are the same type, give each one a unique identifier and check that in the datasource.