У меня есть диаграмма для OS X-приложения, которое можно изменить с помощью окна. Я ожидал, когда ширина будет уменьшена, легенда будет усечена или обрезана. Однако он разливается вне области графика, как показано ниже. В идеале я хотел бы, чтобы легенда обрезала или, по крайней мере, закрепила содержимое. Как это может быть сделано?Coreplot Легенда чертежа за пределами рамки кадра
Моя установка легенда выглядит следующим образом
- (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);
}