Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example implements executing the following operations:
The arrays containing new color values and scale data are formed.
The scale parameters required for data update are set.
The scale data is updated by means of the ValueScale.updateWithData: method.
The scale value are updated by means of the ValueScale.setScaleValues: method.
The scale color value is set for missing data.
A new value for map root layer border colors is set that was obtained by means of the ValueScale.getValue method.
A new value of map title fill color is set that was obtained by means of the ValueScale.getValue: method.
Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Creating a Map with a Timeline section):
// Get object for working with map visual element MapAreaVisual *visual = [[[[m_view layers] objectAtIndex:0] visuals] objectAtIndex:0]; // Get object for working with scale ValueScale *scale = [[visual background] scale]; // Create an array for storing scale data NSMutableArray *scaleValue = [NSMutableArray array]; // Create an array for storing scale color values NSMutablerray *colorBrushes = [NSMutableArray array]; // Create an object for working with color UIColor *noDataColor = [UIColor colorWithHex:@"79c4fb"]; /* Create an object for working with the brush used for filling map layer areas, for which there is no data */ SolidColorBrush* noDataBrush = [SolidColorBrush solidColorBrushWithColor: noDataColor]; // Set scale brush [scale setNoData:noDataBrush]; // Set colors for filling map layer area background NSArray *colors = [NSArray arrayWithObjects:@"50b1fa", @"078bed", @"0673c4", nil]; // Set scale type [scale setScaleType:ValueScaleLinear]; // Set number of scale steps required on data update [scale setScaleSteps:2]; // Determine map scale step double step = (datasource.maxValue - datasource.minValue) / [scale scaleSteps]; /* Add new maximum and minimum scale values to data array */ [scaleValue addObject:[NSNumber numberWithDouble: 100]]; [scaleValue addObject:[NSNumber numberWithDouble: 10]]; // Update scale data [scale updateWithData: scaleValue]; // Fill array of color values in cycle for (int i = 0; i <= [scale scaleSteps]; i++) { // Get current color value NSString *hexColor = [colors objectAtIndex:i]; UIColor *color = [UIColor colorWithHex:hexColor]; /* Create an object for working with the brush used to fill map layer area background*/ SolidColorBrush* brush = [SolidColorBrush solidColorBrushWithColor:color]; // Add the current object for working with brush to array of color values [colorBrushes addObject:brush]; } // Update scale values [scale setScaleValues: colorBrushes]; // Create arrays for working with the Equal and Greater values NSMutableArray *equals = [NSMutableArray array]; NSMutableArray *greaters = [NSMutableArray array]; // Parse the Equal and Greater arrays in cycle for (int i = 0; i < [scale scaleSteps]; i++) { // Offset color values of arrays by 1 unit [equals addObject:[scale.less objectAtIndex:i + 1]]; } // Get a new color value for last elements of array NSString *hexLastColor = [colors objectAtIndex:[scale scaleSteps]]; UIColor *lastColor = [UIColor colorWithHex:hexLastColor]; /* Create an object for working with the brush used to fill map layer area background */ SolidColorBrush* brush = [SolidColorBrush solidColorBrushWithColor:lastColor]; // Fill last elements of array with new color value [equals addObject: brush]; // Set new scale values for the Equal and Greater arrays [scale setEqual: equals]; [scale setGreater:equals]; /* Get the brush used to fill map layer areas, for which there is no data */ SolidColorBrush *borders = [scale getValue]; // Set area border color for map root layer [[[m_view layers] objectAtIndex:0] setStrokeColor: [borders color]]; // Set area border thickness for map root layer [[[m_view layers] objectAtIndex:0] setStrokeThickness:1]; // Set the number, by which scale value is searched NSNumber *number = [NSNumber numberWithDouble:20.2]; /* Get the brush corresponding to the number and set it as a map title background */ [[m_view caption] setBackground:[scale getValue: number]];
After executing the example new color values for map scale are set. A blue color is applied for all map root layer area borders that corresponds to scale value for missing data. A background color is set for map title that corresponds to the 20.2 value:
See also: