Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example implements removing of obtained chart data series. The following operations are also executed on clicking the chart area:
Data series animation parameters are removed if they exist.
New values are set for data series marker size and shape.
Values of data series line thickness and color are changed.
The obtained series point marker is resized.
The following values are displayed in the development environment console:
Indicates whether animation is played on the chart.
Chart name.
Name of the obtained chart data series.
Executing the example requires to place the following code instead of the executeExample class of the ViewController method (see the Creating a Line Chart section):
// Example execution function -(void) executeExample{ // Get data series LineSeries *series = [chart seriesList][1]; if([chart hasSeries:series]){ // Delete obtained data series [chart deleteSeries:series]; } }; // Handle chart area touch event - (void)chartTouchesTapInView:(UIView *)v withPoint:(CGPoint)point{ // Get data series LineSeries *series = [chart seriesList][1]; [series setColor:[UIColor purpleColor]]; [series setShadowColor:[UIColor purpleColor]]; // Remove animation parameters if they exist if([[series animations] count] == 1) [series removeAnimation:[series animations][0]]; if([[series animations] count] > 1) [series removeAllAnimations]; // Set marker size [series setMarkerSize:10]; // Get marker object ChartMarker *marker = [series marker]; [marker setBorderColor:[UIColor purpleColor]]; // Get object with marker shape settings NSMutableDictionary *mDict = [marker dumpConfigurationToDict]; NSMutableDictionary *shapeDict = [mDict objectForKey:@"shape"]; // Set new value of marker shape [shapeDict setValue:@2 forKey:@"value"]; [mDict setValue:shapeDict forKey:@"shape"]; // Create marker object based on specified settings ChartMarker *newMarker = [ChartMarker markerWithDict:mDict]; // Set marker [series setMarker:newMarker]; // Get object with data series settings NSMutableDictionary *sDict = [series dumpConfigurationToDict]; // Get object with data series line width settings NSMutableDictionary *thicknessDict = [sDict objectForKey:@"thickness"]; // Set new value of data series line width [thicknessDict setValue:@5 forKey:@"value"]; [sDict setValue:thicknessDict forKey:@"thickness"]; [series configureSeriesWithDict:sDict]; // Refresh data series [series forceDataUpdate]; // Get data series point in specified coordinates LinePoint *linePoint = [[chart seriesList][0] findChartPointHit:CGPointMake(262, 201)]; // Set data series point marker size [linePoint setMarkerSize:30]; // Redraw chart [[series chart] setNeedsRedraw]; // Display whether chart animation is played NSLog(@"%@ %hhd", @"Whether animation is played:", [chart isAnimationPlaying]); // Display chart name NSLog(@"%@ %@", @"Chart name:", [chart name]); // Display chart series name NSLog(@"%@ %@", @"Chart series name:", [series seriesName]); }
After executing the example the obtained series is removed:
Press the chart area.
As a result, data series parameters are changed:
The development environment console also displays chart and data series parameters:
Indicates whether animation is played: 0
Chart name: chart
Chart series name: a2
See also: