Core-Plot 饼图切片颜色
我正在我的 iPhone 项目之一中使用核心图。是否可以更改饼图中选定切片的颜色(使用 CPPieChartDataSource、CPPieChartDelegate)?
I am using core plot in one of my iPhone projects. Is it possible to change the color for a selected slice in a pie chart (using CPPieChartDataSource, CPPieChartDelegate)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在饼图数据源中实现以下方法:
CPFill 可以是颜色、图像或渐变。
Implement the following method in your pie chart datasource:
CPFill can be a color, image, or gradient.
在 .h 文件中的
.m 文件
中它将更改 PieChart Slice 颜色。谢谢
In your .h file
in your .m file
It will change PieChart Slice color. Thanks
我将其添加到我的 .m 文件(这是饼图的数据源文件)。颜色很丑——只是用它们来测试,因为它们与默认值确实不同。我的图表中只有三个切片,因此硬编码了 3 种颜色。我发现 Core Plot 文档对这一切很有帮助。 这是 fillWithColor 方法文档的链接。注意:您现在需要使用 CPT 作为前缀,而不是旧的 CP。
抱歉,如果我弄乱了答案条目——这是我在 StackOverflow 上的第一篇文章
I added this to my .m file (which is the data source file for the pie chart). The colors are ugly -- just used them to test as they are really different than the defaults. And there are only three slices in my chart, hence the hard-coded 3 colors. I found the Core Plot documentation helpful for all this. Here's the link to the fillWithColor method documentation. NOTE: You need to use CPT as a prefix now, not the old CP.
Sorry if I messed up the answer entry -- this is my first ever post on StackOverflow
斯威夫特版本:
Swift version: