piaoyongren / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

Returning nil as data value hides plot #244

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Return nil in numberForPlot:field:recordIndex: when fieldEnum == 
CPScatterPlotFieldY
--> A previously correctly displayed plot will disappear

What is the expected output? What do you see instead?
I expect to see a plot where the data point where I returned nil is omitted 
when drawn.

What version of the product are you using? On what operating system?
Latest, iOS Sim and iPhone

I saw in CPPlot.m:368 a nil value is handled by adding an [NSNull null] value 
to the fieldValues array. So I thought CorePlot should know what to do when I 
return nil. Does it? Or is this just a fail safe code so that CorePlot does not 
crash?

Original issue reported on code.google.com by stefan.d...@gmail.com on 13 Jan 2011 at 5:27

GoogleCodeExporter commented 8 years ago
Returning nil or [NSNull null] from your datasource tells Core Plot that there 
is missing data at that index. This is useful for showing a break in a line 
plot, for example. If you return nil for all points, there is no valid data at 
any point and the plot will not have anything to draw.

Original comment by eskr...@mac.com on 13 Jan 2011 at 11:54

GoogleCodeExporter commented 8 years ago
I am not returning nil for every data point just for one or two. And I expected 
that Core Plot will behave as you wrote. But instead the Plot disappears.

Original comment by stefan.d...@gmail.com on 14 Jan 2011 at 10:32

GoogleCodeExporter commented 8 years ago
I found the problem [CPXYPlotspace scaleToFitPlots] does not work correctly 
with [NSNull null] values. This caused by axis range to show a range where the 
plot had no values. 

Original comment by stefan.d...@runtastic.com on 27 Jan 2011 at 7:56

GoogleCodeExporter commented 8 years ago

Original comment by drewmcco...@mac.com on 27 Jan 2011 at 8:28

GoogleCodeExporter commented 8 years ago
I added some code to remove the nulls during the plot range calculation. Can 
you see if that helps by pulling the changes?

Original comment by drewmcco...@mac.com on 27 Jan 2011 at 8:44

GoogleCodeExporter commented 8 years ago
I'm also facing the issue that a plot hides if you return gaps respectively nil 
values. My experiences:

I have 3 line plots (1 having no nil values, 1 having the first half nil 
values, 1 having at the beginning and at the end nil values) - Core Plot does 
only display the plot with no nil values.

As I'm using the latest revision of core plot it seems for me that Drew's 
modifications did not solve the problem.

Bernhard

Original comment by bernhard...@gmail.com on 24 Mar 2011 at 10:40

GoogleCodeExporter commented 8 years ago
I just tested this in CPTestApp, and it worked as expected. Returning nil 
caused a gap. Returning nil for the first half of the data caused that half to 
disappear, but the rest to remain.

When you say you have the latest version, do you have the version from the 
mercurial repository? The downloadable release is out of date.

If you do have the very latest version from mercurial (use "hg pull -u" to 
update), then you need to examine your data very carefully. For example, are 
you accidentally returning nil on every single point?

Original comment by drewmcco...@mac.com on 25 Mar 2011 at 11:42

GoogleCodeExporter commented 8 years ago
I just figured out my problem - I was returning the wrong number of records 
(numberOfRecordsForPlot). So I just returned the number of "valid" records - 
but I overlooked the nil values. That's why the plot seemed to disappear!

Works all fine now!

Original comment by bernhard...@gmail.com on 29 Mar 2011 at 6:34

GoogleCodeExporter commented 8 years ago

Original comment by eskr...@mac.com on 30 Jun 2011 at 12:31