This is a migrated thread and some comments may be shown as answers.

Suppress rescaling of value axis in chart legend click event

2 Answers 127 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Dirk
Top achievements
Rank 1
Dirk asked on 02 Sep 2013, 09:19 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 04 Sep 2013, 03:33 PM
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!
0
Dirk
Top achievements
Rank 1
answered on 11 Sep 2013, 07:24 PM
Hi,

using the internal API works fine.

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

Thanks
Dirk
Tags
Charts
Asked by
Dirk
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Dirk
Top achievements
Rank 1
Share this question
or