You could make the Core Plot hosting view a fixed size and place it inside another view that tracks changes in the in the window size. This would clip the edges of the graph inside the parent view. If that won't work, you'll need to track changes to the size...
dynamic,graph,core-plot,reloaddata
You are correct, -reloadData only updates the plot data. You can call -scaleToFitPlots: afterwards to adjust the plot ranges to fit the new plot data. Consider using axisConstraints instead of the orthogonalCoordinateDecimal to position the axes. That way the axes stay in position as the plot ranges change....
ios,objective-c,gradient,core-plot,cptimage
Set the scale of the image. CPTImage *image = [CPTImage imageWithCGImage:img.CGImage scale:img.scale]; If you're using the latest Core Plot code (after release 1.5.1), you can load the image directly: CPTImage *image = [CPTImage imageNamed:@"orange_bar_graph"]; ...
CPTColor defines the same basic colors as UIColor, including +lightGrayColor and +darkGrayColor. If those don't meet your needs, you can use +colorWithGenericGray: to make any gray between black and white or +colorWithComponentRed:green:blue:alpha: to make any RGB color including those with transparency....
Use the topDownLayerOrder to move the axis line in front of the plots. CPTPlotArea *plotArea = graph.plotAreaFrame.plotArea; plotArea.topDownLayerOrder = @[@(CPTGraphLayerTypeAxisLines)]; Set the yRange to start at 5.0 with length 10.0: lPlotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(5.0) length:CPTDecimalFromDouble(10.0)]; ...
You need to set the tickLocation of each new label. newLabel.tickLocation = next ...
ios,objective-c,core-plot,nsnotificationcenter,addobserver
The Core Plot hosting view removes itself as an observer of all notifications whenever you set the hosted graph or the collapsesLayers property. Please post a bug report on the issue tracker if you'd like us to fix it. In the meantime, add your observers after you set up the...
You need to add another plot space for the second y-axis. Make the xRange the same as the first plot space. The Plot Gallery example app has several demos for this. The "Plot Space Demo" creates several plot spaces with different settings and assigns an axis to each one. The...
There are several methods available to tell a Core Plot plot that you have new data available: -reloadData: Replace all of the plot data with new data points. Calling this method on the graph causes all plots in the graph to reload their data. -reloadDataInIndexRange:: Replace the plot data in...
ios,objective-c,cocoa-touch,annotations,core-plot
Use the displacement property to offset the annotation away from the anchor point. The displacement is measured in pixels so it won't change with the plot space.
ios,objective-c,swift,core-plot
The problem is that mutableCopy returns an AnyObject. An AnyObject has no properties, so you can't assign into a property of it. You need to cast this to a CPTMutableLineStyle. var lineStyle = aaplPlot.dataLineStyle.mutableCopy() as CPTMutableLineStyle lineStyle.lineColor = aaplColor; ...
It works fine, although the automatic labeling algorithm doesn't know about the dates, so it won't split the axis into "nice" date intervals like days or weeks. You will probably want to use CPTTimeFormatter or CPTCalendarFormatter as the labelFormatter.
ios,iphone,xcode,swift,core-plot
The axis labelingPolicy controls the tick spacing and labels. With custom labels (CPTAxisLabelingPolicyNone), it's up to you to give each label a location. If you want tick marks and/or grid lines, you need to set those locations (majorTickLocations and/or minorTickLocations) separately. There is a labeling policy demo in the Plot...
objective-c,core-plot,ios-charts
Several of the Core Plot example apps show how to add multiple axes in a graph. See, for example, the "Axis Demo" in the Plot Gallery app. Position one x-axis at the top and the other at the bottom using the axisConstraints or orthogonalCoordinateDecimal.
If you only want to hide them, you can loop through the axisLabels set and hide or show the contentLayer of each label with the hidden property. You can also remove the labels to hide them. For custom labels (CPTAxisLabelingPolicyNone), just set the axisLabels to nil to hide them and...
ios,objective-c,animation,nstimer,core-plot
I just added an example to the "Simple Pie Chart" demo in the Plot Gallery example app. I added two properties to the controller to hold the index of the selected slice and the desired offset value. Since the offset is a CGFloat it is easily animated using Core Animation...
The -plotSpace:shouldScaleBy:aboutPoint: method is only called in response to a pinch gesture on the hosting view. The -plotSpace:willChangePlotRangeTo:forCoordinate: method is called for every change so you can do all of your limit checks there.
ios,objective-c,xcode,uiview,core-plot
After playing on and off in Interface Builder trying everything again and again, I've started to search more on StackOverflow and I've stumbled upon this question: Application crashes when working with core plot Pretty weird, but it wasn't and IB issue (I was sure I was doing the right thing...
What data is being plotted? Please show the datasource methods. The visible data ranges in the plot area are controlled by the plot space: plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(-5) length:CPTDecimalFromInteger(10)]; plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInteger(-7) length:CPTDecimalFromInteger(14)]; The labelExclusionRanges skips over any labels in the specified ranges. If you want to see...
Try the lineFill property of the line style instead. You can use a gradient or an image to provide the fill pattern.
You can use the -renderAsVectorInContext:atPoint:scale: method to draw the symbol into a CGContext. Create a context, draw the symbol into it, and use UIGraphicsGetImageFromCurrentImageContext() to create a UIImage.
Use the labelingOrigin to adjust the starting point for fixed interval ticks. Setting it to 10 (or 30 or 50, etc.) will work.
In your method that you make the plot and the graph there should be a line that goes like this. _yourGraph.plotSymbolMarginForHitDetection = 20.0f; I always use 20.0f because of 'fat' fingers too. I have a method that I called configurePlots, I get a reference to the graph and plot space....
By default the axes always cross at (0, 0). I suspect your plot data doesn't cover that point, so scaleToFitPlots pushes (0, 0) outside the visible plot area and hides the axes. You have several options: Use axisConstraints to lock the axes to a certain spot (e.g., the left edge...
ios,objective-c,animation,core-plot
Clearing the selectedIndex drives the radial offset to zero right away. Don't clear it until after the animation finishes. You can use an animation delegate or clear it in -setSliceOffset: after the offset reaches zero.
ios,graph,core-plot,stacked-area-chart
To make the line smoother, either give it more data points or make a curved plot. plot.interpolation = CPTScatterPlotInterpolationCurved; If you know the range of data values, just set the xRange directly. Remember to set the location to the min value and the length to (max - min). You can...
The location of a plot range is the left end (on the x-axis) or bottom end (on the y-axis). Give each range a location of one (1) and adjust the length to the max - min (i.e., one in this case).
ios,objective-c,core-plot,ios8.1
Create a NSNumberFormatter and configure it to format the labels however you want. Set the labelFormatter on the plot to the new formatter.
The automatic labeling algorithm doesn't know about dates, so it won't split the axis into "nice" date intervals like days or weeks. Right now, the fixed interval labeling policy is the best solution. It is up to you to determine the proper interval based on the range being displayed. There...
ios,objective-c,calayer,core-plot
The short answer to your question is that you need to flip the layer of the view which contains your legend layer. [[viewWithLegendSublayer layer] setTransform:CATransform3DMakeScale(1.0f, -1.0f, 1.0f)]; This will do the trick, but if you add any other subviews to that view, they'll be upside down. N.B.: There may be...
ios,xcode,swift,graph,core-plot
Use a plot area delegate and implement one or more of the following delegate methods: -(void)plotAreaWasSelected:(CPTPlotArea *)plotArea withEvent:(CPTNativeEvent *)event; -(void)plotAreaTouchDown:(CPTPlotArea *)plotArea withEvent:(CPTNativeEvent *)event; -(void)plotAreaTouchUp:(CPTPlotArea *)plotArea withEvent:(CPTNativeEvent *)event; Use the -plotPointForEvent: plot space method to get the data coordinates of the interaction point from the event....
You can add a binding to an array of plot symbols using the binding identifier CPTScatterPlotBindingPlotSymbols. This array should be the same size as your data arrays. If you don't want a symbol at a particular index, insert [NSNull null] in the array instead of a plot symbol.
ios,objective-c,ios7,core-plot
Make sure the xRange of the plot space is set correctly. For example, to make a range enclosing the values listed in the question, do this: NSTimeInterval minTime = 1398172101; NSTimeInterval maxTime = 1398196536; plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(minTime) length:CPTDecimalFromDouble(maxTime - minTime)]; ...
For this application, the barOffset should be zero (0). The offset is used to displace the bars from the location given by the datasource. The most common use is to separate the bars at the same location when plotting multiple bar plots on the same graph that might have overlapping...
ios,objective-c,graph,core-plot,ios8.1
The X Axis needs to know where to draw in relation to the Y axis. Try adding in this line: axisSet.xAxis.orthogonalCoordinateDecimal = CPTDecimalFromUnsignedInteger(35); ...
The symbol datasource method signature in Swift is: func symbolForScatterPlot(plot: CPTPlot!, recordIndex: UInt) -> CPTPlotSymbol? Return a plot symbol object or nil to omit the symbol at that index....
ios,objective-c,graph,core-plot,ios8.1
Use a plot space delegate to constrain the plot ranges. Implement the -plotSpace:willChangePlotRangeTo:forCoordinate: method. Check the passed in range and make sure it falls in the desired range. If not, make a mutable copy and modify it to fit. Return the original or modified range as appropriate.
You're positioning the custom labels outside the visible plot range. The xRange covers values between 800 and 1,200 (length of 400). The labels are at 1, 2, 3, etc. Use the label value as the tickLocation: label.tickLocation = CPTDecimalFromString(string); [xLocations addObject:string]; ...
ios,objective-c,xcode,core-plot,vdsp
You need to link with the Accelerate.framework
ios,scale,core-plot,zooming,scatter-plot
If you always want the axes to cross at the same place, use the orthogonalCoordinateDecimal property. It defaults to zero for both axes, but you can change that if you want. If the crossing point is outside the visible range after calling -scaleToFitPlots:, you can adjust the location and length...
You are creating more than 100,000 axis labels. That takes time, plus puts a lot of memory pressure on your app. Choose the major and minor increments so that the app only generates a reasonable number of labels for each axis.
ios,objective-c,core-plot,scatter-plot
Try different style on your scatter plot CPTScatterPlotInterpolationLinear: This is the default. CPTScatterPlotInterpolationStepped CPTScatterPlotInterpolationHistogram CPTScatterPlotInterpolationCurved example: CPTScatterPlot *yourPlot = [[CPTScatterPlot alloc] init]; yourPlot.dataSource = self; yourPlot.interpolation=CPTScatterPlotInterpolationCurved; ...
You answered your own question—you need to account for the timezone difference. One way would be to set the timezone of the NSCalendar in the -beginningOfDay: method.
I have found a historical article that's similar to my request (core-plot iOS reversed Y axis). I have got what I needed after using this: CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-yMax-1) length:CPTDecimalFromFloat(yMax) P.S. you need to add the -1 to the Location parameter (-yMax-1) otherwise the horizontal bar at index 0 will not be...
osx,cocoa,core-plot,quartz-graphics
I believe this issue has been fixed. Release 1.6 should be out soon, or you can pull the latest code from GitHub.
"Fixed Interval" means exactly that—the intervals between the ticks don't change no matter the scale of the plot space. If you want the labels to change as you zoom in and out, you have a couple of options: Use the automatic labeling policy. This policy changes the intervals dynamically to...
objective-c,core-plot,cocoapods
The new version of Cocoapods enabled a new build option that broke Core Plot builds. It's fixed in the latest code. See issue 138 for details. Point your pod file at the repository head rather than a release number....
The time intervals are in seconds, so you should multiply the index by 10 to space the data points 10 seconds apart.
Knowing the bar length (from the xValue), you can use the plot space to determine its size on screen. After creating the textLayer, check its bounds size. Compare the two and decide whether to position the label inside or outside the bar.
-scaleToFitPlots: adjusts the plot space to fit the plot data exactly. You can use it as a starting point to fit the data and then expand the resulting range to leave extra space around the edges or to fix the location of one of the ranges. For example, you could...
I came up with a solution by myself: I just remove the plot and add it back. In that way the plot is raised in the z-Hierarchy. [self.graph removePlot:plot]; [self.graph addPlot:plot]; ...
I experienced similar problems while developing another app. To my experience, CGRectZero is causing problems with Swift. Try with an actual CGRect or call var pie = CPTPieChart(frame: CGRectMake(x,y,width,height)) ...
The -addPlot: method always adds plots to the default plot space. When setting up the plots, use the -addPlot:toPlotSpace: method to add the plots to the graph. Specify the "y2" plot space for the plots that should use the secondary scale....
Create a plot delegate and implement the -didFinishDrawing: method. The plot that finished a draw cycle is passed as a parameter to the method so you can keep track of which ones are finished.
Core Plot applies a flip transform on iOS so we can use the same drawing code on both the Mac and iOS. This is the transform it uses: self.layer.sublayerTransform = CATransform3DMakeScale( CPTFloat(1.0), CPTFloat(-1.0), CPTFloat(1.0) ); ...
+tubularBarPlotWithColor: is a short cut to create bars with a gradient fill. If you don't want the gradient, set the fill to a solid color. self.helloPlot.fill = [[CPTFill fillWithColor:[CPTColor redColor]]; ...
ios,objective-c,core-plot,addsubview
As the error message suggests, you're trying to add an object that isn't of type UIView as a subview to the cell. Add the CTPGraph object to an instance of type CPTGraphHostingView, then add this as a subview to the cell: CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc] initWithFrame:frame]; hostingView.hostedGraph = graph;...
ios,objective-c,core-plot,pie-chart
Usually you fill out the DataSource function to provide the color, which means you already have the color. For you case, I think you could use this function: + (CPTColor *) defaultPieSliceColorForIndex:(NSUInteger) pieSliceIndex The doc is here. To get the UIColor of CPTColor, simply get the CPTColor's property uiColor. Detailed...
ios,objective-c,xcode,core-plot
//Add plot space CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace; plotSpace.delegate = self; plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0.0) length:CPTDecimalFromInt(25)]; then change x axis label policy like this x.labelingPolicy = CPTAxisLabelingPolicyFixedInterval; ...
ios,objective-c,core-plot,cabasicanimation
CAAnimation is KVC compliant, so we can store whether you're starting or finishing for lookup in the delegate methods: { CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.x"]; [scaleAnimation setValue:@(YES) forKey:@"scaleAnimation"]; // set the delegate scaleAnimation.delegate = self; scaleAnimation.fromValue = [NSNumber numberWithFloat:1.0]; scaleAnimation.toValue = [NSNumber numberWithFloat:0.5]; scaleAnimation.duration = 1.0f; scaleAnimation.removedOnCompletion = NO; [self.pieChart...
You can use an axis delegate to detect touches on the axis labels. Implement the -axis:labelWasSelected: method or one of the other selection methods. The contentLayer of the axis label is a CPTTextLayer so you can add a background fill and border to make it look like a button. If...
There is no 2.0 release of Core Plot (yet). Use the following line in your podfile to point at the release-2.0 branch: pod 'CorePlot', :git => 'https://github.com/core-plot/core-plot.git', :branch => 'release-2.0' There is a combined header file that works for both Mac and iOS apps. You can also use the CorePlot-CocoaTouch.h...
Use the axisConstraints to position the x-axis at the lower edge of the plot area: x.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0]; ...
Swift doesn't support NSDecimal values. We've made some changes to the Core Plot API, replacing NSDecimal with NSDecimalNumber. The changes are on the release-2.0 branch and not in a release package yet. See Core Plot issue #96 for more discussion of the issue.
Pinch and scroll gestures are also available on the Mac. I don't think this feature has been included in any release yet, so you'll need to get the latest source from GitHub.
You have several options: Set the identifier for the new plot space and use -plotSpaceWithIdentifier: to retrieve a reference from the graph. Use -plotSpaceAtIndex: to refer to plot spaces in the order they were added to the graph. The default plot space is at index 0. Keep a reference to...
Make sure the graph is masking its sublayers. Use masksToBounds to clip to the outside of the border line or masksToBorder to clip to the inside edge of the border.
You need to leave a gap in the data (return nil or [NSNull null] from the datasource) to break the plot line at the discontinuity.
ios,objective-c,core-data,core-plot
Ok I managed to figure it out :). Here is my solution, in case anyone else stumbles across this problem: I realised that the only way to fetch my visible date range is to extract the date values from the axis labels. I then used those date values to perform...
ios,objective-c,core-plot,pie-chart
The pie chart centerAnchor is given as fractions of the width and height. Be sure to multiply the anchor values by the corresponding dimension of the graph before computing dx and dy.
ios,objective-c,animation,core-plot
When configuring the plot, set the initial endAngle to the same value as the startAngle. The default of NAN tells the plot to draw a full circle starting from the startAngle.
expandRangeByFactor exists, but it takes an NSDecimal. You are trying to supply an NSDecimalNumber, which is not the same thing. (Another problem with your code - irrelevant in this situation, but still a problem - is that you cannot say NSDecimalNumber(1.1). There is no such initializer.) You need to pass...
ios,objective-c,core-plot,jbchartview
Core Plot can absolutely do this. The scatterplot pulls data from its datasource independently for the x- and y-values. Most of the included examples just use the data index for the x-value, but that choice was only to make the examples easier to follow. The x-values can be anything. The...
Try this: var popPoint = graphView.hostedGraph.defaultPlotSpace.plotAreaViewPointForPlotPoint(&pointers, numberOfCoordinates: idx) ...
ios,objective-c,animation,core-plot,pie-chart
I finally got it thanks to @RoryMcKinnel. [CPTAnimation animate:pieChart property:@"endAngle" from:pieChart.startAngle + M_PI * 2 to:pieChart.startAngle duration:2.0]; This will animate your pie chart like this: http://jsfiddle.net/ozgr1wfx/. Again. Thanks to @RoryMcKinnel who put me on the right track to get it!...
Instead of replacing the default axis set, just set your new axes array to it: _graph.axisSet.axes = @[_xAxis, _yAxisLeft, _yAxisRight]; You are replacing a CPTXYAxisSet with a CPTAxisSet that doesn't know how to lay out and draw the x-y axes....
Since the x data points are one unit apart, giving the xRange a length of 6 (plus a bit for the plot symbols) will do what you want. In the code you posted, the xRange is set up with -scaleToFitPlots: before expanding the range. This makes it fit all of...
There are several example apps included with Core Plot that demonstrate working with dates. See, for example, the "Date Plot" demo in the Plot Gallery app. You need to convert the date value to numeric values and use those for the x-values instead of the data index. Be sure to...
By default the axes always cross at (0, 0), which is far below the starting location of the yRange (9,000). The large bottom padding pushes the graph up so that y = 0 is visible, although with a large empty space below the graph. You have several options: Use axisConstraints...
This is what I used for such situation: @property (nonatomic, retain) CPTScatterPlot *myLine; @property (nonatomic, retain) CPTGraph *graph; -(void) configureHorizontalLine { // 1 - Create plot space CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) self.graph.defaultPlotSpace; // 2 - Create the plot self.myLine = [[CPTScatterPlot alloc] init]; self.myLine.dataSource = self; self.myLine.identifier = @"myLine";...
Add "alpha" (transparency) to the color: CPTColor *color = [[CPTColor redColor] colorWithAlphaComponent:0.1]; ...
I too tested your code -(void)viewDidLoad { UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTap)]; [longPressGesture setMinimumPressDuration:1]; [self.tempView addGestureRecognizer:longPressGesture]; [self.tempView setUserInteractionEnabled:YES]; } -(void)longTap { NSLog(@"tapped"); } my longTap method is getting called... If your stil not working ,you could provide more code so I could have more look in it for...
Configure the labelFormatter on the y-axis to add the currency symbol. NSNumberFormatter gives you many options. You need to add padding on the plot area frame to leave room for the labels, e.g., graph.plotAreaFrame.paddingLeft = 50.0;....
The plot data is sorted from left to right. Find the data points on either side of the green line. It's trivial to determine which one is closer to the line. A simple linear search is fine if you don't have a lot of data. Use something more efficient like...
ios,objective-c,core-plot,uicolor
CTPColor has a property which allows you to obtain a UIColor object from itself. Assuming your CTPColor object is called myColor: UIColor myUiColor = myColor.uiColor; This can be found really easily by checking out the documentation for CTPColor, found here. Documentation is written for a reason! Hope this helps!...
Foundry's answer is great if you use Cocoapods, but I'll will provide you a step-by-step guide to do it manually : Create a folder named Workspace, and create a new "testCoreplot" project in it from within Xcode. Download CorePlot, and copy the "Source/framework" folder into your workspace folder. Rename it...
ios,cocoa-touch,core-plot,nsnumberformatter
The answer is to set the label formatter on the axis. From a quick look at the documentation for NSNumberFormatter, it seems you should be able to do what you're looking for with a combination of setPositiveFormat, setMultiplier, and setPositiveSuffix. Something like: NSNumberFormatter *labelFormatter = [[NSNumberFormatter alloc] init]; [labelFormatter setPositiveFormat:@"#.##"];...
This is fixed in later Core Plot releases. Release 1.5.1 has been out since March 2014.
calayer,core-plot,cabasicanimation
The issue was that I had the collapsesLayers property on my CPTGraphHostingView set to YES. Setting it to NO fixed the issue.
(Answering the question based on comments above) Save a copy of each dataset separately. It looks like the calculated plot data gets overwritten each time you call -getDataForPlot1:. Also, set a unique identifier for each plot so the datasource can know which one is requesting data....
You can configure a graph to bounce back if the user pulls the plot past the global plot range (set allowsMomentum to YES on the plot space). However, this doesn't give you enough control of the bounce to pause it and display the spinner that is normally displayed during the...
ios,objective-c,uiimage,core-plot
Use a plot space annotation: CPTBorderedLayer *imageLayer = [[CPTBorderedLayer alloc] initWithFrame:imageFrame]; imageLayer.fill = [CPTFill fillWithImage:[CPTImage imageNamed:@"image.png"]]; NSArray *plotPoint = @[xCoordinate, yCoordinate]; CPTPlotSpaceAnnotation *imageAnnotation = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:plotSpace anchorPlotPoint:plotPoint]; imageAnnotation.contentLayer = imageLayer; ...