Line plot not connected

Hi,
I’m using plotly.js for a 3D line plot.
I followed the sample https://plotly.com/javascript/3d-line-plots/.
However, in one of my data, the plot is not connected.
newplot

Anyone have an idea why it look like that?
I have try some layout option but nothing works.
Here is my code:

      Plotly.newPlot(
        plotDiv.current.id,
        [
          {
            type: 'scatter3d',
            mode: 'lines',
            x,
            y,
            z,
            opacity: 1,
            line: {
              width: 6,
              color: 'red',
            },
          },
        ],
        {
          height: 400,
          width: 400,
          margin: {
            r: 10,
            t: 10,
            l: 10,
            b: 10,
          },
          scene: {
            zaxis: {
              range: [_.max(z), _.min(z)],
              title: 'DEPTH',
            },
            xaxis: {
              range: [_.min(x), _.max(x)],
              title: 'X ( x1000 )',
            },
            yaxis: {
              range: [_.min(y), _.max(y)],
              title: 'Y ( x1000 )',
            },
          },
        }
      );