@alfalab/core-components-chart 3.1.12 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/Component.d.ts +2 -1
  2. package/Component.js +1 -1
  3. package/components/Dot/index.css +8 -8
  4. package/components/Dot/index.js +1 -1
  5. package/components/Legends/index.css +8 -8
  6. package/components/Legends/index.js +1 -1
  7. package/components/Tick/index.css +4 -4
  8. package/components/Tick/index.d.ts +2 -1
  9. package/components/Tick/index.js +1 -1
  10. package/components/TooltipContent/index.css +7 -7
  11. package/components/TooltipContent/index.d.ts +2 -1
  12. package/components/TooltipContent/index.js +1 -1
  13. package/cssm/Component.d.ts +2 -1
  14. package/cssm/components/Tick/index.d.ts +2 -1
  15. package/cssm/components/TooltipContent/index.d.ts +2 -1
  16. package/cssm/icons/Circle.d.ts +2 -1
  17. package/cssm/icons/FilledCircle.d.ts +2 -1
  18. package/cssm/icons/Point.d.ts +2 -1
  19. package/cssm/icons/StrokeCircle.d.ts +2 -1
  20. package/esm/Component.d.ts +2 -1
  21. package/esm/Component.js +1 -1
  22. package/esm/components/Dot/index.css +8 -8
  23. package/esm/components/Dot/index.js +1 -1
  24. package/esm/components/Legends/index.css +8 -8
  25. package/esm/components/Legends/index.js +1 -1
  26. package/esm/components/Tick/index.css +4 -4
  27. package/esm/components/Tick/index.d.ts +2 -1
  28. package/esm/components/Tick/index.js +1 -1
  29. package/esm/components/TooltipContent/index.css +7 -7
  30. package/esm/components/TooltipContent/index.d.ts +2 -1
  31. package/esm/components/TooltipContent/index.js +1 -1
  32. package/esm/icons/Circle.d.ts +2 -1
  33. package/esm/icons/FilledCircle.d.ts +2 -1
  34. package/esm/icons/Point.d.ts +2 -1
  35. package/esm/icons/StrokeCircle.d.ts +2 -1
  36. package/esm/index.css +5 -5
  37. package/icons/Circle.d.ts +2 -1
  38. package/icons/FilledCircle.d.ts +2 -1
  39. package/icons/Point.d.ts +2 -1
  40. package/icons/StrokeCircle.d.ts +2 -1
  41. package/index.css +5 -5
  42. package/modern/Component.d.ts +2 -1
  43. package/modern/Component.js +1 -1
  44. package/modern/components/Dot/index.css +8 -8
  45. package/modern/components/Dot/index.js +1 -1
  46. package/modern/components/Legends/index.css +8 -8
  47. package/modern/components/Legends/index.js +1 -1
  48. package/modern/components/Tick/index.css +4 -4
  49. package/modern/components/Tick/index.d.ts +2 -1
  50. package/modern/components/Tick/index.js +1 -1
  51. package/modern/components/TooltipContent/index.css +7 -7
  52. package/modern/components/TooltipContent/index.d.ts +2 -1
  53. package/modern/components/TooltipContent/index.js +1 -1
  54. package/modern/icons/Circle.d.ts +2 -1
  55. package/modern/icons/FilledCircle.d.ts +2 -1
  56. package/modern/icons/Point.d.ts +2 -1
  57. package/modern/icons/StrokeCircle.d.ts +2 -1
  58. package/modern/index.css +5 -5
  59. package/package.json +2 -2
  60. package/src/Component.tsx +404 -0
  61. package/src/components/CustomizedLabel.tsx +29 -0
  62. package/src/components/Dot/index.module.css +22 -0
  63. package/src/components/Dot/index.tsx +79 -0
  64. package/src/components/Legends/index.module.css +36 -0
  65. package/src/components/Legends/index.tsx +85 -0
  66. package/src/components/LinearGradient.tsx +16 -0
  67. package/src/components/RectBar.tsx +50 -0
  68. package/src/components/Tick/index.module.css +16 -0
  69. package/src/components/Tick/index.tsx +32 -0
  70. package/src/components/TooltipContent/index.module.css +51 -0
  71. package/src/components/TooltipContent/index.tsx +83 -0
  72. package/src/hoc/Customized.jsx +7 -0
  73. package/src/hooks/usePathBar/index.tsx +56 -0
  74. package/src/hooks/usePathBar/utils/getRadius.ts +5 -0
  75. package/src/hooks/useSettings/index.tsx +66 -0
  76. package/src/hooks/useSettings/utils/setComposedChartsMargin.ts +29 -0
  77. package/src/hooks/useSettings/utils/setDatas.ts +53 -0
  78. package/src/hooks/useSettings/utils/setGradientCharts.ts +43 -0
  79. package/src/hooks/useSettings/utils/setLegendMargin.ts +16 -0
  80. package/src/hooks/useSettings/utils/sortByIndex.ts +10 -0
  81. package/src/icons/Circle.tsx +12 -0
  82. package/src/icons/CircleLine.tsx +13 -0
  83. package/src/icons/FilledCircle.tsx +25 -0
  84. package/src/icons/Point.tsx +13 -0
  85. package/src/icons/StrokeCircle.tsx +12 -0
  86. package/src/index.module.css +21 -0
  87. package/src/index.ts +2 -0
  88. package/src/types/brush.types.ts +50 -0
  89. package/src/types/cartesianGrid.types.ts +26 -0
  90. package/src/types/chart.types.ts +81 -0
  91. package/src/types/composedChart.types.ts +36 -0
  92. package/src/types/index.ts +14 -0
  93. package/src/types/labelList.types.ts +5 -0
  94. package/src/types/legend.types.ts +35 -0
  95. package/src/types/options.types.ts +69 -0
  96. package/src/types/payload.types.ts +33 -0
  97. package/src/types/responsiveContainer.types.ts +9 -0
  98. package/src/types/seria.types.ts +86 -0
  99. package/src/types/tooltip.types.ts +85 -0
  100. package/src/types/utils/axis.types.ts +88 -0
  101. package/src/types/utils/coordinates.types.ts +11 -0
  102. package/src/types/utils/data.types.ts +19 -0
  103. package/src/types/utils/dot.types.ts +88 -0
  104. package/src/types/utils/gradient.types.ts +33 -0
  105. package/src/types/utils/index.ts +6 -0
  106. package/src/types/utils/tick.types.ts +38 -0
  107. package/src/types/xAxis.types.ts +18 -0
  108. package/src/types/yAxis.types.ts +8 -0
