在Coreplot iOS中的LEGENDS上触摸事件 [英] Touch Event on LEGENDS in Coreplot iOS

查看:85
本文介绍了在Coreplot iOS中的LEGENDS上触摸事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望如果 用户触摸特定的图例,那么我可以触发一些动作 ,例如,显示该切片/条形图的详细信息。
除此之外,是否还有其他委托方法:

I want that if the user touches a particular legend then i can trigger some action,say show details for that slice/bar/plot. Is there any delegate method for this besides :

-(NSString *)legendTitleForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger)index

谢谢!

推荐答案

目前,这在coreplot中不可用。您必须对 CPTLegend 类进行子类化才能添加此功能。 此处的要求。

This is not available in coreplot as of now. You have to subclass CPTLegend class to add this functionality. There is already a request for this here.

只是将您指向正确的方向。为此,您需要执行以下操作

Just to point you to right direction. In order to achieve this, you need to do the following,


  1. 修改方法 renderAsVectorInContext 存储其中绘制了图例标题和色板的CGRect。与图例标题对应的框架之间应该有连接。

  2. 修改方法-(BOOL)pointingDeviceDownEvent:(CPTNativeEvent *)event atPoint:(CGPoint) interactPoint ,然后检查是否在上面存储的所有这些CGRect中点击。如果该点在该框架之内,则需要调用一个委托方法并告诉您点击了哪个图例。在其他coreplot类中检查此方法的类似实现。在这种情况下,应该确定抽头点是否在此框架内。

  1. Modify the method renderAsVectorInContext to store the CGRect in which legend title and swatch is drawn. There should be a connection between the frame corresponding to the legend title.
  2. Modify the method -(BOOL)pointingDeviceDownEvent:(CPTNativeEvent *)event atPoint:(CGPoint)interactionPoint and check if the tap is on any of these CGRect stored above. If the point is within that frame you need to call a delegate method and tell which Legend was tapped. Check for similar implementation of this method in other coreplot classes. It should be almost similar in this case to identify whether the point of tap lies within this frame or not.

这篇关于在Coreplot iOS中的LEGENDS上触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