If you see the picture below, what I want is for the graph to 开发者_JAVA技巧start at 0 on the y axis and 6/28 on the x axis. How can I do this using core data? I can't find a way anywhere.
Both these values are 0 for each axis, so why doesn't the graph start at 0?
Plus I don't want negative values or dates.
I want it to start from a corner, like normal graphs. |_
Thanks for your help.
I am not an expert in CorePlot but try setting the visibleRange and gridLinesRange on the x and y CPXYAxis. Something like this:
CPXYAxisSet *axisSet = (CPXYAxisSet *)self.axisSet; // self is of type CPXYGraph
CPXYAxis *x = axisSet.xAxis;
x.visibleRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0f) length:CPDecimalFromFloat(xMax)];
x.gridLinesRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0f) length:CPDecimalFromFloat(yMax-1)];
CPXYAxis *y = axisSet.yAxis;
y.visibleRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0f) length:CPDecimalFromFloat(yMax - 1.0f)];
y.gridLinesRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0f) length:CPDecimalFromFloat(xMax)];
// Set axes
self.axisSet.axes = [NSArray arrayWithObjects:x, y, nil];
Ah! found it
You have to set:
x.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");
y.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");
:)
While I am searching for the solution of similar problem. I realise "CPDecimalFromFloat" is invalid . Later on Found out that CPDecimalFromFloat no longer there but I can use "CPTDecimalFromFloat".
精彩评论