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

SAP / ui5-webcomponents-react / 7045436957

30 Nov 2023 10:52AM CUT coverage: 87.839% (+0.03%) from 87.809%
7045436957

Pull #5258

github

web-flow
Merge f1154a682 into cb55a0764
Pull Request #5258: feat(ExpandableText): introduce component

2846 of 3803 branches covered (0.0%)

31 of 31 new or added lines in 1 file covered. (100.0%)

2 existing lines in 2 files now uncovered.

5150 of 5863 relevant lines covered (87.84%)

22671.46 hits per line

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

81.25
/packages/charts/src/internal/ChartDataLabel.tsx
1
import { ThemingParameters } from '@ui5/webcomponents-react-base';
2
import React, { createElement } from 'react';
3
import { Label } from 'recharts';
4
import type { IChartMeasure } from '../interfaces/IChartMeasure.js';
5
import { getTextWidth } from '../internal/Utils.js';
6

7
interface CustomDataLabelProps {
8
  config: IChartMeasure;
9
  viewBox?: any;
10
  chartType: 'bar' | 'column' | 'line' | 'radar' | 'pie' | 'area';
11
  position?: string;
12
  value?: any;
13
  children?: any;
14
}
15

16
export const ChartDataLabel = (props: CustomDataLabelProps) => {
53✔
17
  const { config, chartType, viewBox } = props;
1,464✔
18
  if (config.hideDataLabel) {
1,464✔
19
    return null;
360✔
20
  }
21

22
  if (config.DataLabel) {
1,104!
23
    return createElement(config.DataLabel, props);
×
24
  }
25

26
  const formattedLabel = config.formatter(props.value ?? props.children);
1,104!
27
  if (chartType === 'bar' || chartType === 'column') {
1,104✔
28
    if (Math.abs(viewBox.width) < getTextWidth(formattedLabel)) {
252!
29
      return null;
×
30
    }
31
    if (Math.abs(viewBox.height) < 12) {
252!
UNCOV
32
      return null;
×
33
    }
34
  }
35

36
  let fill = ThemingParameters.sapContent_ContrastTextColor;
1,104✔
37
  if (['area', 'line', 'radar'].includes(chartType)) {
1,104✔
38
    fill = ThemingParameters.sapTextColor; // label is displayed outside of the colored element
852✔
39
  }
40

41
  return (
1,104✔
42
    <Label
43
      viewBox={viewBox}
44
      {...(props as any)}
45
      fill={fill}
46
      stroke={'none'}
47
      content={undefined}
48
      value={formattedLabel}
49
    />
50
  );
51
};
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