Trond Kristiansen
Trond Kristiansen

Reputation: 2446

Refresh core plot scatterplot

I have a scatterplot created using Core Plot (v 1.5). The datasource is a dictionary containing (x, y, value). I like to be able to dynamically adjust how many of the (x, y) pairs to plot. However, my graphHostingView does not refresh the scatter-plot after I change the number of (x, y) pairs contained in the datasource until I resize the window. When I resize the window the new values are loaded and plotted. I have tried several solutions including:

Without success. Could anyone suggest a method that would enable my scatterplot to be dynamically updated when values change or send me a link to an example? Thanks in advance. Cheers, Trond

Upvotes: 1

Views: 1235

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

There are several methods available to tell a Core Plot plot that you have new data available:

  • -reloadData: Replace all of the plot data with new data points. Calling this method on the graph causes all plots in the graph to reload their data.

  • -reloadDataInIndexRange:: Replace the plot data in the given index range with new values leaving points outside this range untouched.

  • -insertDataAtIndex:numberOfRecords:: Insert new data points at the given index, moving the existing data points to higher indices as needed.

  • -deleteDataInIndexRange:: Remove existing data in the given range and move existing data points to close the gap.

The "Real Time Plot" demo in the Plot Gallery example app uses these methods to update its data. The demo uses a timer to generate random plot data but your new data can come from anywhere.

Upvotes: 3

Related Questions