2013-05-22 3 views
0

Я пытаюсь использовать использование памяти с использованием основного участка в приложении для iPhone. Я хочу, чтобы метки в заговоре с целью показать шесть знаков после запятой, но он показывает только четыре, хотя Т.И. закодированы показать 6, используя фрагмент кода ниже:Core Plot - количество знаков после запятой для метки графика

CPTScatterPlot *plotMem = [[CPTScatterPlot alloc] initWithFrame:self.graph.bounds]; 
    NSNumberFormatter *plotFormatter = [[NSNumberFormatter alloc] init]; 
    [plotFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; 
    [plotFormatter setMaximumFractionDigits:6]; 
    [plotFormatter setPositiveFormat:@"###0.000000"]; 
    plotMem.labelFormatter = plotFormatter; 

Вот скриншот из приложения: enter image description here

Он показывает сюжетные метки как 0.1623, 0.1624 и т.д., хотя метод numberForPlot вернул номер, как 0,161793, 0,161869, 0,162064 и т.д.

-(NSNumber *) numberForPlot:(CPTPlot *)plot 
        field:(NSUInteger)fieldEnum 
      recordIndex:(NSUInteger)index { 
     if (fieldEnum == CPTScatterPlotFieldY) { 
      NSLog(@"Plot memuse %f for index %d", 
      myData.memuse, index); 
      return [NSNumber numberWithFloat:myData.memuse]; 
    } else { 
     return [NSNumber numberWithInt:index]; 
    } 
} 

Как сделать метки для участков показывает 6 знаков после запятой? Я что-то пропустил в коде? Пожалуйста помоги.

ответ

1

попробовать с помощью setFormatWidth

CPTScatterPlot *plotMem = [[CPTScatterPlot alloc] initWithFrame:self.graph.bounds]; 
    NSNumberFormatter *plotFormatter = [[NSNumberFormatter alloc] init]; 
    [plotFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; 
    [plotFormatterr setFormatWidth:8]; 
    [plotFormatter setMaximumFractionDigits:6]; 
    [plotFormatter setPositiveFormat:@"###0.000000"]; 
    plotMem.labelFormatter = plotFormatter; 
+0

Спасибо! Оно работает! – Jean

Смежные вопросы