New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with overriding lin2log and log2lin #8106

Closed
PhilBraica opened this Issue Mar 30, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@PhilBraica

PhilBraica commented Mar 30, 2018

This is one of those bugs that if you look at the code, you'll just see it after a bit of thought.

Throughout the highcharts.src.js code you see the lin2log and log2lin functions called 1 of 3 different ways, only one of which works in all cases as expected.

  1. Correct:
    value = axis.lin2log(otherValue);

Inside lin2log, the "this" value is set to the axis, and the local lin2log (or log2lin) function can access other scaling data about how the log is to be applied on that chart. In other words, inside my override:
this !== undefined, so I can then do
return this.userOptions.scale * Math.log(adjustedNum) / Math.LN10

  1. Incorrect
    value = lin2log(otherValue);

When called like this, my override can't know which of my charts / which axis is asking for the conversion because this is undefined.

  1. Incorrect2
    var lin2log = axis.lin2log
    value = lin2log(otherValue);

In this case, var lin2log = axis.lin2log doesn't help at all, I double checked and stepped through the code,
the call to lin2log wasn't binded, (perhaps lin2log = axis.lin2log.bind(axis)?) so when lin2log got called this === undefined.

Going through and substituting axis.log2lin in place of log2lin and axis.lin2log in place of lin2log appears to fix things.

@pawelfus

This comment has been minimized.

Contributor

pawelfus commented Apr 3, 2018

Hi @PhilBraica

Thank you for reporting, you are right we should keep context within this method.

@pawelfus pawelfus added the Bug label Apr 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment