1

in code i provided i have a data series column with unevenly spaced data, and set min value for xAxis with 1658086242000, but after seeing chart i saw 2 value that is before my min point, why is that?! my whole code:

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 i already tried startOnTick or pointPlacement but didn't worked

1 Answers1

0

This is related to the series.pointRange which is counted from the distance between the two closest data points and because of that takes more space. You can fix that by changing the pointRange and disable xAxis.ordinal option.

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

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

Example demos: https://jsfiddle.net/BlackLabel/8913ge2f/ https://jsfiddle.net/BlackLabel/tu7vy80z/

API Reference: https://api.highcharts.com/highstock/series.column.pointRange https://api.highcharts.com/highstock/xAxis.ordinal

magdalena
  • 2,657
  • 1
  • 7
  • 12
  • still can see 2 value column that is before min point – shahrooz bazrafshan Jul 18 '23 at 14:26
  • Hi, this is related to the `series.pointRange` which is counted from the distance between the two closest data points and because of that takes more space (https://api.highcharts.com/highstock/series.column.pointRange) . You can fix that by changing the pointRange. To illustrate how it works: https://jsfiddle.net/BlackLabel/n5gvya1m/ and example solution https://jsfiddle.net/BlackLabel/n2xeaby9/ – magdalena Jul 20 '23 at 13:16
  • thk, it worked, i wonder why it should not happens by default, can you change answer maybe help some one else – shahrooz bazrafshan Jul 22 '23 at 07:41
  • thanks for the suggestion, I updated the answer – magdalena Jul 24 '23 at 08:31