How can I set up a numeric X-Axis to look like this?
I already achieved it by using a converter. So my axis goes from -0.7 to 0.7 but I just use a converter to display a 0.2 instead of a 0.1 and 0.3 instead of 0.2, etc. But the problem with that is that XMemberPath of the data also needs to be manipulated before being passed to the chart, else the data appears to be plotted incorrectly because it is going by the original X-Axis points rather than the converted ones. So I have 2 questions actually:
Can the same converter be somehow applied to the XMemberPath. (Couldnt find a way to do this) OR
Is it possible to manipulate the min, max, interval values of the axis to get this look for the X-Axis.
Thanks.
Thank you!!
I will read about custom scalers.
Sudnya
Hello sudnya_s,
There currently does not exist the functionality to apply a converter to the XMemberPath. Essentially what that property does, is it ties back to a property on your underlying data item using reflection, and then uses the exact value that each of your data items returns for that property path. In order to "convert" these values, I would recommend doing what you are currently doing, which is manipulating the original x-value in a separate accessor, and tying that to your series' XMemberPath instead.
As far as a way to have this work by manipulating the NumericXAxis, I suppose it could be possible to have this functionality if you wrote a custom Scaler for your axis. This would allow you to define a range and then scale or unscale certain values to show up further down or further up the NumericXAxis. You can read about creating custom scalers here: https://es.infragistics.com/help/wpf/datachart-creating-custom-axis-scalers.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hi Andrew.
Thanks for your reply. It is not acceptable to put blank strings for the -0.1, 0 and 0.1. As you will see from my attachment, they are totally skipped and the first tick is at 0.2. Like I mentioned, in my question, I am already using converters to format the X-Axis labels just like you suggested. I have also created another accessor thats manipulates the original x value and then I tied in the XMemberPath to this new accessor. However, I was interested in knowing if there is a way to achieve this by actually manipulating the X-Axis in some other way or if there was a way to apply a converter to the XMemberPath rather than in the underlying data class.
In order to achieve a look for the NumericXAxis like is depicted in your attachment, I would recommend continuing by setting the Minimum and Maximum Value properties to -0.7 and 0.7, respectively. You can also set the Interval property to 0.1.
By default, this will show the labels for 0, -0.1, and 0.1, but if you handle the FormatLabel event of the NumericXAxis, you can prevent this. This event has a string return type, and the "item" event argument will return you the value of the label to be drawn. If you catch the -0.1, 0, and 0.1 labels as they are drawn, you can return string.Empty instead. The same goes for your negative values showing as absolute. You can use the FormatLabel event here to check if the item parsed to a double is negative and if so, return the absolute value of that parsed double as a string.
Note, this will keep the space where 0, -0.1, and 0.1 would have been. If this is acceptable for you, I would recommend that you take a look at the sample project that I have attached, as it demonstrates the procedures above. If not, then I would recommend continuing with your current method, but perhaps have a separate property on your underlying data item that you can convert your value into. You can then use your series' XMemberPath with that property instead, rather than the one that contains your "actual" value.
I hope this helps. Please let me know if you have any other questions or concerns on this matter.
Here is an attacment of the image (which is not showing up in the original post).