I have a series chart that displays data in a frequency domain. The data values along the x-axis are very precise, which cases awkward labeling along the x-axis.
I know I can use formatting to clean up the numbers a bit, but I'd rather have custom labeling for more "sensible" labeling steps. For example, in this case, I'd like labels at "1000", "2000", "3000", 4000", "5000" and "6000", even though I don't have data points that correspond to those values. Is it possible to layer in custom labels that do not correspond to the available data points? The only thing I found close to something like this was the custom ticks, but CategoryXAxis doesn't support those. I have a hunch that what I'll need to do is remove labeling from this x-axis, and add another x-axis that contains the values corresponding to the labels I want. Is that right? Is there an easier way that doesn't involve multiple axes?
Thanks
Jason
Hello Jason,
Thank you for your post.
In CategoryXAxis, the data is treated as a sequence of category labels and the marker is placed at a point along the X-axis according to its position in the sequence. CategoryXAxis is used when you need to separate data into categories. To plot the data, xamDataChart uses a value for the Y axis and then the category to visualize on the X axis. The category axis values do not have any order. It you use numbers for a category it is common that you see a sequence on the axis like "50 60 10 20". The numbers are interpreted as labels/tags, not numbers.
In the image that you provided, using the category axis, to make the numbers more readable, you can create a data template for the labels and round the values to more sensible ones. To create the data template, use the following code:
<ig:CategoryXAxis.Label>
<DataTemplate>
</DataTemplate>
</ig:CategoryXAxis.Label>
Inside, you could define a text block to bind to the values and then add a converter that rounds the numbers. You can round 445.936 to 400, 1436.903 to 1400, etc. - to the closest integer divisible by 100. But the values will be misplaced.
Category axis is meant to be used when you need to show a property of the data point. When the property is a numeric value, we recommend using a numeric axis. By using numeric axis you will be able to set minimum and maximum value of the axis and the interval between two adjacent values. You can also calculate those values in code behind based on the data in your collection, and then set the values to the numeric axis.
For more information about axes, refer to this page - http://help.infragistics.com/NetAdvantage/WPF/?page=xamDataChart_Axes.html.
I can have a better look at your issue if you could send me a sample project with the data you want to plot.
Let me know if this works for you.
Sincerely,
Lazar Nikolov
Infragistics
www.infragistics.com/support
Hello Lazar,
Thank you for the response. Unfortunately, using the DataTemplate to round off the numbers won't suffice for this application. I cannot have the labels be misplaced; it throws off the users perception of the data.
I did look into NumericXAxis when I initially approached this, but from what I could tell, it's only supported with a ScatterSeries. This won't work for me, because I need to support Area and Column style charting.
My scenario can be recreated easily by having any data points with arbitrary x-axis values (1.3, 2.7, 3.2, etc.) and then attempting to produce labels at the round value locations (1,2,3,etc.). But if it would be helpful for me to provide a project that does this, I can put something together.