Suppress rescaling of value axis in chart legend click event

3 posts, 1 answers
  1. Dirk
    Dirk avatar
    27 posts
    Member since:
    Aug 2013

    Posted 02 Sep 2013 Link to this post

    Hi,

    is there a simple way (not setting min and max values) to suppress rescaling of value axis if one series of stacked areas is hidden via legend click?
    More details: the chart calculates the min and max values for stacked areas (bars etc) perfectly. But as soon as you hide a series via click on appropriate legend item ,the max value for the axis gets recalculated, which is not always wanted.

    Setting min and max values manually is difficult, because data is loaded dynamically via JSON and calculating appropriate range on Server (aggregate of all data!) and transferring data to client is - from my point of view - not a good way to go since the chart itself calculates min and max very good...

    Thanks in advance
    Dirk
  2. Answer
    T. Tsonev
    Admin
    T. Tsonev avatar
    2831 posts

    Posted 04 Sep 2013 Link to this post

    Hello,

    There's no public API that will give us the current axis range. We can do this by accessing the axis implementation class.
    We need to do this after the dataBound event:

        dataBound: function() {
           var chart = this;
            setTimeout(function() {
              // Using dataBound + setTimeout to wait for the axis to be ready
              // Ideally, this should be done in a (non-existing) "render" event
              chart.options.valueAxis.max = 
                chart._plotArea.valueAxis.range().max;
            });
        }

    -- Live demo --

    Relying on a private implementation always carries the risk of breaking changes. Please double check on updating to newer versions.

    Regards,
    T. Tsonev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Dirk
    Dirk avatar
    27 posts
    Member since:
    Aug 2013

    Posted 11 Sep 2013 Link to this post

    Hi,

    using the internal API works fine.

    Maybe it does make sense to have an according chart option in a future release.

    Thanks
    Dirk
Back to Top