核心绘图轴标签在绘图区域外不可见

Per*_*ave 8 core-plot ios

我对轴标签有些麻烦.看来我的自定义标签在绘图区域外是不可见的.查看核心图的设计概述,轴标签应位于绘图区域之外.关于如何在情节区域外看到它们的任何想法?

下面的代码/图像显示了标签仅在绘图区域内显示的方式.如果我将标签偏移更改为正数,则标签根本不显示.我在iOS 5中使用Core Plot 0.9.

提前致谢!

CPTTheme *theme = [CPTTheme themeNamed:kCPTPlainWhiteTheme];
graph = [[theme newGraph] retain];;

CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;
hostingView.hostedGraph = graph;

graph.paddingLeft = 40.0;
graph.paddingTop = 40.0;
graph.paddingRight = 40.0;
graph.paddingBottom = 40.0;
graph.masksToBorder = NO;

// ... setup axis
axisSet.yAxis.majorIntervalLength = CPTDecimalFromInt(0);
axisSet.yAxis.minorTicksPerInterval = 0;
axisSet.yAxis.labelingPolicy = CPTAxisLabelingPolicyNone;

// if this number is negative, the labels show, 
// if it is positive, that is outside the plot area, the labels are hidden.
axisSet.yAxis.labelOffset = -20; 

// ... setup labels
NSMutableArray *labels = [NSMutableArray array];
for (int i = 0; i < reportData.rowCount; ++i) {

    CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[NSString stringWithFormat:@"Test Row %i", i] textStyle:labelStyle];

    label.tickLocation = CPTDecimalFromInt(i);
    label.offset = axisSet.yAxis.labelOffset;
    label.alignment = CPTAlignmentLeft;
    [labels addObject:label];
    [label release];
}
axisSet.yAxis.axisLabels = [NSSet setWithArray:labels];
Run Code Online (Sandbox Code Playgroud)

图形

Eri*_*och 21

除了图形本身之外或代替图形本身,在绘图区域框架上设置一些填充.

graph.plotAreaFrame.paddingTop    = 20.0;
graph.plotAreaFrame.paddingBottom = 50.0;
graph.plotAreaFrame.paddingLeft   = 50.0;
graph.plotAreaFrame.paddingRight  = 50.0;
Run Code Online (Sandbox Code Playgroud)

此代码来自Plot Gallery示例应用程序中的轴演示.

  • coreplot是使用/ sarc这样一个直接的事情 (5认同)

Mil*_*gan 7

我遇到了完全相同的问题并尝试了我可以在网上找到的每一个解决方案都没有成功.

最后我通过关闭边框遮罩来实现它,如下所示:

graph.plotAreaFrame.masksToBorder = NO;
Run Code Online (Sandbox Code Playgroud)