首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不显示核心地块x轴标签

不显示核心地块x轴标签
EN

Stack Overflow用户
提问于 2011-06-01 12:57:45
回答 1查看 4K关注 0票数 1

这是我的代码。不显示X轴标签。我使用的是核心图。

代码语言:javascript
复制
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轴标签?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-02 13:14:07

我解决了这个问题。正交坐标有一个问题。

我是这样解决的:

scatterPlot.yRange = [CPPlotRange plotRangeWithLocation: CPDecimalFromFloat (min) length:CPDecimalFromFloat(xx)]; xAxis.orthogonalCoordinateDecimal = CPDecimalFromFloat(min);

这里y轴的plotRangeWithLocation和x轴的orthogonalCoordinateDecimal应该是相同的。

感谢你的帮助,奎师那巴陀罗:)

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6196469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档