Skip to main content Skip to footer

Scale Large Numeric Values with Wijmo's Globalize Class

Wijmo's Globalize class now supports .NET-style scaling specifiers, allowing you to easily express a large numeric value in a shorter, more readable way. It's especially useful for labeling grids and charts.

About Scaling

We all use scaling when dealing with large numeric values. For example, we talk about populations in millions, budget deficits in billions or trillions, and storage capacities in giga or terabytes (which are the same as billions and trillions). In many cases, scaling make numbers easier to compare, understand, and deal with. Wijmo’s Globalize class makes scaling easy and convenient by supporting .NET-style scaling specifiers. You can scale values by appending commas to any Wijmo format string. Each trailing comma causes the value to be divided by one thousand. For example:

Format String

Description

n0

No scaling

n2,

Thousands (kilo)

n2,,

Millions (mega)

n2,,,

Billions (giga)

n2,,,,

Trillions (tera)

Adding scaling support to the Globalize class means it is automatically available in all Wijmo controls, including for example the FlexGrid and FlexChart. It also makes this feature available to applications, eliminating the need for extra conversion steps that can be tedious and error-prone. One of our examples has a chart that shows the correlation between country populations and GDP. The sample uses scaling to convert population figures from units to millions and GDP from millions to billions as follows:

chart.axisX.title = 'Population (millions)';  
chart.axisX.format = 'n0,,'; // scale from units to millions  
chart.axisY.title = 'GDP (US$ billions)';  
chart.axisY.format = 'n0,'; // scale from millions to billions

This is much simpler and more efficient than creating an extra copy of the data and calculating the conversions in code.

Expanded in version 5.20152.76

MESCIUS inc.

comments powered by Disqus