在哪里设置背景颜色?

发布于 2024-12-01 03:19:09 字数 1107 浏览 1 评论 0原文

我只是浏览了一个小时的课程,但找不到它!我首先搜索 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一萌ing 2024-12-08 03:19:09

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

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];

取决于你想要实现的结果。

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.

饮惑 2024-12-08 03:19:09

Core Plot 中的背景是使用 CPTFill 对象设置的,类似于代码示例中的 increaseFilldecreaseFill。根据您想要实现的外观,您需要在 graphgraph.plotAreaFrame 和/或 graph.plotAreaFrame.plotArea 上设置填充>。 Mac 版本的 CPTTestApp 中的轴演示使用所有三个区域的填充,以便您可以看到不同的部分。

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.

北城孤痞 2024-12-08 03:19:09

您可以使用 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];

纸伞微斜 2024-12-08 03:19:09

我终于自己找到了。图表的背景由主题管理。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文