触摸 CorePlot 中的绘图符号

发布于 2024-10-03 07:35:43 字数 518 浏览 0 评论 0原文

当用户单击(或触摸)使用 Core Plot 创建的 mye 图表上的plotSymbol 时,我尝试运行一些代码。

这不适用于 scatterPlot:

-(void)scatterPlot:(CPScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:    (NSUInteger)index
{
    NSLog(@"plotSymbolWasSelectedAtRecordIndex %d", index); 
}

但是当我使用 barPlot 时效果很好:

-(void)barPlot:(CPBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index
{
    NSLog(@"barWasSelectedAtRecordIndex %d", index);
}

当用户单击或触摸我的 scatterPlot 时,我尝试捕获时缺少什么?

I'm trying to run some code when the user clicks (or touches) a plotSymbol on mye graph created with Core Plot.

This does not work with scatterPlot:

-(void)scatterPlot:(CPScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:    (NSUInteger)index
{
    NSLog(@"plotSymbolWasSelectedAtRecordIndex %d", index); 
}

But this works well when I use the barPlot:

-(void)barPlot:(CPBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index
{
    NSLog(@"barWasSelectedAtRecordIndex %d", index);
}

What's missing from my attempt to capture when the user clicks or touches on my scatterPlot?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

鹿童谣 2024-10-10 07:35:43

您需要在散点图上设置plotSymbolMarginForHitDetection。您应该将其设置为与绘图符号的大小相匹配,或者如果您需要单击更大的目标,则应将其设置为稍大一些。

You need to set the plotSymbolMarginForHitDetection on your scatter plot. You should set it to match the size of your plot symbols or slightly larger if you need a bigger target to click.

暗藏城府 2024-10-10 07:35:43

另外,不要忘记将 CPScatterPlot 的委托设置为指向您的对象,否则它不会被调用。

Also, don't forget to set the CPScatterPlot's delegate to point to your object, or it won't get called.

回忆那么伤 2024-10-10 07:35:43

如果您在初始化时在 CPTGraphHostingView 的子类中设置您的内容(例如在来自 xib 的 initWithCoder 中),您的 HostedGraph 属性可能会被 Core Plot 破坏(至少从 1.3 开始),因此 Tap 处理会很短-电路。

https://code.google.com/p/core-plot /issues/detail?id=555

不用说,这发生在我身上:-) 我的解决方法是在我的 numberOfRecordsForPlot 中设置 HostedGraph(如果尚未设置)。

If you're setting up your stuff at init time in a subclass of CPTGraphHostingView (say in initWithCoder coming from a xib), your hostedGraph property might get clobbered by Core Plot (at least as of 1.3), and so the tap handling will short-circuit.

https://code.google.com/p/core-plot/issues/detail?id=555

Needless to say this happened to me :-) My workaround is to set the hostedGraph in my numberOfRecordsForPlot if it's not set already.

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