Calculate plotSpace X and Y

83 weergaven
Naar het eerste ongelezen bericht

Nic Hubbard

ongelezen,
1 dec 2010, 17:02:0401-12-2010
aan coreplot-discuss
Currently my graph is just looking flat, and I am wondering why, and
think it is because of my x and y range are wrong. How do I calculate
these? Here is what I am using:

CGFloat max = 0.0;
CGFloat min = FLT_MAX;

for (NSNumber *dataValue in sortedArray) {
min = MIN([dataValue floatValue], min);
max = MAX([dataValue floatValue], max);
}

plotSpace.xRange = [CPPlotRange
plotRangeWithLocation:CPDecimalFromFloat(0.0)
length:CPDecimalFromFloat(max - min)];
plotSpace.yRange = [CPPlotRange
plotRangeWithLocation:CPDecimalFromFloat(0.0)
length:CPDecimalFromFloat(num_points)];

Eric

ongelezen,
1 dec 2010, 23:16:0801-12-2010
aan coreplot-discuss
As I said in my reply to your question on stackoverflow.com (http://
stackoverflow.com/questions/4327712/), you're returning the same value
for X and Y which is what's causing the straight line.

Assuming you meant to use the data index as your X-value and the value
from your dataValue array as the Y-value, I would calculate the plot
space ranges like this:

plotSpace.xRange = [CPPlotRange
plotRangeWithLocation:CPDecimalFromFloat(0.0)
length:CPDecimalFromUnsignedInteger(dataValue.count)];
plotSpace.yRange = [CPPlotRange
plotRangeWithLocation:CPDecimalFromFloat(min)
length:CPDecimalFromFloat(max - min)];

Eric

Nic Hubbard

ongelezen,
2 dec 2010, 14:19:2302-12-2010
aan coreplot-discuss
Thank you, Thank you!

I am not sure why I was not able to figure this out from the examples,
but I now have it working.
Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten