views:

423

answers:

1

I have available an array of dictionary that contains NSDate and NSNumber values. I wanted to plot date on X axis. for plotting I need to supply xRanges to plot with some decimal values.I don't understand how can i supply NSdate values to xRange (low and length).

And what should be there in this method:

-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index

I mean how my date value will be returned as NSNumber..? I think i should use some interval over there.but what should be the exact conversion..? can any one explain me what are the exact requirement to plot the date on xAxis..?

I am plotting my plot in half of the view.

+2  A: 

Take a look at the DatePlot program in the examples folder. It shows how to format axis labels as dates.

Eric Skroch
Infact I am following that example. but using that trick to plot the graph but graph is not visible. as It's not under range or something wrong with providing values.actually, my data contains the date with past 3 to 6 months. I am not getting what exactly I should provide reference date when converting NSdate to equivalent NSDecimalNumber.And I am confused over plotSpace.xRange. what I should supply.? I mean how can i calculate the range of dates to supply for xRange from my datasource..?
xmax
And one more thing is that, I am not able to display date properly on xAxis, with the example stock plot in coreplot.if I have to draw xAxis on core plot StockPlot example, then how it would be..?
xmax
The reference date can be anything you want. It defines the zero point for the axis. The starting location for the axis range is the difference between your first date on the axis and the reference date, in seconds. The range length is the length of the range in seconds (there are 86400 seconds in a day).
Eric Skroch
Thanks for your suggestion. I did it the way you mentioned and it is plotting graph the way it should.But the problem here I am getting is I want to show date label on xAxis. and It is not displaying currently. I setted masksToBorder property to NO. can you tell me where could be the problem..?I provided CPdateFormatter for xAxis as well..
xmax