Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
How to display axis numbers in Scientific notation - Xamdatachart
posted

I am able to set the axes as logarithmic but would like to display the axis numbers in scientific notation. Could anyone please advice on how to do the same?

 

Parents
No Data
Reply
  • 34810
    Suggested Answer
    Offline posted

    Hello P D,

    Thank you for your post.

    To set the labels of a numeric axis to be in exponential format or scientific notation, I would recommend writing a new DataTemplate for the numeric axis' Label property. In this DataTemplate, I would recommend placing a TextBlock with a pair of Run objects for its Text. The first Run can have its Text property set to "10" or whichever base you choose to use with your logarithmic axis. By default, this value is 10 when you set the IsLogarithmic property of your axis to "true."

    For the second Run element, I would recommend setting the BaselineAlignment property to "Superscript" and bind the Text property to Item with an IValueConverter. This "Item" binding will bind to the Item property of the AxisItemDataContex object that makes up the data context of the items you are using for your Label. In the case of the numeric axes in the XamDataChart, this will pass the number that would've been shown by the label by default to your converter. In your converter, you can take the string representation of this number, parse it, and return a number that represents the power that your base 10 is raised to in order to create that number.

    I have attached a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamDataChartSuperScriptLabelsCase.zip
Children