2014-12-05 119 views
1

我有OS X應用程序的圖表,可以調整窗口的大小。我期望寬度足夠小時,圖例會被截斷或剪切。但是,如下所示,它溢出到繪圖區域之外。理想情況下,我希望圖例截斷或至少剪輯內容。如何才能做到這一點?Coreplot Legend圖外繪圖

我的傳說設置如下

- (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); 
} 

Legend Not Clipping

回答

1

確保圖表掩蓋其子層。使用masksToBounds剪輯到邊界線的外側或masksToBorder以剪輯到邊框的內側邊緣。