开发者

How to set second yAxis scale according to data from first yAxis

开发者 https://www.devze.com 2023-03-27 09:49 出处:网络
I have an odd request. My boss wants me to improve an existing chart with a second axis. The blue area must define the scale of the second axis, like a percentage of completion for the reading of th

I have an odd request. My boss wants me to improve an existing chart with a second axis.

How to set second yAxis scale according to data from first yAxis

The blue area must define the scale of the second axis, like a percentage of completion for the reading of the green area. The 100% value must be at the maximum of the blue area. I can collect the highest value of the blue area without any trouble, but I don't kno开发者_开发问答w how to set the properties of the second axis according to this value. The thing is that the second axis does not have any data associated, therefore, he isn't shown...

Any idea ?

PS : I tried to be as clear as possible, but maybe that was not the case. Don't hesitate to tell me if you need more explanations.


You can use axis.linkedTo to get a second axis and data formatters to get the data formatted as percentages.

I'm not modifying the series data, only changing the text shown in the second yAxis scale, the tooltip and the data labels.

yAxis: [{
    // Default options
}, {
    linkedTo: 0,
    opposite: true,
    labels: {
        formatter: function () {
            return formatPercent(this.value);
        }
    }
}]

Example on jsFiddle: http://jsfiddle.net/uPHZx/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号