@easyv/charts 1.7.37 → 1.7.38
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/CHANGELOG.md +18 -18
- package/commitlint.config.js +1 -1
- package/lib/components/Background.js +2 -2
- package/lib/components/Band.js +2 -2
- package/lib/components/Brush.js +2 -2
- package/lib/components/Chart.js +2 -2
- package/lib/components/ChartContainer.js +2 -2
- package/lib/components/ConicalGradient.js +21 -21
- package/lib/components/ExtentData.js +2 -2
- package/lib/components/Indicator.js +2 -2
- package/lib/components/Label.js +2 -2
- package/lib/components/Legend.js +5 -8
- package/lib/components/Lighter.js +2 -2
- package/lib/components/Line.js +2 -2
- package/lib/components/LinearGradient.js +2 -2
- package/lib/components/StereoBar.js +2 -2
- package/lib/css/index.module.css +39 -39
- package/lib/css/piechart.module.css +26 -26
- package/lib/hooks/useAnimateData.js +6 -6
- package/lib/hooks/useFilterData.js +5 -5
- package/lib/hooks/useStackData.js +5 -5
- package/lib/hooks/useTooltip.js +11 -11
- package/package.json +54 -54
- package/src/components/Background.tsx +61 -61
- package/src/components/Band.tsx +334 -334
- package/src/components/Brush.js +159 -159
- package/src/components/Chart.js +157 -157
- package/src/components/ChartContainer.tsx +71 -71
- package/src/components/ConicalGradient.js +258 -258
- package/src/components/Control.jsx +242 -242
- package/src/components/ExtentData.js +18 -18
- package/src/components/Indicator.js +61 -61
- package/src/components/Label.js +262 -262
- package/src/components/Legend.js +286 -289
- package/src/components/Lighter.jsx +173 -173
- package/src/components/Line.js +153 -153
- package/src/components/LinearGradient.js +29 -29
- package/src/components/PieTooltip.jsx +160 -160
- package/src/components/SplitText.tsx +70 -70
- package/src/components/StereoBar.tsx +307 -307
- package/src/components/index.js +61 -61
- package/src/context/index.js +2 -2
- package/src/css/index.module.css +39 -39
- 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 +122 -122
- package/src/hooks/index.js +20 -20
- package/src/hooks/useAnimateData.ts +68 -68
- package/src/hooks/useFilterData.js +77 -77
- package/src/hooks/useStackData.js +140 -140
- package/src/hooks/useTooltip.ts +103 -103
- package/src/index.js +6 -6
- package/src/types/index.d.ts +68 -68
- package/src/utils/index.js +812 -812
- package/tsconfig.json +23 -23
package/src/components/Band.tsx
CHANGED
|
@@ -1,334 +1,334 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* (柱状/条形)图柱子
|
|
3
|
-
*/
|
|
4
|
-
import React, { memo, Fragment } from "react";
|
|
5
|
-
import { min, max } from "d3v7";
|
|
6
|
-
import { getBandBackground, getMultiColorStr, 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
|
-
const len = length?length:0.1; //柱子长度
|
|
41
|
-
if (isVertical){
|
|
42
|
-
return { width: len, height: seriesWidth, x: y, y: x, bgAttr:{
|
|
43
|
-
x:0,
|
|
44
|
-
y:x,
|
|
45
|
-
width: len+x,
|
|
46
|
-
height: seriesWidth,
|
|
47
|
-
} };
|
|
48
|
-
}else{
|
|
49
|
-
return {
|
|
50
|
-
x,
|
|
51
|
-
y,
|
|
52
|
-
width: seriesWidth,
|
|
53
|
-
height: len,
|
|
54
|
-
bgAttr:{
|
|
55
|
-
x,
|
|
56
|
-
y:0,
|
|
57
|
-
width: seriesWidth,
|
|
58
|
-
height: y+len,
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const getBorderRadius = ({
|
|
66
|
-
isVertical,
|
|
67
|
-
positive,
|
|
68
|
-
seriesWidth,
|
|
69
|
-
}: {
|
|
70
|
-
isVertical: boolean;
|
|
71
|
-
positive: boolean;
|
|
72
|
-
seriesWidth: number;
|
|
73
|
-
}) => {
|
|
74
|
-
return isVertical
|
|
75
|
-
? positive
|
|
76
|
-
? "0px " + seriesWidth + "px " + seriesWidth + "px 0"
|
|
77
|
-
: seriesWidth + "px 0 0 " + seriesWidth + "px"
|
|
78
|
-
: positive
|
|
79
|
-
? seriesWidth / 2 + "px " + seriesWidth / 2 + "px 0 0"
|
|
80
|
-
: "0 0 " + seriesWidth / 2 + "px " + seriesWidth / 2 + "px";
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export default memo(
|
|
84
|
-
({
|
|
85
|
-
//控制图部分,主要是为了控制图的指示器,在悬浮的时候显示
|
|
86
|
-
triggerClick,
|
|
87
|
-
indicatorWidth,
|
|
88
|
-
isControlChart = false,
|
|
89
|
-
setCtlTip,
|
|
90
|
-
config: {
|
|
91
|
-
pattern = {},
|
|
92
|
-
seriesIntervalWidth: paddingInner = 0,
|
|
93
|
-
paddingInner: paddingOuter = 0,
|
|
94
|
-
highlight: { show: showHighlight, extent, fill: highlightFill },
|
|
95
|
-
...other
|
|
96
|
-
},
|
|
97
|
-
curXLabel,
|
|
98
|
-
selectStyle,
|
|
99
|
-
bandLength = 0,
|
|
100
|
-
auto = false,
|
|
101
|
-
data,
|
|
102
|
-
xAxis: { scaler: normalScaler, step:normalStep, controlStep, direction, controlDragScaler },
|
|
103
|
-
yAxis: { scaler: yScaler, isClipAxis, clipValue, reverse },
|
|
104
|
-
}: any) => {
|
|
105
|
-
if (!data.length) return null;
|
|
106
|
-
let selectConfig = other;
|
|
107
|
-
if(selectStyle){
|
|
108
|
-
const { show, showType, barStyle, headDecorate } = selectStyle;
|
|
109
|
-
if(show && showType=="bar"){
|
|
110
|
-
selectConfig = { ...barStyle, headDecorate };
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
const step = isControlChart?controlStep:normalStep;
|
|
114
|
-
const xScaler = isControlChart?controlDragScaler:normalScaler;
|
|
115
|
-
const { seriesWidth, seriesStep, seriesStart } = getSeriesInfo({
|
|
116
|
-
step,
|
|
117
|
-
bandLength,
|
|
118
|
-
paddingInner,
|
|
119
|
-
paddingOuter,
|
|
120
|
-
});
|
|
121
|
-
const _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
122
|
-
const isVertical = direction === "vertical";
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<g className="__easyv-band">
|
|
126
|
-
{_data.map(
|
|
127
|
-
(
|
|
128
|
-
{
|
|
129
|
-
flag,
|
|
130
|
-
index,
|
|
131
|
-
bound: [start, end],
|
|
132
|
-
data,
|
|
133
|
-
data: { x, y, s },
|
|
134
|
-
}: DataWithBoundType,
|
|
135
|
-
i: number
|
|
136
|
-
) => {
|
|
137
|
-
let y1: number, y2: number;
|
|
138
|
-
//断轴图相关,断轴图的scaler是一个数组,内含上断轴下断轴的scaler
|
|
139
|
-
if (isClipAxis) {
|
|
140
|
-
if (end > +clipValue) {
|
|
141
|
-
y1 = yScaler[1](start);
|
|
142
|
-
y2 = yScaler[0](end);
|
|
143
|
-
} else {
|
|
144
|
-
y1 = yScaler[1](start);
|
|
145
|
-
y2 = yScaler[1](end);
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
y1 = yScaler(isVertical ? end : start);
|
|
149
|
-
y2 = yScaler(isVertical ? start : end);
|
|
150
|
-
}
|
|
151
|
-
const {
|
|
152
|
-
style,
|
|
153
|
-
fillType,
|
|
154
|
-
fillMode="tile",
|
|
155
|
-
url,
|
|
156
|
-
size,
|
|
157
|
-
fill,
|
|
158
|
-
border,
|
|
159
|
-
opacity,
|
|
160
|
-
headDecorate
|
|
161
|
-
} = x==curXLabel?selectConfig:other;
|
|
162
|
-
const { borderColor:{
|
|
163
|
-
type="pure", pure="transparent", linear
|
|
164
|
-
}, borderWidth=0 } = border || {};
|
|
165
|
-
const borderStr = `${pure} solid ${borderWidth}px`;
|
|
166
|
-
const borderImageSource = getMultiColorStr(linear);
|
|
167
|
-
const positionX =_data.length==1? xScaler(x) -seriesStart/2 :xScaler(x) - step / 2 + seriesStart + index * seriesStep;
|
|
168
|
-
|
|
169
|
-
let showHead, headType, headUrl, headVideo, headWidth, headHeight, headTranslate;
|
|
170
|
-
if (headDecorate) {
|
|
171
|
-
(showHead = headDecorate.show),
|
|
172
|
-
(headType = headDecorate.type),
|
|
173
|
-
(headUrl = headDecorate.url),
|
|
174
|
-
(headVideo = headDecorate.video),
|
|
175
|
-
(headWidth = headDecorate.size.width),
|
|
176
|
-
(headHeight = headDecorate.size.height),
|
|
177
|
-
(headTranslate = headDecorate.translate);
|
|
178
|
-
}
|
|
179
|
-
//断轴图相关,将柱形在断轴处切开
|
|
180
|
-
const setClipPath = () => {
|
|
181
|
-
if (isClipAxis && end > +clipValue) {
|
|
182
|
-
let clipValueY2 = yScaler[0](clipValue); //上方
|
|
183
|
-
let clipValueY1 = yScaler[1](clipValue); //下方
|
|
184
|
-
let top = Math.abs((y2 - clipValueY2) / (y1 - y2)) * 100;
|
|
185
|
-
let bottom = Math.abs((y2 - clipValueY1) / (y1 - y2)) * 100;
|
|
186
|
-
|
|
187
|
-
//clip path属性
|
|
188
|
-
return `polygon(0% 0%, 0% 100%, 0 100%, 0 ${top}%, 100% ${top}%, 100% ${bottom}%, 0 ${bottom}%, 0 100%, 100% 100%, 100% 0%)`;
|
|
189
|
-
} else {
|
|
190
|
-
return "none";
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
if (isNaN(positionX)) return null;
|
|
194
|
-
const positionY = reverse?
|
|
195
|
-
y > 0 ? y1 : y2:
|
|
196
|
-
y < 0 ? y1 : y2;
|
|
197
|
-
const { bgAttr, ...attr } = getAttr({
|
|
198
|
-
isVertical,
|
|
199
|
-
x: positionX,
|
|
200
|
-
y: positionY,
|
|
201
|
-
length: Math.abs(y1 - y2),
|
|
202
|
-
seriesWidth,
|
|
203
|
-
});
|
|
204
|
-
return (
|
|
205
|
-
<Fragment key={i}>
|
|
206
|
-
<foreignObject style={{overflow: "visible",position: "relative",cursor: "pointer",}}
|
|
207
|
-
{...bgAttr}
|
|
208
|
-
onClick={e=>triggerClick(e,"setCurrent")}
|
|
209
|
-
onMouseEnter={() => {
|
|
210
|
-
if(isControlChart){
|
|
211
|
-
setCtlTip((pre:any)=>({
|
|
212
|
-
show:true,
|
|
213
|
-
x:xScaler(x),
|
|
214
|
-
xName:data.x,
|
|
215
|
-
indicatorList:pre.indicatorList.map((item:any)=>{
|
|
216
|
-
if (item.tick === data.x) {
|
|
217
|
-
return { ...item, isShow: true };
|
|
218
|
-
} else {
|
|
219
|
-
return item;
|
|
220
|
-
}
|
|
221
|
-
})
|
|
222
|
-
}))
|
|
223
|
-
}
|
|
224
|
-
}}
|
|
225
|
-
onMouseLeave={() => {
|
|
226
|
-
if(isControlChart && !auto){
|
|
227
|
-
setCtlTip((pre:any)=>({
|
|
228
|
-
show:false,
|
|
229
|
-
x:undefined,
|
|
230
|
-
xName:undefined,
|
|
231
|
-
indicatorList:pre.indicatorList.map((item:any)=>{
|
|
232
|
-
return { ...item, isShow:false }
|
|
233
|
-
})
|
|
234
|
-
}))
|
|
235
|
-
}
|
|
236
|
-
}}
|
|
237
|
-
data-mobile={JSON.stringify({x:xScaler(x),xName:data.x})}
|
|
238
|
-
data-data={JSON.stringify(data)}></foreignObject>
|
|
239
|
-
<foreignObject
|
|
240
|
-
style={{
|
|
241
|
-
overflow: "visible",
|
|
242
|
-
position: "relative",
|
|
243
|
-
pointerEvents:"none"
|
|
244
|
-
}}
|
|
245
|
-
{...attr}
|
|
246
|
-
>
|
|
247
|
-
{(headUrl || headVideo) && showHead && (
|
|
248
|
-
headType=="image"?<div
|
|
249
|
-
style={{
|
|
250
|
-
position: "absolute",
|
|
251
|
-
background: `url(${
|
|
252
|
-
//@ts-ignore
|
|
253
|
-
window.appConfig.ASSETS_URL + headUrl
|
|
254
|
-
}) 0 0/100% 100%`,
|
|
255
|
-
width: headWidth,
|
|
256
|
-
height: headHeight,
|
|
257
|
-
left: isVertical ? "100%" : "50%",
|
|
258
|
-
top: isVertical ? "50%" : "0",
|
|
259
|
-
zIndex: 1,
|
|
260
|
-
transform: `translate(calc(-50% + ${headTranslate.x}px), calc(-50% + ${headTranslate.y}px))`,
|
|
261
|
-
}}
|
|
262
|
-
></div>:<video
|
|
263
|
-
width={headWidth} height={headHeight}
|
|
264
|
-
//@ts-ignore
|
|
265
|
-
src={window.appConfig.ASSETS_URL + headVideo}
|
|
266
|
-
// controls={true}
|
|
267
|
-
loop={true}
|
|
268
|
-
muted={true}
|
|
269
|
-
autoPlay={true}
|
|
270
|
-
style={{
|
|
271
|
-
position: "absolute",
|
|
272
|
-
left: isVertical ? "100%" : "50%",
|
|
273
|
-
top: isVertical ? "50%" : "0",
|
|
274
|
-
zIndex: 1,
|
|
275
|
-
transform: `translate(calc(-50% + ${headTranslate.x}px), calc(-50% + ${headTranslate.y}px))`,
|
|
276
|
-
}}
|
|
277
|
-
></video>
|
|
278
|
-
)}
|
|
279
|
-
<div
|
|
280
|
-
style={{
|
|
281
|
-
width: "100%",
|
|
282
|
-
height: "100%",
|
|
283
|
-
/** Safari Bug **/
|
|
284
|
-
// position: "absolute",
|
|
285
|
-
clipPath: setClipPath(),
|
|
286
|
-
opacity: fillType == "pattern" ? opacity : 1,
|
|
287
|
-
background:
|
|
288
|
-
fillType == "pattern"
|
|
289
|
-
? `${isVertical?y<0?"100%":"0%":"50%"} ${isVertical?"50%":y<0?"0%":"100%"} / ${ fillMode=="tile"?size.width+"px "+size.height+"px":"100% 100%" } repeat ` +
|
|
290
|
-
"url(" +
|
|
291
|
-
//@ts-ignore
|
|
292
|
-
window.appConfig.ASSETS_URL + url +
|
|
293
|
-
")"
|
|
294
|
-
: getBandBackground(
|
|
295
|
-
pattern,
|
|
296
|
-
extent === flag ? highlightFill : fill
|
|
297
|
-
),
|
|
298
|
-
borderRadius:
|
|
299
|
-
style == "square"
|
|
300
|
-
? "0 0 0 0"
|
|
301
|
-
: getBorderRadius({
|
|
302
|
-
isVertical,
|
|
303
|
-
positive: y > 0,
|
|
304
|
-
seriesWidth,
|
|
305
|
-
}),
|
|
306
|
-
...type=="pure" && (isVertical
|
|
307
|
-
? {
|
|
308
|
-
borderTop: borderStr,
|
|
309
|
-
borderRight: borderStr,
|
|
310
|
-
borderBottom: borderStr,
|
|
311
|
-
}
|
|
312
|
-
: {
|
|
313
|
-
borderTop: borderStr,
|
|
314
|
-
borderRight: borderStr,
|
|
315
|
-
borderLeft: borderStr,
|
|
316
|
-
}),
|
|
317
|
-
...type=="linear" && {
|
|
318
|
-
borderImageSource,
|
|
319
|
-
borderImageSlice:1,
|
|
320
|
-
borderWidth:isVertical?`${borderWidth}px ${borderWidth}px ${borderWidth}px 0`:`${borderWidth}px ${borderWidth}px 0 ${borderWidth}px`,
|
|
321
|
-
borderStyle:"solid"
|
|
322
|
-
}
|
|
323
|
-
}}
|
|
324
|
-
/>
|
|
325
|
-
</foreignObject>
|
|
326
|
-
</Fragment>
|
|
327
|
-
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
)}
|
|
331
|
-
</g>
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
);
|
|
1
|
+
/**
|
|
2
|
+
* (柱状/条形)图柱子
|
|
3
|
+
*/
|
|
4
|
+
import React, { memo, Fragment } from "react";
|
|
5
|
+
import { min, max } from "d3v7";
|
|
6
|
+
import { getBandBackground, getMultiColorStr, 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
|
+
const len = length?length:0.1; //柱子长度
|
|
41
|
+
if (isVertical){
|
|
42
|
+
return { width: len, height: seriesWidth, x: y, y: x, bgAttr:{
|
|
43
|
+
x:0,
|
|
44
|
+
y:x,
|
|
45
|
+
width: len+x,
|
|
46
|
+
height: seriesWidth,
|
|
47
|
+
} };
|
|
48
|
+
}else{
|
|
49
|
+
return {
|
|
50
|
+
x,
|
|
51
|
+
y,
|
|
52
|
+
width: seriesWidth,
|
|
53
|
+
height: len,
|
|
54
|
+
bgAttr:{
|
|
55
|
+
x,
|
|
56
|
+
y:0,
|
|
57
|
+
width: seriesWidth,
|
|
58
|
+
height: y+len,
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const getBorderRadius = ({
|
|
66
|
+
isVertical,
|
|
67
|
+
positive,
|
|
68
|
+
seriesWidth,
|
|
69
|
+
}: {
|
|
70
|
+
isVertical: boolean;
|
|
71
|
+
positive: boolean;
|
|
72
|
+
seriesWidth: number;
|
|
73
|
+
}) => {
|
|
74
|
+
return isVertical
|
|
75
|
+
? positive
|
|
76
|
+
? "0px " + seriesWidth + "px " + seriesWidth + "px 0"
|
|
77
|
+
: seriesWidth + "px 0 0 " + seriesWidth + "px"
|
|
78
|
+
: positive
|
|
79
|
+
? seriesWidth / 2 + "px " + seriesWidth / 2 + "px 0 0"
|
|
80
|
+
: "0 0 " + seriesWidth / 2 + "px " + seriesWidth / 2 + "px";
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default memo(
|
|
84
|
+
({
|
|
85
|
+
//控制图部分,主要是为了控制图的指示器,在悬浮的时候显示
|
|
86
|
+
triggerClick,
|
|
87
|
+
indicatorWidth,
|
|
88
|
+
isControlChart = false,
|
|
89
|
+
setCtlTip,
|
|
90
|
+
config: {
|
|
91
|
+
pattern = {},
|
|
92
|
+
seriesIntervalWidth: paddingInner = 0,
|
|
93
|
+
paddingInner: paddingOuter = 0,
|
|
94
|
+
highlight: { show: showHighlight, extent, fill: highlightFill },
|
|
95
|
+
...other
|
|
96
|
+
},
|
|
97
|
+
curXLabel,
|
|
98
|
+
selectStyle,
|
|
99
|
+
bandLength = 0,
|
|
100
|
+
auto = false,
|
|
101
|
+
data,
|
|
102
|
+
xAxis: { scaler: normalScaler, step:normalStep, controlStep, direction, controlDragScaler },
|
|
103
|
+
yAxis: { scaler: yScaler, isClipAxis, clipValue, reverse },
|
|
104
|
+
}: any) => {
|
|
105
|
+
if (!data.length) return null;
|
|
106
|
+
let selectConfig = other;
|
|
107
|
+
if(selectStyle){
|
|
108
|
+
const { show, showType, barStyle, headDecorate } = selectStyle;
|
|
109
|
+
if(show && showType=="bar"){
|
|
110
|
+
selectConfig = { ...barStyle, headDecorate };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const step = isControlChart?controlStep:normalStep;
|
|
114
|
+
const xScaler = isControlChart?controlDragScaler:normalScaler;
|
|
115
|
+
const { seriesWidth, seriesStep, seriesStart } = getSeriesInfo({
|
|
116
|
+
step,
|
|
117
|
+
bandLength,
|
|
118
|
+
paddingInner,
|
|
119
|
+
paddingOuter,
|
|
120
|
+
});
|
|
121
|
+
const _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
122
|
+
const isVertical = direction === "vertical";
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<g className="__easyv-band">
|
|
126
|
+
{_data.map(
|
|
127
|
+
(
|
|
128
|
+
{
|
|
129
|
+
flag,
|
|
130
|
+
index,
|
|
131
|
+
bound: [start, end],
|
|
132
|
+
data,
|
|
133
|
+
data: { x, y, s },
|
|
134
|
+
}: DataWithBoundType,
|
|
135
|
+
i: number
|
|
136
|
+
) => {
|
|
137
|
+
let y1: number, y2: number;
|
|
138
|
+
//断轴图相关,断轴图的scaler是一个数组,内含上断轴下断轴的scaler
|
|
139
|
+
if (isClipAxis) {
|
|
140
|
+
if (end > +clipValue) {
|
|
141
|
+
y1 = yScaler[1](start);
|
|
142
|
+
y2 = yScaler[0](end);
|
|
143
|
+
} else {
|
|
144
|
+
y1 = yScaler[1](start);
|
|
145
|
+
y2 = yScaler[1](end);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
y1 = yScaler(isVertical ? end : start);
|
|
149
|
+
y2 = yScaler(isVertical ? start : end);
|
|
150
|
+
}
|
|
151
|
+
const {
|
|
152
|
+
style,
|
|
153
|
+
fillType,
|
|
154
|
+
fillMode="tile",
|
|
155
|
+
url,
|
|
156
|
+
size,
|
|
157
|
+
fill,
|
|
158
|
+
border,
|
|
159
|
+
opacity,
|
|
160
|
+
headDecorate
|
|
161
|
+
} = x==curXLabel?selectConfig:other;
|
|
162
|
+
const { borderColor:{
|
|
163
|
+
type="pure", pure="transparent", linear
|
|
164
|
+
}, borderWidth=0 } = border || {};
|
|
165
|
+
const borderStr = `${pure} solid ${borderWidth}px`;
|
|
166
|
+
const borderImageSource = getMultiColorStr(linear);
|
|
167
|
+
const positionX =_data.length==1? xScaler(x) -seriesStart/2 :xScaler(x) - step / 2 + seriesStart + index * seriesStep;
|
|
168
|
+
|
|
169
|
+
let showHead, headType, headUrl, headVideo, headWidth, headHeight, headTranslate;
|
|
170
|
+
if (headDecorate) {
|
|
171
|
+
(showHead = headDecorate.show),
|
|
172
|
+
(headType = headDecorate.type),
|
|
173
|
+
(headUrl = headDecorate.url),
|
|
174
|
+
(headVideo = headDecorate.video),
|
|
175
|
+
(headWidth = headDecorate.size.width),
|
|
176
|
+
(headHeight = headDecorate.size.height),
|
|
177
|
+
(headTranslate = headDecorate.translate);
|
|
178
|
+
}
|
|
179
|
+
//断轴图相关,将柱形在断轴处切开
|
|
180
|
+
const setClipPath = () => {
|
|
181
|
+
if (isClipAxis && end > +clipValue) {
|
|
182
|
+
let clipValueY2 = yScaler[0](clipValue); //上方
|
|
183
|
+
let clipValueY1 = yScaler[1](clipValue); //下方
|
|
184
|
+
let top = Math.abs((y2 - clipValueY2) / (y1 - y2)) * 100;
|
|
185
|
+
let bottom = Math.abs((y2 - clipValueY1) / (y1 - y2)) * 100;
|
|
186
|
+
|
|
187
|
+
//clip path属性
|
|
188
|
+
return `polygon(0% 0%, 0% 100%, 0 100%, 0 ${top}%, 100% ${top}%, 100% ${bottom}%, 0 ${bottom}%, 0 100%, 100% 100%, 100% 0%)`;
|
|
189
|
+
} else {
|
|
190
|
+
return "none";
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
if (isNaN(positionX)) return null;
|
|
194
|
+
const positionY = reverse?
|
|
195
|
+
y > 0 ? y1 : y2:
|
|
196
|
+
y < 0 ? y1 : y2;
|
|
197
|
+
const { bgAttr, ...attr } = getAttr({
|
|
198
|
+
isVertical,
|
|
199
|
+
x: positionX,
|
|
200
|
+
y: positionY,
|
|
201
|
+
length: Math.abs(y1 - y2),
|
|
202
|
+
seriesWidth,
|
|
203
|
+
});
|
|
204
|
+
return (
|
|
205
|
+
<Fragment key={i}>
|
|
206
|
+
<foreignObject style={{overflow: "visible",position: "relative",cursor: "pointer",}}
|
|
207
|
+
{...bgAttr}
|
|
208
|
+
onClick={e=>triggerClick(e,"setCurrent")}
|
|
209
|
+
onMouseEnter={() => {
|
|
210
|
+
if(isControlChart){
|
|
211
|
+
setCtlTip((pre:any)=>({
|
|
212
|
+
show:true,
|
|
213
|
+
x:xScaler(x),
|
|
214
|
+
xName:data.x,
|
|
215
|
+
indicatorList:pre.indicatorList.map((item:any)=>{
|
|
216
|
+
if (item.tick === data.x) {
|
|
217
|
+
return { ...item, isShow: true };
|
|
218
|
+
} else {
|
|
219
|
+
return item;
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
}))
|
|
223
|
+
}
|
|
224
|
+
}}
|
|
225
|
+
onMouseLeave={() => {
|
|
226
|
+
if(isControlChart && !auto){
|
|
227
|
+
setCtlTip((pre:any)=>({
|
|
228
|
+
show:false,
|
|
229
|
+
x:undefined,
|
|
230
|
+
xName:undefined,
|
|
231
|
+
indicatorList:pre.indicatorList.map((item:any)=>{
|
|
232
|
+
return { ...item, isShow:false }
|
|
233
|
+
})
|
|
234
|
+
}))
|
|
235
|
+
}
|
|
236
|
+
}}
|
|
237
|
+
data-mobile={JSON.stringify({x:xScaler(x),xName:data.x})}
|
|
238
|
+
data-data={JSON.stringify(data)}></foreignObject>
|
|
239
|
+
<foreignObject
|
|
240
|
+
style={{
|
|
241
|
+
overflow: "visible",
|
|
242
|
+
position: "relative",
|
|
243
|
+
pointerEvents:"none"
|
|
244
|
+
}}
|
|
245
|
+
{...attr}
|
|
246
|
+
>
|
|
247
|
+
{(headUrl || headVideo) && showHead && (
|
|
248
|
+
headType=="image"?<div
|
|
249
|
+
style={{
|
|
250
|
+
position: "absolute",
|
|
251
|
+
background: `url(${
|
|
252
|
+
//@ts-ignore
|
|
253
|
+
window.appConfig.ASSETS_URL + headUrl
|
|
254
|
+
}) 0 0/100% 100%`,
|
|
255
|
+
width: headWidth,
|
|
256
|
+
height: headHeight,
|
|
257
|
+
left: isVertical ? "100%" : "50%",
|
|
258
|
+
top: isVertical ? "50%" : "0",
|
|
259
|
+
zIndex: 1,
|
|
260
|
+
transform: `translate(calc(-50% + ${headTranslate.x}px), calc(-50% + ${headTranslate.y}px))`,
|
|
261
|
+
}}
|
|
262
|
+
></div>:<video
|
|
263
|
+
width={headWidth} height={headHeight}
|
|
264
|
+
//@ts-ignore
|
|
265
|
+
src={window.appConfig.ASSETS_URL + headVideo}
|
|
266
|
+
// controls={true}
|
|
267
|
+
loop={true}
|
|
268
|
+
muted={true}
|
|
269
|
+
autoPlay={true}
|
|
270
|
+
style={{
|
|
271
|
+
position: "absolute",
|
|
272
|
+
left: isVertical ? "100%" : "50%",
|
|
273
|
+
top: isVertical ? "50%" : "0",
|
|
274
|
+
zIndex: 1,
|
|
275
|
+
transform: `translate(calc(-50% + ${headTranslate.x}px), calc(-50% + ${headTranslate.y}px))`,
|
|
276
|
+
}}
|
|
277
|
+
></video>
|
|
278
|
+
)}
|
|
279
|
+
<div
|
|
280
|
+
style={{
|
|
281
|
+
width: "100%",
|
|
282
|
+
height: "100%",
|
|
283
|
+
/** Safari Bug **/
|
|
284
|
+
// position: "absolute",
|
|
285
|
+
clipPath: setClipPath(),
|
|
286
|
+
opacity: fillType == "pattern" ? opacity : 1,
|
|
287
|
+
background:
|
|
288
|
+
fillType == "pattern"
|
|
289
|
+
? `${isVertical?y<0?"100%":"0%":"50%"} ${isVertical?"50%":y<0?"0%":"100%"} / ${ fillMode=="tile"?size.width+"px "+size.height+"px":"100% 100%" } repeat ` +
|
|
290
|
+
"url(" +
|
|
291
|
+
//@ts-ignore
|
|
292
|
+
window.appConfig.ASSETS_URL + url +
|
|
293
|
+
")"
|
|
294
|
+
: getBandBackground(
|
|
295
|
+
pattern,
|
|
296
|
+
extent === flag ? highlightFill : fill
|
|
297
|
+
),
|
|
298
|
+
borderRadius:
|
|
299
|
+
style == "square"
|
|
300
|
+
? "0 0 0 0"
|
|
301
|
+
: getBorderRadius({
|
|
302
|
+
isVertical,
|
|
303
|
+
positive: y > 0,
|
|
304
|
+
seriesWidth,
|
|
305
|
+
}),
|
|
306
|
+
...type=="pure" && (isVertical
|
|
307
|
+
? {
|
|
308
|
+
borderTop: borderStr,
|
|
309
|
+
borderRight: borderStr,
|
|
310
|
+
borderBottom: borderStr,
|
|
311
|
+
}
|
|
312
|
+
: {
|
|
313
|
+
borderTop: borderStr,
|
|
314
|
+
borderRight: borderStr,
|
|
315
|
+
borderLeft: borderStr,
|
|
316
|
+
}),
|
|
317
|
+
...type=="linear" && {
|
|
318
|
+
borderImageSource,
|
|
319
|
+
borderImageSlice:1,
|
|
320
|
+
borderWidth:isVertical?`${borderWidth}px ${borderWidth}px ${borderWidth}px 0`:`${borderWidth}px ${borderWidth}px 0 ${borderWidth}px`,
|
|
321
|
+
borderStyle:"solid"
|
|
322
|
+
}
|
|
323
|
+
}}
|
|
324
|
+
/>
|
|
325
|
+
</foreignObject>
|
|
326
|
+
</Fragment>
|
|
327
|
+
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
)}
|
|
331
|
+
</g>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
);
|