未显示核心图x轴标签

问题描述

| 这是我的代码。 X轴标签显示。我正在使用核心情节。
scattergraph = [[CPXYGraph alloc] initWithFrame:CGRectZero];
CPTheme *theme = nil;
[scattergraph applyTheme:theme];
hostView.hostedGraph = scattergraph;
hostView.backgroundColor = [UIColor clearColor];
hostView.collapsesLayers = NO;

scattergraph.paddingTop = 25.0;
scattergraph.paddingRight = 25.0;
scattergraph.paddingLeft = 25.0;
scattergraph.paddingBottom = 25;
scattergraph.plotAreaFrame.masksToBorder = NO;
CPXYPlotSpace *scatterPlot = (CPXYPlotSpace *) scattergraph.defaultPlotSpace;
scatterPlot.xrange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0) length:CPDecimalFromInt(yCount)];
float xx = [self findMax:LivePriceFeedArray] - [self findMin:LivePriceFeedArray]+1.0;
scatterPlot.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat([self findMin:LivePriceFeedArray]-0.5) length:CPDecimalFromFloat(xx)];

CPXYAxisSet *axisSet =(CPXYAxisSet *) scattergraph.axisSet;
CPXYAxis *xAxis = axisSet.xAxis;
axisSet.delegate = self;
xAxis.title = @\"Days\";
xAxis.titleLocation = CPDecimalFromFloat(4.0f);
xAxis.orthogonalCoordinateDecimal = CPDecimalFromFloat(0.0f);
xAxis.majorIntervalLength = CPDecimalFromFloat(5.0f);
xAxis.labelingPolicy = CpaxisLabelingPolicyNone;

NSUInteger labelLocation = 0;
NSMutableArray *customArray = [[NSMutableArray alloc] initWithCapacity:[xAxisLabels count]];
for (NSNumber *i in customLocations) {
    CpaxisLabel *iLabel = [[CpaxisLabel alloc] initWithText:[xAxisLabels objectAtIndex:labelLocation++] textStyle:xAxis.labelTextStyle];
    iLabel.tickLocation = [i decimalValue];
    [customArray addobject:iLabel];
    [iLabel release];
}

xAxis.axisLabels = [NSSet setWithArray:customArray];
xAxis.majorTickLocations = [NSSet setWithArray:customLocations ];
CPLinestyle *majorGridLinestyle = [CPLinestyle linestyle];
xAxis.majorGridLinestyle = [CPLinestyle linestyle];

CPXYAxis *yAxis = axisSet.yAxis;
yAxis.title = @\"Sales Target\";
yAxis.majorIntervalLength = CPDecimalFromFloat(1.0f);
yAxis.labelOffset = -5.0f;
yAxis.orthogonalCoordinateDecimal = CPDecimalFromFloat(0.0f);
cpscatterPlot *graphplot = [[[cpscatterPlot alloc]init] autorelease];
CPMutableLinestyle *linestyle = [[graphplot.dataLinestyle mutablecopy] autorelease];
linestyle.linewidth = 3.0f;
linestyle.lineColor =  [CPColor whiteColor];
graphplot.dataLinestyle = linestyle;
graphplot.dataSource = self;
[scattergraph addplot:graphplot];
graphplot.backgroundColor = [UIColor clearColor];
CPLinestyle *minorGridLinestyle = majorGridLinestyle;
xAxis.minorGridLinestyle = minorGridLinestyle;
yAxis.majorGridLinestyle = majorGridLinestyle;
yAxis.minorGridLinestyle = minorGridLinestyle;
为什么未显示x轴标签?     

解决方法

        我解决了这个问题。正交坐标存在问题。 我这样解决了:   
scatterPlot.yRange = [CPPlotRange
  plotRangeWithLocation:
  CPDecimalFromFloat (min)
  length:CPDecimalFromFloat(xx)];
  
xAxis.orthogonalCoordinateDecimal =
  CPDecimalFromFloat(min);
此处,y轴的plotRangeWithLocation和x轴的正交CoordinateDecimal应该相同。 感谢您的帮助,Krishnabhadra :)