highcharts xAxis min在不均匀间隔的xAxis数据中不起作用

dw1jzc5e  于 2023-08-05  发布在  Highcharts
关注(0)|答案(1)|浏览(168)

在我提供的代码中,我有一个数据序列列,其中数据间隔不均匀,并为xAxis设置了1658086242000的最小值,但在看到图表后,我看到了2个值,在我的最小点之前,为什么呢?我的整个代码:

const simpleData = [ [
                1638748800000,
                1
            ],
            [
                1654387200000,
                2
            ],
            [
                1670284800000,
               3
            ],
            [
                1678060800000,
                4
            ],
            [
                1685923200000,
                5
            ]
        ];
    Highcharts.stockChart('container', {

        title: {
            text: 'Unevenly X axix data min value'
        },

        xAxis: [{
            type: 'datetime',
            min:1658086242000
        }],
        navigator: {
          enabled: true,
          maskFill: "rgba(37, 150, 190,0.3)",
          series: [{
                type: 'column',
            name: 'series1',
            data: simpleData,
                dataGrouping: {
                enabled: false
                }
            }
                    ],
          xAxis: {
            gridLineColor: 'transparent',
          }
        },
        series: [{
            type: 'column',
            name: 'series1',
            data: simpleData,
                        showInNavigator: false,
            dataGrouping: {
               enabled: false,
            }
        }]
    });

字符串
sample code我已尝试startOnTick或pointPlacement,但不起作用

ubby3x7f

ubby3x7f1#

这与series.pointRange有关,series.pointRange是从两个最近的数据点之间的距离计算出来的,因此需要更多的空间。您可以通过更改pointRange并禁用xAxis.ordinal选项来解决此问题。

xAxis: {
      ordinal: false,
      tickInterval: 24 * 3600 * 1000 // optionally
      ...
    },

  series: [{
    pointRange: 30 * 24 * 3600 * 1000
    ...
  }]

字符串

示例演示:https://jsfiddle.net/BlackLabel/8913ge2f/https://jsfiddle.net/BlackLabel/tu7vy80z/
API引用:https://api.highcharts.com/highstock/series.column.pointRangehttps://api.highcharts.com/highstock/xAxis.ordinal

相关问题