@easyv/charts 1.3.1 → 1.3.2
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.
- package/.babelrc +8 -8
- package/.husky/commit-msg +3 -3
- package/CHANGELOG.md +18 -18
- package/lib/components/Axis.js +10 -10
- package/lib/components/Background.js +2 -2
- package/lib/components/Carousel.js +2 -2
- package/lib/components/Chart.js +2 -1
- package/lib/components/ConicalGradient.js +21 -21
- package/lib/components/Indicator.js +2 -2
- package/lib/components/Lighter.js +179 -179
- package/lib/components/LinearGradient.js +2 -2
- package/lib/components/Marquee.js +3 -3
- package/lib/components/TextOverflow.js +3 -3
- package/lib/css/index.module.css +41 -41
- package/lib/css/piechart.module.css +26 -26
- package/lib/element/ConicGradient.js +72 -72
- package/lib/hooks/useAnimateData.js +5 -5
- package/lib/hooks/useAxes.js +5 -5
- package/lib/hooks/useCarouselAxisX.js +5 -5
- package/lib/hooks/useExtentData.js +6 -6
- package/lib/hooks/useFilterData.js +5 -5
- package/lib/hooks/useStackData.js +5 -5
- package/lib/hooks/useTooltip.js +10 -10
- package/package.json +54 -54
- package/src/components/AnimateData.tsx +24 -24
- package/src/components/Axis.tsx +354 -354
- package/src/components/Background.tsx +62 -62
- package/src/components/Band.tsx +169 -169
- package/src/components/BaseLine.js +82 -82
- package/src/components/Brush.js +159 -159
- package/src/components/Carousel.tsx +144 -144
- package/src/components/Chart.js +99 -99
- package/src/components/ChartContainer.tsx +63 -63
- package/src/components/ConicalGradient.js +258 -258
- package/src/components/ExtentData.js +17 -17
- package/src/components/FilterData.js +23 -23
- package/src/components/Indicator.js +13 -13
- package/src/components/Label.js +225 -225
- package/src/components/Legend.js +158 -158
- package/src/components/Lighter.jsx +173 -173
- package/src/components/Line.js +145 -145
- package/src/components/LinearGradient.js +29 -29
- package/src/components/Mapping.js +71 -71
- package/src/components/Marquee.js +88 -88
- package/src/components/PieChart.js +1278 -1278
- package/src/components/StackData.js +16 -16
- package/src/components/StereoBar.tsx +307 -307
- package/src/components/TextOverflow.js +51 -51
- package/src/components/Tooltip.js +169 -169
- package/src/components/index.js +55 -55
- package/src/context/index.js +2 -2
- package/src/css/index.module.css +41 -41
- package/src/css/piechart.module.css +26 -26
- package/src/element/ConicGradient.jsx +55 -55
- package/src/element/Line.tsx +33 -33
- package/src/element/index.ts +3 -3
- package/src/formatter/index.js +1 -1
- package/src/formatter/legend.js +90 -90
- package/src/hooks/index.js +17 -17
- package/src/hooks/useAnimateData.ts +67 -67
- package/src/hooks/useAxes.js +144 -144
- package/src/hooks/useCarouselAxisX.js +163 -163
- package/src/hooks/useExtentData.js +89 -89
- package/src/hooks/useFilterData.js +72 -72
- package/src/hooks/useStackData.js +101 -101
- package/src/hooks/useTooltip.ts +96 -96
- package/src/index.js +6 -6
- package/src/types/index.d.ts +67 -67
- package/src/utils/index.js +738 -738
- package/tsconfig.json +23 -23
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 轴类图背景
|
|
3
|
-
*/
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { getSeriesInfo } from '../utils';
|
|
6
|
-
|
|
7
|
-
export default ({
|
|
8
|
-
axis: { ticks, scaler, step, direction },
|
|
9
|
-
bandLength,
|
|
10
|
-
config: {
|
|
11
|
-
background,
|
|
12
|
-
seriesIntervalWidth: paddingInner,
|
|
13
|
-
paddingInner: paddingOuter,
|
|
14
|
-
},
|
|
15
|
-
length,
|
|
16
|
-
}: {
|
|
17
|
-
axis: {
|
|
18
|
-
ticks: Array<string>;
|
|
19
|
-
scaler: Function;
|
|
20
|
-
step: number;
|
|
21
|
-
direction: string;
|
|
22
|
-
};
|
|
23
|
-
bandLength: number;
|
|
24
|
-
config: {
|
|
25
|
-
background: string;
|
|
26
|
-
seriesIntervalWidth: number;
|
|
27
|
-
paddingInner: number;
|
|
28
|
-
};
|
|
29
|
-
length: number;
|
|
30
|
-
}) => {
|
|
31
|
-
const isVertical: boolean = direction === 'vertical';
|
|
32
|
-
|
|
33
|
-
const { width: bandwidth } = getSeriesInfo({
|
|
34
|
-
step,
|
|
35
|
-
bandLength,
|
|
36
|
-
paddingInner,
|
|
37
|
-
paddingOuter,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const size = isVertical
|
|
41
|
-
? {
|
|
42
|
-
width: length,
|
|
43
|
-
height: bandwidth,
|
|
44
|
-
}
|
|
45
|
-
: {
|
|
46
|
-
width: bandwidth,
|
|
47
|
-
height: length,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return ticks.map((tick, index: number) => {
|
|
51
|
-
return (
|
|
52
|
-
<rect
|
|
53
|
-
key={index}
|
|
54
|
-
{...size}
|
|
55
|
-
x={isVertical ? 0 : scaler(tick) - bandwidth / 2}
|
|
56
|
-
y={isVertical ? scaler(tick) - bandwidth / 2 : 0}
|
|
57
|
-
fill={background}
|
|
58
|
-
stroke='none'
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* 轴类图背景
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { getSeriesInfo } from '../utils';
|
|
6
|
+
|
|
7
|
+
export default ({
|
|
8
|
+
axis: { ticks, scaler, step, direction },
|
|
9
|
+
bandLength,
|
|
10
|
+
config: {
|
|
11
|
+
background,
|
|
12
|
+
seriesIntervalWidth: paddingInner,
|
|
13
|
+
paddingInner: paddingOuter,
|
|
14
|
+
},
|
|
15
|
+
length,
|
|
16
|
+
}: {
|
|
17
|
+
axis: {
|
|
18
|
+
ticks: Array<string>;
|
|
19
|
+
scaler: Function;
|
|
20
|
+
step: number;
|
|
21
|
+
direction: string;
|
|
22
|
+
};
|
|
23
|
+
bandLength: number;
|
|
24
|
+
config: {
|
|
25
|
+
background: string;
|
|
26
|
+
seriesIntervalWidth: number;
|
|
27
|
+
paddingInner: number;
|
|
28
|
+
};
|
|
29
|
+
length: number;
|
|
30
|
+
}) => {
|
|
31
|
+
const isVertical: boolean = direction === 'vertical';
|
|
32
|
+
|
|
33
|
+
const { width: bandwidth } = getSeriesInfo({
|
|
34
|
+
step,
|
|
35
|
+
bandLength,
|
|
36
|
+
paddingInner,
|
|
37
|
+
paddingOuter,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const size = isVertical
|
|
41
|
+
? {
|
|
42
|
+
width: length,
|
|
43
|
+
height: bandwidth,
|
|
44
|
+
}
|
|
45
|
+
: {
|
|
46
|
+
width: bandwidth,
|
|
47
|
+
height: length,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return ticks.map((tick, index: number) => {
|
|
51
|
+
return (
|
|
52
|
+
<rect
|
|
53
|
+
key={index}
|
|
54
|
+
{...size}
|
|
55
|
+
x={isVertical ? 0 : scaler(tick) - bandwidth / 2}
|
|
56
|
+
y={isVertical ? scaler(tick) - bandwidth / 2 : 0}
|
|
57
|
+
fill={background}
|
|
58
|
+
stroke='none'
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
};
|
package/src/components/Band.tsx
CHANGED
|
@@ -1,169 +1,169 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* (柱状/条形)图柱子
|
|
3
|
-
*/
|
|
4
|
-
import React, { memo } from 'react';
|
|
5
|
-
import { min, max } from 'd3v7';
|
|
6
|
-
import { getBandBackground, getSeriesInfo } from '../utils';
|
|
7
|
-
|
|
8
|
-
const getHighlightData = (data: Array<DataWithBoundType>, extent: string) => {
|
|
9
|
-
switch (extent) {
|
|
10
|
-
case 'min':
|
|
11
|
-
const minData = min(data, (d: DataWithBoundType) => d.data.y);
|
|
12
|
-
return data.map((item) => ({
|
|
13
|
-
...item,
|
|
14
|
-
flag: minData == item.data.y ? 'min' : '',
|
|
15
|
-
}));
|
|
16
|
-
case 'max':
|
|
17
|
-
const maxData = max(data, (d: DataWithBoundType) => d.data.y);
|
|
18
|
-
return data.map((item) => ({
|
|
19
|
-
...item,
|
|
20
|
-
flag: maxData == item.data.y ? 'max' : '',
|
|
21
|
-
}));
|
|
22
|
-
default:
|
|
23
|
-
return data;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const getAttr = ({
|
|
28
|
-
isVertical,
|
|
29
|
-
seriesWidth,
|
|
30
|
-
length,
|
|
31
|
-
x,
|
|
32
|
-
y,
|
|
33
|
-
}: {
|
|
34
|
-
isVertical: boolean;
|
|
35
|
-
seriesWidth: number;
|
|
36
|
-
length: number;
|
|
37
|
-
x: number;
|
|
38
|
-
y: number;
|
|
39
|
-
}) => {
|
|
40
|
-
if (isVertical) return { width: length, height: seriesWidth, x: y, y: x };
|
|
41
|
-
return {
|
|
42
|
-
x,
|
|
43
|
-
y,
|
|
44
|
-
width: seriesWidth,
|
|
45
|
-
height: length,
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const getBorderRadius = ({
|
|
50
|
-
isVertical,
|
|
51
|
-
positive,
|
|
52
|
-
seriesWidth,
|
|
53
|
-
}: {
|
|
54
|
-
isVertical: boolean;
|
|
55
|
-
positive: boolean;
|
|
56
|
-
seriesWidth: number;
|
|
57
|
-
}) => {
|
|
58
|
-
return isVertical
|
|
59
|
-
? positive
|
|
60
|
-
? '0px ' + seriesWidth + 'px ' + seriesWidth + 'px 0'
|
|
61
|
-
: seriesWidth + 'px 0 0 ' + seriesWidth + 'px'
|
|
62
|
-
: positive
|
|
63
|
-
? seriesWidth / 2 + 'px ' + seriesWidth / 2 + 'px 0 0'
|
|
64
|
-
: '0 0 ' + seriesWidth / 2 + 'px ' + seriesWidth / 2 + 'px';
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default memo(
|
|
68
|
-
({
|
|
69
|
-
triggerClick,
|
|
70
|
-
config: {
|
|
71
|
-
pattern = {},
|
|
72
|
-
seriesIntervalWidth: paddingInner = 0,
|
|
73
|
-
paddingInner: paddingOuter = 0,
|
|
74
|
-
style,
|
|
75
|
-
fillType,
|
|
76
|
-
url,
|
|
77
|
-
size,
|
|
78
|
-
fill,
|
|
79
|
-
opacity,
|
|
80
|
-
highlight: { show: showHighlight, extent, fill: highlightFill },
|
|
81
|
-
},
|
|
82
|
-
bandLength = 0,
|
|
83
|
-
data,
|
|
84
|
-
xAxis: { scaler: xScaler, step, direction },
|
|
85
|
-
yAxis: { scaler: yScaler },
|
|
86
|
-
}: any) => {
|
|
87
|
-
if (!data.length) return null;
|
|
88
|
-
|
|
89
|
-
const { seriesWidth, seriesStep, seriesStart } = getSeriesInfo({
|
|
90
|
-
step,
|
|
91
|
-
bandLength,
|
|
92
|
-
paddingInner,
|
|
93
|
-
paddingOuter,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
97
|
-
|
|
98
|
-
const isVertical = direction === 'vertical';
|
|
99
|
-
return (
|
|
100
|
-
<g className='__easyv-band'>
|
|
101
|
-
{_data.map(
|
|
102
|
-
(
|
|
103
|
-
{
|
|
104
|
-
flag,
|
|
105
|
-
index,
|
|
106
|
-
bound: [start, end],
|
|
107
|
-
data,
|
|
108
|
-
data: { x, y, s },
|
|
109
|
-
}: DataWithBoundType,
|
|
110
|
-
i: number
|
|
111
|
-
) => {
|
|
112
|
-
const y1 = yScaler(isVertical ? end : start);
|
|
113
|
-
const y2 = yScaler(isVertical ? start : end);
|
|
114
|
-
|
|
115
|
-
const positionX =
|
|
116
|
-
xScaler(x) - step / 2 + seriesStart + index * seriesStep;
|
|
117
|
-
|
|
118
|
-
if (isNaN(positionX)) return null;
|
|
119
|
-
const positionY = y < 0 ? y1 : y2;
|
|
120
|
-
const attr = getAttr({
|
|
121
|
-
isVertical,
|
|
122
|
-
x: positionX,
|
|
123
|
-
y: positionY,
|
|
124
|
-
length: Math.abs(y1 - y2),
|
|
125
|
-
seriesWidth,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<foreignObject
|
|
130
|
-
key={i}
|
|
131
|
-
{...attr}
|
|
132
|
-
onClick={triggerClick}
|
|
133
|
-
data-data={JSON.stringify(data)}
|
|
134
|
-
>
|
|
135
|
-
<div
|
|
136
|
-
style={{
|
|
137
|
-
width: '100%',
|
|
138
|
-
height: '100%',
|
|
139
|
-
/** Safari Bug **/
|
|
140
|
-
position: 'fixed',
|
|
141
|
-
opacity: fillType == 'pattern' ? opacity : 1,
|
|
142
|
-
background:
|
|
143
|
-
fillType == 'pattern'
|
|
144
|
-
? `50% 50% / ${size.width}px ${size.height}px repeat ` +
|
|
145
|
-
'url(' +
|
|
146
|
-
url +
|
|
147
|
-
')'
|
|
148
|
-
: getBandBackground(
|
|
149
|
-
pattern,
|
|
150
|
-
extent === flag ? highlightFill : fill
|
|
151
|
-
),
|
|
152
|
-
borderRadius:
|
|
153
|
-
style == 'square'
|
|
154
|
-
? '0 0 0 0'
|
|
155
|
-
: getBorderRadius({
|
|
156
|
-
isVertical,
|
|
157
|
-
positive: y > 0,
|
|
158
|
-
seriesWidth,
|
|
159
|
-
}),
|
|
160
|
-
}}
|
|
161
|
-
/>
|
|
162
|
-
</foreignObject>
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
)}
|
|
166
|
-
</g>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
);
|
|
1
|
+
/**
|
|
2
|
+
* (柱状/条形)图柱子
|
|
3
|
+
*/
|
|
4
|
+
import React, { memo } from 'react';
|
|
5
|
+
import { min, max } from 'd3v7';
|
|
6
|
+
import { getBandBackground, getSeriesInfo } from '../utils';
|
|
7
|
+
|
|
8
|
+
const getHighlightData = (data: Array<DataWithBoundType>, extent: string) => {
|
|
9
|
+
switch (extent) {
|
|
10
|
+
case 'min':
|
|
11
|
+
const minData = min(data, (d: DataWithBoundType) => d.data.y);
|
|
12
|
+
return data.map((item) => ({
|
|
13
|
+
...item,
|
|
14
|
+
flag: minData == item.data.y ? 'min' : '',
|
|
15
|
+
}));
|
|
16
|
+
case 'max':
|
|
17
|
+
const maxData = max(data, (d: DataWithBoundType) => d.data.y);
|
|
18
|
+
return data.map((item) => ({
|
|
19
|
+
...item,
|
|
20
|
+
flag: maxData == item.data.y ? 'max' : '',
|
|
21
|
+
}));
|
|
22
|
+
default:
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getAttr = ({
|
|
28
|
+
isVertical,
|
|
29
|
+
seriesWidth,
|
|
30
|
+
length,
|
|
31
|
+
x,
|
|
32
|
+
y,
|
|
33
|
+
}: {
|
|
34
|
+
isVertical: boolean;
|
|
35
|
+
seriesWidth: number;
|
|
36
|
+
length: number;
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
}) => {
|
|
40
|
+
if (isVertical) return { width: length, height: seriesWidth, x: y, y: x };
|
|
41
|
+
return {
|
|
42
|
+
x,
|
|
43
|
+
y,
|
|
44
|
+
width: seriesWidth,
|
|
45
|
+
height: length,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const getBorderRadius = ({
|
|
50
|
+
isVertical,
|
|
51
|
+
positive,
|
|
52
|
+
seriesWidth,
|
|
53
|
+
}: {
|
|
54
|
+
isVertical: boolean;
|
|
55
|
+
positive: boolean;
|
|
56
|
+
seriesWidth: number;
|
|
57
|
+
}) => {
|
|
58
|
+
return isVertical
|
|
59
|
+
? positive
|
|
60
|
+
? '0px ' + seriesWidth + 'px ' + seriesWidth + 'px 0'
|
|
61
|
+
: seriesWidth + 'px 0 0 ' + seriesWidth + 'px'
|
|
62
|
+
: positive
|
|
63
|
+
? seriesWidth / 2 + 'px ' + seriesWidth / 2 + 'px 0 0'
|
|
64
|
+
: '0 0 ' + seriesWidth / 2 + 'px ' + seriesWidth / 2 + 'px';
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default memo(
|
|
68
|
+
({
|
|
69
|
+
triggerClick,
|
|
70
|
+
config: {
|
|
71
|
+
pattern = {},
|
|
72
|
+
seriesIntervalWidth: paddingInner = 0,
|
|
73
|
+
paddingInner: paddingOuter = 0,
|
|
74
|
+
style,
|
|
75
|
+
fillType,
|
|
76
|
+
url,
|
|
77
|
+
size,
|
|
78
|
+
fill,
|
|
79
|
+
opacity,
|
|
80
|
+
highlight: { show: showHighlight, extent, fill: highlightFill },
|
|
81
|
+
},
|
|
82
|
+
bandLength = 0,
|
|
83
|
+
data,
|
|
84
|
+
xAxis: { scaler: xScaler, step, direction },
|
|
85
|
+
yAxis: { scaler: yScaler },
|
|
86
|
+
}: any) => {
|
|
87
|
+
if (!data.length) return null;
|
|
88
|
+
|
|
89
|
+
const { seriesWidth, seriesStep, seriesStart } = getSeriesInfo({
|
|
90
|
+
step,
|
|
91
|
+
bandLength,
|
|
92
|
+
paddingInner,
|
|
93
|
+
paddingOuter,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
97
|
+
|
|
98
|
+
const isVertical = direction === 'vertical';
|
|
99
|
+
return (
|
|
100
|
+
<g className='__easyv-band'>
|
|
101
|
+
{_data.map(
|
|
102
|
+
(
|
|
103
|
+
{
|
|
104
|
+
flag,
|
|
105
|
+
index,
|
|
106
|
+
bound: [start, end],
|
|
107
|
+
data,
|
|
108
|
+
data: { x, y, s },
|
|
109
|
+
}: DataWithBoundType,
|
|
110
|
+
i: number
|
|
111
|
+
) => {
|
|
112
|
+
const y1 = yScaler(isVertical ? end : start);
|
|
113
|
+
const y2 = yScaler(isVertical ? start : end);
|
|
114
|
+
|
|
115
|
+
const positionX =
|
|
116
|
+
xScaler(x) - step / 2 + seriesStart + index * seriesStep;
|
|
117
|
+
|
|
118
|
+
if (isNaN(positionX)) return null;
|
|
119
|
+
const positionY = y < 0 ? y1 : y2;
|
|
120
|
+
const attr = getAttr({
|
|
121
|
+
isVertical,
|
|
122
|
+
x: positionX,
|
|
123
|
+
y: positionY,
|
|
124
|
+
length: Math.abs(y1 - y2),
|
|
125
|
+
seriesWidth,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<foreignObject
|
|
130
|
+
key={i}
|
|
131
|
+
{...attr}
|
|
132
|
+
onClick={triggerClick}
|
|
133
|
+
data-data={JSON.stringify(data)}
|
|
134
|
+
>
|
|
135
|
+
<div
|
|
136
|
+
style={{
|
|
137
|
+
width: '100%',
|
|
138
|
+
height: '100%',
|
|
139
|
+
/** Safari Bug **/
|
|
140
|
+
position: 'fixed',
|
|
141
|
+
opacity: fillType == 'pattern' ? opacity : 1,
|
|
142
|
+
background:
|
|
143
|
+
fillType == 'pattern'
|
|
144
|
+
? `50% 50% / ${size.width}px ${size.height}px repeat ` +
|
|
145
|
+
'url(' +
|
|
146
|
+
url +
|
|
147
|
+
')'
|
|
148
|
+
: getBandBackground(
|
|
149
|
+
pattern,
|
|
150
|
+
extent === flag ? highlightFill : fill
|
|
151
|
+
),
|
|
152
|
+
borderRadius:
|
|
153
|
+
style == 'square'
|
|
154
|
+
? '0 0 0 0'
|
|
155
|
+
: getBorderRadius({
|
|
156
|
+
isVertical,
|
|
157
|
+
positive: y > 0,
|
|
158
|
+
seriesWidth,
|
|
159
|
+
}),
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
</foreignObject>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
)}
|
|
166
|
+
</g>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
);
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 参考线
|
|
3
|
-
*/
|
|
4
|
-
import React, { memo } from 'react';
|
|
5
|
-
import { getFontStyle } from '../utils';
|
|
6
|
-
|
|
7
|
-
export default memo(
|
|
8
|
-
({
|
|
9
|
-
width,
|
|
10
|
-
height,
|
|
11
|
-
baseLineOri: orientation,
|
|
12
|
-
config: {
|
|
13
|
-
dataStyle: {
|
|
14
|
-
data: {
|
|
15
|
-
show: dataShow,
|
|
16
|
-
dataStyle,
|
|
17
|
-
translate: dataTranslate
|
|
18
|
-
},
|
|
19
|
-
label: {
|
|
20
|
-
label,
|
|
21
|
-
show: labelShow,
|
|
22
|
-
textStyle,
|
|
23
|
-
translate: labelTranslate,
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
line: {
|
|
27
|
-
color,
|
|
28
|
-
lineType,
|
|
29
|
-
lineWidth,
|
|
30
|
-
margin: {
|
|
31
|
-
marginLeft,
|
|
32
|
-
marginRight
|
|
33
|
-
},
|
|
34
|
-
strokeDasharray,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
yAxis: { scaler: yScaler },
|
|
38
|
-
data
|
|
39
|
-
}) => {
|
|
40
|
-
if (!data.value) return null;
|
|
41
|
-
const x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
|
|
42
|
-
x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
|
|
43
|
-
y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
|
|
44
|
-
y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<g className='__easyv-baseLine' >
|
|
48
|
-
<line
|
|
49
|
-
x1={x1}
|
|
50
|
-
x2={x2}
|
|
51
|
-
y1={y1}
|
|
52
|
-
y2={y2}
|
|
53
|
-
stroke={color}
|
|
54
|
-
fill='none'
|
|
55
|
-
strokeDasharray={lineType === 'dash' ? strokeDasharray : null}
|
|
56
|
-
strokeWidth={lineWidth}
|
|
57
|
-
/>
|
|
58
|
-
</g>
|
|
59
|
-
{labelShow &&
|
|
60
|
-
<foreignObject
|
|
61
|
-
width={100}
|
|
62
|
-
height={100}
|
|
63
|
-
x={x2 + labelTranslate.x}
|
|
64
|
-
y={y2 - textStyle.fontSize + labelTranslate.y}>
|
|
65
|
-
<div>
|
|
66
|
-
<span style={{ ...getFontStyle(textStyle) }}>{label}</span>
|
|
67
|
-
</div>
|
|
68
|
-
</foreignObject>}
|
|
69
|
-
{dataShow &&
|
|
70
|
-
<foreignObject
|
|
71
|
-
width={100}
|
|
72
|
-
height={100}
|
|
73
|
-
x={x2 + dataTranslate.x}
|
|
74
|
-
y={y2 + dataTranslate.y}>
|
|
75
|
-
<div>
|
|
76
|
-
<span style={{ ...getFontStyle(dataStyle) }}>{data.value}</span>
|
|
77
|
-
</div>
|
|
78
|
-
</foreignObject>}
|
|
79
|
-
</>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
);
|
|
1
|
+
/**
|
|
2
|
+
* 参考线
|
|
3
|
+
*/
|
|
4
|
+
import React, { memo } from 'react';
|
|
5
|
+
import { getFontStyle } from '../utils';
|
|
6
|
+
|
|
7
|
+
export default memo(
|
|
8
|
+
({
|
|
9
|
+
width,
|
|
10
|
+
height,
|
|
11
|
+
baseLineOri: orientation,
|
|
12
|
+
config: {
|
|
13
|
+
dataStyle: {
|
|
14
|
+
data: {
|
|
15
|
+
show: dataShow,
|
|
16
|
+
dataStyle,
|
|
17
|
+
translate: dataTranslate
|
|
18
|
+
},
|
|
19
|
+
label: {
|
|
20
|
+
label,
|
|
21
|
+
show: labelShow,
|
|
22
|
+
textStyle,
|
|
23
|
+
translate: labelTranslate,
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
line: {
|
|
27
|
+
color,
|
|
28
|
+
lineType,
|
|
29
|
+
lineWidth,
|
|
30
|
+
margin: {
|
|
31
|
+
marginLeft,
|
|
32
|
+
marginRight
|
|
33
|
+
},
|
|
34
|
+
strokeDasharray,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
yAxis: { scaler: yScaler },
|
|
38
|
+
data
|
|
39
|
+
}) => {
|
|
40
|
+
if (!data.value) return null;
|
|
41
|
+
const x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
|
|
42
|
+
x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
|
|
43
|
+
y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
|
|
44
|
+
y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<g className='__easyv-baseLine' >
|
|
48
|
+
<line
|
|
49
|
+
x1={x1}
|
|
50
|
+
x2={x2}
|
|
51
|
+
y1={y1}
|
|
52
|
+
y2={y2}
|
|
53
|
+
stroke={color}
|
|
54
|
+
fill='none'
|
|
55
|
+
strokeDasharray={lineType === 'dash' ? strokeDasharray : null}
|
|
56
|
+
strokeWidth={lineWidth}
|
|
57
|
+
/>
|
|
58
|
+
</g>
|
|
59
|
+
{labelShow &&
|
|
60
|
+
<foreignObject
|
|
61
|
+
width={100}
|
|
62
|
+
height={100}
|
|
63
|
+
x={x2 + labelTranslate.x}
|
|
64
|
+
y={y2 - textStyle.fontSize + labelTranslate.y}>
|
|
65
|
+
<div>
|
|
66
|
+
<span style={{ ...getFontStyle(textStyle) }}>{label}</span>
|
|
67
|
+
</div>
|
|
68
|
+
</foreignObject>}
|
|
69
|
+
{dataShow &&
|
|
70
|
+
<foreignObject
|
|
71
|
+
width={100}
|
|
72
|
+
height={100}
|
|
73
|
+
x={x2 + dataTranslate.x}
|
|
74
|
+
y={y2 + dataTranslate.y}>
|
|
75
|
+
<div>
|
|
76
|
+
<span style={{ ...getFontStyle(dataStyle) }}>{data.value}</span>
|
|
77
|
+
</div>
|
|
78
|
+
</foreignObject>}
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
);
|