x_轴颠倒
正在使用 coreplot 创建条形图。条形图正在显示,但它是颠倒的。X 轴从屏幕顶部开始,而不是在屏幕底部。甚至 X 轴也不是' t 可见..看起来好像图表中的条形悬挂着:(....我如何更改其位置并使其正确,甚至使 x 轴可见???
这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
[self generateDataSamples];
double xAxisStart = 0;
double xAxisLength = 14;
double yAxisStart = 0;
// double yAxisLength = [[samples valueForKeyPath:@"@max.Y_VAL"] doubleValue];
double yAxisLength = 190.0;
CPGraphHostingView *hostingView = [[CPGraphHostingView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:hostingView];
CPXYGraph *graph = [[CPXYGraph alloc] initWithFrame:self.view.bounds];
hostingView.hostedGraph = graph;
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromDouble(xAxisStart)
length:CPDecimalFromDouble(xAxisLength+1)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromDouble(yAxisStart)
length:CPDecimalFromDouble(yAxisLength+3)];
CPBarPlot *plot = [[CPBarPlot alloc] initWithFrame:CGRectZero];
plot.plotRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromDouble(0.0)
length:CPDecimalFromDouble(xAxisLength-5)];
plot.barOffset = CPDecimalFromDouble(1.5);
plot.dataSource = self;
[graph addPlot:plot];
[plot release];
[graph release];
[hostingView release];
}
谢谢
Am working with coreplot for creating bar-chart .Bar-chart is getting displayed but its upside down..X-axis starts at the top of the screen instead of being at the bottom of the screen..and even X-Axis isn't visible..It looks as if bars in the chart are hanging :(....How do I change its position and make it proper and even make x-Axis visible???
Here is my code:
- (void)viewDidLoad {
[super viewDidLoad];
[self generateDataSamples];
double xAxisStart = 0;
double xAxisLength = 14;
double yAxisStart = 0;
// double yAxisLength = [[samples valueForKeyPath:@"@max.Y_VAL"] doubleValue];
double yAxisLength = 190.0;
CPGraphHostingView *hostingView = [[CPGraphHostingView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:hostingView];
CPXYGraph *graph = [[CPXYGraph alloc] initWithFrame:self.view.bounds];
hostingView.hostedGraph = graph;
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromDouble(xAxisStart)
length:CPDecimalFromDouble(xAxisLength+1)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromDouble(yAxisStart)
length:CPDecimalFromDouble(yAxisLength+3)];
CPBarPlot *plot = [[CPBarPlot alloc] initWithFrame:CGRectZero];
plot.plotRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromDouble(0.0)
length:CPDecimalFromDouble(xAxisLength-5)];
plot.barOffset = CPDecimalFromDouble(1.5);
plot.dataSource = self;
[graph addPlot:plot];
[plot release];
[graph release];
[hostingView release];
}
Thank U
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在绘图区域框架中添加一些填充以使轴可见:
我不确定为什么图形会上下颠倒。托管视图的超级视图是否应用了任何转换?
Add some padding to the plot area frame to make the axes visible:
I'm not sure why the graph would appear upside down. Does the hosting view's superview have any transforms applied to it?