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?
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,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hello I want to do the same thing but when I try this solution it is not working. In visual studio
<ig:NumericXAxis.Label> <DataTemplate>
</DataTemplate>
I have the message "Resource is never used" and it does not work.
Not sure why.
Hello Marc,
I have been investigating into the behavior you are seeing where the solution I provided above is not working, but at this time I am unable to reproduce an error where a message “Resource is never used” appears.
I have updated the sample project I provided above to version 2021.1 (specific version 21.1.20211.27) and I am attaching it here. If you are using a different version, please let me know what version you are using so I may test against it, but it appears that the code I provided in 2016 is still valid for showing superscript labels with the XamDataChart with the latest version of Infragistics for WPF at the time of writing this.
XamDataChartSuperScriptLabelsCase.zip
thanks for the quick response. We are currently using V15.2 of the XamDataChart dll. I know it old :-(
Can you check it is a 15.2 problem?
I think we can use 17.2 because some other dlls in the project are 17.2.
If it is a 15.2 problem, if I use 17.2, will it work?
Thanks again
Marc Samson
Agilent Technologies
I have changed the assemblies locally to target the latest service release of 15.2 and 17.2 and I can confirm that it works with both versions. For reference, those specific versions are 15.2.20152.2212 and 17.2.20172.2217. Everything is still working as expected, which leads me to believe this may be something you are missing or something specific with the project are using?
Assuming you are not using the sample project I have provided directly, and are just trying to use code from it, would it be possible for you to please attach an isolated version of the sample you are using such that it reproduces the behavior you are seeing?
Thanks for checking.
I thought the problem was the "Resource is never used " message I am seeing but I see the same message with your project and it is running OK.
This is the exception I am getting
System.Windows.Markup.XamlParseException: 'A TwoWay or OneWayToSource binding cannot work on the read-only property 'Item' of type 'Infragistics.Controls.Charts.AxisItemDataContext'.'
I am using .net Framework 4.8. So I changed your project to use it also.
Now Your project sends the same error.
I have added , Mode=OneWay to the Item binding and it is fixing this error in your project and in mine. :-)
However I now see an other error in my project.
System.Windows.Markup.XamlParseException: ''Add value to collection of type 'Infragistics.Controls.Charts.AxisCollection' threw an exception.' Line number '209' and line position '22'.'
{"The value \"- \" is not of type \"Infragistics.Controls.Charts.Axis\" and cannot be used in this generic collection.\r\nParameter name: value"}
I am searching the cause for this now.
Thanks
Thank you for your update on this matter. I have updated to .NET 4.8 and I was able to reproduce the behavior you are seeing as well. It seems that this may be something specific to this version of .NET Framework, but setting the Mode to OneWay does appear to resolve it.
Regarding the new XamlParseException you are seeing, this sounds like a syntax error in your XAML that is trying to add something other than one of the XamDataChart axes to the Axes collection. I’d be curious to know what line 209 and the surrounding code of your XAML looks like, as this error appears to be calling that out, specifically.
I found the problem in my code. Thanks. It is now working.