x_轴颠倒

发布于 2024-11-28 17:42:21 字数 1569 浏览 0 评论 0原文

正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海风掠过北极光 2024-12-05 17:42:21

在绘图区域框架中添加一些填充以使轴可见:

graph.plotAreaFrame.paddingTop = 20.0;
graph.plotAreaFrame.paddingBottom = 50.0;
graph.plotAreaFrame.paddingLeft = 50.0;
graph.plotAreaFrame.paddingRight = 20.0;

我不确定为什么图形会上下颠倒。托管视图的超级视图是否应用了任何转换?

Add some padding to the plot area frame to make the axes visible:

graph.plotAreaFrame.paddingTop = 20.0;
graph.plotAreaFrame.paddingBottom = 50.0;
graph.plotAreaFrame.paddingLeft = 50.0;
graph.plotAreaFrame.paddingRight = 20.0;

I'm not sure why the graph would appear upside down. Does the hosting view's superview have any transforms applied to it?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文