【问题标题】:Coreplot Legend drawing outside of plot frame绘图框外的 Coreplot 图例绘图
【发布时间】:2014-12-05 18:25:10
【问题描述】:

我有可以随窗口调整大小的 OS X 应用程序图表。我预计当宽度足够减小时,图例会被截断或剪裁。但是,它正在溢出到绘图区域之外,如下所示。理想情况下,我希望图例截断或至少剪辑内容。这是怎么做到的?

我的图例设置如下

- (void)configureLegend
{
    // 1 - Get graph instance
    CPTGraph *graph = self.graphHostingView.hostedGraph;
    // 2 - Create legend
    CPTLegend *theLegend;
    if (!theLegend) {
        theLegend = [CPTLegend legendWithGraph:graph];
    }

    //Configure Text
    CPTMutableTextStyle *textStyle = [CPTMutableTextStyle textStyle];
    textStyle.color = [CPTColor colorWithComponentRed:0.612f green:0.612f blue:0.612f alpha:1.00f];
    textStyle.fontName = @"HelveticaNeue";
    textStyle.fontSize = 12.0f;
    theLegend.textStyle = textStyle;

    // 3 - Configure legend
    theLegend.numberOfColumns = 1;
    theLegend.fill = nil;
    theLegend.borderLineStyle = nil;
    theLegend.swatchSize = CGSizeMake(10.0, 10.0);
    theLegend.swatchCornerRadius = 5.0f;
    // 4 - Add legend to graph
    graph.legend = theLegend;
    graph.legendAnchor = CPTRectAnchorLeft;
    CGFloat viewWidth = self.graphHostingView.bounds.size.width;
    CGFloat legendPadding = (viewWidth * 0.3) + self.pieChart.pieRadius + (viewWidth * 0.05);
    graph.legendDisplacement = CGPointMake(legendPadding, 0.0);
}

【问题讨论】:

    标签: cocoa core-plot


    【解决方案1】:

    确保图表掩盖了它的子层。使用masksToBounds 剪切到边框线的外侧或使用masksToBorder 剪切到边框的内侧边缘。

    【讨论】:

      猜你喜欢
      • 2016-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-10
      相关资源
      最近更新 更多