FusionCharts simple tutorial (4) ----- basic Number Format

Source: Internet
Author: User

In statistical legends, what are the most basic and important elements? That is data. A statistical image of a piece of data is a pile of blank space. However, there are multiple forms of data, such as decimal places, such as kilobytes. If the data size is 12.000000001, but the data requirements are not very strict, won't you show it that way? Therefore, we often need to control data formats in statistical reports.

1. Control decimal places

FusionCharts has a decimal point retention attribute: decimalPrecision. The value after this attribute indicates the number of decimal places to retain. For example, when decimalPrecision is set to '0', the final display of 12.14, 15.1111, and 15.68 will be 12, 15, and 16. Its rule is rounding. For example:

Ii. format data

By default, FusionCharts will add the K () and M (million) symbols to those large data, as shown below:

The actual data input shown above is 20560, 26514, 16542, 36265, 16589, 26511, and 26653, therefore, FusionCharts automatically converts the data to data in the unit of thousands or millions.

Of course, if you want to see specific data, you need to add these two element attributes: formatNumberScale = '0' decimalPrecision = '0 '. As follows:

Although the above images have actual and specific data, they all carry a comma (,). FunshionCharts will use commas (,) to separate the data. If we do not want to see a comma, you can use formatNumber = '0 '. Note that if we use formatNumber = '0', we cannot format decimal places.

3. Custom Separator

In the previous two sections, we can see that FusionCharts is used to separate the thousands of decimal places, and. is used to separate the decimal places. In FusionCharts, decimalSeparator and thousandSeparator can be used to specify separators. ThousandSeparator specifies the sub-location, while decimalSeparator specifies the decimal point.

Here we use? To separate decimal places ,! To separate sub-bits: decimalSeparator = '? 'Thousandseparator = '! '

Note that the formatNumberScale = '0' element must be added during display. Data cannot be formatted.

4. Add a data prefix and suffix

Sometimes we need to add a prefix or suffix to our data. For example, we need to add prefix $ and $ for money, and add percent sign % for statistics.

FusionCharts uses numberPrefix to add a prefix and numberSuffix to add a suffix. For example:

If numberPrefix = '$' is set, "$" will be added before all numbers, like this: $20560, $26514.
If numberSuffix = '% 25' is set, "%" is added after the number, as shown in the following figure: 25%, 89%.

We noticed that % is transcoded when FusionCharts displays "%. The next section describes transcoding in detail.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.