CPTXYScatterPlot-我可以设置绘图符号的Z顺序吗? [英] CPTXYScatterPlot - Can I set the Z order of plot symbols?
问题描述
使用Core Plot的CPTScatterPlot,我制作了一个类似于上面的气泡图。
Using Core Plot's CPTScatterPlot, I've made a bubble chart that looks like the above.
我已经实现了 plotSymbolWasSelectedAtRecordIndex
我的代表,这样我就可以检测到用户何时触摸了其中一个气泡。以该屏幕截图为例,我希望能够突出显示黄色气泡,并在用户触摸时将其置于红色气泡之前。用图形方式,我想将所选 CPTPlotSymbol
的Z顺序设置为高于其他顺序。我该怎么做?我可以通过在 symbolForScatterPlot
方法中将其绘制为不同的颜色来突出显示选定的气泡,但是我似乎找不到找到使它在前面绘制的方法
I've implemented plotSymbolWasSelectedAtRecordIndex
in my delegate so I can detect when the user touches one of the bubbles. Using this screenshot as an example, I want to be able to highlight the yellow bubble and bring it in front of the red one when the user touches it. In graphical terms, I want to set the Z order of the selected CPTPlotSymbol
to be higher than the others. How can I accomplish that? I'm able to highlight the selected bubble by drawing it in a different color in my symbolForScatterPlot
method, but I can't seem to find a way to make it draw in front of the overlapping symbol.
推荐答案
Core Plot以数据点在数据源中出现的顺序绘制数据点。您需要对数据进行重新排序,以使最上面的气泡位于最后一个索引处,并在绘图上调用 -reloadData
告诉其刷新数据。如果数组中有数据点,则按所需的z索引(从后到前)对其进行排序,然后使用排序后的数组来填充数据源。
Core Plot draws the data points in the order they appear in the datasource. You'll need to reorder the data so the top-most bubble is at the last index and call -reloadData
on the plot to tell it to refresh its data. If you have the data points in an array, sort it by the desired z-index (back to front) and use the sorted array to feed the datasource.
这篇关于CPTXYScatterPlot-我可以设置绘图符号的Z顺序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!