在哪里设置背景颜色?
我只是浏览了一个小时的课程,但找不到它!我首先搜索 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];
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];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是一个非常简单的例子。这:
会将图表的背景变成红色。但正如 Eric Skroch 所说,你可能想要这样做......
和/或这个......
取决于你想要实现的结果。
Here's a very simple example. This:
will turn your graph's background red. But as Eric Skroch said, you may want to do this...
and / or this...
depending on the result you want to achieve.
Core Plot 中的背景是使用
CPTFill
对象设置的,类似于代码示例中的increaseFill
和decreaseFill
。根据您想要实现的外观,您需要在graph
、graph.plotAreaFrame
和/或graph.plotAreaFrame.plotArea
上设置填充>。 Mac 版本的 CPTTestApp 中的轴演示使用所有三个区域的填充,以便您可以看到不同的部分。Backgrounds in Core Plot are set using
CPTFill
objects similar to theincreaseFill
anddecreaseFill
in your code sample. Depending on the look you want to achieve, you need to set the fill ongraph
,graph.plotAreaFrame
, and/orgraph.plotAreaFrame.plotArea
. The axis demo in the Mac version of CPTTestApp uses fills in all three areas so you can see the different parts.您可以使用 CPTColor 在 xAxis 或 yAxis 中设置它。
axisSet.yAxis.alternatingBandFills = [NSArray arrayWithObjects:[CPTColor redColor],
[CPTColor 白色颜色], [CPTColor 紫色颜色], nil];
You may set it in xAxis or yAxis using CPTColor.
axisSet.yAxis.alternatingBandFills = [NSArray arrayWithObjects:[CPTColor redColor],
[CPTColor whiteColor], [CPTColor purpleColor], nil];
我终于自己找到了。图表的背景由主题管理。 core-plot 库的 theme 文件夹中有几个主题文件,其中之一是 CPTStocksTheme。 CPTStocksTheme 创建一个蓝色渐变背景,可以在那里更改。
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.