Number Formatting basics | |||||||||||||||||||||||||||
FusionMaps XT offers you a lot of options to format your numbers on the map.You can configure number prefixes & suffixes, decimal places, and scaling of numbers based on a pre-defined scale. In this section, we'll see the number formatting properties supported by FusionMaps XT and look into number scaling in the next section. We'll start with setting decimal precisions for the numbers on map. |
|||||||||||||||||||||||||||
Controlling decimal precision | |||||||||||||||||||||||||||
All the maps in FusionMaps XT support the decimals attribute. This single attribute lets you control the decimal precision of all the numbers on the map. Using this attribute, you can globally set the number of decimal places of ALL the numbers on the map. By default, the decimal precision of all the numbers on the map is set to 2. Using this attribute, you can re-define it. For e.g., if you have numbers on your map as 2.386 and 7.4, by default the numbers will be rounded off to 2 decimal places and the numbers will become 2.39 and 7.4. To display all the 3 decimals of the first number, you need to explicitly set <map ... decimals='3' >. |
|||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
Note that even though decimals has been set to 3, FusionMaps XT doesn't forcefully add 0s to 7.4 and convert it to 7.400 or to any of the other numbers on the map which originally have less than 3 decimal places. To forcibly add 0s to all these numbers, set <map ... forceDecimals='1' ...> | |||||||||||||||||||||||||||
Automatic number formatting | |||||||||||||||||||||||||||
FusionMaps XT allows you to format your numbers by adding K, M and proper commas to the numbers. The commas are added to the numbers by default. But to convert all the big numbers on the map to numbers made smaller by using K or M, set <map ...formatNumberScale='1' ...>. | |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
If you don't want the numbers on the map to be formatted using commas, you can set <map ... formatNumber='0' ..> . But, setting formatNumber='0' will not format any decimal places too (even if explicitly specified in XML/JSON). | |||||||||||||||||||||||||||
Setting custom thousand and decimal separator character | |||||||||||||||||||||||||||
By default, FusionMaps XT uses . (dot) as decimal separator and , (comma) as thousand separator character. However, you can customize this character depending on your requirements. To do so, use the decimalSeparator and thousandSeparator attribute. For example, let's set our thousands separator as dot and decimal separator as comma. To do so, you'll have to use the following XML: <map ... decimalSeparator=',' thousandSeparator='.' > Shown below is the output. |
|||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
Configuring thousand separator position | |||||||||||||||||||||||||||
FusionMaps XT automatically decides the position of the thousand separator. By default, the thousand separator is placed after every three digits from right. A map with default thousand separator position will look as under: Starting FusionMaps XT, you can customize the position of the thousand separator and place it as required. To place the thousand separator in custom positions you need to use the thousandSeparatorPosition attribute. Shown below is a map with the thousand separator placed after four digits from right: In the above map, the attribute thousandSeparatorPosition is set to '4'. So, the thousand separator (,) is placed after every four digits starting from right. You can also set multiple values (separated by comma) to this attribute, instead of a single value. Thus, you can specify complex thousand separator positions. For example, specifying multiple values, you can display numbers in Indian currency format, where the first thousand separator (for thousand) is placed after three digits from right and then onwards the thousand separator is placed after every two digits. Shown below is an example map displaying Indian currency format: In the above map, we have set thousandSeparatorPosition='2,3'. So, the thousand separator is first placed after 3 digits starting from right and then onwards after every two digits. Given below are some sample combinations of values which can be set to this attribute: | |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
Note: Any negative value set to this attribute will be converted to a positive value. For example, thousandSeparator="-2" will be converted to thousandSeparator="2". | |||||||||||||||||||||||||||
Adding number prefix and suffix | |||||||||||||||||||||||||||
FusionMaps XT allows you to add a prefix or suffix to all the numbers on the map. You can use the following attributes of the <map> element to attain the same:
To know more on how to use currency symbols (£, €, ¥ etc.) refer to Using Currency Symbols page. If you intended to use special punctuation or characters like &, <, >, % etc. refer to Using Special Punctuation page. In Data URL method, you can directly specify the character. |
|||||||||||||||||||||||||||
| |||||||||||||||||||||||||||