-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathhelper.ts
More file actions
25 lines (22 loc) · 910 Bytes
/
helper.ts
File metadata and controls
25 lines (22 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) 2025 The Linux Foundation and each contributor.
// SPDX-License-Identifier: MIT
import { isArray } from 'lodash-es';
export const isEmptyData = (value: Record<string, unknown>[] | null | undefined) => {
// check if the value is null or undefined or the length of the value is 0
if (value === null || value === undefined || value.length === 0 || !isArray(value)) {
return true;
}
// Check if all values in the chart data are 0
return value.every((dataPoint) => {
const values = dataPoint.values as number[];
if (!values) {
return false;
}
return (values[0] || 0) === 0 && (values[1] || 0) === 0;
});
};
export const isElementVisible = (element: HTMLElement) => {
const rect = element.getBoundingClientRect();
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
return rect.top >= 0 && rect.bottom <= windowHeight;
};