Skip to content
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

parallel channel in Highstock does not work in logarithmic mode #16769

Closed
anoosurf opened this issue Dec 8, 2021 · 2 comments · Fixed by #19548
Closed

parallel channel in Highstock does not work in logarithmic mode #16769

anoosurf opened this issue Dec 8, 2021 · 2 comments · Fixed by #19548

Comments

@anoosurf
Copy link

anoosurf commented Dec 8, 2021

Expected behaviour

when drawing a parallel channel the chart should take into accoun the logarithmic scale and appear parallel to end user even in that case.. that is how stock trader would use

Actual behaviour

when in logarithmic mode, it gets skewed which is incorrect

Live demo with steps to reproduce

https://jsfiddle.net/anoosurf/uzwvrhjt/3/

Product version

highcharts /highstock 9.3.2

Affected browser(s)

image

@highsoft-bot highsoft-bot added this to To do in Development-Flow Dec 8, 2021
@raf18seb
Copy link
Contributor

raf18seb commented Dec 9, 2021

Hi @anoosurf, thank you for reporting a bug!

Internal note:

  • When fixing for a parallel channel, check other annotations too.

@pawelfus
Copy link
Contributor

Workaround:
Demo: https://jsfiddle.net/BlackLabel/o93v7quz/
Plugin:

(function(H) {
  H.wrap(
    H.Annotation.types.tunnel.prototype,
    'getPointsOptions',
    patch16769
  );

  function patch16769(proceed, ...args) {
    const points = proceed.apply(this, args),
      yAxisIndex = points[0].yAxis,
      yAxis = this.chart.yAxis[yAxisIndex];

    // In case of log axis, translate the bottom left point again
    if (yAxis && yAxis.logarithmic) {
      // Get the height in pixels
      const h = yAxis.toPixels(points[2].y) - yAxis.toPixels(points[1].y),
      // Get the pixel position of the last point
        y3 = yAxis.toPixels(points[0].y) + h;

      // Set the new value
      points[3].y = yAxis.toValue(y3);
    }

    return points;
  }

})(Highcharts);

Internal note:
It's caused by using height to control all bottom points. We simply add height value to the first two points' values in heightPointOptions(). Even though it's mathematically correct, visually we can observe the skew. For example this demo: (tunnel has height=20)
Zrzut ekranu 2021-12-10 o 12 30 10

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

Successfully merging a pull request may close this issue.

5 participants