lightningchart

Y-Axis fitting does not work for LineSeries when Y-Axis data is constant


My expectation is that the Y-axis will fit correctly whatever the data is.

This is my code about "setScrollStrategy" and "addArrayY"

const chart = lightningChart().ChartXY()

chart.getDefaultAxisY().setScrollStrategy(AxisScrollStrategies.fitting)

const series = chart
          .addLineSeries({
            dataPattern: {
              pattern: "ProgressiveX",
              regularProgressiveStep: true,
            },
          })

series.addArrayY([10,10,10, ..., 10])

Chart doesn't fit. And When I call the fit method manually, the view fits where I want it to be.

What should I do to make Y-Axis fitting always works whatever the data is?


Solution

  • I think it would be expected behavior if in this case the Y axis would automatically scroll to [9, 11] for example, so the data would be visible at least. This currently happens if you programmatically do chart.getDefaultAxisY().fit().

    I'll push this as a fix to a future LCJS release.