How to get max value by comparing dual y-axis in highchart?
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 |
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 |
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 '18 at 3:26
CrazyCrazy
407115
407115
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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 |
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 |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 |
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 |
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 '18 at 8:40
answered Nov 13 '18 at 8:28
ewoldenewolden
4,21031225
4,21031225
add a comment |
add a comment |
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 |
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 |
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 '18 at 13:24
ppotaczekppotaczek
4,8861210
4,8861210
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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