cocoa - Coreplot Legend drawing outside of plot frame -
i have chart os x app can resized window. expected when width reduced enough legend truncated or clipped. however, spilling outside of plot area shown below. ideally, legend truncate or @ least clip contents. how can done?
my legend setup follows
- (void)configurelegend { // 1 - 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 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); }
make sure graph masking sublayers. use maskstobounds
clip outside of border line or maskstoborder
clip inside edge of border.
Comments
Post a Comment