简体   繁体   English

Highcharts - 对数轴上的线性系列缩放

[英]Highcharts - Linear series zoom on logarithmic axis

I'm having trouble when zooming in on a linear series that is on a logarithmic yAxis.放大对数 yAxis 上的线性系列时遇到问题。 What would be an easy solution?什么是一个简单的解决方案?

Zoom out:缩小:
在此处输入图像描述

Zoom in:放大:
在此处输入图像描述

Linear series is not rescaling correcly, those series should remain on same position relative to main series, is there any missing configs to those series that would adjust them to logarithmic axis?线性系列没有正确重新缩放,这些系列应该相对于主系列保持在相同的位置,这些系列是否有任何缺失的配置可以将它们调整为对数轴?

Demo: https://jsfiddle.net/bernardo0marques/dfqouLm5/30/演示: https ://jsfiddle.net/bernardo0marques/dfqouLm5/30/

Code snippet:代码片段:

Highcharts.stockChart("container", {
  chart: {
    type: "line",
    zoomType: "xy",
  },
  series: [
    {
      data: [
        {
          x: -220924800000,
          high: 63,
          low: 56,
          close: 62,
          open: 56,
          name: "01/01/1963",
          color: "#F57350",
        },
        {
          x: 1657670400000,
          high: 18893.92,
          low: 18159.03,
          close: 18159.03,
          open: 18593.15,
          name: "13/07/2022",
          color: "#297F0D",
        },
      ],
      dataGrouping: {
        forced: true,
        groupPixelWidth: 0,
        units: [["day", 1]],
      },
      id: "main-series",
      name: "Demo series",
      type: "candlestick",
      yAxis: "default",
    },
    {
      color: "#C0C0C0",
      data: [
        [-220914000000, 369],
        [1659236400000, 198817.91340815497],
      ],
      dashStyle: "LongDash",
      id: "upper-tendency",
      tooltip: {
        valueDecimals: 0,
        xDateFormat: "%B %Y",
      },
      showInLegend: false,
      yAxis: "default",
    },
    {
      color: "#C0C0C0",
      data: [
        [-220914000000, 34],
        [1659236400000, 16672.03531810569],
      ],
      dashStyle: "Solid",
      id: "lower-tendency",
      tooltip: {
        valueDecimals: 0,
        xDateFormat: "%B %Y",
      },
      showInLegend: false,
      yAxis: "default",
    },
  ],
  title: { text: "Logarithmic Zoom: Linear series" },
  tooltip: { shared: true, split: false },
  xAxis: {
    dateTimeLabelFormats: {
      second: "%d/%m/%y<br/>%H:%M:%S",
      minute: "%d/%m/%y<br/>%H:%M",
      hour: "%d/%m/%y<br/>%H:%M",
      day: "%d/%m/%y",
      month: "%m/%y",
      year: "%Y",
    },
    type: "datetime",
  },
  yAxis: [
    {
      id: "default",
      opposite: true,
      type: "logarithmic",
      title: { text: "" },
      reversed: false,
      offset: 50,
      tickInterval: 0.4,
    },
  ],
});

It is a bug which you can track in the following ticket: https://github.com/highcharts/highcharts/issues/16784这是一个错误,您可以在以下票证中跟踪: https ://github.com/highcharts/highcharts/issues/16784

As a temporary workaround, you can set xAxis.ordinal to false in your config.作为临时解决方法,您可以在配置中将xAxis.ordinal设置为false

Demo: https://jsfiddle.net/BlackLabel/rfxygz5m/演示: https ://jsfiddle.net/BlackLabel/rfxygz5m/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM