constructScaleElements (values: Array)
values. Array on values to use to create a scale.
The constructScaleElements method creates a collection of scale intervals based on transmitted data.
To execute the example, the HTML page must contain the MapChart component (see Placing of Map on a HTML Page) named map, XML file with settings of map and the Russia.svg topobase.
The XML file must contain settings of the fill factor that is the first located in the list of map factors. Fill background - dependency object, for which scale is set up that contains values of the Brush type. The XML file must also have legend set up with the MapLegend0 identifier.
Create an array of data and calculate scale intervals based on this array.
Division into intervals in the Equal intervals mode (The entire data range is divided into the specified number of groups containing equal number of units, the units are equal in length):
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; //create a data array
// number of items
var count = data.length;
// minimum value
var min = scale.setMinValue(data[0]);
// maximum value
var max = scale.setMaxValue(data[count - 1]);
scale = map.getFirstVisual().getBackground().getMapScale();
scale.setMode("Uniform");//Division into intervals in Equal Intervals mode
scale.setRecalcValues(True); //recalculate collection of scale values
scale.constructScaleElements(data); //create scale based on new data
legend = map.getLegends().MapLegend0;
legend.draw(); //draw the legend
Linear mode of dividing the range into intervals (The data range is divided into specified number of groups with the same length.):
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; //create a data array
// number of items
var count = data.length;
// minimum value
var min = scale.setMinValue(data[0]);
// maximum value
var max = scale.setMaxValue(data[count - 1]);
scale = map.getFirstVisual().getBackground().getMapScale();
scale.setMode("Linear");//Division into intervals in Linear mode
scale.setRecalcValues(True); //recalculate collection of scale values
scale.constructScaleElements(data); //create scale based on new data
legend = map.getLegends().MapLegend0;
legend.draw(); //draw the legend
After executing the example scale intervals are based on data stored in the created array, minimum and maximum scale values are sets, map and legend are redrawn:
Equal intervals:
Linear:
See also: