3

Im developing an iPhone app which shows line graph. I plot the sales of fruits based on the date.

Im planning to use Core-plot for drawing graphs.

i know how to plot single graph using Core plot library..

How do i draw 2 different graphs in a single plot i.e both the graphs should have the same x and y axis.

The scenario is similar to comparing 2 different graphs. For eg. if i want to compare Apple and orange sales for the month. I need to plot both the line charts in the same plot so that i can know the ups and downs in the sales.

Is it possible using Core plot or should i use some other library or drawRect method to achieve the same..

Thanks in advance,

cancerian

cancerian
  • 942
  • 1
  • 10
  • 18

1 Answers1

1

Yes it is possible. There is a example of it in the Examples folder when you download it. You basically create two CPTScatterPlot-s and give them two different identifiers. When calling -(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index you check the identifier and return different values. Check the examples folder for more info.

Majster
  • 3,611
  • 5
  • 38
  • 60
  • thanks it worked.. how do i add date to xAxis using coreplot?? – cancerian May 22 '12 at 09:13
  • I think you can find this on the following link: http://stackoverflow.com/questions/2998398/using-core-plot-for-iphone-drawing-date-on-x-axis. Its quite a chunk of code, hope you will manage it. – Majster May 22 '12 at 09:36
  • thanks :) it worked.. I have another issue. the graph axis is distorted first time it loads. What should i do to rectify that? any idea??? – cancerian May 28 '12 at 08:55