gpt4 book ai didi

objective-c - 如何使用绑定(bind)配置核心图数据标签

转载 作者:行者123 更新时间:2023-12-03 17:40:02 24 4
gpt4 key购买 nike

我正在尝试使用核心图和绑定(bind)来设置饼图。我可以使用 CPTPieChartBindingPieSliceWidthValues 让图表正确显示

[pieChart bind:CPTPieChartBindingPieSliceWidthValues
toObject:[self sectorAllocation]
withKeyPath:@"arrangedObjects.sectorPercentage"
options:nil];

(sectorAllocation 是一个 NSArray Controller )

类似地,我尝试使用 CPTPlotBindingDataLabels 绑定(bind)数据标签

[pieChart bind:CPTPlotBindingDataLabels
toObject:[self sectorAllocation]
withKeyPath:@"arrangedObjects.sectorName"
options:nil];

(sectorName 是一个 NSString 值)

但这似乎不起作用,我在控制台中收到以下错误

[__NSCFString setShadow:]: unrecognized selector sent to instance 0x60800023fb00

它似乎不喜欢字符串对象,那么我该怎么办呢?它正在寻找什么类型的对象?

最佳答案

绑定(bind)需要一个核心图层 (CPTLayer) 的 NSArray,每个数据索引对应一个。 CPTTextLayer 是一种常见的选择,因为它显示文本,但也允许其他图层类型。

关于objective-c - 如何使用绑定(bind)配置核心图数据标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19758495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com