MCPcopy
hub / github.com/msgbyte/tianji / CustomizedErrorArea

Function CustomizedErrorArea

src/client/components/monitor/CustomizedErrorArea.tsx:7–48  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

5import { Rectangle } from 'recharts';
6
7export const CustomizedErrorArea: React.FC = (props) => {
8 const { colors } = useTheme();
9 const y = get(props, 'offset.top', 10);
10 const height = get(props, 'offset.height', 160);
11 const points = get(props, 'formattedGraphicalItems.0.props.points', []) as {
12 x: number;
13 y: number | null;
14 }[];
15
16 const errorArea = useMemo(() => {
17 const _errorArea: { x: number; width: number }[] = [];
18 let prevX: number | null = null;
19 points.forEach((item, i, arr) => {
20 if (i === 0 && !item.y) {
21 prevX = 0;
22 } else if (!item.y && prevX === null && arr[i - 1].y) {
23 prevX = arr[i - 1].x;
24 } else if (item.y && prevX !== null) {
25 _errorArea.push({
26 x: prevX,
27 width: item.x - prevX,
28 });
29 prevX = null;
30 }
31 });
32
33 return _errorArea;
34 }, [points]);
35
36 return errorArea.map((area, i) => {
37 return (
38 <Rectangle
39 key={i}
40 width={area.width}
41 height={height}
42 x={area.x}
43 y={y}
44 fill={colors.chart.error}
45 />
46 );
47 });
48};
49CustomizedErrorArea.displayName = 'CustomizedErrorArea';

Callers

nothing calls this directly

Calls 2

useThemeFunction · 0.90
getFunction · 0.85

Tested by

no test coverage detected