Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example describes creating and displaying of a sparkline. After starting the example the following operations are executed:
Sparkline data is determined.
Maximum and minimum sparkline values are set.
Indexes of values corresponding to maximum and minimum sparkline nodes are set.
A sparkline area is created separately, sparkline maximum and minimum nodes are created.
Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Creating a Simple Data Grid section):
SparklineCell *cell = [SparklineCell new]; /* Enable redefinition of the drawRect: method of the SparklineCell class. Create a separate sparkline area in this method, create its maximum and minimum nodes */ [cell setIsUseSparkline:YES]; // Determine new sparkline data NuGridSparklineData *sparklineData = [[NuGridSparklineData new] autorelease]; [sparklineData setValues:[NSArray arrayWithObjects:[NSNumber numberWithInt:5], [NSNumber numberWithInt:4], [NSNumber numberWithInt:4], [NSNumber numberWithInt:3], [NSNumber numberWithInt:2], [NSNumber numberWithInt:2], [NSNumber numberWithInt:1], [NSNumber numberWithInt:0], [NSNumber numberWithInt:0], nil]]; // Determine minimum and maximum sparkline values [sparklineData setMinValue:0]; [sparklineData setMaxValue:5]; // Determine indexes of points corresponding to maximum and minimum sparkline nodes [sparklineData setMaxPeakElementIndex:5]; [sparklineData setMinPeakElementIndex:7]; // Set sparkline data [cell setRowData:sparklineData]; // Display sparkline in table [proxyDatasource beforeUpdate:@"DataSource"]; [proxyDatasource setDefaultCell:cell]; [proxyDatasource afterUpdate:@"DataSource"];
After executing the example a separate sparkline of orange color is created in the redefined drawRect: method of the SparklineCell class, its maximum and minimum nodes are created. A sparkline of red color is also created based on the other dataset together with black-color points corresponding to its maximum and minimum nodes. Both sparklines are built in the left top table corner cell:
See also: