2

I saw that in the .NET version of LightningChart that there is a way to add breaks in line charts. Is this possible in the JS version as well? I saw someone ask a similar question a couple years ago, but hoping that this has been implemented since then.

I've looked through the documentation and examples and didn't couldn't find anything. I'm hoping to replicate something that looks like this in ApexCharts: https://apexcharts.com/javascript-chart-demos/line-charts/null-values/

Force
  • 3,288
  • 1
  • 13
  • 19

1 Answers1

1

Line breaks in LineSeries can be specified by using NaN.

At this time there is no official mention of supporting this, but this is just about to be changed with the next version release. Afterwards, please check the data input method documentation of each series type whether this is supported or not because it might be that not all features support it.

Here is a snippet with the same data as in your referenced ApexCharts example.

const {
  lightningChart
} = lcjs

const chart = lightningChart().ChartXY()
const data = [
  [5, 5, 10, 8, 7, 5, 4, NaN, NaN, NaN, 10, 10, 7, 8, 6, 9],
  [10, 15, NaN, 12, NaN, 10, 12, 15, NaN, NaN, 12, NaN, 14, NaN, NaN, NaN],
  [NaN, NaN, NaN, NaN, 3, 4, 1, 3, 4, 6, 7, 9, 5, NaN, NaN, NaN]
]
data.forEach(yValues => chart.addPointLineSeries().addArrayY(yValues))
<script src="http://unpkg.com/@arction/lcjs@3.3.0/dist/lcjs.iife.js"></script>
Niilo Keinänen
  • 2,187
  • 1
  • 7
  • 12
  • 1
    Thanks again Niilo, this is working well, but I've noticed that when you send 'NaN' values it causes the Y axis min interval to scale down to 0. I've added some code to reset the Y interval after a 'NaN' value has been sent, but it cause the Y axis to snap up and back a bit. Thoughts? This is super minor, but figured I'd ask. – Force Feb 05 '22 at 23:53
  • This is a very good observation. Thanks, we'll add it to our issues list on NaN values. Frankly, we are also not 100% aware of all the consequences of using NaN values - it's new to us too. – Niilo Keinänen Feb 06 '22 at 08:16