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
230
Custom labels on CategoryXAxis
posted

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

Parents
  • 405
    posted

    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

Reply Children