Вопрос

i was just browsing the classes for an hour and cant find it! i started with searching the example of the AAPLot project.

i changed the graph a bit and was expecting to find all settings in the CPTTradingRangePlot class but it´s not there.

there are a lot of properties which i can change, but i can´t find the background settings in any of the classes.

could anybody give me a hint?

// OHLC plot
CPTMutableLineStyle *whiteLineStyle = [CPTMutableLineStyle lineStyle];
whiteLineStyle.lineColor = [CPTColor whiteColor];
whiteLineStyle.lineWidth = 1.0f;
CPTTradingRangePlot *ohlcPlot = [[[CPTTradingRangePlot alloc] initWithFrame:graph.bounds] autorelease];
ohlcPlot.identifier = @"OHLC";
ohlcPlot.lineStyle = whiteLineStyle;
ohlcPlot.barWidth = 4.0f;
ohlcPlot.increaseFill = [(CPTFill *)[CPTFill alloc] initWithColor:[CPTColor greenColor]];
ohlcPlot.decreaseFill = [(CPTFill *)[CPTFill alloc] initWithColor:[CPTColor redColor]];
    CPTMutableTextStyle *whiteTextStyle = [CPTMutableTextStyle textStyle];
whiteTextStyle.color = [CPTColor whiteColor];
    whiteTextStyle.fontSize = 12.0;
    ohlcPlot.labelTextStyle = whiteTextStyle;
    ohlcPlot.labelOffset = 5.0;
ohlcPlot.stickLength = 2.0f;
ohlcPlot.dataSource = self;
ohlcPlot.plotStyle = CPTTradingRangePlotStyleCandleStick;
[graph addPlot:ohlcPlot];
Это было полезно?

Решение 4

i finally found it by myself. the background of the chart is managed by a theme. there are several theme files in the folder theme of the core-plot library and one of them is CPTStocksTheme. The CPTStocksTheme creates a blue gradient background which can be changed there.

Другие советы

Here's a very simple example. This:

CPTColor *your_color = [CPTColor colorWithComponentRed:1 green:0 blue:0 alpha:1];
your_graph.fill = [CPTFill fillWithColor:your_color];

will turn your graph's background red. But as Eric Skroch said, you may want to do this...

your_graph.plotAreaFrame.fill = [CPTFill fillWithColor:your_color];

and / or this...

your_graph.plotAreaFrame.plotArea.fill = [CPTFill fillWithColor:your_color];

depending on the result you want to achieve.

Backgrounds in Core Plot are set using CPTFill objects similar to the increaseFill and decreaseFill in your code sample. Depending on the look you want to achieve, you need to set the fill on graph, graph.plotAreaFrame, and/or graph.plotAreaFrame.plotArea. The axis demo in the Mac version of CPTTestApp uses fills in all three areas so you can see the different parts.

You may set it in xAxis or yAxis using CPTColor.

axisSet.yAxis.alternatingBandFills = [NSArray arrayWithObjects:[CPTColor redColor], [CPTColor whiteColor], [CPTColor purpleColor], nil];

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top