Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I implemented corePlot into my xcode project. I'm trying to add the legend enter image description here to another cell.

I'm able to add the legend to another cell, but when I do that, the text is upside down.

Here is my code:

Objective-C
- (void)configureLegend
{
    CPTGraph *graph = self.hostView.hostedGraph;
    CPTLegend *theLegend = [CPTLegend legendWithGraph:graph];

    // Add legend to graph
    graph.legend = theLegend;
    graph.legendAnchor = CPTRectAnchorRight;
    CGFloat legendPadding = - (self.chartView.bounds.size.width / 8);
    graph.legendDisplacement = CGPointMake(legendPadding, 0.0);

    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
    [cell.layer addSublayer:graph.legend];
This is what I tried:

    theLegend.transform = CATransform3DMakeRotation(M_PI / 180.0f, 0, 1, 0);
}

That didn't do anything. The results where the same. How can I get the text to show normally, not upside down?
Posted
Comments
PIEBALDconsult 28-Apr-15 0:24am    
Because computer coordinates are upside down?
Member 11360293 28-Apr-15 0:40am    
How do I fix that?
PIEBALDconsult 28-Apr-15 0:41am    
Math.
Member 11360293 28-Apr-15 0:43am    
Do u understand my question???
Sergey Alexandrovich Kryukov 28-Apr-15 0:43am    
5.—SA

1 solution

because this code is a rotation.
C++
CATransform3DMakeRotation(M_PI / 180.0f, 0, 1, 0);


You should rotate for 360 degrees to get a better result ;-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900