Core Plot: Move the legend on the plotting area - core-plot

I achieved to plot my 5 lines, but wherever I place the legend, it doesn't allow me to see clearly the interception of some lines.
There is a way to allow the user to move/drag the legend along the plotting area?

No. You could position the legend outside the plot area so it doesn't overlap the plot or subclass CPTLegend and override the user interaction methods (-pointingDeviceDownEvent:atPoint:, etc.) to implement the dragging behavior.

Related

Is it possible to add CPTLegend in UIview not a CPTGraphHostingView?

I am trying to add the CPTLegend in uiview how can i add.Basically many people adding in Graph hosting view. Any idea?
All visible parts of a Core Plot graph, including the legend (drawn by CPTLegend), are Core Animation layers that are derived from a common superclass, CPTLayer. These layers rely on the hosting view to set up the coordinate transform and event handling and to handle layout changes.
Why do you need to have a legend that is not attached to a graph? CPTLegend depends on plots both to determine the contents of the legend and to actually draw it. These plots are normally part of a graph, so you should have one available to use as a host for the legend.
Enlarge the hosting view to cover the whole area where the pie chart and legend should appear. Change the centerAnchor of the pie chart to move it away from the center of the hosting view and position the legend on the other side of the graph. The separator view can be placed on top of the hosting view to separate the plot from the legend. Note that Core Animation hosting views don't allow subviews, so it needs to be a sibling (i.e., have the same superview) of the hosting view, not a subview.

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!

How to achieve customizations in core plot -scatter plot?

I am working on core Plot library in ios.I was able to add mutliple scatter plots to graph.I am not able to achieve following customizations(Pls refer attached image):
Need to connect multiple Y-axis points and draw a vertical line.
On X-axis,need to add number of tasks(Custom UI views) for every month.
Thanks for any help you can give.
Use a third scatter plot to draw the vertical lines.
Don't add subviews to the Core Plot hosting view. Add them to the hosting view's superview. You can use the plot space to find the coordinates along the x-axis to anchor your custom views.

How to increase the distance between the columns in the legend Core plot pieChart

I want to have 2 columns legend under the diagram, and I would like that they are on the sides of the screen, not on the left.
This how it's look like now:
How can I do it?
Core Plot legends have many options to customize the layout, including the size of the color swatch, the spacing between rows and columns, and the number of rows and/or columns in the grid. See the CPTLegend docs for the details.
The legend itself is just a CPTLayer (Core Animation CALayer subclass). The Core Plot graph provides convenience properties for positioning the legend (legendAnchor and legendDisplacement). If these don't provide enough control, you can position the legend layer anywhere you want using annotations. Use a layer annotation to tie the location to a specific graph layer (fixed screen position) or a plot space annotation so it moves with the plot data.
It's done only just by one line of code: theLegend.columnMargin = 90.0;
Or theLegend.columnWidths = arrOfWidths;

Adding label to core plot chart

I want to add a label to a core plot scatter chart. It should be at a specific y value at the left edge of the chart, like that:
I tried doing it using annotation but I have a problem with dragging. When I drag the chart the annotation is also being dragged, and I would like it to always stay at the left edge.
Create your label as a plot space annotation. Use a plot space delegate to monitor changes to the xRange and update the x-value of the anchor point as needed. You can use the plot space to convert the desired x-position to the corresponding data value for the anchor point.

Resources