Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ljg93

macrumors member
Original poster
Mar 13, 2011
98
0
hey guys i just put the core data plot into my app so the user can make a custom graph based on user information.. it is tracking someones weight..

but when the user clicks the button to log the weight, the numbers on the y axis are too far apart from each other, so like if someone logs the weight 150 pounds, the x axis automatically starts around 140 then to 160 then 180 and 200, im looking for it to be something starting around 5 pound intervals from the original weight logged.. has anyone else had this problem? does anyone know how to fix it?
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
Screenshot? What framework/code are you using for the plot?

I would have imagined the x axis to be time and the y axis to be weight, but obviously that is not what you are describing.

B
 

ljg93

macrumors member
Original poster
Mar 13, 2011
98
0
Screenshot? What framework/code are you using for the plot?

I would have imagined the x axis to be time and the y axis to be weight, but obviously that is not what you are describing.

B

PHP:


ok heres a screen shot
 

Attachments

  • Screen shot 2011-03-23 at 3.03.07 PM.png
    Screen shot 2011-03-23 at 3.03.07 PM.png
    85.2 KB · Views: 74

ljg93

macrumors member
Original poster
Mar 13, 2011
98
0
As I expected, I see dates on the X axis (independent), weights on the Y axis (dependent). Not the other way around.

What is it that you want to be done differently?

B
im just wondering how i can get the dates on the x to not get all smashed together and how i can get the numbers on the y to be in increments of 5 from the first weight that was logged.
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
im just wondering how i can get the dates on the x to not get all smashed together and how i can get the numbers on the y to be in increments of 5 from the first weight that was logged.

As I asked before: What framework or other code are you using to generate the plot?

It must have some way to set the x and y axes. Without knowing what it is it becomes very hard to provide any help.

Note that your test data is unrealistic. You've got all the dates on the same day and massive weight changes. You may want to test out your code with something a bit more "sane".

B
 

ljg93

macrumors member
Original poster
Mar 13, 2011
98
0
As I asked before: What framework or other code are you using to generate the plot?

It must have some way to set the x and y axes. Without knowing what it is it becomes very hard to provide any help.

Note that your test data is unrealistic. You've got all the dates on the same day and massive weight changes. You may want to test out your code with something a bit more "sane".

B

http://code.google.com/p/core-plot/

is where i got the sample code as far as the looks.

i know the data is un realistic but i have tried it over a period of days and they still smash and the x axis gets generated after the first log and never moves after that. so it does not really matter...

all my question is how can i get the increments in 5 not by 20 plus and have the dates no smush.
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
http://www.14oranges.com/2011/02/how-to-use-core-plot-for-ios/

http://www.14oranges.com/2011/02/how-to-use-core-plot-for-ios/
Using Core Plot
Here are the important classes to use:

CPXYGraph: That’s the main graph class where the plots will be written to.
CPGraphHostingView: That’s a special view design to host CPXYGraph. One trick you will need to do is that whichever UIView you will want to have the graph in will need to be changed to a CPGraphHostingView in Interface Builder using the Identity Inspector. The class won’t show up in the list so you have to type in manually. Note this class used to be called CPLayerHostingView so old instructions may reference this.
CPXYPlotSpace: That defines the drawing area for the plots. You can define the start position (say -10) and the length (say 20) to give you how big your plot is going to show (say from -10 to 10) and you do that for X and Y using the xRange and yRange properties.
CPScatterPlot: That class is to create a scatter plot.
CPBarPlot: That class is to create a bar plot.
CPXYAxisSet: That class represents the axis in the plot. You use the properties xAxis and yAxis to decide how they are going to look like. You can set major intervals, ticks per intervals, line style, and label offset amongst other things.
CPPlotSymbol: That class defines the style/color for the dots on the plot

Try tweaking yRange and the major tick intervals to get things where you want them. You may also have to use a different formatter to have the dates not get smooshed.

Build some fake data for testing don't rely on the app to do it for you. Take some different examples. Someone trying to lose weight, someone trying to gain and someone trying to stay the same.

B
 

ljg93

macrumors member
Original poster
Mar 13, 2011
98
0
http://www.14oranges.com/2011/02/how-to-use-core-plot-for-ios/



Try tweaking yRange and the major tick intervals to get things where you want them. You may also have to use a different formatter to have the dates not get smooshed.

Build some fake data for testing don't rely on the app to do it for you. Take some different examples. Someone trying to lose weight, someone trying to gain and someone trying to stay the same.

B

ok that explains a lot to me thanks! but if i posted my code that housed the x and y range could you tell me like some code to put in that spot to get me started? because right now i dont know where to begin on it really and where to start.
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
ok that explains a lot to me thanks! but if i posted my code that housed the x and y range could you tell me like some code to put in that spot to get me started? because right now i dont know where to begin on it really and where to start.

Post as much of your code as you feel comfortable with, preferably enough that it can be compiled and I'll definitely take a look at it at some point.

B
 

ljg93

macrumors member
Original poster
Mar 13, 2011
98
0
Post as much of your code as you feel comfortable with, preferably enough that it can be compiled and I'll definitely take a look at it at some point.

B

is there anyway you could give me an email? i dont feel comfortable posting a compilable code on here
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.