Count ticks on CategoricalAxis?

4 posts, 0 answers
  1. Sam
    Sam avatar
    67 posts
    Member since:
    Jun 2011

    Posted 20 Nov 2014 Link to this post

    Hi, how do I determine the number of ticks on a CategoricalAxis, purely from the axis object itself, if possible?

    Thanks,

    Sam

  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 25 Nov 2014 Link to this post

    Hello Sam,

    Currently, the axes do not have any API for this. We do have plans to enhance our axes in a few directions, one of which is to allow the users to have information about the actual categories in the axis and the data points associated with each category. However, at the moment we don't have this.

    One approach would be look at the series associated with the axis, and make a set of the categories. This, obviously does not use purely the axis object.

    Another approach would be to find the visible visual elements in the axis - Rectangle elements are ticks, TextBlock elements are labels (or ContentPresenters, if you are using a LabelTemplate). Note, there is one ContentPresenter used for measurement purposes only.

    Sam, if this is related to the other issues I have been helping with
    #882350, Serious issue trying to apply adaptive stepping to LinearAxis / RadCartesianChart
    #881364, URGENT: Need help calculating optimal MajorStep on LinearAxis (Y-Axis)
    I must say that the second approach is inapplicable and the first is just not as good as the proposal I have made in ticket #882350.

    I hope this information helps. Perhaps you can explain what you need as a final result, so that we can give an even better approach. Let us know if you need more information.

    Regards,
    Petar Marchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Sam
    Sam avatar
    67 posts
    Member since:
    Jun 2011

    Posted 25 Nov 2014 in reply to Petar Marchev Link to this post

    Hi Petar,

    Thanks for the reply - I ended up counting the visible TextBlock children of the axis that did not have the same text as the axis title, this works very well, particularly as the text is already arranged and measured so it is very easy to determine the maximum width of labels on the axis. 

    We have charts that enable custom labels to be specified by the user, so in order to control the stepping of the axis correctly we have to know what the actual widths of all the labels are so that can inform the stepping behaviour by providing the maximum label width.
  5. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 26 Nov 2014 Link to this post

    Hi Sam,

    Thank you for the additional information.

    As already discussed in the other tickets, we do not have a built-in feature that avoids labels overlapping. I think that your solution should not rely on the actual width of the text block. I will explain why.

    You can get the actual width of the currently displayed text blocks, but you do not know the width of the categories (or numeric values) that will be displayed after setting the tick interval property (or major step property). So after changing the tick interval, the max actual width may very well change, which will most probably lead to your code choosing a new tick interval, which may lead again to different max actual width ... I hope you see that you may get into a very unpleasant cycle, flickering or even application freeze.

    A safer way to go is to assume that the max label width is 100 (or any other number you like).

    I mentioned that this is a feature that we do not have and it doesn't make much sense not have it. I have reported this to our development team and its priority will be raised. Hopefully, this will soon be available out-of-the-box and you will no longer need a work-around.

    Regards,
    Petar Marchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top