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.
Related
I'm trying to make the labels appear inside the pie chart, but with an even distance from the pie border. I'm using distance: -30 to make the labels stay inside of the pie, but it seems to be applied to the top of the labels' box rather than to a mid point or as margin. This causes the labels to look unevenly placed.
Is there a way to place the labels at an even distance from the border?
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;
The problem starts with the fact i have a very small area to plot a chart and i need to have markers on it as well. Now because of the small area, the markers are getting cut off and they are a key piece of information. So is there any way by which i can add some spacing between the border of the plot and the actual start of the data plot itself ?
Heres a running example: https://dl.dropboxusercontent.com/u/138190/charts/index.html
Set minPadding and maxPadding for xAxis. This will work as long, as yod don't have scrolling/panning options enabled.
In my App, I am using Coreplot to draw a CPTScatterPlot. Now i want to do a scanner on the chart and this animation of UIView (a line) should be like a Line aligned with Y-axis and travels through x=0 to whatever the last value of x is.
I want to perform an action based on the y value while this custom UIView (scanner) travels.
Any help would be appreciated.
Thanks,
i have something similar in an app of mine, the way i went about it was to add a bar graph on top of the scatter plot, i used that bar graph to represent the line that tracks the user's touch.
then i have a UIView that is overlaid on the plot and tracks the scatter plot touches and displays details of the point being touched.
if you just want to display a line, adding a bar graph is probably the easiest, then you don't have to worry about plot space coordinates vs superview coordinates.
the bar graph data source is only returning a value for the location the user is touching, with a height to match the size of the scatter plot.
the quick version is you can use handlePlotTouchEventInSpace:atPoint:isNewEvent to track the user's touches on the graph.
from there you can use the plotPoint:forPlotAreaViewPoint method on the plot space to get the coordinates of the touch.
something like this is a good starting point. it's a bit of a journey to get it all working, but its not too bad once you get the puzzle started.
-(void)handlePlotTouchEventInSpace:(CPTPlotSpace *)space atPoint:(CGPoint)point isNewEvent:(BOOL)newEvent {
NSDecimal plotPoint[2];
CPTXYPlotSpace *xySpace = (CPTXYPlotSpace *)space;
[xySpace plotPoint:plotPoint forPlotAreaViewPoint:point];
after that plotPoint will contain the x and y location of the touch inside the plot space.
In Core-Plot I want to plot only the visible area of the plot. For this I need the visible range of the plot after Zoom-In and Zoom-Out.
Any Idea how to get visible range of X-Axis?
You can use a plot space delegate to find out when the plot ranges change. Each delegate method receives a reference to the plot space as one of its parameters. You can read the xRange and yRange to find out what the new ranges are.
You can get visible range of X-Axis using code like this:
space.graph.axisSet.xAxis.visibleAxisRange