Как установить Plotarea Core Plot Graph с пользовательским представлением - PullRequest
2 голосов
/ 06 января 2012

Я строю график с использованием основного графика.Я пытаюсь построить график на участке, но он содержит белый фон.Но я хочу построить график с моим собственным фоном.Это мой код.

CGRect frame = [self.hostingView bounds];
self.graph = [[[CPTXYGraph alloc] initWithFrame:frame] autorelease];

// Add some padding to the graph, with more at the bottom for axis labels.
self.graph.plotAreaFrame.paddingTop = 10.0f;
self.graph.plotAreaFrame.paddingRight = 10.0f;
self.graph.plotAreaFrame.paddingBottom = 25.0f;
self.graph.plotAreaFrame.paddingLeft = 30.0f;
self.graph.plotAreaFrame.plotArea.fill=[(CPTFill *)[CPTFill alloc] initWithColor:    [CPTColor colorWithComponentRed:0.8 green:0.8 blue:0.8 alpha:1.0]];

// Tie the graph we've created with the hosting view.
self.hostingView.hostedGraph = self.graph;
}

В приведенном выше коде я пытался изменить цвет, но я хочу нарисовать горизонтальные пунктирные линии для каждого тика по оси y.

Ответы [ 2 ]

0 голосов
/ 24 июля 2013

попробуйте это: -

 //configure plot method 
    //0 - Create Theme
    CPTTheme *theme = [CPTTheme themeNamed:kCPTPlainWhiteTheme];

    // 1 - Create the graph
    CPTGraph *graph = [[CPTXYGraph alloc] initWithFrame:self.GraphView.frame];
    graph = (CPTXYGraph *)[theme newGraph];
    graph.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
    graph.plotAreaFrame.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
0 голосов
/ 07 января 2012

Чтобы нарисовать горизонтальные линии, установите majorGridLineStyle и / или minorGridLineStyle для оси Y, чтобы рисовать линии от основных и второстепенных тиков соответственно. Используйте свойства dashPattern и patternPhase стиля линии для управления точечным рисунком. См. Документацию Apple Quartz 2D для получения подробной информации об использовании этих свойств стиля линии.

...