核心图:显示数据点标签,或者数据点何时被触摸?
有没有办法使用 Core Plot 将周期性标签分配给数据图?例如在我的情节点上列出 10-20 个标签。
这是我希望做的事情的示例(模型):
是否可以在图表加载时执行此操作,或者当您在图表上滑动时您会看到数据点显示他们的呼唤?
Is there a way using Core Plot to have periodic labels assigned to data plots? Such as 10-20 labels listed across my plot points.
Here is an example (mockup) of what I am hoping to do:
Is it possible to do this when the graph loads, or maybe when you swipe across the graph you see the data points showing their call out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须自己绘制标注气泡,但可以标记数据点。要进行标注,您可以子类化 CPTextLayer 并让它在文本周围绘制气泡。使用这个新类来制作标签。
您可以实现一个数据源方法来通知 Core Plot 哪些数据点应该被标记,并根据需要提供您自己的标签(这就是您进行标注的方式)。您还可以响应触摸事件(Mac 上的单击事件)并显示触摸点的标签。您必须单独触摸每个点 - 如果您从一个点拖动到下一个点,您将不会收到委托通知。
Core Plot 中包含的示例演示了这两种技术的工作原理。
You'll have to draw the callout bubbles yourself, but it is possible to label data points. To make a callout, you could subclass CPTextLayer and have it draw the bubble around the text. Use this new class to make your labels.
You can implement a datasource method to inform Core Plot which data points should be labeled and provide your own labels if you wish (this is how you'd do the callouts). You can also respond to touch events (click events on the Mac) and show a label for the point that was touched. You have to touch each point individually--you won't get the delegate notification if you drag from one point to the next.
The examples included with Core Plot demonstrate how both techniques work.