Dynamically setting the "MAX" value on the valueAxis the same for two charts

2 posts, 0 answers
  1. Lisa
    Lisa avatar
    35 posts
    Member since:
    May 2011

    Posted 05 Sep 2013 Link to this post

    Hi - I would like to set the Max value on the valueAxis for two charts to the same value.  I want to use the max value found, and it won't always be the same or even on the same chart.  The charts sit side-by-side on my page and having the max be different can be misleading for our customers.  Attached is a screen shot showing what I mean.  In this case, I'd want the max to be either 43.36, or better yet rounded up to 50, for both charts, since that's the largest value I have.

    Is there a way to do this?  I can of course hard-code a value, but we get quite a range depending on what the users pick to look at.


  2. T. Tsonev
    T. Tsonev avatar
    2760 posts

    Posted 06 Sep 2013 Link to this post


    I was about to suggest that you use data source aggregates to get the maximum value, but this won't work well as the axis extend beyond that.
    There's no public API that will get us the effective axis range, but we can reach to the implementation objects to get this information.

        function createMaster() {
            // ...
            dataBound: function() {
              setTimeout(createSlave, 0);

        function createSlave(e) {
          var master = $("#chartMaster").data("kendoChart"),
              max = master._plotArea.valueAxis.range().max;
            // ...
            valueAxis: {
              max: max

    -- Live demo --

    The setTimeout is necessary as we don't have an event that fires when the axis range is set. This happens immediately after data binding.
    Please keep in mind that relying on implementation details such as _plotArea carries a risk, as they're subject to change. Please test when upgrading.

    I hope this helps.

    T. Tsonev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top