The need to display a graph of some kind comes up surprisingly often when developing applications. Because of this, for almost every language and framework under the sun, there is some sort of graphing/plotting library (and sometimes a lot more than just one). While there is no built in library for graphing for iPhone applications, there is an open source library called Core Plot. This library is under active development and can be used to create a number of different types of graphs - if you want, you can check our their example page here.
Today we are going to be taking a look at how to get this library into your iPhone application, as well as how to use it to create a simple plot. But before we can do anything, first you have to go get the source for Core Plot. Because the library is still relatively new and under quick active development, there are no packages available - you have to get the source code straight from Core Plot's repository. So as a first step, you probably need to install Mercurial. Once you have that, getting the source is a simple matter of the following command:
hg clone http://core-plot.googlecode.com/hg/ core-plot
That last argument (in our case here core-plot) is the directory you
want to check the code out to. Ok, now that we have the code, what do we
do? Well, let's get an iPhone Xcode project going! For this tutorial,
our project is going to be named "SOTC-CorePlotTest". The first thing to
do after you get an Xcode project off the ground is drag the
CorePlot-CocoaTouch.xcodeproj file from the core-plot/framework
directory into your new project. When you do that, you will get the
following dialog:

The defaults are fine - most of the time we don't want to copy the
entire library into your project - we just want a reference to wherever
you checked our core-plot. So leave "Copy items into destination
group's folder" unchecked. One you click "Add" on this dialog, an entry
for CorePlot-CocoaTouch.xcodeproj will show up the "Groups & Files"
tree for your project:

Because the iPhone core-plot is a static library, it needs to be linked
with your application. To do this, you need to grab the entry
libCorePlot-CocoaTouch.a from the "Groups & Files" (it is a child of
the CorePlot-CocoaTouch.xcodeproj entry) and drag it to "Link Binaries
with Libraries" node in your application's target:

Now we have to tell Xcode that our application is dependent on the core
plot library - that way the library gets built when we build our app.
This is done in the settings window for the application target. Under
the "General" tab, you can add CorePlot-CocoaTouch as a direct
dependency:

But don't think we are done yet! Now we have to modify some build
settings. You do this by going to the "Build" tab of the project
settings (not the build tab of the settings widow you were just in -
those were build settings for the target). In here there are two
properties that we have to modify: "Header Search Paths" and "Other
Linker Flags". There are a lot of properties, but fortunately Apple
gives us a little filter box to find the properties that we want. So
first, "Header Search Paths". Here we need to add the full path to the
core-plot/framework directory:

Then we need to add the -ObjC linker flag, which causes the linker to
"Loads all members of static archive libraries that define an Objective
C class or a category". We need this flag because Core Plot uses
Objective C categories on existing classes, and when compiling against
it as a static library, the code for the categories is not linked into
the final executable. This flag forces that code to be included.

Ok, we are almost done with all this configuration - just one more step.
We have to add the built in Core Animation library to our project,
because Core Plot is built on top of Core Animation. To do this, you add
the QuartzCore framework to the project. Right click on the Frameworks
folder in the "Groups & Files" tree and choose Add->Existing Framework
and browse for QuartzCore:

Whew! We are finally set to actually start using Core Plot. If you created a simple window project when you started, you probably have an AppDelegate and a ViewController class in your classes folder (mine here are "CorePlotTestAppDelegate" and "CorePlotTestViewController"). We aren't going to worry about the AppDelegate class today - all the code we are going to write will be in the ViewController. So start off by pulling up the .h file for your controller (in my case "CorePlotTestViewController.h"). It probably looks something like this at the moment:
#import <UIKit/UIKit.h>
@interface CorePlotTestViewController : UIViewController
{
}
@end
Not much will change in this file, but there are a few things we are going to need to add:
#import <UIKit/UIKit.h>
#import "CorePlot-CocoaTouch.h"
@interface CorePlotTestViewController : UIViewController <CPPlotDataSource>
{
CPXYGraph *graph;
}
@end
First off, we need to reference the Core Plot libraries with an import
statement. Since this is an iPhone application, we pull in the
"CocoaTouch" version of the header file. Now that we have that, we can
make the other two changes - an instance variable (to hold our graph)
and a protocol. The variable is self explanatory, but the protocol
probably needs some explanation. In this case, this view controller is
going to be the data source for our graph, and so it has to implement
the protocol CPPlotDataSource. This protocol is defined in Core Plot
and consists of two functions:
@protocol CPPlotDataSource <NSObject>
-(NSUInteger)numberOfRecords;
@optional
// Implement one of the following
-(NSArray *)numbersForPlot:(CPPlot *)plot
field:(NSUInteger)fieldEnum
recordIndexRange:(NSRange)indexRange;
-(NSNumber *)numberForPlot:(CPPlot *)plot
field:(NSUInteger)fieldEnum
recordIndex:(NSUInteger)index;
-(NSRange)recordIndexRangeForPlot:(CPPlot *)plot
plotRange:(CPPlotRange *)plotRect;
@end
Well, four functions actually, but you only have to implement two of
them. The first one is a getter for the number of data points on the
plot (numberOfRecords), and the last three (of which you need to
implement one) are functions for getting the specific value for a
particular data point.
Ok, that is it for talking about our ViewController header file - but
before we move on to the actual implementation, we have to do one other
thing. A core plot graph cannot be hosted in just any UIView - it has to
be hosted in a CPLayerHostingView. To get this to happen we have to
change the base type of our view. So pull open the xib file for the view
for this view controller, and change the base type of the view to
CPLayerHostingView in the Identity Inspector:

Finally, some implementation code! We will start off with the implementation of the protocol you saw above. In our case we will actually be drawing two plots on one graph - one being the function x\^2, and the other being 1/x:
-(NSUInteger)numberOfRecords {
return 51;
}
-(NSNumber *)numberForPlot:(CPPlot *)plot
field:(NSUInteger)fieldEnum
recordIndex:(NSUInteger)index
{
double val = (index/5.0)-5;
if(fieldEnum == CPScatterPlotFieldX)
{ return [NSNumber numberWithDouble:val]; }
else
{
if(plot.identifier == @"X Squared Plot")
{ return [NSNumber numberWithDouble:val*val]; }
else
{ return [NSNumber numberWithDouble:1/val]; }
}
}
For these plots, I am explicitly returning 51 data points spread over
the x range -5 to 5. In a real application the data would probably be
coming from somewhere, like a file or user input, but here we are just
graphing functions. When numberForPlot is called, I take the data
point index passed in and transform it to an x value between -5 and 5.
If the function was called asking for the X value (when fieldEnum is
CPScatterPlotFieldX), I just return it. Otherwise, depending on the
the identifier of the plot, I return the value either squared or
inverted.
So that takes care of generating data for the graph. Now we need to take care of the creation of the graph itself:
- (void)viewDidLoad {
[super viewDidLoad];
graph = [[CPXYGraph alloc] initWithFrame: self.view.bounds];
CPLayerHostingView *hostingView = (CPLayerHostingView *)self.view;
hostingView.hostedLayer = graph;
graph.paddingLeft = 20.0;
graph.paddingTop = 20.0;
graph.paddingRight = 20.0;
graph.paddingBottom = 20.0;
If you remember from the header file, graph is a instance variable,
and here we are finally populating it. Here we are creating a
CPXYGraph (currently the only type of graph Core Plot offers), and
then setting it as the hosted layer in our view (which is actually a
CPLayerHostingView thanks to the change in the xib file earlier). We
also set some padding here to give the graph some space on the screen.
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-6)
length:CPDecimalFromFloat(12)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-5)
length:CPDecimalFromFloat(30)];
A Core Plot graph can have many PlotSpaces. A PlotSpace is where
individual plots live - but all plots in a plot space share the same
range. In this case, we only need one PlotSpace, so we grab the
default one. Here we are setting the x and y range of the plot space -
one thing to note is that range is set in terms of position and length,
not minimum and maximum values.
CPLineStyle *lineStyle = [CPLineStyle lineStyle];
lineStyle.lineColor = [CPColor blackColor];
lineStyle.lineWidth = 2.0f;
axisSet.xAxis.majorIntervalLength = [NSDecimalNumber decimalNumberWithString:@"5"];
axisSet.xAxis.minorTicksPerInterval = 4;
axisSet.xAxis.majorTickLineStyle = lineStyle;
axisSet.xAxis.minorTickLineStyle = lineStyle;
axisSet.xAxis.axisLineStyle = lineStyle;
axisSet.xAxis.minorTickLength = 5.0f;
axisSet.xAxis.majorTickLength = 7.0f;
axisSet.xAxis.axisLabelOffset = 3.0f;
axisSet.yAxis.majorIntervalLength = [NSDecimalNumber decimalNumberWithString:@"5"];
axisSet.yAxis.minorTicksPerInterval = 4;
axisSet.yAxis.majorTickLineStyle = lineStyle;
axisSet.yAxis.minorTickLineStyle = lineStyle;
axisSet.yAxis.axisLineStyle = lineStyle;
axisSet.yAxis.minorTickLength = 5.0f;
axisSet.yAxis.majorTickLength = 7.0f;
axisSet.yAxis.axisLabelOffset = 3.0f;
In this large chunk of code, we are setting up various axes properties (all of which are pretty much self explanatory). There are already a huge number of properties that you can set on axes, and that number is only going to grow as Core Plot continues to improve.
Finally, let's add some plots:
CPScatterPlot *xSquaredPlot = [[[CPScatterPlot alloc]
initWithFrame:graph.defaultPlotSpace.bounds] autorelease];
xSquaredPlot.identifier = @"X Squared Plot";
xSquaredPlot.dataLineStyle.lineWidth = 1.0f;
xSquaredPlot.dataLineStyle.lineColor = [CPColor redColor];
xSquaredPlot.dataSource = self;
[graph addPlot:xSquaredPlot];
CPPlotSymbol *greenCirclePlotSymbol = [CPPlotSymbol ellipsePlotSymbol];
greenCirclePlotSymbol.fill = [CPFill fillWithColor:[CPColor greenColor]];
greenCirclePlotSymbol.size = CGSizeMake(2.0, 2.0);
xSquaredPlot.defaultPlotSymbol = greenCirclePlotSymbol;
CPScatterPlot *xInversePlot = [[[CPScatterPlot alloc]
initWithFrame:graph.defaultPlotSpace.bounds] autorelease];
xInversePlot.identifier = @"X Inverse Plot";
xInversePlot.dataLineStyle.lineWidth = 1.0f;
xInversePlot.dataLineStyle.lineColor = [CPColor blueColor];
xInversePlot.dataSource = self;
[graph addPlot:xInversePlot];
}
In both cases we are creating scatter plots (CPScatterPlot), although
there are other XY plot types (such as CPBarPlot). The key thing here
is the setting of the dataSource property - you have to set that
property to whatever object is going to provide data for that plot
(i.e., the one that implemented the CPPlotDataSource protocol). In
this case, it is the controller itself, so we just put self. For the
inverse plot, all we do is color the line blue, but for the squared plot
we do a little bit extra. The scatter plot allows for markers to be put
at data points, and so in this case we have a small green circle at
every point.
Well, that is it! You want to see what all this work looks like? If you were coding along, you could just hit "Go", but for those that weren't, here is a screenshot:

Because that viewDidLoad function is spread across a couple code
blocks and probably hard to just read (or copy), here is the
CorePlotTestViewController.m file in one block:
//
// CorePlotTestViewController.m
// CorePlotTest
//
#import "CorePlotTestViewController.h"
@implementation CorePlotTestViewController
- (void)viewDidLoad {
[super viewDidLoad];
graph = [[CPXYGraph alloc] initWithFrame: self.view.bounds];
CPLayerHostingView *hostingView = (CPLayerHostingView *)self.view;
hostingView.hostedLayer = graph;
graph.paddingLeft = 20.0;
graph.paddingTop = 20.0;
graph.paddingRight = 20.0;
graph.paddingBottom = 20.0;
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-6)
length:CPDecimalFromFloat(12)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-5)
length:CPDecimalFromFloat(30)];
CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;
CPLineStyle *lineStyle = [CPLineStyle lineStyle];
lineStyle.lineColor = [CPColor blackColor];
lineStyle.lineWidth = 2.0f;
axisSet.xAxis.majorIntervalLength = [NSDecimalNumber decimalNumberWithString:@"5"];
axisSet.xAxis.minorTicksPerInterval = 4;
axisSet.xAxis.majorTickLineStyle = lineStyle;
axisSet.xAxis.minorTickLineStyle = lineStyle;
axisSet.xAxis.axisLineStyle = lineStyle;
axisSet.xAxis.minorTickLength = 5.0f;
axisSet.xAxis.majorTickLength = 7.0f;
axisSet.xAxis.axisLabelOffset = 3.0f;
axisSet.yAxis.majorIntervalLength = [NSDecimalNumber decimalNumberWithString:@"5"];
axisSet.yAxis.minorTicksPerInterval = 4;
axisSet.yAxis.majorTickLineStyle = lineStyle;
axisSet.yAxis.minorTickLineStyle = lineStyle;
axisSet.yAxis.axisLineStyle = lineStyle;
axisSet.yAxis.minorTickLength = 5.0f;
axisSet.yAxis.majorTickLength = 7.0f;
axisSet.yAxis.axisLabelOffset = 3.0f;
CPScatterPlot *xSquaredPlot = [[[CPScatterPlot alloc]
initWithFrame:graph.defaultPlotSpace.bounds] autorelease];
xSquaredPlot.identifier = @"X Squared Plot";
xSquaredPlot.dataLineStyle.lineWidth = 1.0f;
xSquaredPlot.dataLineStyle.lineColor = [CPColor redColor];
xSquaredPlot.dataSource = self;
[graph addPlot:xSquaredPlot];
CPPlotSymbol *greenCirclePlotSymbol = [CPPlotSymbol ellipsePlotSymbol];
greenCirclePlotSymbol.fill = [CPFill fillWithColor:[CPColor greenColor]];
greenCirclePlotSymbol.size = CGSizeMake(2.0, 2.0);
xSquaredPlot.defaultPlotSymbol = greenCirclePlotSymbol;
CPScatterPlot *xInversePlot = [[[CPScatterPlot alloc]
initWithFrame:graph.defaultPlotSpace.bounds] autorelease];
xInversePlot.identifier = @"X Inverse Plot";
xInversePlot.dataLineStyle.lineWidth = 1.0f;
xInversePlot.dataLineStyle.lineColor = [CPColor blueColor];
xInversePlot.dataSource = self;
[graph addPlot:xInversePlot];
}
-(NSUInteger)numberOfRecords {
return 51;
}
-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum
recordIndex:(NSUInteger)index
{
double val = (index/5.0)-5;
if(fieldEnum == CPScatterPlotFieldX)
{ return [NSNumber numberWithDouble:val]; }
else
{
if(plot.identifier == @"X Squared Plot")
{ return [NSNumber numberWithDouble:val*val]; }
else
{ return [NSNumber numberWithDouble:1/val]; }
}
}
@end
Hope you found this intro to Core Plot useful! While it is still quite young as a plotting framework, it has a lot of potential (especially since it is the first one for the iPhone). You can grab a zip file below that holds the Xcode project we built today, if you want to try it out for yourself (although you will have to grab the core plot source separately - I did not include them).
Source Files:
Theres a problem with the build. coreplot.h uses wrong folder directory for its includes (the folder is source and it writes CorePlot) Also, when I build and go the app stops in debug mode and I get EXC_BAD_ACCESS. It may be due to the app I put it in. I had a project already started it is a cocoa app I made with the apple tutorial and it had a main already would that generate the error?. It would be nice to show what kind of project to start it in if its better to start with a new project and maybe to specify what to do with the main.
I actually had to put coreplot.hg like it was for the examples I ran.
I also had to transfer some files from the iphoneOnly folder to the Source folder.
BTW, i was doing all the same steps but for a mac application and I changed all the iphone names for mac names
Sorry for the newbie question: What kind of mac osx application xcode project did you start out with to start integrating these changes to get it working on the mac rather than the iphone?
The following line does not work...it seems defaultPlotSymbol has been removed from the latest Core-plot release:
xSquaredPlot.defaultPlotSymbol = greenCirclePlotSymbol;
concerning that same last comment.
There are 2 problems with this. its a pointer not a var so -> should be used and secondly defaultPlotSymbol doesnt exist....only plotSymbols.
Me again sorry.....plotSymbol being protected with getter setter methods i put this line instead :
[xSquaredPlot setPlotSymbol:greenCirclePlotSymbol];
and finally im getting these warnings:
warning: incomplete implementation of class 'CorePlotTestViewController' warning: method definition for '-numberOfRecordsForPlot:' not found warning: class 'CorePlotTestViewController' does not fully implement the 'CPPlotDataSource' protocolThis is all with you example on the iphone simulator. The application still launches but I get a crash asking to send to apple
Me again, after commenting all the code in the controlller method no more crashes but of course my screen is white so something in the code is doing it.....By the way I liked your tutorial though I learned to link static libs with it :)...dont want to be too negative for nothing
Sorry about the compile-time problems you're having. That's the problem with a framework at this stage, the APIs tend to change rapidly. In the case of the warning you're getting, you'll need to change
[language] -(NSUInteger)numberOfRecords { [/language]
in the above code to the new
[language] -(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot { [/language]
definition.
The white screen you're seeing may be due to the fact that the delegate method is missing and therefore won't report back how many data points need to be plotted.
If you have additional questions, I recommend posting them to the Google Group for this project at http://groups.google.com/group/coreplot-discuss?hl=en
Thanks for the response Brad, we will quickly get the tutorial above updated. You guys are doing an awesome job at really kicking some programming tail on core plot, keep it up.
I am having exactly the same issues as the last post, any ideas???
I'm getting the following; any ideas? I think i set the paths right.
Building target “CorePlotTest” of project “CorePlotTest” with configuration “Debug” — (1 error, 3 warnings) /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m: In function '-[CorePlotTestViewController viewDidLoad]': /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m:60: error: request for member 'defaultPlotSymbol' in something not a structure or union /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m: At top level: /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m:87: warning: incomplete implementation of class 'CorePlotTestViewController' /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m:87: warning: method definition for '-numberOfRecordsForPlot:' not found /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m:87: warning: class 'CorePlotTestViewController' does not fully implement the 'CPPlotDataSource' protocol /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m:60: error: request for member 'defaultPlotSymbol' in something not a structure or union /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m: At top level: /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m:87: warning: incomplete implementation of class 'CorePlotTestViewController' /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m:87: warning: method definition for '-numberOfRecordsForPlot:' not found /Developer/upstat/core-plot/CorePlotTest/Classes/CorePlotTestViewController.m:87: warning: class 'CorePlotTestViewController' does not fully implement the 'CPPlotDataSource' protocol Build failed (1 error, 3 warnings)
See Brad's comment above - the CPPlotDataSource protocol has changed since I wrote this tutorial. I haven't tried to build against the latest code yet, so I don't know exactly what you have to do to fix it. But if you look at the protocol definition, it should be pretty obvious.
I tried adding core-plot to my project using the steps above and these are the errors I"m getting
The compiling erros:
CorePlotProbes.h:No such file or directory warnings: implicit declaration of function 'COREPLOT_LAYER_POSITION_CHANGE_ENABLED' warnings:'CPLayer may not respond to '-className'
And for Linking errors: i686-apple-darwin9-gcc-4.2.1: /Users/fn/Documents/iPhone/core-plot/framework/build/Debug-iphonesimulator/libCorePlot-CocoaTouch.a: No such file or directory
Any ideas?
Farhad: You need to update from the repository, there was some dtrace stuff missing in the .xcodeproj file.
I get the same warning about "may not respond to '-className' and since warnings are treated like errors per configuration default, you should go and change that setting in the core-plot cocoa touch project file.
Another issue I'm having:
is throwing an error, complaining axisSet would be undeclared (which is true, but why is it missing in the tutorial?)
nvm, solution is to add:
right before the problem...
in the simulator works but on the real one not: any idea? the error is: GDB: Program received signal: "SIGABRT"
The problem is in this line:
layerHost.hostedLayer= graph;
Console throws:
*** -[NSDecimalNumber isGreaterThanOrEqualTo:]: unrecognized selector sent to instance 0x101680 2009-08-05 12:33:05.416 ChecarPlazas[1908:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSDecimalNumber isGreaterThanOrEqualTo:]: unrecognized selector sent to instance 0x101680' 2009-08-05 12:33:05.506 ChecarPlazas[1908:207] Stack: (
But in the simulator everything is OK...
Problem solved:
add the next flag to the Linker:
-all_load
suerte carnales!!
Lazio,
Thanks for that fix. Core Plot is not working on my iPhone. As I try to become more skilled in Objective C coding, I'd like to understand how you figured out that fix? Can you guide us through the steps to determine the all_load flag was missing? It seems random but I am sure it's not.
Thanks, Amit
These are the errors I keep receiving when trying to compile:
Line Location MainWindow.xib:3: The 'window' outlet of 'Layer Hosting View' is connected to 'Window' but 'window' is no longer defined on CPLayerHostingView.
Line Location CPLayer.h:3: error: CPPlatformSpecificDefines.h: No such file or directory Line Location CPPlatformSpecificCategories.h:3: error: CPLayer.h: No such file or directory
I'm getting similar issues.. is there a resolution for this?
I found my problem. I didn't make the include path recursive
I'm having major issues just compiling the example code supplied in the zip file. I've downloaded core plot source and made sure all header search paths are correct. Anyone help!? Are you using The Simulator as the SDK?
Building target “CorePlot-CocoaTouch” of project “CorePlot-CocoaTouch” with configuration “Debug” — (1 error) Checking Dependencies error: There is no SDK with specified name or path 'Unknown Path' error: There is no SDK with specified name or path 'Unknown Path' Build failed (1 error)
I'm getting the same errors as the person above...
Building target “CorePlot-CocoaTouch” of project “CorePlot-CocoaTouch” with configuration “Debug” — (1 error) Checking Dependencies error: There is no SDK with specified name or path 'Unknown Path' error: There is no SDK with specified name or path 'Unknown Path' Build failed (1 error)
I'm sure I'm being dumb but could someone please set us straight?
Thank you!
Chris.
Forget it. I figured it out. I skipped a step in the tutorial set-up.
Thanks!
Which step did you skip? The other guys might have skipped the same step.
Good point...
You know, I'm not sure. I only assumed I did 'cause I went back and followed the tutorial's setup carefully from scratch and it worked. I'm known (worldwide) for skimming through the manual and getting all messed up :)
I have another question though:
Has anyone seen the view invert when closing the example app running in the iPhone simulator? I'm actually seeing it in all the example iPhone projects. Anyone know what the deal is there? I love the API, but, I'm not sure I want to use it in my apps unless I can get that (very minor) issue resolved. For all I know, it's something I'm doing, but, I don't think so as I didn't edit any of the code...BTW - I'm using the 2.2.1 SDK.
Great Job, Guys!
Chris.
Chris if you can please figure out what you changed that would help a ton! I've followed the tutorial about 5 times now. I get different errors whether I use the Simulator, Project Settings, or Debug vs. Release modes to build and Go.
If I use Simulator and Debug, my first error is: error: CPPlatformSpecificDefines.h: No such file or directory error: CPLayer.h No such file or directory.
Help Please!!!
OK...
Here's what I did, exactly...
?1) installed Mercurial (http://www.selenic.com/mercurial/wiki/) 2) Cloned the code base (hg clone http://core-plot.googlecode.com/hg/ core-plot) 3) Grabbed the Sample Project from this Tutorial (http://www.switchonthecode.com/sites/default/files/713/source/SOTC-CorePlotTest.zip) 4) Went through the tutorial step by step. Obviously (or maybe not), the tutorial project is setup to use paths to the core-plot installation location on the tutorial developer's machine. I installed the core-plot framework at /Users/mycompname/ so when I added/edited the compiler flags I referenced my install location. (e.g. the HEADER_SEARCH_PATHS = /Users/mycompname/core-plot/framework/**) w/ recursive setting ON).
My dev envorinment looks like this: computer - intel MacBook pro (5 months old) iPhone SDK - 2.2.1 Project Target - iPhone Simulator 2.2.1 DEBUG
I don't know what else to say.
It sounds like your paths are setup all the way. Especially since you get different errors for different targets...as unless you have identical global project/target settings for all you builds.
I hope this helps you. I know how frustrating this can be.
My suggestion is to start from scratch. Do what I outlined (with very special attention paid to following the tuorials step for edit the settings for the TARGET and the PROJECT...they're very different). Do that and get back to us/me...we'll get you sorted out...then you can help the next guy/gal :)
Peace and cars that run on chicken grease!
Chris.
Hi!
I was getting this same error. But doing the recursive thing (and paying attention to the TARGET and PROJECT settings) got me going....to the next error (which is better than nothing).
I imported "CorePlot-CocoaTouch.h" in my ViewController, and now I am getting the following error: "CorePlot-CocoaTouch.h: No such file or directory"
I am at a lost... Can you help? Thanks in Advance!
You forgot to tick the "Recursive" checkbox when you added the path to core-plot in the "Header Search Paths" in the build properties.
Where's that box?? wich setting takes with value in the Project Info window??? THANKS!
I meant = "It sounds like your paths AREN'T setup all the way."
Interface Builder error.
I did not set the class name of the view correctly. Fat fingered CPlayer instead of CPLayer...
If you see that error, you know where to go.
im still getting this error...im unable to set up the view outlet in the Layer Hosting View (view) to the FIle's Owner outlet and vv...it just wont let me...why?
if you add .h files from core-plot to your project you will not have this crash
Great job!!! Thank you. It works with a few modifications. Complete code looks like this:
[objc] -(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot{ return 51; }
-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index { double val = (index/5.0)-5; if(fieldEnum == CPScatterPlotFieldX) { return [NSNumber numberWithDouble:val]; } else { if(plot.identifier == @"X Squared Plot") { return [NSNumber numberWithDouble:val*val]; } else { return [NSNumber numberWithDouble:1/val]; } } }
[xSquaredPlot setPlotSymbol:greenCirclePlotSymbol]; CPScatterPlot *xInversePlot = [[[CPScatterPlot alloc] initWithFrame:graph.defaultPlotSpace.bounds] autorelease]; xInversePlot.identifier = @"X Inverse Plot"; xInversePlot.dataLineStyle.lineWidth = 1.0f; xInversePlot.dataLineStyle.lineColor = [CPColor blueColor]; xInversePlot.dataSource = self; [graph addPlot:xInversePlot]; } [/objc]
Nice tutorial...thanks!
Hello,
I have got 2 errors when i try to compile :
* for x and y axis axisSet.xAxis.majorIntervalLength = [NSDecimalNumber decimalNumberWithString:@"5"]; --> error : incompatible type for argument 1 of 'setMajorIntervalLenght'
axisSet.yAxis.majorIntervalLength = [NSDecimalNumber decimalNumberWithString:@"5"]; --> error : incompatible type for argument 1 of 'setMajorIntervalLenght'
Anyway I commented out these two lines to test. The build succed but unfortunatly when i run the app it gives me the following error :
dyld: Library not loaded: /System/Library/Frameworks/UIKit.framework/UIKit Referenced from: /Users/yyy/iphone/testCorePlot/build/Debug-iphonesimulator/testCorePlot.app/testCorePlot Reason: image not found
I'm new at objective-c and xcode it's certainly a simple step i forgot (i hope), so if someone has an idea i will be very happy \^\^
regards
Just call the decimalValue method:
thank you gfwalters for reply but i found another way on core-plot google group discuss (http://groups.google.com/group/coreplot-discuss/browse_thread/thread/b4ccaedad834eb9e) there are a lot of information here.
axisSet.xAxis.majorIntervalLength = CPDecimalFromFlot(5.0);
it works for me :)
This info helped me get Core Plot working in my OS X test app which had this same error. Just leaving it here for others to find.
http://lists.apple.com/archives/Applescriptobjc-dev/2010/May/msg00032.html
Summary of what I did to get this to work on both the simulator and the device: http://alanduncan.net/index.php?q=node/22
Hi Alan,
How can i customize the axis label.
I want to have the month name (Jan, Feb, Mar...) & so on in the X-Axis. When i set the axisLabelingPolicy is equal to CPAxisLabelingPolicyNone & try to create my own axis labels, I get the following error Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray allObjects]: unrecognized selector sent to instance 0xe9b6c0'.
>axisSet.xAxis.majorIntervalLength = CPDecimalFromFlot(5.0);
Should be,
axisSet.xAxis.majorIntervalLength = CPDecimalFromFloat(5.0);
Got it working in the simulator now and will try it on the device shortly.
Yeah - the "-all_load" flag made it run on the device too. :)
Hi Brad et al. Thanks for your tutorial. It was very helpful and descriptive. I got the basic plot feature working on the iphone simulator. Could anyone point out how I could possibly integrate thse changes to create an interactive plotting application on the mac using the core plot framework? TIA, cheers!
Hi, I have study this example and work fine, only my problem is that label not appear in te axis, why? thanks for all
can i write a word like @"ABC" on the core-plot graph?
if use core-plot example ex.CPTestApp-iPhone
can i write words on the graph?
or can i create a label on th graph?
please teach me!!
thanks!!
Hi,
Has anyone encountered this error when compiling?
Thanks everyone!
You might want to check that you have not included both MacOS and iPhone specific headers in the header search path.
You've mentioned that you can include multiple PlotSpaces in a single plot. How do I assign a second PlotSpace to a single graph? Right now I only have access to the default PlotSpace.
Hi,
I'm getting this error.
/Users/xxxx/XcodeProject/SOTC-CorePlotExample/SOTC_CorePlotExampleViewController.xib:-1:0 The 'view' outlet of 'File's Owner' is connected to 'Layer Hosting View' but 'CPLayerHostingView' is not a kind of 'UIView' as specified by the outlet type.
Help please!
Thank you!
In the CPTestApp, ive started coding it from scratch for my own use. All is fine, but it crashes saying Unknown Class CPLayerHostingView in IB, [UIView setHostedLayer:] unrecognized selector.
In IB, i can see that the MainWIndow.xib is fine, everything identical, set up properly. But in the individual xib files, for each individual UIView, the view outlet is connected to files owner but in yellow and the alert reads:
The view outlet of Files Owner is connected to Layer Hosting View but CPLayerHostingView is not a kind of UIView as specified by the outlet type...
any ideas? Ive tried starting the file from scratch again but i get the same error.
i got it to work....ok, i added the -all_load -ObjC flag in the Target>Settings....I think this is where everyone gets confused...
There are 2 places where to put the other link and header search paths, in Project Settings and in Target Settings...I found these following things confusing:
?1) where to add the Header Search Paths &IF Recursive or not &IF framework/ &OR framework/iPhoneonly &OR framework/Source &IF to check Always Search User Paths or not. 2) where to add the Other Links &IF to check Link with Std Libraries or Not
thx mars www.santiapps.com
Has anyone figured out this issue:
/Users/ghegazi/Documents/SOTC_CorePlotTest/SOTC_CorePlotTestViewController.xib:-1:0 The 'view' outlet of 'File's Owner' is connected to 'Layer Hosting View' but 'CPLayerHostingView' is not a kind of 'UIView' as specified by the outlet type.
I got everything else right.
I download the code, and run it on my mac.
I got the following errors: error: incompatible type for argument 1 of 'setMajorIntervalLength:' error: request for member 'axisLabelOffset' in something not a structure or union error: incompatible type for argument 1 of 'setMajorIntervalLength:' error: incompatible type for argument 1 of 'setMajorIntervalLength:' and etc 7 errors. Anyone have any ideas what's going wrong here??
Try: // axisSet.xAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue]; axisSet.xAxis.majorIntervalLength = CPDecimalFromFloat(5.0); And // axisSet.xAxis.axisLabelOffset = 3.0f; axisSet.xAxis.labelOffset = 3.0f;
Ali in all; to get the copy I downloaded working:
// axisSet.xAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue]; axisSet.xAxis.majorIntervalLength = CPDecimalFromFloat(5.0); axisSet.xAxis.minorTicksPerInterval = 4; axisSet.xAxis.majorTickLineStyle = lineStyle; axisSet.xAxis.minorTickLineStyle = lineStyle; axisSet.xAxis.axisLineStyle = lineStyle; axisSet.xAxis.minorTickLength = 5.0f; axisSet.xAxis.majorTickLength = 7.0f; // axisSet.xAxis.axisLabelOffset = 3.0f; axisSet.xAxis.labelOffset = 3.0f; axisSet.yAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue]; axisSet.yAxis.minorTicksPerInterval = 4; axisSet.yAxis.majorTickLineStyle = lineStyle; axisSet.yAxis.minorTickLineStyle = lineStyle; axisSet.yAxis.axisLineStyle = lineStyle; axisSet.yAxis.minorTickLength = 5.0f; axisSet.yAxis.majorTickLength = 7.0f; // axisSet.yAxis.axisLabelOffset = 3.0f; axisSet.yAxis.labelOffset = 3.0f; // CPScatterPlot *xSquaredPlot = [[[CPScatterPlot alloc] // initWithFrame:graph.defaultPlotSpace.bounds] autorelease]; CPScatterPlot *xSquaredPlot = [[[CPScatterPlot alloc]initWithFrame: CGRectMake(90, 12, 200, 25)] autorelease]; xSquaredPlot.identifier = @"X Squared Plot"; xSquaredPlot.dataLineStyle.lineWidth = 1.0f; xSquaredPlot.dataLineStyle.lineColor = [CPColor redColor]; xSquaredPlot.dataSource = self; [graph addPlot:xSquaredPlot]; CPPlotSymbol *greenCirclePlotSymbol = [CPPlotSymbol ellipsePlotSymbol]; greenCirclePlotSymbol.fill = [CPFill fillWithColor:[CPColor greenColor]]; greenCirclePlotSymbol.size = CGSizeMake(2.0, 2.0); // xSquaredPlot.defaultPlotSymbol = greenCirclePlotSymbol; xSquaredPlot.plotSymbol = greenCirclePlotSymbol; // CPScatterPlot *xInversePlot = [[[CPScatterPlot alloc] // initWithFrame:graph.defaultPlotSpace.bounds] autorelease]; CPScatterPlot *xInversePlot = [[[CPScatterPlot alloc]initWithFrame: CGRectMake(90, 12, 200, 25)] autorelease]; xInversePlot.identifier = @"X Inverse Plot"; xInversePlot.dataLineStyle.lineWidth = 1.0f; xInversePlot.dataLineStyle.lineColor = [CPColor blueColor]; xInversePlot.dataSource = self; [graph addPlot:xInversePlot]; }
How can i zoom in the graph or relocate the graph ?
I will do it like in the sample code of "CPTestApp-iPhone"
Any ideas ?
Please help.
Great tutorial!
Regarding the header search paths setup, wouldn't it be better to enter a relative path for the framework folder instead of an absolute path? If the folder contains the project- and framework is moved, the search path is still valid.
My app works well inside the simulator but fails if run inside the device. This is the error it raises: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString sizeWithTextStyle:]: unrecognized selector sent to instance 0x407be60'
any idea?
Had same exact issue where the app ran in simulator but not in iPad.
A post above mentions the fix (and thanks as this post save me a bunch of time )...
Add these flags here in XCode 3.2.2 ...
Target>yourApp>GetInfo>Build>Settings>Linking>OtherLinkerFlags
-all_load -ObjC
VERY IMPORTANT: Make the search path recursive as mentioned by ErikCJordan
/Users/me/Documents/workspace/core-plot/framework//
Yes...thats two forward slashes followed by two stars
hey im getting 2 errors saying this
error: CorePlot-CocoaTouch.h: No such file or directory error: CorePlot-CocoaTouch.h: No such file or directory
any idea's
I did several times, everything what creator and others wrote in this tutorial, but i'm stil getting error: CorePlot-CocoaTouch.h: No such file or directory Can anyone help me, what can be the problem?
I can import the .h file like this: [language] #import "/Users/atee/Documents/core- plot/framework/CorePlot-CocoaTouch.h" [/language] But then the compiler still have problem with CorePlot-CocoaTouch.h, its importing 61 headers, but the compiler cant find them.Please, help me!
I have the solution! you should verify that you set the "Header Search Paths" and "Other Linker Flags" for "All Configurations". There's a dropdown menu under the "Build" tab in the "Project Info". It takes 8 hours from my life! :)
Hi,
I am getting the error " CorePlot-CocoaTouch.h: No such file or directory". I have kept the coreplot0.2.2 folder in the desktop. I used the following path for set header path. "/Users/Giri/Desktop/iPhoneGraph/CorePlot 0.2.2/Source/framework".
is it correct ? please Help Me. Thanks in advance.
Thanks Sean you helped me
I recently updated my app to use the latest version of core-plot and started getting these errors:
Syntax error before '\^' token and 'type name' declared as function returning a function.
I also see this warning '__IPHONE_OS_VERSION_MIN_REQUIRED' redefined - any thoughts or ideas are appreciated
I updated to alpharelease-0.1
I have the same problem/
with alpharelease-0.1
If you're getting __IPHONE_OS_VERSION_MIN_REQUIRED redefine errors during build, try going into the CorePlot-CocoaTouch project's target and under the Build tab changing the 'iOS Deployment Target' to 'Compiler Default' (or match it with what's in your main app).
The problem seems to come up when the deployment targets for the main app and the core-plot library project are both defined but are mismatched.
HTH
thanks a lot , you're right
So I have created a UITabBar application with 2 view controllers the one is a TableViewController and the second one has to hold a graph drawn with core plot. Everything is ok but my CorePlotView isn't calling it's methods. Any ideas why? I have linked everything in IB but the methods aren't called
I just upgraded my (working) project to iOS4 (upgraded to the latest version of XCode and downloaded the latest version of CorePlot) and I was having a lot of problems similar to the above.
The solution for me: I had to replace all references to CPLayerHostingView to CPGraphHostingView both in my code and in Interface Builder.
Hope that helps someone!
David
Hello i still have some error running this code.If u could send me the Classes files with the Correction u made.Thanks..
Finally it worked for me...Thanks.
Ajit, what did you do to get this working
Thanks for the tutorial. I have a problem. I couldn't change the base type to CPLayerHostingView or CPGraphHostingView. These options were not found in the drop-down list. How to change? Using UIView , i got error.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x622d360'
Someone please help me.
Just Replace the CPLayerHostingView with CPGraphHostingView both in code and the Nib file.That much will do.
Thanks for the reply. I figured it out. The option CPGraphHostingView, was not there in the drop down list of Base Class type in Xib inspector. But I manually typed it and set it. It works fine now.
Hi,
I tried everything that has been said here but I am getting following error
Library not found for -lCorePlot
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
I am using 4.2 compiler and 4.1 iOS
Please help
Thanks,
I am a seriously stumped newbie. I've followed the instructions to the letter, but when I compile (without actually coding ANYTHING yet), I get 69 compiler errors.
The header search paths seem to check out fine, and I made sure it was for "All configurations".
Same with the -all_load -ObjC in Other Linker Flags.
I am using Xcode 3.1-compatible project format, with iOS Device 3.2, and using the iPad Simulator 3.2.
Can someone seriously dumb it down for me? I can muddle my way through creating a graph, if I can just get the thing to compile at the outset. And is there anything special I need to do for the iPad?
http://www.mediafire.com/?4gz9zopm0kbdh30
Its the working copy.Try it and dont forget to change the Framework Location on the Target Setting.
Hi Jimmy, How do we use this code, into our project?
Has anyone encountered this error? I tried running the iPad demo:
CPTestApp-iPad[84:307] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
Hi,
Finally I have got the code working: The only one change that you have to do apart from look into the below code is, in the interface builder use CPGraphHostingView instead of CPLayerHostingView for your view class.
If you want to install the core-plot using sdk and not the way it is described above, then please go over the the following link
http://stackoverflow.com/questions/4146341/core-plot-configuration-error/4173170#4173170
Everything about the installation seem straightforward, except for the part about-
"add the full path to the core-plot/framework directory".
Using Spotlight, I can't find any directory named "core-plot/framework". I've tried various guesses for what this might refer to, but nothing works. I keep getting a build failure of-
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=armv6 armv7).
Any ideas of what I am missing?
After lots of trial and error, I finally got a link to the framework working. The error mentioned above was caused by creating a project for MacOS rather than iOS.
I'm still getting about twenty build errors, even after applying all of the fixes that are mentioned in the above thread. I will keep trying, but perhaps it is time to post a new version of the demo and installation procedures.
Hello, I've been trying to add the core plot library for a while and it is still not working out. I am getting 138 errors. The main error is :
pbxcp: CorePlot-CocoaTouch.h: No such file or directory
I've added the header search path and other linkage stuff but still same errors. My header search path is /Users/moeassi/Downloads/CorePlot_0.2.1/Source/framework and Ive added the -ObjC and -all_load. Please help
I also had this problem. To solve it just make sure the header search path is set as recursive (double click on it and select the "Recursive" option)
Hi,
I was able to compile the code but I am getting an runtime exception, I have given the exception below.
I am using IOS 4.2, Xcode 3.2.5
Exception:
2010-12-16 10:30:07.156 MyCorePlotTest[9237:207] -[CPMutableNumericData setDataType:]: unrecognized selector sent to instance 0x4c10be0 (gdb) continue 2010-12-16 10:30:08.346 MyCorePlotTest[9237:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPMutableNumericData setDataType:]: unrecognized selector sent to instance 0x4c10be0' *** Call stack at first throw: ( 0 CoreFoundation 0x00f99be9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x010ee5c2 objc_exception_throw + 47 2 CoreFoundation 0x00f9b6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 3 CoreFoundation 0x00f0b366 ___forwarding___ + 966 4 CoreFoundation 0x00f0af22 _CF_forwarding_prep_0 + 50 5 MyCorePlotTest 0x00005d3c -[CPPlot setCachedDataType:] + 288 6 MyCorePlotTest 0x00004ef3 -[CPPlot cacheNumbers:forField:atRecordIndex:] + 226 7 MyCorePlotTest 0x00008309 -[CPScatterPlot reloadDataInIndexRange:] + 312 8 MyCorePlotTest 0x00003d06 -[CPPlot reloadData] + 129 9 MyCorePlotTest 0x00003d4c -[CPPlot reloadDataIfNeeded] + 63 10 CoreFoundation 0x00f102cf -[NSArray makeObjectsPerformSelector:] + 239 11 MyCorePlotTest 0x00012343 -[CPGraph reloadDataIfNeeded] + 70 12 MyCorePlotTest 0x0001f7d3 -[CPLayer layoutAndRenderInContext:] + 147 13 MyCorePlotTest 0x0002c304 -[CPGraphHostingView drawRect:] + 294 14 UIKit 0x0037d6eb -[UIView(CALayerDelegate) drawLayer:inContext:] + 426 15 QuartzCore 0x00d409e9 -[CALayer drawInContext:] + 143 16 QuartzCore 0x00d405ef _ZL16backing_callbackP9CGContextPv + 85 17 QuartzCore 0x00d3fdea CABackingStoreUpdate + 2246 18 QuartzCore 0x00d3f134 -[CALayer _display] + 1085 19 QuartzCore 0x00d3ebe4 CALayerDisplayIfNeeded + 231 20 QuartzCore 0x00d3138b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 325 21 QuartzCore 0x00d310d0 _ZN2CA11Transaction6commitEv + 292 22 UIKit 0x0034819f -[UIApplication _reportAppLaunchFinished] + 39 23 UIKit 0x00348659 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690 24 UIKit 0x00352db2 -[UIApplication handleEvent:withNewEvent:] + 1533 25 UIKit 0x0034b202 -[UIApplication sendEvent:] + 71 26 UIKit 0x00350732 _UIApplicationHandleEvent + 7576 27 GraphicsServices 0x018cfa36 PurpleEventCallback + 1550 28 CoreFoundation 0x00f7b064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 29 CoreFoundation 0x00edb6f7 __CFRunLoopDoSource1 + 215 30 CoreFoundation 0x00ed8983 __CFRunLoopRun + 979 31 CoreFoundation 0x00ed8240 CFRunLoopRunSpecific + 208 32 CoreFoundation 0x00ed8161 CFRunLoopRunInMode + 97 33 UIKit 0x00347fa8 -[UIApplication _run] + 636 34 UIKit 0x0035442e UIApplicationMain + 1160 35 MyCorePlotTest 0x000020f8 main + 102 36 MyCorePlotTest 0x00002089 start + 53 ) terminate called after throwing an instance of 'NSException' Program received signal: “SIGABRT”.
Hey, After editing the code for the current coreplot SDK, I now have 0 errors and 0 warnings. Unfortuantly the simulator dies on startup. The nib name in the .xib is set to CPGraphHostingView and seems to be working.
.h file:
.m file
Any help would be appreciated. Thanks!
Edit/Update:
.m file:
sigh,
I have the following error, even though, I followed all the settings suggested above. Any idea?
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
I followed the instructions on googlecode, and made some changes according to the information I found here. This works for me:
Hope that helps someone.
I am getting a compiler error with the sample code on the following two lines:
xSquaredPlot.dataLineStyle.lineWidth = 1.0f; xSquaredPlot.dataLineStyle.lineColor = [CPColor redColor];
These two lines are repeated 3 times so I get six errors. All six lines get this error:
Object cannot be set - either readonly property or no setter found
What could be causing this?
I'm getting the following error:
Any Idea?
solved it:
Do you have the -all_load flag in your build settings.
following code shows error:
lineStyle.lineColor = [CPColor blackColor]; lineStyle.lineWidth = 2.0f;
xSquaredPlot.dataLineStyle.lineWidth = 1.0f; xSquaredPlot.dataLineStyle.lineColor = [CPColor redColor];
xInversePlot.dataLineStyle.lineWidth = 1.0f; xInversePlot.dataLineStyle.lineColor = [CPColor blueColor];
Object can not be set ..... either read only or no setter found
this error shown because in library their property is set read only which can't be edit.... what is the soln...??
I was seeing the same compile error. THis is because the category that redeclares the property as readwrite is located in the CPLineStyle implementation file (CPLineStyle.m). If you followed the tutorial from the Core Plot site as I did, you added only the Core Plot project to our own app's Xcode project and not all the sources. So, when we build our projects, the compiler knows nothing about what's in the implementation files of the dependent project. I "fixed" this by moving the CPLineStyle category into CPLineStyle.h.
Aslkm Am trying this from last 2 days have u got it .I have the errors #import "coreplot_......h" nosiuch file opr direcory.If u have integrated send me.
Thank u
I am getting CPLayerHostingView undeclared error. Please help me.
Use CPGraphHostingView in place of CPLayerHostingView
Hi. Can I use core-plot with monoDevelop ?
This works for me;
OH SWEET JESUS THANK YOU DEAR GOD. This almost works!
If you're having trouble with this code use the Mutable variety of lineStyle.
I am Using xcode4.0.1. This builds OK without errors. But when I run in the IOS simulator I get 2 errors
-[CPMutableNumericData setDataType:]: unrecognized selector sent to instance 0x4e1ed10
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPMutableNumericData setDataType:]: unrecognized selector sent to instance 0x4e1ed10'
This seems to be coming from an issue in CPPLot.m any help appreciated
wornish
Cracked it
I needed the -all_load in the other build settings
thanks to anonymous above
I'm off and running
Hi,
I am getting the error " CorePlot-CocoaTouch.h: No such file or directory". I have kept the coreplot0.2.2 folder in the desktop. I used the following path for set header path. "/Users/Giri/Desktop/iPhoneGraph/CorePlot 0.2.2/Source/framework".
is it correct ? please Help Me. Thanks in advance.
Try to set "Headers Search Paths" in your target's settings instead of project settings.
Try this "/Users/Giri/Desktop/iPhoneGraph/CorePlot\ 0.2.2/Source/framework"
I can't get this to work. It gives me 168 erros! First one saying: "CorePlot-CocoaTouch.h: no such file or directory" Any help would be appreciated! Thanks
Make the header path Recursive
I am new to core plot and get the same problem CorePlot-CocoaTouch.h No such file or directory and 162 issues.
You say to make the path to the header files recursive , how do you do that ?
I found the check box in xcode4
Got into this problem (when compiling for device)
"___switch32", referenced from: -[CPPlotSymbol newSymbolPath] in libCorePlot-CocoaTouch.a(CPPlotSymbol.o)
Any hint?
I seem to be getting the same issue but don't know how to fix it. Please help
File /Users/oscar/core-plot/systemtests/tests/build/Debug-iphonesimulator/libCorePlot-CocoaTouch.a depends on itself. This target might include its own product.
In case anyone else has a problem with the line
giving a selector not recognised error, try the following
How do I get a Core Plot into an already existing window? In other words, say I've left a space on an already designed .xib. Now I want to add a graph in the middle of the page. Please help, and answer like I know nothing (which is very close to accurate).
Just to add more depth...in my .m file for the .xib, I have the following lines in my ViewDidLoad:
graph = [[CPXYGraph alloc] initWithFrame:self.view.bounds]; self.view = [[CPGraphHostingView alloc] initWithFrame:[UIScreen mainScreen].bounds]; CPGraphHostingView *hostingView = (CPGraphHostingView *)self.view; hostingView.hostedGraph = graph;
This appears to override everything in the .xib and just present the graph. I'm looking for a fix to change this so it only appears as part of the screen without replacing my buttons, etc. Again, I don't know too much so if you could walk me through the steps that would be great!!!
Maybe try: CPGraphHostingView *hostingview = [[CPGraphHostingView alloc] initWithFrame:[UIScreen mainScreen].bounds]; [self.view addSubView: hostingview];
When using "this works for me" code i get a "CPMutableLineStyle undefined" error on this line: CPMutableLineStyle *lineStyle = [CPMutableLineStyle lineStyle];
Changing this to CPLineStyle it compiles but I get a SIGBRT when running the code:
[CPMutableNumericData setDataType:]: unrecognized selector sent to instance 0x6044600 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPMutableNumericData setDataType:]: unrecognized selector sent to instance 0x6044600'
... and yes i have the -all_load flag set
i stand corrected, i had was looking in the core-plot proect settings not my project -all_load made it work :-)
1.what is the difference between CPLayerHostingView and CPGraphHostingView? 2. how i call CPLayerHostingView in my application
I don't have any build errors, but when the app crashes upon start-up in the simulator.
If I comment-out this line, the app does not crash, but produces a blank, white view:
graph = [[CPXYGraph alloc] initWithFrame:self.view.bounds];
Any ideas?
i kept getting the following errors
Undefined symbols for architecture i386: "_OBJC_CLASS_\$_CPXYGraph", referenced from: objc-class-ref in CorePlotImplViewController.o "_OBJC_CLASS_\$_CPPlotRange", referenced from: objc-class-ref in CorePlotImplViewController.o "_OBJC_CLASS_\$_CPLineStyle", referenced from: objc-class-ref in CorePlotImplViewController.o "_OBJC_CLASS_\$_CPColor", referenced from: objc-class-ref in CorePlotImplViewController.o "_OBJC_CLASS_\$_CPScatterPlot", referenced from: objc-class-ref in CorePlotImplViewController.o "_OBJC_CLASS_\$_CPPlotSymbol", referenced from: objc-class-ref in CorePlotImplViewController.o "_OBJC_CLASS_\$_CPFill", referenced from: objc-class-ref in CorePlotImplViewController.o ".objc_class_name_NSNumber", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPScatterPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPBarPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPUtilities.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPTradingRangePlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPPieChart.o) ".objc_class_name_NSMutableDictionary", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPTheme.o) ".objc_class_name_NSDecimalNumber", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPScatterPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPBarPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(NSNumberExtensions.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPUtilities.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPPlotRange.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPAxis.o) ... ".objc_class_name_NSMutableArray", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPScatterPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPBarPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPGraph.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPTradingRangePlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPPieChart.o) ".objc_class_name_NSArray", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPScatterPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPBarPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPGraph.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPAxisSet.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPTheme.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPTradingRangePlot.o) ... ".objc_class_name_NSException", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPScatterPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPBarPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPGraph.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPGradient.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPLayer.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPXYPlotSpace.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPTheme.o) ... ".objc_class_name_NSNull", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPScatterPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPBarPlot.o) ".objc_class_name_NSValueTransformer", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPScatterPlot.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPTradingRangePlot.o) ".objc_class_name_NSObject", referenced from: .objc_class_name_CPPlotSymbol in libCorePlot.a(CPPlotSymbol.o) .objc_class_name_CPPlotSpace in libCorePlot.a(CPPlotSpace.o) .objc_class_name_CPPlotRange in libCorePlot.a(CPPlotRange.o) .objc_class_name_CPFill in libCorePlot.a(CPFill.o) .objc_class_name_CPGradient in libCorePlot.a(CPGradient.o) .objc_class_name_CPImage in libCorePlot.a(CPImage.o) .objc_class_name_CPLineStyle in libCorePlot.a(CPLineStyle.o) ... ".objc_class_name_NSNotificationCenter", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPGraph.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPXYPlotSpace.o) ".objc_class_name_NSString", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPUtilities.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPPlotRange.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPLayer.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPAxis.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPTextLayer.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPAxisLabel.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPAxisTitle.o) ... ".objc_class_name_NSScanner", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPUtilities.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPAxis.o) ".objc_class_name_NSLocale", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPPlotRange.o) ".objc_class_name_UIColor", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPPlatformSpecificCategories.o) pointer-to-literal-objc-class-name in libCorePlot.a(CPLayerHostingView.o) ".objc_class_name_NSMutableData", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPLayer.o) ".objc_class_name_CALayer", referenced from: .objc_class_name_CPLayer in libCorePlot.a(CPLayer.o) ".objc_class_name_NSMutableSet", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPAxis.o) ".objc_class_name_NSNumberFormatter", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPAxis.o) .objc_class_name_CPTimeFormatter in libCorePlot.a(CPTimeFormatter.o) ".objc_class_name_NSSet", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPAxis.o) ".objc_class_name_UIView", referenced from: .objc_class_name_CPLayerHostingView in libCorePlot.a(CPLayerHostingView.o) ".objc_class_name_NSDateFormatter", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPTimeFormatter.o) ".objc_class_name_NSDate", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPTimeFormatter.o) ".objc_class_name_UIFont", referenced from: pointer-to-literal-objc-class-name in libCorePlot.a(CPTextStylePlatformSpecific.o) ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status
any idea?
change axisSet.xAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"1"] decimalValue];
to
axisSet.xAxis.majorIntervalLength = CPDecimalFromString(@"5");
Hi,
I am using core plat framework to plot a graph between probability(Y axis) and ratio(X axis).I have two arrays, each consisting of 700 values. When i plot the graph, the graph is drawn only for 30 too 700th value of array and not for 0 to 30th value. The value to be plotted are in float(ex. 0.986788876755). Will this create a problem. If i use plot symbol to plot the point, then the thirty points are get plotted and the line connecting the point is not visible. I am not sure where did i gone wrong. Please help me out. Thanks.
I have copied the latest source code from here , as well as latest coreplot framework from the code google and set the correct relative path too. But still i am getting the following error.
error: cannot find protocol declaration for 'CPPlotDataSource'
Urgent help is required.
How to add a button (or any control) to CPGraphHostingView ? When I try to add UIButton normally, It is covered by the CPGraphHostingView.
I have seen a similar post about this, but it says only to add the button to the parent view of CPGraphHostingView.
How can we add to the parent view? can anybody help with a simple answer with example.
Thanks in advance.
-S.Philip
hi I exactly followed the tutorial of adding the coreplot framework.
But still received the error CorePlot-CocoaTouch.h:No such file or directory \~\~ anyone can help me ? I'm in a hurry to get this corePlot work.
thanks a lot
BTW
Where should I put this??
@protocol CPPlotDataSource
-(NSUInteger)numberOfRecords;
@optional
// Implement one of the following -(NSArray *)numbersForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange;
-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index;
-(NSRange)recordIndexRangeForPlot:(CPPlot *)plot plotRange:(CPPlotRange *)plotRect;
@end
thanks
I too have same problem have u solved it.If u have got guide me.
Thank u
Hi,
i am trying to intergrate from 2 days, i have the errror /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:7:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:7:32: error: CorePlot-CocoaTouch.h: No such file or directory
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:16:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:16: error: expected ')' before 'CPPlot'
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:20:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:20: error: expected ')' before 'CPPlot'
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:24:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:24: error: expected ')' before 'CPPlot'
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:25:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:25: error: expected ')' before 'CPPlotRange'
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:31:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.h:31: error: expected specifier-qualifier-list before 'CPXYGraph'
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:14:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:14: error: 'graph' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:14:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:14: error: 'CPXYGraph' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:16:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:16: error: 'CPLayerHostingView' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:16:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:16: error: 'hostingView' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:16:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:16: error: expected expression before ')' token
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:23:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:23: error: 'CPXYPlotSpace' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:23:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:23: error: 'plotSpace' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:23:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:23: error: expected expression before ')' token
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:24:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:24: error: 'CPPlotRange' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:27:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:27: error: 'CPXYAxisSet' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:27:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:27: error: 'axisSet' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:27:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:27: error: expected expression before ')' token
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:29:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:29: error: 'CPLineStyle' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:29:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:29: error: 'lineStyle' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:30:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:30: error: 'CPColor' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:51:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:51: error: 'CPScatterPlot' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:51:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:51: error: 'xSquaredPlot' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:58:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:58: error: 'CPPlotSymbol' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:58:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:58: error: 'greenCirclePlotSymbol' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:59:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:59: error: 'CPFill' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:63:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:63: error: 'xInversePlot' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:75:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:75: error: expected ')' before 'CPPlot'
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:77:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:77: error: 'CPScatterPlotFieldX' undeclared (first use in this function)
/Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:81:0 /Users/nowpos/Desktop/TrackBP3511/CorePlotTestViewController.m:81: error: request for member 'identifier' in something not a structure or union
totally 30 errors
can any one guide me.Or send me the sample which u have integrated.
I made it work with xcode 3, but I can't with xcode 4, could you make a tuto for xcode 4 please? or give some links
regards
The changes that you have to make with the new package are below in addition:
* the header search paths need to be updated to include iphoneOnly or macOnly in the framework folder.
this is the viewDidLoad body
This is the change to the number of records method for the protocol. It has a different interface now.
Hi guys,
i'm an newbie on iphone. Trying to follow this,
"A core plot graph cannot be hosted in just any UIView - it has to be hosted in a CPLayerHostingView. To get this to happen we have to change the base type of our view. So pull open the xib file for the view for this view controller, and change the base type of the view to CPLayerHostingView in the Identity Inspector:"
But in my project i only have Mainwindow.xlib, after i followed all the steps. I cannot find CPLayerHostingView in the list.
Base SDK is IOS Device 4.1 MAC OS 10.6.7
Any suggestions ?
Hi Guys,
I have downloaded this code and it is showing undeclared error for every library function. What I found is following:
Most of Libery function is changed like: CPPlot -> CPTPlot CPXYGraph -> CPTXYGraph CPGraphHostingView -> CPTGraphHostingView etc..
I ll update the code once I finished with this example
Spent a lot of time with compile time error : "CorePlot-CocoaTouch.h" No such file or directory
:( just wasted 4 hours of my life.
Just to report an issue I had with hostingView initialization. The app crashed and returned the following error:
2011-07-11 22:49:03.498 CorePlotTester[4222:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x4e050e0'
My problem was solved with:
[language] - (void)viewDidLoad { [super viewDidLoad]; graph = [[CPTXYGraph alloc] initWithFrame: self.view.bounds]; //CPTLayerHostingView *hostingView = (CPTLayerHostingView *)self.view;
CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:hostingView];
hostingView.hostedLayer = graph; [/language]
Great post, by the way. Wouldn't have made without it.
Regards,
rPedroso
Sorry, I forgot to correct the last line:
what is mean by synchronous application in iphone ?
Can any one please help me out.
How to get each Bar CGMutablePathRef in Bar chart created by using Core Plot?
Thanks in advance
Got solution for my above question. By using below method we can get Each bar path,
-(CGMutablePathRef)newBarPathWithContext:(CGContextRef)context recordIndex:(NSUInteger)index
I have followed every single step with complete accuracy. QuartzCore seems to have allot missing... 136 errors all to do with importing missing classes. Here are just some that im having problems with: #import "CPTAnnotation.h" #import "CPTAnnotationHostLayer.h" #import "CPTAxis.h" #import "CPTAxisLabel.h" #import "CPTAxisLabelGroup.h" #import "CPTAxisSet.h" #import "CPTAxisTitle.h" #import "CPTBarPlot.h" #import "CPTBorderedLayer.h" #import "CPTColor.h" #import "CPTColorSpace.h" #import "CPTConstrainedPosition.h" #import "CPTDarkGradientTheme.h" #import "CPTDefinitions.h" #import "CPTExceptions.h" #import "CPTFill.h" #import "CPTGradient.h" #import "CPTGraph.h" #import "CPTGraphHostingView.h" #import "CPTGridLines.h" #import "CPTImage.h" #import "CPTLayer.h" #import "CPTLayerAnnotation.h" #import "CPTLayoutManager.h" #import "CPTLegend.h" #import "CPTLegendEntry.h" #import "CPTLimitBand.h" #import "CPTLineCap.h" #import "CPTLineStyle.h" #import "CPTMutableLineStyle.h" #import "CPTMutableNumericData.h" #import "CPTMutableNumericData+TypeConversion.h" #import "CPTMutableTextStyle.h" #import "CPTNumericData.h" #import "CPTNumericData+TypeConversion.h" #import "CPTNumericDataType.h" #import "CPTPieChart.h" #import "CPTPlainBlackTheme.h" #import "CPTPlainWhiteTheme.h" #import "CPTPlatformSpecificDefines.h" #import "CPTPlatformSpecificFunctions.h" #import "CPTPlatformSpecificCategories.h" #import "CPTPathExtensions.h" #import "CPTPlot.h" #import "CPTPlotArea.h" #import "CPTPlotAreaFrame.h" #import "CPTPlotGroup.h" #import "CPTPlotRange.h" #import "CPTPlotSpace.h" #import "CPTPlotSpaceAnnotation.h" #import "CPTPlotSymbol.h" #import "CPTPolarPlotSpace.h" #import "CPTRangePlot.h" #import "CPTResponder.h" #import "CPTScatterPlot.h" #import "CPTSlateTheme.h" #import "CPTSlateTheme.h" #import "CPTStocksTheme.h" #import "CPTTextLayer.h" #import "CPTTextStyle.h" #import "CPTTheme.h" #import "CPTTimeFormatter.h" #import "CPTTradingRangePlot.h" #import "CPTUtilities.h" #import "CPTXYAxis.h" #import "CPTXYAxisSet.h" #import "CPTXYGraph.h" #import "CPTXYPlotSpace.h" #import "CPTXYTheme.h"
I m getting this is exit 1 status.Please let me know where should I have to resolve?
Build CorePlotApp of project CorePlotApp with configuration Debug
Ld build/Debug-iphonesimulator/CorePlotApp.app/CorePlotApp normal i386 cd /CorePlotApp setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk -L/CorePlotApp/build/Debug-iphonesimulator -F/CorePlotApp/build/Debug-iphonesimulator -filelist /CorePlotApp/build/CorePlotApp.build/Debug-iphonesimulator/CorePlotApp.build/Objects-normal/i386/CorePlotApp.LinkFileList -mmacosx-version-min=10.6 -ObjC -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -o /CorePlotApp/build/Debug-iphonesimulator/CorePlotApp.app/CorePlotApp
Undefined symbols: "_OBJC_CLASS_\$_CPTFill", referenced from: objc-class-ref-to-CPTFill in CorePlotTesetViiewController.o "_OBJC_CLASS_\$_CPTPlotSymbol", referenced from: objc-class-ref-to-CPTPlotSymbol in CorePlotTesetViiewController.o "_OBJC_CLASS_\$_CPTColor", referenced from: objc-class-ref-to-CPTColor in CorePlotTesetViiewController.o "_OBJC_CLASS_\$_CPTLineStyle", referenced from: objc-class-ref-to-CPTLineStyle in CorePlotTesetViiewController.o "_OBJC_CLASS_\$_CPTXYGraph", referenced from: objc-class-ref-to-CPTXYGraph in CorePlotTesetViiewController.o "_OBJC_CLASS_\$_CPTScatterPlot", referenced from: objc-class-ref-to-CPTScatterPlot in CorePlotTesetViiewController.o "_CPTDecimalFromFloat", referenced from: -[CorePlotTesetViiewController viewDidLoad] in CorePlotTesetViiewController.o -[CorePlotTesetViiewController viewDidLoad] in CorePlotTesetViiewController.o -[CorePlotTesetViiewController viewDidLoad] in CorePlotTesetViiewController.o -[CorePlotTesetViiewController viewDidLoad] in CorePlotTesetViiewController.o "_OBJC_CLASS_\$_CPTPlotRange", referenced from: objc-class-ref-to-CPTPlotRange in CorePlotTesetViiewController.o ld: symbol(s) not found collect2: ld returned 1 exit status
I have simillar problem when trying to compile for Ipod Touch. On the simulator it works, but it happens when target is device
Can you send me a copy of your working code? visualjazz@gmail.com
Thanks
And for me I got:
2011-08-03 22:08:41.633 CardsInventory MTG[9009:b603] -[NSDecimalNumber cgFloatValue]: unrecognized selector sent to instance 0x4e750c0 2011-08-03 22:08:41.635 CardsInventory MTG[9009:b603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSDecimalNumber cgFloatValue]: unrecognized selector sent to instance 0x4e750c0'
on CPTXYPlotSpace at line CGFloat viewCoordinate = viewLength * [[NSDecimalNumber decimalNumberWithDecimal:factor] cgFloatValue];
I suspect an error of my part on setting the UIView
Solved,
Forgot the -all_load flag
Hi EynErgy,
I'm also getting same error. I'm not able to find out the problem as same code is working at some other place. Pls, let me know the solution.
Thanks
I've modified this code to run on xcode4, I have a view that I put into my ConsoleViewControllor.xib with its class as CPTGraphHostingView.
Compiles great, at runtime however, I get a SIGABRT at line [language] hostingView.hostedGraph = graph;[/language] with the error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x5910d40' *** Call stack at first throw:
Anyone else run into this issue? Thanks.
IF ANY ONE HAS A PROBLEM WHERE 100 OR MORE CLASSES ARE MISSING (MIGHT NOT BE A FIX, BUT IT MIGHT BE): Copy ALL the files from the Source folder to the framework folder. Then it reduces to 6 errors. Im working on getting those 6 files over to the framework folder.
Anything you do is your own responsibility.
This will not solve anything. Sorry. Tried it as many times with as many things. Sorry
Take a look at this question on Stack Overflow. It should help:
http://stackoverflow.com/questions/6996863/getting-exc-bad-access-when-trying-to-compile-with-core-plot
Also, be sure to check the "Recursive" box when you add the header search path
Can someone who got this code running please make the source available. This tutorial is pretty much useless as it is currently.
Hope this helps anyone trying to follow this tutorial against the latest Core Plot trunk (as at 22/08/2011): https://gist.github.com/1161262
Note: the data line style doesn't seem to work (lines are black not red/blue) and you need to add the -load_all linker flag as previous commenters have noted.
I need to ask that the values do not take up the entire length of the y axis in core plot suppose i plot 5 minimum value and 15 maximum value the values do not take up entire length of the graph or probably exceeded from 15 max to 20 or 25 automatically so how would i use the entire length on y-axis on particular max and min values
To get this working for me, I followed the tutorial here: http://recycled-parts.blogspot.com/2011/07/setting-up-coreplot-in-xcode-4.html?showComment=1314810959571#c1827020697114663107
Then I changed the ViewDidLoad code to look like this: [objc] // Do any additional setup after loading the view from its nib. graph = [[CPTXYGraph alloc] initWithFrame: self.view.bounds]; CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view; hostingView.hostedGraph = graph; graph.paddingLeft = 20.0; graph.paddingTop = 20.0; graph.paddingRight = 20.0; graph.paddingBottom = 20.0; CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace; plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-6) length:CPTDecimalFromFloat(12)]; plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-5) length:CPTDecimalFromFloat(30)]; CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet; CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle]; lineStyle.lineColor = [CPTColor blackColor]; lineStyle.lineWidth = 2.0f;
axisSet.xAxis.majorIntervalLength = [[NSNumber numberWithInt:5] decimalValue]; axisSet.xAxis.minorTicksPerInterval = 4; axisSet.xAxis.majorTickLineStyle = lineStyle; axisSet.xAxis.minorTickLineStyle = lineStyle; axisSet.xAxis.axisLineStyle = lineStyle; axisSet.xAxis.minorTickLength = 5.0f; axisSet.xAxis.majorTickLength = 7.0f; axisSet.xAxis.labelOffset = 3.0f; axisSet.yAxis.majorIntervalLength = [[NSNumber numberWithInt:5] decimalValue]; axisSet.yAxis.minorTicksPerInterval = 4; axisSet.yAxis.majorTickLineStyle = lineStyle; axisSet.yAxis.minorTickLineStyle = lineStyle; axisSet.yAxis.axisLineStyle = lineStyle; axisSet.yAxis.minorTickLength = 5.0f; axisSet.yAxis.majorTickLength = 7.0f; axisSet.yAxis.labelOffset = 3.0f; CPTScatterPlot *xSquaredPlot = [[[CPTScatterPlot alloc] initWithFrame:graph.defaultPlotSpace.accessibilityFrame] autorelease]; xSquaredPlot.identifier = @"X Squared Plot"; CPTMutableLineStyle *ls1 = [CPTMutableLineStyle lineStyle]; ls1.lineWidth = 1.0f; ls1.lineColor = [CPTColor redColor]; xSquaredPlot.dataLineStyle = ls1; xSquaredPlot.dataSource = self; [graph addPlot:xSquaredPlot]; CPTPlotSymbol *greenCirclePlotSymbol = [CPTPlotSymbol ellipsePlotSymbol]; greenCirclePlotSymbol.fill = [CPTFill fillWithColor:[CPTColor greenColor]]; greenCirclePlotSymbol.size = CGSizeMake(2.0, 2.0); xSquaredPlot.plotSymbol = greenCirclePlotSymbol; CPTScatterPlot *xInversePlot = [[[CPTScatterPlot alloc] initWithFrame:graph.defaultPlotSpace.accessibilityFrame] autorelease];
xInversePlot.identifier = @"X Inverse Plot"; CPTMutableLineStyle *ls2 = [CPTMutableLineStyle lineStyle]; ls2.lineWidth = 1.0f; ls2.lineColor = [CPTColor blueColor]; xInversePlot.dataLineStyle = ls2; xInversePlot.dataSource = self; [graph addPlot:xInversePlot]; [/objc]
Thank you so much!!! It works!
The code which I downloaded from this tutorial is not working.It is giving 30 errors.One of it is "CorePlot-CocoaTouch.h"-No such file or directory.Can anyone help me please.
Works like a charm. I'm on Xcode 4.2 - ios 5.0 sim.
Thank you for posting this! I realize you didn't have to which is why you're royally awesome for doing so. Thanks x10.
Finally the right code......you're great!
Great Job!
We will start to develop a graph app using Core-Plot!Thanks for this tutorial.
i had problem with -[CPMutableNumericData setDataType:]: i resolved it. The true way is to put -all_load -ObjC to others link flags. Hope this help.
/* Mans
Here is the configuration used: Xcode 4.1 , Mac OS Lion 10.7, coreplot_0.9
My app is crashing with following error: [NSDecimalNumber cgFloatValue]: unrecognized selector sent to instance...
I'm not able to find out the solution on this as same code is working on Xcode4.2 with Mac OS 10.6.7. Plz, let me know the solution.
I have exactly the same problem as Pravin... XCode 4.2, .Lion 10.7.2, code plot_0.9.
Great work guys...
I just installed CorePlot inside an XCode 4.2.1 app using the example from:
http://recycled-parts.blogspot.com/2011/07/setting-up-coreplot-in-xcode-4.html?showComment=1314810959571#c1827020697114663107
Then I found this tutorial. I got some errors then read some of the most recent posts, changed the viewDidLoad code to match Anonymous (12/17/11). I noticed the graph was upside down and reflected. I then copied Anonymous (8/31/11) viewDidLoad code and it built the graph as expected.
Thanks, and make sure to post your experience with this tutorial!
You're amazing. I spent all day on this, and your tutorial cleared loads of stuff up. No worries if its a bit out of date - good programmers can get through that stuff without a problem. THANK YOU.
how to add point by point for math function like y=2x (x,y)
Thx to
"Anonymous 12/17/2011 - 17:50"
His code works
Ok, the data points look correct, however the background is solid black, and that means I can't tell if the axis labels are showing up. Anybody else have this issue? What property sets the background color?
EDIT: Also the graph is upside down.
EDIT: Solved. The initWithFrame for the CPTGraphHostingView is flipping the view upside down. Also the default plotArea seems to have nil set for the background fill. I create a white fill and assign it to the property.
[language] CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view; //CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc] initWithFrame:self.view.bounds]; //[self.view addSubview:hostingView]; hostingView.hostedGraph = graph; graph.plotAreaFrame.plotArea.fill = [CPTFill fillWithColor:[CPTColor whiteColor]]; [/language]
folks,
I have been on this tutorial for a few days. but still have trouble to get it works. I am able to include core plot frame work in, and be able to compile clear. I used the code from "Anonymous 12/17/2011 - 17:50"(thanks, btw). However, when execute, the simulator is up but black. With this error message in the debug window "..Application windows are expected to have a root view controller at the end of application launch"
any ideas? many thanks
nidm
btw, the only step I didn't follow is 'add the -ObjC linker flag'. I am able to compile clean without this step. While with this step, an error actually occur.
Just got a big step forward(not there yet). As I mentioned earlier, that whenever I added the link flag -ObjC. I got an error complaining about duplicate symbol. Finally, after hours of struggle. I found that by rename libCorePlot-CocoaTouch.a to 'libCorePlotCocoaTouch.a'. I can compiler clean now. and able to draw something out. Still some distance to go...
The app works fine with the exception of one error (in 2 places) and one semantic issue (also in 2 places)
[C++] CPTScatterPlot *xSquaredPlot = [[[CPTScatterPlot alloc] initWithFrame:graph.defaultPlotSpace.accessibilityFrame] autorelease]; [/C++]
This gives me an error. Removing the autorelease argument gets rid of the error. (I did not disable automatic reference counting in my test app.)
[C++] xSquaredPlot.dataSource = self; [C++]
This gives me a warning. "Assigning to 'id There are two places where this warning pops up. Ignoring them seems to be ok.
I have a project where in I have included speech to text implementation and I need Core plot in it. If i include -ObjC as a linker flag then Speech to text doesn't works. It gives a linker error. And If i remove -ObjC then Graphs are not plotting. What should I do. ? Please help
Thanks a lot!
I think i might have a UIView problem.... I have added my view in interface builder, and i'm using storyboard.
I changed the Class in my UIView till CPTGraphHostingView.
Stille i get the error below...
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x6b91e60'
What to do - i cannot find the "UIView definition" ?
CGSize textSize = [self.text sizeWithTextStyle:self.textStyle];
Iam getting the below error at above line in CPTTextLayer.m file. How to resolve it..? Please help.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString sizeWithTextStyle:]: unrecognized selector sent to instance 0xa45c600' *** Call stack at first throw:
I have the same issue. Does it happen right after the viewDidLoad method? To me it points to assembly code in the CPTTextLayer.m file as well.
Can you updated this for latest version of XCode?
I've created an update to this tutorial based on user comments and other helpful sources. It works with Xcode 4.5.1 and CorePlot_1.0
[url]http://www.possumpiggyproductions.com/CorePlotTutUpdate.htm[/url]
Awesome, thanks for doing this! I only got partway through it on my own.