0

I'm using a Silverlight chart to display data that contains very big numbers.

Having labels on the axes like "36000000000000" isn't particularly great. How can I format them as exponentials like "3.6 x 10^13"?

alnorth29
  • 3,525
  • 2
  • 34
  • 50

1 Answers1

0

What you want is a numeric string format which will take a number and output a string of the format you want.

Here's a list of some basic numeric string formats built into .NET:

http://msdn.microsoft.com/en-us/library/0c899ak8.aspx

So for example, you could use the following code to convert a big number into a condensed format:

long bigNum = 36000000000000;
string displayString = bigNum.ToString("e0");

You can utilize these right in XAML if you're using a binding, either by creating a IValueConverter object to do a custom conversion, or use a StringFormat on the binding itself. You may have to post more details about your implementation of your chart to determine how to create a template for the display of the axes labels.

So essentially you may have two different problems which need a solution:

  1. Finding or creating a String Format provider which can format your numbers into strings you want.

  2. Customizing the labels on your chart control.

So let us know which issue it is you need help with (or both) and post the code for your chart.

Trevor Elliott
  • 11,292
  • 11
  • 63
  • 102