Label valueAxis only on whole numbers when min and max are decimal

6 posts, 0 answers
  1. Ross
    Ross avatar
    3 posts
    Member since:
    Apr 2012

    Posted 04 May Link to this post

    I have line chart with 2 y axes (valueAxis) representing centimeters and inches. It's important that they align so that the cm value on one is equivalent to the inch value on the other. I have given the cm axis a min of 28 and a max of 55. This means the inch axis would have a min of 11.02 and a max of 21.65. But I want the inch axis to be labeled only on ticks representing whole numbers. Is there a way to do this? I've tried setting the label.skip to 1 and label.majorUnit to .98 so the first label would be at 12. I then created and label.visual function where I modified the label.majorUnit to 1 so the next label would be 13, but this didn't work. It ended up skipping the 13 and labeled the rest with decimals, which was confusing. I've tried a lot of things along these lines. Any suggestions? Thanks.
  2. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 09 May Link to this post

    Hi Ross,

    You could use the visual setting of the value axis labels to control what is rendered. For your convenience here is a basic example.

    Regards,
    Iliana Nikolova
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Ross
    Ross avatar
    3 posts
    Member since:
    Apr 2012

    Posted 09 May in reply to Iliana Nikolova Link to this post

    Hi Iliana -

    Your example stops labeling after the 12. How do I label 13, 14, etc. without labeling the decimal ticks?

    thanks
    Ross

  5. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 11 May Link to this post

    Hi Ross,

    With the provided configuration from your first post (min, max, majorUnit etc.) 13 and 14 labels are not rendered (dojo). If you would like to keep this configuration but render different labels you should use custom JavaScript logic in the valueAxis.labels.visual function. A basic example is here

    Regards,
    Iliana Nikolova
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Ross
    Ross avatar
    3 posts
    Member since:
    Apr 2012

    Posted 11 May in reply to Iliana Nikolova Link to this post

    Hi Iliana -

    I'm not trying to round the decimal numbers. I'm trying to label only the non-decimal numbers. So if the numbers are 12.98, 13, 13.5, 13.6, 14, 15, 15.7, then only 13, 14 and 15 would get labels.

    thanks
    Ross

  7. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 13 May Link to this post

    Hi Ross,

    The example in my first post demonstrates how to achieve this. However, as I mentioned with the with the labels configuration from your first post 13, 14 and 15 are not rendered. Could you please modify my example and demonstrate your exact setup - maybe I am missing something? Thank you in advance for your cooperation.

    Regards,
    Iliana Nikolova
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready