1
votes

I had added labels to the pie chart like this -(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index {

CPTTextLayer *newLayer = nil;
UIFont *theFont;

static CPTMutableTextStyle *whiteText = nil;

if ( !whiteText )
{
    whiteText = [[CPTMutableTextStyle alloc] init];
    whiteText.color = [CPTColor blackColor];
    whiteText.textAlignment = CPTTextAlignmentCenter;
    whiteText.fontName = @"Helvetica-Bold";
    whiteText.fontSize =  10.0f;
   theFont = [UIFont fontWithName:whiteText.fontName size:whiteText.fontSize];


}
if ( [plot isKindOfClass:[CPTPieChart class]] ) 
{
    newLayer.delegate = self;
    newLayer = [[[CPTTextLayer alloc] initWithText:[NSString stringWithFormat:@"%@", [pieChartData2 objectAtIndex:index]] style:whiteText] autorelease];
      }

return newLayer;
    }

What I want here is (1)I want to wrap the text which is too long. (2) I want to display the the Slice title and and its value . (3) I need to draw a line to title and Slice . Please any one help me.

thanks in advance

1

1 Answers

1
votes
  1. You can insert newline characters ('\n') in the text to wrap to the next line. Core Plot does not auto-wrap any text.

  2. This is a datasource method—it should have access to the data values and the title. Use both to build the label string.

  3. Drawing lines to a label is not supported yet. You could make a custom subclass of CPTTextLayer that draws the line in addition to the text and use that instead of the stock CPTTextLayer to make the labels.