繁体   English   中英

iPhone SDK:核心图如何在右侧显示y轴

[英]iPhone sdk: Core-plot How to display y Axis on the right side on

iPhone SDK:核心图如何在右侧显示y轴?

我现在在iphone sdk中使用Core-plot,

这是我到目前为止所做的

在此处输入图片说明

但我想将Yaxis放在右侧。

我启用了allowsuserInteractive

**plotSpace.allowsUserInteraction=NO;
volumePlotSpace.allowsUserInteraction=YES;**

但是我希望X轴和Y轴始终保持在右侧和底部,

无论用户规模大小,...

像这样: 在此处输入图片说明

您正在使用哪个版本的Core-Plot?

Core-Plot 0.9允许您设置轴位置的约束。 这样的代码行就可以完成这项工作:

// 'graph' is your CPTXYGraph object
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
// move axis to the rightmost position
axisSet.yAxis.axisConstraints = [CPTConstraints constraintWithUpperOffset:0];
// put ticks on the right hand side of the axis
axisSet.yAxis.tickDirection = CPTSignPositive;
// add some padding to the right so that labels are actually visible
graph.plotAreaFrame.paddingRight = 20.0f;

我不知道引入哪个版本,但是至少对于Core-Plot 0.2.2,该过程有些不同。 我的盒子上现在没有它,所以无法检查,但这是如何在左侧固定Y轴的方法:

CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
axisSet.yAxis.isFloatingAxis = YES;
// fixed lower constraint, no upper constraint
CPConstraints yConstraints = {CPConstraintFixed, CPConstraintNone};
axisSet.yAxis.constraints = yConstraints;

我猜想对于右侧yConstraints应该是{CPConstraintNone, CPConstraintFixed}

在coreplot 1.5.1中,您可以使用CPTConstraints在左侧或右侧设置Y轴,或者在底部或顶部设置X轴

 yAxis.axisConstraints = CPTConstraints(lowerOffset: CGFloat(0.0))

lowerOffset表示左侧(Y轴)或底部(X轴); upperOffset表示右(Y轴)或上(X轴)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM