views:

56

answers:

1

Hi all,

I try to draw an XY graph using GraphKit.

Information of this framework is very limited on the internet...

Here's what I did:

// a xychart is predefined in header as GRChart

GRDateSet *dataset = [[GRXYDataSet alloc] initWithOwnerChart:xychart];
[xychart addDataSet:dataSet loadData:YES];
[xychart reloaddata];

also I implement delegate methods:

(double)chart:(GRChartView *)aChart xValueForDataSet:(GFDataSet*)aDataSet element:(NSUInteger)index 

 { return index * 10.0; }

    (double)chart:(GRChartView *)aChart yValueForDataSet:(GFDataSet*)aDataSet element:(NSUInteger)index 
 { return index * 10.0; }

(NSUInteger) chart:(GRChartView *)aChart  numberOfElementsForDataSet:(GFDataSet*)aDataSet {
   return 10;
}

however, it only draws the axes but no data points at all...

what did I miss here?

thanks!

A: 

I got it. This framework only stores data points and draws axes according to the data points. (It automatically calculates the bounds of each axes and zoom into a suitable plot area.)

However, no drawing method is rooted. To get an immediate graph, I have to use GRAreaDataSet, which is a subclass of GRXYDataSet. Then it will draw an area chart.

I also tried out core-plot. But it's more difficult to use to me. I have to calculate the bounds myself; and padding the graph to show the label values of axes. Also, it's not so beautiful if I don't customize the symbols and lines. However, the default GraphKit charting is nice-looking enough. Though it doesn't have a document...

I'll try to write a tutorial of it when I try out everything in it :)

Frost