The chart in its current state is a little plain! This section will build on the simple chart that you have created and add a bit more style.
Firstly, the axes could do with having some labels. Also, the Y axis could do with a bit of padding around the top and bottom values to make it easier to see the top and bottom of the curves.
Open up ViewController.m and edit the axis creation code as follows:
// add a pair of axes
SChartNumberAxis *xAxis = [[SChartNumberAxis alloc] init];
xAxis.title = @"X Value";
_chart.xAxis = xAxis;
SChartNumberAxis *yAxis = [[SChartNumberAxis alloc] init];
yAxis.title = @"Y Value";
yAxis.rangePaddingLow = @(0.1);
yAxis.rangePaddingHigh = @(0.1);
_chart.yAxis = yAxis;
It would be nice to see the legend on the iPad, where there is much more screen space to play with. Add the following to the
_chart.legend.hidden = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
One of the most powerful features of the Shinobi charts is their gesture-based interactions. Enable pan and zoom on each axis by adding the following code:
// enable gestures
yAxis.enableGesturePanning = YES;
yAxis.enableGestureZooming = YES;
xAxis.enableGesturePanning = YES;
xAxis.enableGestureZooming = YES;
These properties allow the user to pan the chart with a single-finger pan gesture, and zoom using two-finger pinch.
Finally, enable area fill by adding the following just after each series is created within
lineSeries.style.showFill = YES;
Each series has a style object associated with it, where the style type depends on the series type. A line series has a style object of type
SChartLineSeriesStyle. These objects have a a number of properties which you can adjust including line color, thickness and the colors used for gradient fill.
To see the effect of the few simple changes you have just made, build and run:
Now that you have created a simple chart, why not have a go at creating a column, or pie chart?
If you got stuck at any point, you can find this project in the samples folder of your ShinobiCharts download.