在CorePlot DatePlot使用CPTAnnotation(IOS) [英] Using CPTAnnotation in CorePlot DatePlot (iOS)

查看:222
本文介绍了在CorePlot DatePlot使用CPTAnnotation(IOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序使用CorePlot,我想显示在一个plotSymbol注解。我还没有发现在最新的0.9版CorePlot的样本项目的任何code。经过一番研究,我已经到了这个地步:

I am Using CorePlot in my app, and I want to display a annotation over the plotSymbol. I haven't found any code in the sample projects of the latest 0.9 version of CorePlot. After some research i have come to this point:

- (void)scatterPlot:(CPTScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)index
{
    CPTLayerAnnotation *annot = [[CPTLayerAnnotation alloc]initWithAnchorLayer:graph];
    CPTBorderedLayer * logoLayer = [[(CPTBorderedLayer *) [CPTBorderedLayer alloc] initWithFrame:CGRectMake(10,10,100,50)] autorelease]; 
    CPTFill *fillImage = [CPTFill fillWithImage:[CPTImage imageForPNGFile:@"whatEver!"]]; 
    logoLayer.fill = fillImage; 
    annot.contentLayer = logoLayer; 
    annot.rectAnchor=CPTRectAnchorTop;
    [graph addAnnotation:annot];
}

但它显然没有工作....任何人可以帮助我吗?

But its obviously not working.... Can anybody help me?

我的目标是让在选定的情节符号注释,类似的MKMapView注释。

My goal is to get an annotation over the selected plot symbol, similar to annotations in MKMapView.

更新

有一个DatePlot,只是为了阐明的东西,并且自2001年它正在与时间间隔在X轴

It is a DatePlot, just to clarify things and it is working with time intervals since 2001 on the x-axis.

推荐答案

有在核心绘图示例应用程序的这几款例子。在绘图库的应用程序的梯度散点图(和其他几个应用程序,以及)使用此方法将文本标签附加到所选点。在CPTTestApp Mac版的点选择演示使用第二散点图在选定点绘制一个十字星。

There are several examples of this in the Core Plot example apps. The gradient scatter plot in the Plot Gallery app (and several other apps as well) use this method to attach a text label to the selected point. The point selection demo in the Mac version of CPTTestApp uses a second scatter plot to draw a crosshairs over the selected point.

记住要设置 plotSymbolMarginForHitDetection 的散点图属性了。默认值为0,这意味着你必须打点的中心精确地注册一个触摸。

Remember to set the plotSymbolMarginForHitDetection property on the scatter plot, too. The default is 0, which means you have to hit the center of the point exactly to register a touch.

有两种类型的核心情节的注释。 A CPTLayerAnnotation 被固定到一个给定的Core Animation层(你的情况的图表)。 A CPTPlotSpaceAnnotation 锚定到一个阴谋的空间坐标(==坐标数据)。下面您的评论使得它听起来像你想使用一个阴谋空间注释,而不是一个图层标注。

There are two types of annotation in Core Plot. A CPTLayerAnnotation is anchored to a given Core Animation layer (the graph in your case). A CPTPlotSpaceAnnotation is anchored to a plot space coordinate (== data coordinate). Your comment below makes it sound like you want to use a plot space annotation instead of a layer annotation.

这篇关于在CorePlot DatePlot使用CPTAnnotation(IOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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