CPTXYScatterPlot - Can I set the Z order of plot symbols? - core-plot

Using Core Plot's CPTScatterPlot, I've made a bubble chart that looks like the above.
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 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.

Related

How to make a vertical range plot filled with color using CorePlot in iOS?

I need to show a graph in my iOS app something like
We have been using CorePlot for all the graphs and now I need to add a new kind as shown above. I found I could draw a graph like the above with CPTRangePlot. My problem is I can only draw a horizontal graph as shown below.
Is there any way to make it vertical? For a single curve we can easily do that by switching the value on X-axis and Y-axis. But for this kind of "range plot", I could not find a way to make it work for drawing the upper-bound and lower-bound lines and filling range with color can only be achieved on a normal horizontal graph. And yes, I can easily rotate the container view by 90 degrees, as I did in my testbed app. But I just cannot do this in our current app because this new added "range plot" graph is not the only one on the view. We have many other curves sharing the same plot space. So is there any hidden property or method to achieve the job? Thanks in advance!
I just added a fillDirection property to the range plot to enable this feature. You'll need to use the latest code from the release-2.3 branch.

Coreplot - selecting area below line

I am using coreplot to draw a scatter plot like that:
I use 4 different plots (as coloured) and create a "bar like" feeling by adding 0-value points at the beginning/end of each "bar".
I want to determine which bar was selected by the user and then change alphas of other plots.
I've tried using
-(BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDownEvent:(id)event atPoint:(CGPoint)point {
//here I translate the selected point to Data points coordinates
//and check which of the plot sources has value >0 (that means bar is visible)
//and is closest to the selected point
}
This method works, but when I want to scroll the data, the method above is called as well.
There must be some easier solution to do that. Thanks.
Return YES from your delegate method to inform the plot space that you've taken action on the event and it does not need to start the scroll. You may need to handle the other events, too, so your app can differentiate between a tap and a drag.

shinobi chart gridline end in data point instead of going all the way to the top of chart

I'm drawing a chart in an iOS app and I want the gridlines to start in the x axis but end in the data point instead of extending all the way up to the top.
Is this possible?
Thanks in advance.
NC
Disclaimer: I work for ShinobiControls
The shinobicharts framework doesn't currently support this as an out-of-the-box feature.
A workaround may exist though. You may be able to add your own gridline subviews by using the SChartAxis method pixelValueForDataValue: to work out where in the plot area coordinate space you should draw your vertical line up to for a given data point.
Once you have your coordinates there are various ways you could draw your gridlines:
Add a canvas view behind or in front of the chart (depending on what effect you want). Then use your coordinates to draw your gridlines using CoreGraphics or some other drawing technique.
Create individual UIViews that each represent a gridline using your coordinates and add these behind or in front of the chart.
One thing to be aware of with this technique is that the gridlines will not automatically update when you pan and zoom. In order to do this you will need to override one of the chart's delegate methods that notify you of range changes and update your drawn gridlines to match the new data point positions.
Another potential workaround could be to use a column series to mimic gridlines. If you create a column series and feed it the same data points as your original series this will result in columns that go up to the y-value of each data point. You could then use the property interSeriesSetPadding on SChartAxisStyle to cause the columns to appear very thin.
I hope that information is useful!

Click on the graph core-plot

How to do that when you click on the graph, on the point (shows the value at that point)?
And how it make if i have 4 graph on one view.
Any examples?
Thanks for Help!
Look at the example apps included with Core Plot. The Plot Gallery has an example of adding a label when the user clicks a plot. The Mac version of CPTTestApp shows another technique of drawing a crosshairs over the selected point on a scatter plot.
Each plot has its own delegate that will be notified of the click. The delegate methods all have the sending plot as one of the parameters so you can use the same delegate object to handle more than one plot.

How do i add label to the pie chart slice when a particular slice is touched using coreplot?

I had drawn a pie chart using core-plot. I need to display the item name when a particular slice is touched. can anyone suggest me a solution to achieve this?
You can handle individual slice events by implementing CPPieChartDelegate methods. Declare CPPieChartDelegate protocol and implement the method (void)pieChart:sliceWasSelectedAtRecordIndex: . Set the delegate of piechart to self(controller). This method gives you which slice(index) is selected. And now for drawing the label, you have to re-draw the pie chart, specifying which slice to be labeled. You can set empty string to labels for other slices.
The iPhone version of CPTTestApp (in the Core Plot examples folder) shows how to display the selected slice index. It displays the index in the graph title, but you just as easily display it in a Core Plot annotation or in a separate UI control.

Resources