我正在使用Core Plot中的CPTXYGraph绘制饼图。我已经使用委托方法在CPTXYGraph上获取触摸反馈饼图
-(void)pieChart:(CPTPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)index
在单击某个饼图的特定切片时执行某些操作。但是当我触摸这个饼图时,我需要得到一个反馈或某种类型的图像变化来表示特定的切片就像按钮事件一样被触摸。
是否有任何委托方法实现相同。
我正在使用Core Plot中的CPTXYGraph绘制饼图。我已经使用委托方法在CPTXYGraph上获取触摸反馈饼图
-(void)pieChart:(CPTPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)index
在单击某个饼图的特定切片时执行某些操作。但是当我触摸这个饼图时,我需要得到一个反馈或某种类型的图像变化来表示特定的切片就像按钮事件一样被触摸。
是否有任何委托方法实现相同。
实现您的数据源的-sliceFillForPieChart:recordIndex:
方法。跟踪选定的切片(如果有的话)并使用它来决定应用到每个切片的填充。每次选择更改时强制在图上调用-reloadData
以强制它加载新的切片填充。
您可以让我知道如何为特定选定切片添加渐变色... – 2012-07-10 17:21:06
使用'[CPTFill fillWithGradient:myGradient]'创建填充。请参阅[CPTGradient文档](http://core-plot.googlecode.com/hg/documentation/html/iOS/interface_c_p_t_gradient.html)和Core Plot示例应用程序,以获取有关使用渐变可以执行的操作的详细信息。 – 2012-07-11 00:23:29
会有一些工作要做。
首先,将其实现为饼图委托功能。
-(void)pieChart:(CPTPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)index
{
indexOfPieGraphPlot = index; //gives index of pie which is selected.
isPieGraphPlot = YES; //boolean. if set to yes, will call rootcontroller function which will add pop up.
}
然后添加CPTPlotSpaceDelegate在.h文件中
然后使用此功能
- (BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceUpEvent:(id)event atPoint:(CGPoint)point
{
if(isPieGraphPlot) //if yes call showpopup of rootcontroller
{
isPieGraphPlot = NO;
[rootController showPopUpView:point indexForPlot:indexOfPieGraphPlot];
// point gives the x,y of the pie over which you want a pop up.
}
else // if no then call remove popup from rootcontroller. this, incase user clicks anywhere else in graph.
{
[rootController removePopUp];
}
return YES;
}
我已经在使用 - (void)pieChart:(CPTPieChart *)plot sliceWasSelectedAtRecordIndex:(NSUInteger)索引方法根据单击的片段填充表视图。我想指定给用户他已经点击了特定的片段。例如,当你点击一个按钮时,会有一个ON状态和一个OFF状态来指定他点击它的用户。有没有实现饼图? – 2012-07-06 09:57:58
你想提供什么样的反馈?更改所选切片的填充?爆炸选定的切片?添加标签或注释?核心剧情可以做所有这些事情,但没有单一的“选择”指示。 – 2012-07-06 11:31:01
我想给每个切片提供一个按钮类型的反馈。告诉用户他选择了哪个片段。 – 2012-07-06 11:36:07
“按钮式反馈”是什么意思? – 2012-07-06 23:24:28