• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SAP / ui5-webcomponents-react / 9806057916

05 Jul 2024 09:19AM CUT coverage: 80.734% (-0.2%) from 80.928%
9806057916

Pull #6020

github

web-flow
Merge 5cdfcb721 into dba28ce13
Pull Request #6020: feat: move `Loader` to `compat` package & replace with `BusyIndicator`

2614 of 4029 branches covered (64.88%)

8 of 8 new or added lines in 2 files covered. (100.0%)

27 existing lines in 5 files now uncovered.

4727 of 5855 relevant lines covered (80.73%)

68409.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.92
/packages/charts/src/internal/ChartContainer.tsx
1
import { type CommonProps, Label, Loader } from '@ui5/webcomponents-react';
2
import { useStylesheet } from '@ui5/webcomponents-react-base';
3
import { clsx } from 'clsx';
4
import type { ComponentType, CSSProperties, ReactElement, ReactNode } from 'react';
5
import { Component, forwardRef } from 'react';
6
import { ResponsiveContainer } from 'recharts';
7
import { classNames, styleData } from './ChartContainer.module.css.js';
8

9
export interface ContainerProps extends CommonProps {
10
  children: ReactElement;
11
  Placeholder?: ComponentType;
12
  dataset: unknown[];
13
  loading?: boolean;
14
  resizeDebounce: number;
15
}
16

17
const loaderStyles: CSSProperties = {
79✔
18
  position: 'absolute',
19
  top: 0,
20
  left: 0,
21
  right: 0
22
};
23

24
class ErrorBoundary extends Component<{ children: ReactNode }, { errorCount: number }> {
162✔
25
  state = {
127✔
26
    errorCount: 0
27
  };
28

29
  componentDidCatch() {
UNCOV
30
    if (this.state.errorCount < 3) {
×
UNCOV
31
      this.setState((old) => ({ ...old, errorCount: old.errorCount + 1 }));
×
32
    }
33
  }
34

35
  render() {
36
    if (this.state.errorCount >= 3) {
268!
UNCOV
37
      return <Label>Sorry, something went wrong while rendering this chart!</Label>;
×
38
    }
39
    return this.props.children;
268✔
40
  }
41
}
42

43
const ChartContainer = forwardRef<HTMLDivElement, ContainerProps>((props, ref) => {
79✔
44
  const { Placeholder, loading = false, dataset, className, slot, children, resizeDebounce, ...rest } = props;
421✔
45

46
  useStylesheet(styleData, ChartContainer.displayName);
386✔
47

48
  return (
386✔
49
    <div ref={ref} className={clsx(classNames.container, className)} slot={slot} {...rest}>
50
      {dataset?.length > 0 ? (
386✔
51
        <>
52
          {loading && <Loader style={loaderStyles} />}
268!
53
          <ErrorBoundary>
54
            <ResponsiveContainer debounce={resizeDebounce}>{children}</ResponsiveContainer>
55
          </ErrorBoundary>
56
        </>
57
      ) : (
58
        <Placeholder />
59
      )}
60
    </div>
61
  );
62
});
63

64
ChartContainer.displayName = 'ChartContainer';
79✔
65

66
export { ChartContainer };
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc