0
x 축과 y 축에 레이블이 표시되지 않는다는 점을 제외하면 코어 플롯을 사용하여 그래프를 작성하고 있습니다. 나는 메이저 틱과 마이너 틱을 볼 수 있지만 그 옆에 가치는 없다. 내가 누락 된 것이 있어야하지만 나는 무엇을 모르는가. 또한 각 축에 레이블을 추가 할 수 있습니다 (예 : x (시간), y (값)).iPhone : 코어 플롯 그래프에 아무 레이블도 표시되지 않습니다.
제가 작업중인 그래프는 listview의 첫 번째 행의 일부입니다.
코드는 다음과 같습니다
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"GraphCustomViewCell" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[GraphCustomViewCell class]])
{
cell = (GraphCustomViewCell *)currentObject;
break;
}
}
CGRect frame = cell.contentView.bounds;
CPLayerHostingView *hostingView = [[CPLayerHostingView alloc] initWithFrame: frame];
[cell addSubview:hostingView];
// Create graph
CPTheme *theme = [CPTheme themeNamed:kCPPlainWhiteTheme];
graph = (CPXYGraph *)[theme newGraph];
// Add graph to view
hostingView.hostedLayer = graph;
graph.paddingLeft = 50.0;
graph.paddingTop = 5.0;
graph.paddingRight = 5.0;
graph.paddingBottom = 25.0;
// Adjust graph
float xmax = [[[self arrayFromData] objectForKey:@"data"] count];
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
length:CPDecimalFromFloat(xmax)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
length:CPDecimalFromFloat(3000)];
CPTextStyle *blackText = [[CPTextStyle textStyle] color:[CPColor blackColor]];
CPLineStyle *lineStyle = [CPLineStyle lineStyle];
lineStyle.lineColor = [CPColor blackColor];
lineStyle.lineWidth = 1.0f;
axisSet.xAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue];
axisSet.xAxis.minorTicksPerInterval = 4;
axisSet.xAxis.majorTickLineStyle = lineStyle;
axisSet.xAxis.minorTickLineStyle = lineStyle;
axisSet.xAxis.axisLineStyle = lineStyle;
axisSet.xAxis.minorTickLength = 4.0f;
axisSet.xAxis.majorTickLength = 8.0f;
axisSet.xAxis.labelOffset = 3.0f;
axisSet.xAxis.labelTextStyle = blackText;
axisSet.yAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"500"] decimalValue];
axisSet.yAxis.minorTicksPerInterval = 4;
axisSet.yAxis.majorTickLineStyle = lineStyle;
axisSet.yAxis.minorTickLineStyle = lineStyle;
axisSet.yAxis.axisLineStyle = lineStyle;
axisSet.yAxis.minorTickLength = 4.0f;
axisSet.yAxis.majorTickLength = 8.0f;
axisSet.yAxis.labelOffset = 1.0f;
CPScatterPlot *dataSourceLinePlot = [[[CPScatterPlot alloc] init] autorelease];
dataSourceLinePlot.identifier = @"MyGraph";
dataSourceLinePlot.dataLineStyle.lineWidth = 1.f;
dataSourceLinePlot.dataLineStyle.lineColor = [CPColor greenColor];
dataSourceLinePlot.dataSource = self;
[graph addPlot:dataSourceLinePlot];
// Put an area gradient under the plot above
CPColor *areaColor = [CPColor colorWithComponentRed:0.3
green:1.0
blue:0.3
alpha:0.3];
CPGradient *areaGradient = [CPGradient gradientWithBeginningColor:areaColor
endingColor:[CPColor clearColor]];
areaGradient.angle = -90.0f;
CPFill *areaGradientFill = [CPFill fillWithGradient:areaGradient];
dataSourceLinePlot.areaFill = areaGradientFill;
dataSourceLinePlot.areaBaseValue = CPDecimalFromString(@"1.75");
고마워, 감사 뤽
PS : 빠른 편집, 내가 graph.name = "내 그래프"로 확인했지만 아무 것도 표시되지 않습니다 그래프에서