@@ -0,0 +1,50 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import React, { useMemo } from 'react';
3
+
4
+ import { usePathBar } from '../hooks/usePathBar';
5
+
6
+ // eslint-disable-next-line complexity
7
+ const getPath = (
8
+ x: number,
9
+ width: number,
10
+ height: number,
11
+ initHeight: number,
12
+ topRadius: number,
13
+ bottomRadius: number,
14
+ initY: number,
15
+ ): string =>
16
+ `
17
+ M${x + ((height !== 0 && bottomRadius) || 0)} ${initY + initHeight || 0}
18
+ Q${x} ${initY + initHeight} ${x} ${
19
+ initY + initHeight - ((height !== 0 && bottomRadius) || 0)
20
+ }
21
+ L${x} ${initY + ((height !== 0 && topRadius) || 0)}
22
+ Q${x} ${initY} ${x + ((height !== 0 && topRadius) || 0)} ${initY}
23
+ L${x + width - ((height !== 0 && topRadius) || 0)} ${initY}
24
+ Q${x + width} ${initY} ${x + width} ${initY + (topRadius || 0)}
25
+ L${x + width} ${initY + initHeight - ((height !== 0 && bottomRadius) || 0)}
26
+ Q${x + width} ${initY + initHeight} ${x + width - ((height !== 0 && bottomRadius) || 0)} ${
27
+ initY + initHeight
28
+ }
29
+ Z
30
+ `;
31
+
32
+ export const RectBar = ({ fill, x, y, width, height, radius, background }: any): JSX.Element => {
33
+ const [initHeight, topRadius, bottomRadius, initY]: any = usePathBar({
34
+ radius,
35
+ height,
36
+ background,
37
+ y,
38
+ });
39
+
40
+ return useMemo(
41
+ () => (
42
+ <path
43
+ d={getPath(x, width, height, initHeight, topRadius, bottomRadius, initY)}
44
+ stroke='none'
45
+ fill={fill}
46
+ />
47
+ ),
48
+ [x, width, height, initHeight, topRadius, bottomRadius, initY, fill],
49
+ );
50
+ };
@@ -0,0 +1,16 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+
3
+ .tickText {
4
+ fill: var(--color-light-text-primary);
5
+ @mixin paragraph_primary_medium;
6
+ }
7
+
8
+ .circle {
9
+ opacity: 0.3;
10
+ fill: var(--color-dark-bg-primary);
11
+ }
12
+
13
+ .circle {
14
+ opacity: 0.3;
15
+ fill: var(--color-dark-bg-primary);
16
+ }
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+
4
+ import { TickProps } from '../../types/utils/tick.types';
5
+
6
+ import styles from './index.module.css';
7
+
8
+ export const Tick = ({ y, payload, tickFormatter, xAxis }: TickProps) => {
9
+ const radius = 4;
10
+
11
+ const marginTick =
12
+ xAxis?.tickMargin &&
13
+ (xAxis.tickMargin > 0 ? xAxis.tickMargin - radius / 2 : xAxis.tickMargin === 0)
14
+ ? (radius / 2) * -1
15
+ : null;
16
+
17
+ return (
18
+ <g
19
+ className={cn(styles.tick)}
20
+ opacity='1'
21
+ textAnchor='middle'
22
+ transform={`translate(${payload.coordinate}, ${
23
+ y - (typeof marginTick === 'number' ? marginTick : 0) - radius * 2
24
+ })`}
25
+ >
26
+ <text className={cn(styles.tickText)} y='30'>
27
+ {tickFormatter ? tickFormatter(payload.value) : payload.value}
28
+ </text>
29
+ <circle r={radius} className={cn(styles.circle)} />
30
+ </g>
31
+ );
32
+ };
@@ -0,0 +1,51 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+
3
+ .tooltip {
4
+ background-color: var(--color-light-bg-primary);
5
+ border: 1px solid var(--color-light-border-primary);
6
+ box-shadow: var(--shadow-l);
7
+ border-radius: var(--border-radius-m);
8
+ padding: var(--gap-s) var(--gap-m);
9
+ pointer-events: none;
10
+ position: relative;
11
+ }
12
+
13
+ .tooltipList {
14
+ position: relative;
15
+ z-index: 5;
16
+ list-style-type: none;
17
+ padding: 0;
18
+ margin: 0;
19
+ }
20
+
21
+ .tooltipItem {
22
+ margin-bottom: 10px;
23
+ }
24
+
25
+ .tooltipArrow {
26
+ position: absolute;
27
+ left: 0;
28
+ top: 50%;
29
+ transform: translate(-50%, -50%) scale(1, 1) rotate(45deg);
30
+ width: 10px;
31
+ height: 10px;
32
+ border: 1px solid var(--color-light-border-primary);
33
+ background-color: var(--color-light-bg-primary);
34
+ }
35
+
36
+ .tooltipArrow:before {
37
+ content: '';
38
+ position: absolute;
39
+ left: -2px;
40
+ top: -2px;
41
+ width: 0;
42
+ height: 0;
43
+ border-style: solid;
44
+ border-width: 0 24px 24px 0;
45
+ border-color: transparent var(--color-light-bg-primary) transparent transparent;
46
+ }
47
+
48
+ .tooltipArrowRight {
49
+ left: 100%;
50
+ transform: translate(-50%, -50%) scale(-1, 1) rotate(45deg);
51
+ }
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+
4
+ import { Typography } from '@alfalab/core-components-typography';
5
+
6
+ import { PayloadProps } from '../../types/payload.types';
7
+ import { SeriaProps } from '../../types/seria.types';
8
+ import { TooltipProps } from '../../types/tooltip.types';
9
+
10
+ import styles from './index.module.css';
11
+
12
+ export interface TooltipContentProps extends TooltipProps {
13
+ payload: PayloadProps[];
14
+ series: SeriaProps[];
15
+ }
16
+
17
+ export const TooltipContent = ({
18
+ payload,
19
+ separator,
20
+ label,
21
+ tooltipArrowSide,
22
+ arrow,
23
+ series,
24
+ labelFormatter,
25
+ labelStyle,
26
+ }: TooltipContentProps) => {
27
+ if (!label || payload.length === 0) return null;
28
+
29
+ return (
30
+ <div className={cn(styles.tooltip)}>
31
+ {arrow && (
32
+ <span
33
+ className={cn(
34
+ styles.tooltipArrow,
35
+ tooltipArrowSide ? '' : styles.tooltipArrowRight,
36
+ )}
37
+ />
38
+ )}
39
+ <ul className={cn(styles.tooltipList)}>
40
+ <li className={cn(styles.tooltipItem)} style={labelStyle}>
41
+ <Typography.Text
42
+ view='primary-medium'
43
+ tag='span'
44
+ weight='medium'
45
+ className={cn(styles.tooltipLabel)}
46
+ >
47
+ {labelFormatter ? labelFormatter(label) : label}
48
+ </Typography.Text>
49
+ </li>
50
+ {payload.map((entry: PayloadProps) => {
51
+ const data: SeriaProps | undefined = series.find(
52
+ (d: SeriaProps) => d.properties.dataKey === entry.dataKey,
53
+ );
54
+
55
+ if (data?.hideTooltip || data?.hide) return null;
56
+
57
+ return (
58
+ <li
59
+ className={cn(styles.tooltipItem)}
60
+ key={entry.dataKey}
61
+ style={{ color: entry.color }}
62
+ >
63
+ <Typography.Text
64
+ view='primary-medium'
65
+ tag='span'
66
+ weight='medium'
67
+ className={cn(styles.tooltipValue)}
68
+ >
69
+ {entry?.formatter ? entry.formatter(entry.value) : entry.value}
70
+ {separator || ' '}
71
+ </Typography.Text>
72
+ <Typography.Text
73
+ view='secondary-large'
74
+ tag='span'
75
+ className={cn(styles.tooltipName)}
76
+ >{`${entry.name}`}</Typography.Text>
77
+ </li>
78
+ );
79
+ })}
80
+ </ul>
81
+ </div>
82
+ );
83
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ export const CustomizedHOC = (Component, options) => {
4
+ const NewComponent = (props) => <Component {...props} {...options} />;
5
+
6
+ return NewComponent;
7
+ };
@@ -0,0 +1,56 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ import { RadiusProp } from '../../types/seria.types';
4
+
5
+ import { getRadius } from './utils/getRadius';
6
+
7
+ // eslint-disable-next-line @typescript-eslint/naming-convention
8
+ export type usePathBarProps = {
9
+ radius?: RadiusProp;
10
+ height: number;
11
+ background?: {
12
+ x: number;
13
+ y: number;
14
+ height: number;
15
+ width: number;
16
+ };
17
+ y?: number;
18
+ };
19
+
20
+ export const usePathBar = (props: usePathBarProps): number[] => {
21
+ const [topRadius, setTopRadius] = useState<number>(0);
22
+ const [bottomRadius, setBottomRadius] = useState<number>(0);
23
+ const [initHeight, setInitHeight] = useState<number>(0);
24
+ const [initY, setInitY] = useState<number>(0);
25
+
26
+ useEffect(() => {
27
+ const { radius, height, background, y } = props;
28
+ const radiusTop = radius?.top ? getRadius(height, radius.top) : 0;
29
+ const radiusBottom = radius?.bottom ? getRadius(height, radius.bottom) : 0;
30
+
31
+ const heightCheck =
32
+ (radius && height !== 0 && height / 2 < (radius?.top || 0)) ||
33
+ height / 2 < (radius?.bottom || 0);
34
+
35
+ // eslint-disable-next-line no-nested-ternary
36
+ const heightInit = heightCheck
37
+ ? (radiusTop || radiusBottom) && radiusTop + radiusBottom
38
+ : height > 0 && height < 2
39
+ ? 2
40
+ : height;
41
+
42
+ if (background && y) {
43
+ const yInit = heightCheck
44
+ ? background.height + background.y - (radiusTop + radiusBottom)
45
+ : y;
46
+
47
+ setInitY(yInit);
48
+ }
49
+
50
+ if (radiusTop !== 0) setTopRadius(radiusTop);
51
+ if (radiusBottom !== 0) setBottomRadius(radiusBottom);
52
+ if (heightInit !== 0) setInitHeight(heightInit);
53
+ }, [props]);
54
+
55
+ return [initHeight, topRadius, bottomRadius, initY];
56
+ };
@@ -0,0 +1,5 @@
1
+ export const getRadius = (height: number, radius: number): number => {
2
+ const result = radius && height / 2 < radius ? Math.ceil(height / 2) : radius || 0;
3
+
4
+ return result;
5
+ };
@@ -0,0 +1,66 @@
1
+ import { Dispatch, SetStateAction, useEffect, useState } from 'react';
2
+
3
+ import { OptionsProps } from '../../types/options.types';
4
+ import { DataDynamicBooleanProps, DataDynamicProps } from '../../types/utils/data.types';
5
+
6
+ import { setComposedChartsMargin } from './utils/setComposedChartsMargin';
7
+ import { setDatas } from './utils/setDatas';
8
+ import { setGradientCharts } from './utils/setGradientCharts';
9
+ import { setLegendMargin } from './utils/setLegendMargin';
10
+ import { sortByIndex } from './utils/sortByIndex';
11
+
12
+ type Settings = [
13
+ {
14
+ state: OptionsProps | null;
15
+ data: DataDynamicProps[];
16
+ charts: DataDynamicBooleanProps;
17
+ filterCount: number;
18
+ },
19
+ {
20
+ setState: Dispatch<SetStateAction<OptionsProps | null>>;
21
+ setData: Dispatch<SetStateAction<DataDynamicProps[]>>;
22
+ setCharts: Dispatch<SetStateAction<DataDynamicBooleanProps>>;
23
+ setFilterCount: Dispatch<SetStateAction<number>>;
24
+ },
25
+ ];
26
+
27
+ export const useSettings = (options: OptionsProps): Settings => {
28
+ const [state, setState] = useState<OptionsProps | null>(null);
29
+ const [charts, setCharts] = useState<DataDynamicBooleanProps>({});
30
+ const [data, setData] = useState<DataDynamicProps[]>([]);
31
+ const [filterCount, setFilterCount] = useState<number>(0);
32
+
33
+ useEffect(() => {
34
+ const settings: OptionsProps = { ...options };
35
+ const { brush, legend, series, labels, composeChart, xAxis } = settings;
36
+
37
+ if (settings.legend?.margin && brush && legend)
38
+ settings.legend.margin.top = setLegendMargin(brush, legend);
39
+
40
+ settings.series = setGradientCharts(series);
41
+ const [initData, chartsNames, count] = setDatas(settings.series, labels);
42
+
43
+ settings.composeChart.margin = setComposedChartsMargin(composeChart, legend, brush, xAxis);
44
+ settings.series = sortByIndex(settings.series);
45
+
46
+ setState(settings);
47
+ setData(initData);
48
+ setCharts(chartsNames);
49
+ setFilterCount(count);
50
+ }, [options]);
51
+
52
+ return [
53
+ {
54
+ state,
55
+ data,
56
+ charts,
57
+ filterCount,
58
+ },
59
+ {
60
+ setState,
61
+ setData,
62
+ setCharts,
63
+ setFilterCount,
64
+ },
65
+ ];
66
+ };
@@ -0,0 +1,29 @@
1
+ import { BrushProps } from '../../../types/brush.types';
2
+ import { ComposedChartProps } from '../../../types/composedChart.types';
3
+ import { LegendProps } from '../../../types/legend.types';
4
+ import { XAxisProps } from '../../../types/xAxis.types';
5
+
6
+ type ComposedChartsMarginResultProps = {
7
+ top: number;
8
+ bottom: number;
9
+ left: number;
10
+ right: number;
11
+ };
12
+
13
+ export const setComposedChartsMargin = (
14
+ composeChart: ComposedChartProps,
15
+ legend: LegendProps | undefined,
16
+ brush: BrushProps | undefined,
17
+ xAxis: XAxisProps,
18
+ ): ComposedChartsMarginResultProps => ({
19
+ top:
20
+ (composeChart?.initMargin?.top || 0) +
21
+ (legend?.verticalAlign === 'top' && legend?.marginTop ? Math.abs(legend.marginTop) : 0),
22
+ bottom:
23
+ (composeChart?.initMargin?.bottom || 0) +
24
+ (xAxis?.tickMargin || 0) +
25
+ (brush?.brushMargin || 0) +
26
+ (legend?.verticalAlign !== 'top' && legend?.marginTop ? legend.marginTop : 0),
27
+ left: composeChart?.initMargin?.left || 0,
28
+ right: composeChart?.initMargin?.right || 0,
29
+ });
@@ -0,0 +1,53 @@
1
+ import { SeriaProps } from '../../../types/seria.types';
2
+ import {
3
+ DataDynamicBooleanProps,
4
+ DataDynamicProps,
5
+ DataProps,
6
+ } from '../../../types/utils/data.types';
7
+
8
+ type DatasResultProps = [DataDynamicProps[], DataDynamicBooleanProps, number];
9
+
10
+ export const setDatas = (
11
+ series: SeriaProps[],
12
+ labels: Array<string | number>,
13
+ ): DatasResultProps => {
14
+ const initData: DataDynamicProps[] = [];
15
+ const chartsNames: DataDynamicBooleanProps = {};
16
+ let count = 0;
17
+
18
+ for (let i = 0; i < series.length; i++) {
19
+ const {
20
+ properties: { dataKey = '' } = {},
21
+ data: seriaData = [],
22
+ hideLegend,
23
+ hide,
24
+ } = series[i];
25
+
26
+ if (!hideLegend && !hide) count += 1;
27
+
28
+ labels.map((label) => {
29
+ const item = seriaData.find((d: DataProps) => d.label === label);
30
+
31
+ if (item) {
32
+ const obj: DataDynamicProps = {
33
+ label,
34
+ };
35
+
36
+ obj[`${dataKey}`] = item.value;
37
+
38
+ if (!chartsNames[`${dataKey}`]) chartsNames[`${dataKey}`] = true;
39
+
40
+ const index = initData
41
+ .map((dataItem: DataDynamicProps) => dataItem.label)
42
+ .indexOf(label);
43
+
44
+ if (index === -1) initData.push(obj);
45
+ else initData[index] = { ...initData[index], ...obj };
46
+ }
47
+
48
+ return null;
49
+ });
50
+ }
51
+
52
+ return [initData, chartsNames, count];
53
+ };
@@ -0,0 +1,43 @@
1
+ import { SeriaProps } from '../../../types/seria.types';
2
+ import { DataProps } from '../../../types/utils/data.types';
3
+
4
+ export const setGradientCharts = (series: SeriaProps[]): SeriaProps[] => {
5
+ const filterSeries = series.filter((item) => item.chart !== 'gradient');
6
+
7
+ return filterSeries.reduce((accum: SeriaProps[], item: SeriaProps) => {
8
+ const { chart, data: dataSeria, offset, fill } = item;
9
+
10
+ if (chart === 'area') {
11
+ let newData = null;
12
+
13
+ if (offset) {
14
+ newData = dataSeria.map((d: DataProps) => {
15
+ const { label, value } = d;
16
+
17
+ return {
18
+ label,
19
+ value: Math.ceil(value - value * offset),
20
+ };
21
+ });
22
+ }
23
+
24
+ accum.push({
25
+ ...item,
26
+ zIndex: -100,
27
+ chart: 'gradient',
28
+ hideLegend: true,
29
+ hideTooltip: true,
30
+ properties: {
31
+ ...item.properties,
32
+ dataKey: `${item.properties.dataKey}-gradient`,
33
+ fill,
34
+ },
35
+ data: newData || item.data,
36
+ });
37
+ }
38
+
39
+ accum.push(item);
40
+
41
+ return accum;
42
+ }, []);
43
+ };
@@ -0,0 +1,16 @@
1
+ import { BrushProps } from '../../../types/brush.types';
2
+ import { LegendProps } from '../../../types/legend.types';
3
+
4
+ export const setLegendMargin = (brush: BrushProps, legend: LegendProps): number => {
5
+ let top = 0;
6
+
7
+ if (typeof brush?.brushMargin !== 'number' || !legend?.verticalAlign) return top;
8
+
9
+ if (legend.verticalAlign === 'top') {
10
+ top = legend.marginTop ? Number(legend.marginTop * -1) : 0;
11
+ } else {
12
+ top = legend?.marginTop ? legend.marginTop + (brush?.brushMargin || 0) : brush?.brushMargin;
13
+ }
14
+
15
+ return top;
16
+ };
@@ -0,0 +1,10 @@
1
+ import { SeriaProps } from '../../../types/seria.types';
2
+
3
+ export const sortByIndex = (series: SeriaProps[]): SeriaProps[] =>
4
+ series.sort((a: SeriaProps, b: SeriaProps) => {
5
+ if (a?.zIndex && b?.zIndex && a?.zIndex > b?.zIndex) {
6
+ return 1;
7
+ }
8
+
9
+ return -1;
10
+ });
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+
3
+ type Props = {
4
+ fill?: string;
5
+ height?: number;
6
+ };
7
+
8
+ export const CircleIcon = ({ fill = '#FF5C5C', height = 16 }: Props) => (
9
+ <svg xmlns='http://www.w3.org/2000/svg' height={height} viewBox='0 0 16 16' fill='none'>
10
+ <circle cx='8' cy='8' r='8' fill={fill} />
11
+ </svg>
12
+ );
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+
3
+ type Props = {
4
+ fill?: string;
5
+ height?: number;
6
+ };
7
+
8
+ export const CircleLineIcon = ({ fill = '#FF5C5C', height = 16 }: Props): React.ReactElement => (
9
+ <svg xmlns='http://www.w3.org/2000/svg' height={height} viewBox='0 0 22 12' fill='none'>
10
+ <circle cx='11' cy='6' r='6' fill={fill} />
11
+ <rect y='5' width='22' height='2' fill={fill} />
12
+ </svg>
13
+ );
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+
3
+ type Props = {
4
+ fill?: string;
5
+ height?: number;
6
+ };
7
+
8
+ export const FilledCircleIcon = ({ fill = '#5A8ECF', height = 16 }: Props) => (
9
+ <svg xmlns='http://www.w3.org/2000/svg' height={height} viewBox='0 0 22 22' fill='none'>
10
+ <circle cx='11' cy='11' r='10' fill='url(#paint0_linear)' stroke={fill} strokeWidth='2' />
11
+ <defs>
12
+ <linearGradient
13
+ id='paint0_linear'
14
+ x1='11'
15
+ y1='1'
16
+ x2='11'
17
+ y2='21'
18
+ gradientUnits='userSpaceOnUse'
19
+ >
20
+ <stop stopColor={fill} stopOpacity='0.2' />
21
+ <stop offset='1' stopColor={fill} stopOpacity='0' />
22
+ </linearGradient>
23
+ </defs>
24
+ </svg>
25
+ );
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+
3
+ type Props = {
4
+ fill?: string;
5
+ height?: number;
6
+ };
7
+
8
+ export const PointIcon = ({ fill = '#5A8ECF', height = 16 }: Props) => (
9
+ <svg height={height} viewBox='0 0 18 18'>
10
+ <circle cx='9' cy='9' r='9' strokeWidth='1' fill={fill} fillOpacity='0.4' />
11
+ <circle cx='9' cy='9' r='3' strokeWidth='2' stroke='#fff' fill={fill} />
12
+ </svg>
13
+ );
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+
3
+ type Props = {
4
+ fill?: string;
5
+ height?: number;
6
+ };
7
+
8
+ export const StrokeCircleIcon = ({ fill = '#5A8ECF', height = 16 }: Props) => (
9
+ <svg xmlns='http://www.w3.org/2000/svg' height={height} viewBox='0 0 22 22' fill='none'>
10
+ <circle cx='11' cy='11' r='10' stroke={fill} strokeWidth='2' strokeDasharray='8 8' />
11
+ </svg>
12
+ );
@@ -0,0 +1,21 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+
3
+ .coreChart {
4
+ & :global(.recharts-line path) {
5
+ transition: d 0.2s ease-out;
6
+ }
7
+
8
+ & :global(.recharts-text tspan) {
9
+ fill: var(--color-light-text-primary);
10
+ font-size: 16px;
11
+ line-height: 22px;
12
+ }
13
+ }
14
+
15
+ .bar {
16
+ transition: opacity 0.2s ease-out, d 0.2s ease-out;
17
+ }
18
+
19
+ .unfocused {
20
+ opacity: 0.3;
21
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './Component';
2
+ export * from './types';