折线图与核心图的绘图问题
|
我的y轴有总测试数
和x轴表示时间
以下是我用来绘制的代码:
- (NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot {
NSUInteger recordplot;
if (plot.identifier == @\"Plot Error\")
{
recordplot = [HourErroroArray count];
recordplot--;
}
return recordplot;
}
- (NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index {
NSDecimalNumber *num = nil;
int eTemp1;
int eHour1;
int eMin1;
int eSec1;
// Number of the X axis asked
if (fieldEnum == CPScatterPlotFieldX)
{
if (plot.identifier == @\"Plot Error\")
{
eHour1=[[HourErroroArray objectAtIndex:index]intValue ];
eMin1=[[MinErrorArray objectAtIndex:index]intValue ];
eSec1=[[SecErrorArray objectAtIndex:index]intValue ];
eTemp1=eHour1*eMin1*eSec1;
num = (NSDecimalNumber *)[NSDecimalNumber numberWithInt:eTemp1];
}
}
// Number of the Y axis asked
else if (fieldEnum == CPScatterPlotFieldY)
{
if (plot.identifier == @\"Plot Error\")
{
num = (NSDecimalNumber *)[NSNumber numberWithInteger:index];
}
}
return num;
}
我可以看到该图正在绘制,但仅在一条直线上,即与xaxis平行
!-> y轴,_-> x轴和。 ->线正在绘制值
y轴
!
!
! ...........
!
______________ x轴
但我想要以下内容:
http://www.buggyprogrammer.co.uk/2010/10/03/using-core-plot-to-draw-line-graphs/
也许不是上下线,但至少有一定角度。
没有找到相关结果
已邀请:
1 个回复
诧不达
中插入一些NSLog语句,并确保数字(eTemp1,eHour1,eMin1,eSec1)符合您的期望。 [根据评论添加] 在绘图空间上检查您的绘图范围,以确保它们对您的数据合理。如果y范围的长度太大,它将压缩图,使其看起来像一条水平线。绘图范围的一个常见错误是在创建范围时误认为最终值的长度。 CPTPlotRange的工作方式与NSRange相同。作为实验,尝试使用图空间方法
使数据填充图范围。有关示例,请参阅Mac CPTTestApp。