1

我只是浏览了一个小时的课程,找不到它!我从搜索 AAPLot 项目的示例开始。

我稍微更改了图表,并希望在 CPTTradingRangePlot 类中找到所有设置,但它不存在。

我可以更改很多属性,但我无法在任何类中找到背景设置。

有人可以给我一个提示吗?

// 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

4 回答 4

14

这是一个非常简单的例子。这个:

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

会将图表的背景变为红色。但正如 Eric Skroch 所说,你可能想要这样做......

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

和/或这个...

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

取决于你想要达到的结果。

于 2012-12-19T19:53:52.670 回答
2

Core Plot 中的背景是使用与代码示例中的和CPTFill类似的对象设置的。根据您想要实现的外观,您需要将填充设置为、和/或。Mac 版 CPTTestApp 中的轴演示使用填充所有三个区域,因此您可以看到不同的部分。increaseFilldecreaseFillgraphgraph.plotAreaFramegraph.plotAreaFrame.plotArea

于 2011-08-25T01:14:20.647 回答
1

您可以使用 CPTColor 在 xAxis 或 yAxis 中设置它。

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

于 2012-09-20T11:55:16.493 回答
0

我终于自己找到了。图表的背景由主题管理。core-plot 库的文件夹主题中有几个主题文件,其中之一是 CPTStocksTheme。CPTStocksTheme 创建一个可以在此处更改的蓝色渐变背景。

于 2011-08-25T08:59:30.270 回答