How to add scroll to CPTLegend in CorePlot

I have a lot of entries for legend.can anyone please help scroll CPTLegend?

Here is the code that I use for CPTLegend.

-(void)configureLegend {
    // 1 - Get graph instance
    CPTGraph *graph = self.hostView.hostedGraph;
    // 2 - Create legend
    CPTLegend *theLegend = [CPTLegend legendWithGraph:graph];
    // 3 - Configure legen
    theLegend.numberOfColumns = 1;
    theLegend.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
    theLegend.borderLineStyle = [CPTLineStyle lineStyle];
    theLegend.cornerRadius = 2.0;
    // 4 - Add legend to graph
    graph.legend = theLegend;     
    graph.legendAnchor = CPTRectAnchorBottom;
    CGFloat legendPadding = -(self.view.bounds.size.width / 3);
    graph.legendDisplacement = CGPointMake(-80, 120.0);

}
+4
source share
2 answers

you can create scrollView and add legend. This is a workaround, but work. Code example:

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 1000, 450)];
scrollView.showsVerticalScrollIndicator = YES;
scrollView.clipsToBounds = YES;
scrollView.userInteractionEnabled = YES;
scrollView.contentSize = CGSizeMake(scrollView.contentSize.width, 5000);
[scrollView.layer addSublayer:self.hostView.hostedGraph.legend];
[self.hostView addSubview:scrollView];

PS you have to calculate the coordinates for the legend and scrollview and contentSize for scrollview

+3
source

, . , , . .

+3

All Articles