How to get max value by comparing dual y-axis in highchart?
up vote
0
down vote
favorite
I have a chart with dual y-axis, how can i get the min and max value from both?
load: function () {
var series = this.series,
max = series[0].dataMax,
min = series[0].dataMin;
series.forEach(function (serie) {
if (serie.dataMax > max) {
max = serie.dataMax;
}
if (serie.dataMin < min) {
min = serie.dataMin;
}
});
this.yAxis[0].update({
min: min,
max: max
});
I am trying the method above, but it will only get either one side got max value and update the axis value.
How can i make both y axis using the same max value?
javascript jquery highcharts
add a comment |
up vote
0
down vote
favorite
I have a chart with dual y-axis, how can i get the min and max value from both?
load: function () {
var series = this.series,
max = series[0].dataMax,
min = series[0].dataMin;
series.forEach(function (serie) {
if (serie.dataMax > max) {
max = serie.dataMax;
}
if (serie.dataMin < min) {
min = serie.dataMin;
}
});
this.yAxis[0].update({
min: min,
max: max
});
I am trying the method above, but it will only get either one side got max value and update the axis value.
How can i make both y axis using the same max value?
javascript jquery highcharts
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a chart with dual y-axis, how can i get the min and max value from both?
load: function () {
var series = this.series,
max = series[0].dataMax,
min = series[0].dataMin;
series.forEach(function (serie) {
if (serie.dataMax > max) {
max = serie.dataMax;
}
if (serie.dataMin < min) {
min = serie.dataMin;
}
});
this.yAxis[0].update({
min: min,
max: max
});
I am trying the method above, but it will only get either one side got max value and update the axis value.
How can i make both y axis using the same max value?
javascript jquery highcharts
I have a chart with dual y-axis, how can i get the min and max value from both?
load: function () {
var series = this.series,
max = series[0].dataMax,
min = series[0].dataMin;
series.forEach(function (serie) {
if (serie.dataMax > max) {
max = serie.dataMax;
}
if (serie.dataMin < min) {
min = serie.dataMin;
}
});
this.yAxis[0].update({
min: min,
max: max
});
I am trying the method above, but it will only get either one side got max value and update the axis value.
How can i make both y axis using the same max value?
javascript jquery highcharts
javascript jquery highcharts
asked Nov 13 at 3:26
Crazy
395112
395112
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
To get min/max values from an axis, use getExtremes which returns an ExtremesObject. The ExtremesObject has the following properties:
dataMax, dataMin, max, min, userMax, userMin
If you want to set a new min/max value you should use setExtremes
setExtremes( [newMin] [, newMax] [, redraw] [, animation] [, eventArguments])
Set the minimum and maximum of the axes after render time. If the startOnTick and endOnTick options are true, the minimum and maximum values are rounded off to the nearest tick. To prevent this, these options can be set to false before calling setExtremes. Also, setExtremes will not allow a range lower than the minRange option, which by default is the range of five points.
So the get the min and max from both axis, you could do something like this for the min value (if you want to tailor your view to the data and not manually set extremes):
let firstAxisExtremes = chart.yAxis[0].getExtremes(),
secondAxisExtremes = chart.yAxis[1].getExtremes(),
min, max;
if(firstAxisExtremes.dataMin <= secondAxisExtremes.dataMin) {
min = firstAxisExtremes.dataMin
} else {
min = secondAxisExtremes.dataMin
}
API references: getExtremes, setExtremes, ExtremesObject
add a comment |
up vote
0
down vote
Also, you can use your current code and set yAxis.linkedTo property:
...
When an axis is linked to a master axis, it will take the same
extremes as the master, but as assigned by min or max or by
setExtremes. (...)
yAxis: [{}, {
linkedTo: 0,
opposite: true
}]
Live demo: http://jsfiddle.net/BlackLabel/n5bzrqs8/
API: https://api.highcharts.com/highcharts/yAxis.linkedTo
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
To get min/max values from an axis, use getExtremes which returns an ExtremesObject. The ExtremesObject has the following properties:
dataMax, dataMin, max, min, userMax, userMin
If you want to set a new min/max value you should use setExtremes
setExtremes( [newMin] [, newMax] [, redraw] [, animation] [, eventArguments])
Set the minimum and maximum of the axes after render time. If the startOnTick and endOnTick options are true, the minimum and maximum values are rounded off to the nearest tick. To prevent this, these options can be set to false before calling setExtremes. Also, setExtremes will not allow a range lower than the minRange option, which by default is the range of five points.
So the get the min and max from both axis, you could do something like this for the min value (if you want to tailor your view to the data and not manually set extremes):
let firstAxisExtremes = chart.yAxis[0].getExtremes(),
secondAxisExtremes = chart.yAxis[1].getExtremes(),
min, max;
if(firstAxisExtremes.dataMin <= secondAxisExtremes.dataMin) {
min = firstAxisExtremes.dataMin
} else {
min = secondAxisExtremes.dataMin
}
API references: getExtremes, setExtremes, ExtremesObject
add a comment |
up vote
0
down vote
To get min/max values from an axis, use getExtremes which returns an ExtremesObject. The ExtremesObject has the following properties:
dataMax, dataMin, max, min, userMax, userMin
If you want to set a new min/max value you should use setExtremes
setExtremes( [newMin] [, newMax] [, redraw] [, animation] [, eventArguments])
Set the minimum and maximum of the axes after render time. If the startOnTick and endOnTick options are true, the minimum and maximum values are rounded off to the nearest tick. To prevent this, these options can be set to false before calling setExtremes. Also, setExtremes will not allow a range lower than the minRange option, which by default is the range of five points.
So the get the min and max from both axis, you could do something like this for the min value (if you want to tailor your view to the data and not manually set extremes):
let firstAxisExtremes = chart.yAxis[0].getExtremes(),
secondAxisExtremes = chart.yAxis[1].getExtremes(),
min, max;
if(firstAxisExtremes.dataMin <= secondAxisExtremes.dataMin) {
min = firstAxisExtremes.dataMin
} else {
min = secondAxisExtremes.dataMin
}
API references: getExtremes, setExtremes, ExtremesObject
add a comment |
up vote
0
down vote
up vote
0
down vote
To get min/max values from an axis, use getExtremes which returns an ExtremesObject. The ExtremesObject has the following properties:
dataMax, dataMin, max, min, userMax, userMin
If you want to set a new min/max value you should use setExtremes
setExtremes( [newMin] [, newMax] [, redraw] [, animation] [, eventArguments])
Set the minimum and maximum of the axes after render time. If the startOnTick and endOnTick options are true, the minimum and maximum values are rounded off to the nearest tick. To prevent this, these options can be set to false before calling setExtremes. Also, setExtremes will not allow a range lower than the minRange option, which by default is the range of five points.
So the get the min and max from both axis, you could do something like this for the min value (if you want to tailor your view to the data and not manually set extremes):
let firstAxisExtremes = chart.yAxis[0].getExtremes(),
secondAxisExtremes = chart.yAxis[1].getExtremes(),
min, max;
if(firstAxisExtremes.dataMin <= secondAxisExtremes.dataMin) {
min = firstAxisExtremes.dataMin
} else {
min = secondAxisExtremes.dataMin
}
API references: getExtremes, setExtremes, ExtremesObject
To get min/max values from an axis, use getExtremes which returns an ExtremesObject. The ExtremesObject has the following properties:
dataMax, dataMin, max, min, userMax, userMin
If you want to set a new min/max value you should use setExtremes
setExtremes( [newMin] [, newMax] [, redraw] [, animation] [, eventArguments])
Set the minimum and maximum of the axes after render time. If the startOnTick and endOnTick options are true, the minimum and maximum values are rounded off to the nearest tick. To prevent this, these options can be set to false before calling setExtremes. Also, setExtremes will not allow a range lower than the minRange option, which by default is the range of five points.
So the get the min and max from both axis, you could do something like this for the min value (if you want to tailor your view to the data and not manually set extremes):
let firstAxisExtremes = chart.yAxis[0].getExtremes(),
secondAxisExtremes = chart.yAxis[1].getExtremes(),
min, max;
if(firstAxisExtremes.dataMin <= secondAxisExtremes.dataMin) {
min = firstAxisExtremes.dataMin
} else {
min = secondAxisExtremes.dataMin
}
API references: getExtremes, setExtremes, ExtremesObject
edited Nov 13 at 8:40
answered Nov 13 at 8:28
ewolden
3,97431125
3,97431125
add a comment |
add a comment |
up vote
0
down vote
Also, you can use your current code and set yAxis.linkedTo property:
...
When an axis is linked to a master axis, it will take the same
extremes as the master, but as assigned by min or max or by
setExtremes. (...)
yAxis: [{}, {
linkedTo: 0,
opposite: true
}]
Live demo: http://jsfiddle.net/BlackLabel/n5bzrqs8/
API: https://api.highcharts.com/highcharts/yAxis.linkedTo
add a comment |
up vote
0
down vote
Also, you can use your current code and set yAxis.linkedTo property:
...
When an axis is linked to a master axis, it will take the same
extremes as the master, but as assigned by min or max or by
setExtremes. (...)
yAxis: [{}, {
linkedTo: 0,
opposite: true
}]
Live demo: http://jsfiddle.net/BlackLabel/n5bzrqs8/
API: https://api.highcharts.com/highcharts/yAxis.linkedTo
add a comment |
up vote
0
down vote
up vote
0
down vote
Also, you can use your current code and set yAxis.linkedTo property:
...
When an axis is linked to a master axis, it will take the same
extremes as the master, but as assigned by min or max or by
setExtremes. (...)
yAxis: [{}, {
linkedTo: 0,
opposite: true
}]
Live demo: http://jsfiddle.net/BlackLabel/n5bzrqs8/
API: https://api.highcharts.com/highcharts/yAxis.linkedTo
Also, you can use your current code and set yAxis.linkedTo property:
...
When an axis is linked to a master axis, it will take the same
extremes as the master, but as assigned by min or max or by
setExtremes. (...)
yAxis: [{}, {
linkedTo: 0,
opposite: true
}]
Live demo: http://jsfiddle.net/BlackLabel/n5bzrqs8/
API: https://api.highcharts.com/highcharts/yAxis.linkedTo
answered Nov 19 at 13:24
ppotaczek
3,278129
3,278129
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273345%2fhow-to-get-max-value-by-comparing-dual-y-axis-in-highchart%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown