@easyv/charts 1.8.24 → 1.8.25
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/lib/components/Axis.js +8 -5
- package/lib/components/Band.js +7 -3
- package/lib/components/CartesianChart.js +24 -6
- package/lib/components/Chart.js +17 -7
- package/lib/components/Label.js +11 -3
- package/package.json +1 -1
- package/src/components/Axis.tsx +72 -63
- package/src/components/Band.tsx +153 -113
- package/src/components/CartesianChart.js +287 -211
- package/src/components/Chart.js +94 -60
- package/src/components/Label.js +85 -39
package/src/components/Band.tsx
CHANGED
|
@@ -37,29 +37,34 @@ const getAttr = ({
|
|
|
37
37
|
x: number;
|
|
38
38
|
y: number;
|
|
39
39
|
}) => {
|
|
40
|
-
const len = length?length:0.1;
|
|
41
|
-
if (isVertical){
|
|
42
|
-
return {
|
|
43
|
-
|
|
44
|
-
y:x,
|
|
45
|
-
width: len+x,
|
|
40
|
+
const len = length ? length : 0.1; //柱子长度
|
|
41
|
+
if (isVertical) {
|
|
42
|
+
return {
|
|
43
|
+
width: len,
|
|
46
44
|
height: seriesWidth,
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
x: y,
|
|
46
|
+
y: x,
|
|
47
|
+
bgAttr: {
|
|
48
|
+
x: 0,
|
|
49
|
+
y: x,
|
|
50
|
+
width: len + x,
|
|
51
|
+
height: seriesWidth,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
49
55
|
return {
|
|
50
56
|
x,
|
|
51
57
|
y,
|
|
52
58
|
width: seriesWidth,
|
|
53
59
|
height: len,
|
|
54
|
-
bgAttr:{
|
|
60
|
+
bgAttr: {
|
|
55
61
|
x,
|
|
56
|
-
y:0,
|
|
62
|
+
y: 0,
|
|
57
63
|
width: seriesWidth,
|
|
58
|
-
height: y+len,
|
|
59
|
-
}
|
|
64
|
+
height: y + len,
|
|
65
|
+
},
|
|
60
66
|
};
|
|
61
67
|
}
|
|
62
|
-
|
|
63
68
|
};
|
|
64
69
|
|
|
65
70
|
const getBorderRadius = ({
|
|
@@ -83,7 +88,7 @@ const getBorderRadius = ({
|
|
|
83
88
|
export default memo(
|
|
84
89
|
({
|
|
85
90
|
//控制图部分,主要是为了控制图的指示器,在悬浮的时候显示
|
|
86
|
-
|
|
91
|
+
triggerEvents,
|
|
87
92
|
indicatorWidth,
|
|
88
93
|
isControlChart = false,
|
|
89
94
|
setCtlTip,
|
|
@@ -100,23 +105,29 @@ export default memo(
|
|
|
100
105
|
bandLength = 0,
|
|
101
106
|
auto = false,
|
|
102
107
|
data,
|
|
103
|
-
xAxis: {
|
|
108
|
+
xAxis: {
|
|
109
|
+
scaler: normalScaler,
|
|
110
|
+
step: normalStep,
|
|
111
|
+
controlStep,
|
|
112
|
+
direction,
|
|
113
|
+
controlDragScaler,
|
|
114
|
+
},
|
|
104
115
|
yAxis: { scaler: yScaler, isClipAxis, clipValue, reverse },
|
|
105
116
|
}: any) => {
|
|
106
117
|
if (!data.length) return null;
|
|
107
118
|
let selectConfig = other;
|
|
108
|
-
if(selectStyle){
|
|
119
|
+
if (selectStyle) {
|
|
109
120
|
const { show, showType, barStyle, headDecorate } = selectStyle;
|
|
110
|
-
if(show && showType=="bar"){
|
|
121
|
+
if (show && showType == "bar") {
|
|
111
122
|
selectConfig = { ...barStyle, headDecorate };
|
|
112
123
|
}
|
|
113
124
|
}
|
|
114
125
|
let highlightConfig = other;
|
|
115
|
-
if(highlightStyle){
|
|
126
|
+
if (highlightStyle) {
|
|
116
127
|
highlightConfig = { ...other, ...highlightStyle };
|
|
117
128
|
}
|
|
118
|
-
const step = isControlChart?controlStep:normalStep;
|
|
119
|
-
const xScaler = isControlChart?controlDragScaler:normalScaler;
|
|
129
|
+
const step = isControlChart ? controlStep : normalStep;
|
|
130
|
+
const xScaler = isControlChart ? controlDragScaler : normalScaler;
|
|
120
131
|
const { seriesWidth, seriesStep, seriesStart } = getSeriesInfo({
|
|
121
132
|
step,
|
|
122
133
|
bandLength,
|
|
@@ -153,32 +164,41 @@ export default memo(
|
|
|
153
164
|
y1 = yScaler(isVertical ? end : start);
|
|
154
165
|
y2 = yScaler(isVertical ? start : end);
|
|
155
166
|
}
|
|
156
|
-
const {
|
|
167
|
+
const {
|
|
157
168
|
style,
|
|
158
169
|
fillType,
|
|
159
|
-
fillMode="tile",
|
|
170
|
+
fillMode = "tile",
|
|
160
171
|
url,
|
|
161
172
|
size,
|
|
162
173
|
fill,
|
|
163
174
|
border,
|
|
164
175
|
opacity,
|
|
165
|
-
headDecorate
|
|
166
|
-
} = x==curXLabel?selectConfig:flag?highlightConfig:other;
|
|
167
|
-
const {
|
|
168
|
-
type="pure", pure="transparent", linear
|
|
169
|
-
|
|
176
|
+
headDecorate,
|
|
177
|
+
} = x == curXLabel ? selectConfig : flag ? highlightConfig : other;
|
|
178
|
+
const {
|
|
179
|
+
borderColor: { type = "pure", pure = "transparent", linear },
|
|
180
|
+
borderWidth = 0,
|
|
181
|
+
} = border || {};
|
|
170
182
|
const borderStr = `${pure} solid ${borderWidth}px`;
|
|
171
183
|
const borderImageSource = getMultiColorStr(linear);
|
|
172
|
-
const positionX =isXRepeat
|
|
173
|
-
|
|
184
|
+
const positionX = isXRepeat
|
|
185
|
+
? xScaler(x) - step / 2 + seriesStart + index * seriesStep
|
|
186
|
+
: xScaler(x) - seriesWidth / 2;
|
|
187
|
+
let showHead,
|
|
188
|
+
headType,
|
|
189
|
+
headUrl,
|
|
190
|
+
headVideo,
|
|
191
|
+
headWidth,
|
|
192
|
+
headHeight,
|
|
193
|
+
headTranslate;
|
|
174
194
|
if (headDecorate) {
|
|
175
195
|
(showHead = headDecorate.show),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
196
|
+
(headType = headDecorate.type),
|
|
197
|
+
(headUrl = headDecorate.url),
|
|
198
|
+
(headVideo = headDecorate.video),
|
|
199
|
+
(headWidth = headDecorate.size.width),
|
|
200
|
+
(headHeight = headDecorate.size.height),
|
|
201
|
+
(headTranslate = headDecorate.translate);
|
|
182
202
|
}
|
|
183
203
|
//断轴图相关,将柱形在断轴处切开
|
|
184
204
|
const setClipPath = () => {
|
|
@@ -195,9 +215,7 @@ export default memo(
|
|
|
195
215
|
}
|
|
196
216
|
};
|
|
197
217
|
if (isNaN(positionX)) return null;
|
|
198
|
-
const positionY = reverse?
|
|
199
|
-
y > 0 ? y1 : y2:
|
|
200
|
-
y < 0 ? y1 : y2;
|
|
218
|
+
const positionY = reverse ? (y > 0 ? y1 : y2) : y < 0 ? y1 : y2;
|
|
201
219
|
const { bgAttr, ...attr } = getAttr({
|
|
202
220
|
isVertical,
|
|
203
221
|
x: positionX,
|
|
@@ -207,79 +225,92 @@ export default memo(
|
|
|
207
225
|
});
|
|
208
226
|
return (
|
|
209
227
|
<Fragment key={i}>
|
|
210
|
-
<foreignObject
|
|
228
|
+
<foreignObject
|
|
229
|
+
style={{
|
|
230
|
+
overflow: "visible",
|
|
231
|
+
position: "relative",
|
|
232
|
+
cursor: "pointer",
|
|
233
|
+
}}
|
|
211
234
|
{...bgAttr}
|
|
212
|
-
onClick={e=>
|
|
235
|
+
onClick={(e) => triggerEvents(e, "setCurrent")}
|
|
236
|
+
onMouseMove={(e) => triggerEvents(e, "mouseenter")}
|
|
213
237
|
onMouseEnter={() => {
|
|
214
|
-
if(isControlChart){
|
|
215
|
-
setCtlTip((pre:any)=>({
|
|
216
|
-
show:true,
|
|
217
|
-
x:xScaler(x),
|
|
218
|
-
xName:data.x,
|
|
219
|
-
indicatorList:pre.indicatorList.map((item:any)=>{
|
|
238
|
+
if (isControlChart) {
|
|
239
|
+
setCtlTip((pre: any) => ({
|
|
240
|
+
show: true,
|
|
241
|
+
x: xScaler(x),
|
|
242
|
+
xName: data.x,
|
|
243
|
+
indicatorList: pre.indicatorList.map((item: any) => {
|
|
220
244
|
if (item.tick === data.x) {
|
|
221
245
|
return { ...item, isShow: true };
|
|
222
246
|
} else {
|
|
223
247
|
return item;
|
|
224
248
|
}
|
|
225
|
-
})
|
|
226
|
-
}))
|
|
249
|
+
}),
|
|
250
|
+
}));
|
|
227
251
|
}
|
|
228
252
|
}}
|
|
229
|
-
onMouseLeave={() => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
253
|
+
onMouseLeave={(e) => {
|
|
254
|
+
triggerEvents(e, "mouseleave");
|
|
255
|
+
if (isControlChart && !auto) {
|
|
256
|
+
setCtlTip((pre: any) => ({
|
|
257
|
+
show: false,
|
|
258
|
+
x: undefined,
|
|
259
|
+
xName: undefined,
|
|
260
|
+
indicatorList: pre.indicatorList.map((item: any) => {
|
|
261
|
+
return { ...item, isShow: false };
|
|
262
|
+
}),
|
|
263
|
+
}));
|
|
239
264
|
}
|
|
240
265
|
}}
|
|
241
|
-
data-mobile={JSON.stringify({x:xScaler(x),xName:data.x})}
|
|
242
|
-
data-data={JSON.stringify(data)}
|
|
266
|
+
data-mobile={JSON.stringify({ x: xScaler(x), xName: data.x })}
|
|
267
|
+
data-data={JSON.stringify(data)}
|
|
268
|
+
></foreignObject>
|
|
243
269
|
<foreignObject
|
|
244
270
|
style={{
|
|
245
271
|
overflow: "visible",
|
|
246
272
|
position: "relative",
|
|
247
|
-
pointerEvents:"none"
|
|
273
|
+
pointerEvents: "none",
|
|
248
274
|
}}
|
|
249
275
|
{...attr}
|
|
250
276
|
>
|
|
251
|
-
{(headUrl || headVideo) &&
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
277
|
+
{(headUrl || headVideo) &&
|
|
278
|
+
showHead &&
|
|
279
|
+
(headType == "image" ? (
|
|
280
|
+
<div
|
|
281
|
+
style={{
|
|
282
|
+
position: "absolute",
|
|
283
|
+
background: `url(${
|
|
284
|
+
//@ts-ignore
|
|
285
|
+
window.appConfig.ASSETS_URL + headUrl
|
|
286
|
+
}) 0 0/100% 100%`,
|
|
287
|
+
width: headWidth,
|
|
288
|
+
height: headHeight,
|
|
289
|
+
left: isVertical ? (y < 0 ? "0%" : "100%") : "50%",
|
|
290
|
+
top: isVertical ? "50%" : y < 0 ? "100%" : "0%",
|
|
291
|
+
zIndex: 1,
|
|
292
|
+
transform: `translate(calc(-50% + ${headTranslate.x}px), calc(-50% + ${headTranslate.y}px))`,
|
|
293
|
+
}}
|
|
294
|
+
></div>
|
|
295
|
+
) : (
|
|
296
|
+
<video
|
|
297
|
+
width={headWidth}
|
|
298
|
+
height={headHeight}
|
|
299
|
+
//@ts-ignore
|
|
300
|
+
src={window.appConfig.ASSETS_URL + headVideo}
|
|
301
|
+
// controls={true}
|
|
302
|
+
loop={true}
|
|
303
|
+
muted={true}
|
|
304
|
+
autoPlay={true}
|
|
305
|
+
style={{
|
|
306
|
+
position: "absolute",
|
|
307
|
+
left: isVertical ? "100%" : "50%",
|
|
308
|
+
top: isVertical ? "50%" : "0",
|
|
309
|
+
zIndex: 1,
|
|
310
|
+
transform: `translate(calc(-50% + ${headTranslate.x}px), calc(-50% + ${headTranslate.y}px))`,
|
|
311
|
+
}}
|
|
312
|
+
></video>
|
|
313
|
+
))}
|
|
283
314
|
<div
|
|
284
315
|
style={{
|
|
285
316
|
width: "100%",
|
|
@@ -290,15 +321,22 @@ export default memo(
|
|
|
290
321
|
opacity: fillType == "pattern" ? opacity : 1,
|
|
291
322
|
background:
|
|
292
323
|
fillType == "pattern"
|
|
293
|
-
? `${isVertical?y<0?"100%":"0%":
|
|
324
|
+
? `${isVertical ? (y < 0 ? "100%" : "0%") : "50%"} ${
|
|
325
|
+
isVertical ? "50%" : y < 0 ? "0%" : "100%"
|
|
326
|
+
} / ${
|
|
327
|
+
fillMode == "tile"
|
|
328
|
+
? size.width + "px " + size.height + "px"
|
|
329
|
+
: "100% 100%"
|
|
330
|
+
} repeat ` +
|
|
294
331
|
"url(" +
|
|
295
332
|
//@ts-ignore
|
|
296
|
-
window.appConfig.ASSETS_URL +
|
|
333
|
+
window.appConfig.ASSETS_URL +
|
|
334
|
+
url +
|
|
297
335
|
")"
|
|
298
336
|
: getBandBackground(
|
|
299
337
|
pattern,
|
|
300
338
|
fill,
|
|
301
|
-
y//是否小于0
|
|
339
|
+
y //是否小于0
|
|
302
340
|
),
|
|
303
341
|
borderRadius:
|
|
304
342
|
style == "square"
|
|
@@ -308,28 +346,30 @@ export default memo(
|
|
|
308
346
|
positive: y > 0,
|
|
309
347
|
seriesWidth,
|
|
310
348
|
}),
|
|
311
|
-
...type=="pure" &&
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
349
|
+
...(type == "pure" &&
|
|
350
|
+
(isVertical
|
|
351
|
+
? {
|
|
352
|
+
borderTop: borderStr,
|
|
353
|
+
borderRight: borderStr,
|
|
354
|
+
borderBottom: borderStr,
|
|
355
|
+
}
|
|
356
|
+
: {
|
|
357
|
+
borderTop: borderStr,
|
|
358
|
+
borderRight: borderStr,
|
|
359
|
+
borderLeft: borderStr,
|
|
360
|
+
})),
|
|
361
|
+
...(type == "linear" && {
|
|
323
362
|
borderImageSource,
|
|
324
|
-
borderImageSlice:1,
|
|
325
|
-
borderWidth:isVertical
|
|
326
|
-
|
|
327
|
-
|
|
363
|
+
borderImageSlice: 1,
|
|
364
|
+
borderWidth: isVertical
|
|
365
|
+
? `${borderWidth}px ${borderWidth}px ${borderWidth}px 0`
|
|
366
|
+
: `${borderWidth}px ${borderWidth}px 0 ${borderWidth}px`,
|
|
367
|
+
borderStyle: "solid",
|
|
368
|
+
}),
|
|
328
369
|
}}
|
|
329
370
|
/>
|
|
330
371
|
</foreignObject>
|
|
331
372
|
</Fragment>
|
|
332
|
-
|
|
333
373
|
);
|
|
334
374
|
}
|
|
335
375
|
)}
|