amcharts / amcharts4

The most advanced amCharts charting library for JavaScript and TypeScript apps.
https://www.amcharts.com/
1.16k stars 322 forks source link

Should We Filter Null Values Before Providing Data to AmCharts 4? #4425

Closed amtjoshi closed 1 month ago

amtjoshi commented 1 month ago

I am working with AmCharts and have a dataset that sometimes includes null values. For example:

javascript Copy code

const data = [
  { data: null, timestamp: 111 },
  { data: 10, timestamp: 112 },
  { data: null, timestamp: 113 },
  { data: 20, timestamp: 114 },
];

I wanted to know whether it is necessary to filter out these null values before passing the data to AmCharts, or if the library can handle null data points gracefully.

Will including null values affect the chart rendering or performance? Are there any best practices for handling such scenarios when using AmCharts? What is the recommended approach to ensure that the chart accurately reflects the intended data without misleading gaps or errors?

martynasma commented 1 month ago

You don't need to filter out null values.

If you are plotting a LineSeries and set connect = false on it, null values will break the line on those places.

As for performance, it depends how many data points there are. If you have thousands of data points and a lot of them are nulls, it makes sense to filter them out so that chart does not have to waste time parsing them.