@tsingroc/tsingroc-components 1.0.4 → 1.0.5

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.
@@ -0,0 +1,967 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { LeftOutlined, RightOutlined } from "@ant-design/icons";
3
+ import { DatePicker } from "antd";
4
+ import DayJs from "dayjs";
5
+ import * as echarts from "echarts";
6
+ import ReactECharts from "echarts-for-react";
7
+ import React, { useEffect, useMemo, useRef, useState } from "react";
8
+ // 带风险区间的折线图
9
+ const RiskEchartMult = React.memo(function EchartMult(props) {
10
+ const l = localStorage.getItem("lang");
11
+ const { riskArr, max, x: propsX, yArr, nameArr, notFormat, nofoot, step, h = "350px", w = "100%", noDiff, addMaxBar, echartColorArr = [
12
+ "#2FDAFF",
13
+ "#77DA9B",
14
+ "#FFB82E",
15
+ "#5470c6",
16
+ "#91cc75",
17
+ "#fac858",
18
+ "#ee6666",
19
+ "#73c0de",
20
+ "#3ba272",
21
+ "#fc8452",
22
+ "#9a60b4",
23
+ "#ea7ccc",
24
+ ], areaStyle = [
25
+ "rgba(47,218,255 ,0.3)",
26
+ "rgba(119,218,155,0.3)",
27
+ "rgba(255,184,46,0.3)",
28
+ ], yAxis = "功率(MW)", barColor, legendLeft, unit = "MW", specialLine, pickLine, type, } = props;
29
+ const xTemp = useMemo(() => {
30
+ return new Array(24).fill(0).map((item, index) => {
31
+ const time = (index + 1).toString().padStart(2, "0");
32
+ return time + ":00";
33
+ });
34
+ }, []);
35
+ let x = [];
36
+ if (!propsX) {
37
+ x = xTemp;
38
+ }
39
+ else {
40
+ x = propsX;
41
+ }
42
+ // 获取最大值,构建bar
43
+ const option = useMemo(() => {
44
+ const barArr = [];
45
+ if (Array.isArray(yArr) && yArr.length > 0 && addMaxBar) {
46
+ const length = yArr[0].length;
47
+ for (let i = 0; i < length; i++) {
48
+ let max = Number.NEGATIVE_INFINITY;
49
+ let tempIndex = -1;
50
+ const secendLoopLength = yArr.length;
51
+ for (let j = 0; j < secendLoopLength; j++) {
52
+ if (yArr[j][i] > max) {
53
+ max = yArr[j][i];
54
+ tempIndex = j;
55
+ }
56
+ }
57
+ barArr.push({
58
+ value: max,
59
+ itemStyle: {
60
+ color: barColor[tempIndex],
61
+ },
62
+ });
63
+ }
64
+ }
65
+ const option = {
66
+ grid: {
67
+ top: "30",
68
+ left: "40",
69
+ right: "40",
70
+ bottom: "20",
71
+ containLabel: true,
72
+ },
73
+ xAxis: {
74
+ type: "category",
75
+ show: !nofoot,
76
+ data: notFormat ? x.map((item) => new DayJs(item).format("HH:mm")) : x,
77
+ },
78
+ yAxis: [
79
+ {
80
+ max: max,
81
+ name: yAxis,
82
+ nameGap: 10,
83
+ position: "left",
84
+ nameTextStyle: {
85
+ align: "center",
86
+ fontWeight: "bold",
87
+ },
88
+ type: "value",
89
+ splitLine: {
90
+ lineStyle: {
91
+ color: "rgba(130, 144, 157, 0.18)",
92
+ },
93
+ },
94
+ splitNumber: 3,
95
+ },
96
+ {
97
+ type: "value",
98
+ splitLine: {
99
+ lineStyle: {
100
+ color: "#DCDEE0",
101
+ },
102
+ },
103
+ splitNumber: 3,
104
+ },
105
+ ],
106
+ legend: {
107
+ data: [...nameArr, "风险区间"].map((item, index) => {
108
+ return {
109
+ name: item,
110
+ itemStyle: {
111
+ color: item === "风险区间"
112
+ ? "rgba(99,211,149,0.8)"
113
+ : echartColorArr[index],
114
+ },
115
+ icon: item === "实际"
116
+ ? "path://M304.43 532.76H221.4c-11.47 0-20.76-9.3-20.76-20.76s9.29-20.76 20.76-20.76h83.03c11.47 0 20.76 9.3 20.76 20.76s-9.29 20.76-20.76 20.76zM581.19 532.76H442.81c-11.47 0-20.76-9.3-20.76-20.76s9.29-20.76 20.76-20.76h138.38c11.47 0 20.76 9.3 20.76 20.76s-9.3 20.76-20.76 20.76zM802.59 532.76h-83.03c-11.47 0-20.76-9.3-20.76-20.76s9.29-20.76 20.76-20.76h83.03c11.47 0 20.76 9.3 20.76 20.76s-9.29 20.76-20.76 20.76z"
117
+ : "rect",
118
+ };
119
+ }),
120
+ textStyle: {
121
+ color: "#646566",
122
+ },
123
+ left: legendLeft,
124
+ right: "20",
125
+ // formatter: (name) => {
126
+ // return shark(name,l)
127
+ // }
128
+ },
129
+ color: echartColorArr,
130
+ tooltip: {
131
+ trigger: "axis",
132
+ valueFormatter: (value) => value ? value.toFixed(2) + unit : value === 0 ? 0 + unit : "",
133
+ },
134
+ series: yArr
135
+ ?.map((item, index) => ({
136
+ data: item?.map((i) => (typeof i === "number" ? i : undefined)),
137
+ type: type || "line",
138
+ smooth: true,
139
+ name: nameArr[index],
140
+ lineStyle: {
141
+ // type: noDiff ? "solid" : index === 0 ? "dashed" : "solid",
142
+ type: specialLine
143
+ ? nameArr[index] === pickLine
144
+ ? "solid"
145
+ : "dashed"
146
+ : "solid",
147
+ color: echartColorArr[index],
148
+ },
149
+ step: step || "",
150
+ symbol: "none",
151
+ emphasis: {
152
+ itemStyle: {
153
+ color: "red",
154
+ },
155
+ },
156
+ // areaStyle:{
157
+ // color:areaStyle[index]
158
+ // }
159
+ }))
160
+ .concat(addMaxBar
161
+ ? [
162
+ {
163
+ data: barArr,
164
+ type: "bar",
165
+ name: "max",
166
+ barWidth: "101%",
167
+ yAxisIndex: 1,
168
+ tooltip: {
169
+ show: false,
170
+ },
171
+ },
172
+ ]
173
+ : []),
174
+ };
175
+ if (riskArr && riskArr.length > 0 && riskArr[0]) {
176
+ option.series.push({
177
+ data: riskArr[1],
178
+ type: "line",
179
+ name: "风险上边界",
180
+ smooth: true,
181
+ showSymbol: false,
182
+ tooltip: {
183
+ show: true,
184
+ },
185
+ lineStyle: {
186
+ opacity: 0,
187
+ },
188
+ }, {
189
+ yAxisIndex: 0,
190
+ data: riskArr[0],
191
+ type: "line",
192
+ name: "风险下边界",
193
+ smooth: true,
194
+ stack: "st",
195
+ showSymbol: false,
196
+ lineStyle: {
197
+ opacity: 0,
198
+ },
199
+ tooltip: {
200
+ show: true,
201
+ },
202
+ emphasis: {
203
+ disabled: true,
204
+ },
205
+ }, {
206
+ yAxisIndex: 0,
207
+ name: "风险区间",
208
+ stack: "st",
209
+ stackStrategy: "all",
210
+ data: riskArr[1].map((item, index) => {
211
+ return riskArr[1][index] - riskArr[0][index];
212
+ }),
213
+ type: "line",
214
+ smooth: true,
215
+ symbol: "none",
216
+ lineStyle: {
217
+ opacity: 0,
218
+ },
219
+ areaStyle: {
220
+ color: "#63D395",
221
+ },
222
+ emphasis: {
223
+ disabled: true,
224
+ },
225
+ tooltip: {
226
+ show: false,
227
+ },
228
+ });
229
+ }
230
+ return option;
231
+ }, [
232
+ echartColorArr,
233
+ addMaxBar,
234
+ x,
235
+ yArr,
236
+ nameArr,
237
+ noDiff,
238
+ nofoot,
239
+ step,
240
+ yAxis,
241
+ notFormat,
242
+ barColor,
243
+ riskArr,
244
+ ]);
245
+ const echartRef = useRef(null);
246
+ useEffect(() => {
247
+ if (echartRef.current) {
248
+ const ins = echartRef.current.getEchartsInstance();
249
+ }
250
+ }, [x, yArr, nameArr, riskArr, option]);
251
+ const onEvents = {
252
+ " click": () => { },
253
+ };
254
+ return (_jsx(ReactECharts, { ref: echartRef, option: option, style: { height: h, width: w }, onEvents: onEvents }));
255
+ });
256
+ // 折线图
257
+ const EchartMult = React.memo(function EchartMult(props) {
258
+ const l = localStorage.getItem("lang");
259
+ const { max, x: propsX, yArr, nameArr, notFormat, nofoot, step, h = "350px", w = "100%", left = 30, right = 40, noDiff, addMaxBar, barWidth = "15px", barLinearGradientArr, echartColorArr = [
260
+ "#2FDAFF",
261
+ "#77DA9B",
262
+ "#FFB82E",
263
+ "#5470c6",
264
+ "#91cc75",
265
+ "#fac858",
266
+ "#ee6666",
267
+ "#73c0de",
268
+ "#3ba272",
269
+ "#fc8452",
270
+ "#9a60b4",
271
+ "#ea7ccc",
272
+ ], legendTextColor = "#fff", areaStyle = [
273
+ "rgba(47,218,255 ,0.3)",
274
+ "rgba(119,218,155,0.3)",
275
+ "rgba(255,184,46,0.3)",
276
+ ], yAxis = "功率(MW)", barColor, legendLeft, unit = "MW", specialLine, pickLine, type, } = props;
277
+ if (barLinearGradientArr) {
278
+ echartColorArr[0] = barLinearGradientArr[1];
279
+ }
280
+ const xTemp = useMemo(() => {
281
+ return new Array(24).fill(0).map((item, index) => {
282
+ const time = (index + 1).toString().padStart(2, "0");
283
+ return time + ":00";
284
+ });
285
+ }, []);
286
+ let x = [];
287
+ if (!propsX) {
288
+ x = xTemp;
289
+ }
290
+ else {
291
+ x = propsX;
292
+ }
293
+ // 获取最大值,构建bar
294
+ const option = useMemo(() => {
295
+ const barArr = [];
296
+ if (Array.isArray(yArr) && yArr.length > 0 && addMaxBar) {
297
+ const length = yArr[0].length;
298
+ for (let i = 0; i < length; i++) {
299
+ let max = Number.NEGATIVE_INFINITY;
300
+ let tempIndex = -1;
301
+ const secendLoopLength = yArr.length;
302
+ for (let j = 0; j < secendLoopLength; j++) {
303
+ if (yArr[j][i] > max) {
304
+ max = yArr[j][i];
305
+ tempIndex = j;
306
+ }
307
+ }
308
+ barArr.push({
309
+ value: max,
310
+ itemStyle: {
311
+ color: barColor[tempIndex],
312
+ },
313
+ });
314
+ }
315
+ }
316
+ const option = {
317
+ grid: {
318
+ top: "30",
319
+ left: left,
320
+ right: right,
321
+ bottom: "20",
322
+ containLabel: true,
323
+ },
324
+ xAxis: {
325
+ type: "category",
326
+ // axisLabel: {
327
+ // interval: 0 // 强制显示所有x轴标签
328
+ // },
329
+ show: !nofoot,
330
+ data: notFormat ? x.map((item) => new DayJs(item).format("HH:mm")) : x,
331
+ },
332
+ yAxis: [
333
+ {
334
+ max: max,
335
+ name: yAxis,
336
+ nameGap: 10,
337
+ position: "left",
338
+ nameTextStyle: {
339
+ align: "center",
340
+ fontWeight: "bold",
341
+ },
342
+ type: "value",
343
+ splitLine: {
344
+ lineStyle: {
345
+ color: "rgba(130, 144, 157, 0.18)",
346
+ },
347
+ },
348
+ splitNumber: 3,
349
+ },
350
+ {
351
+ type: "value",
352
+ splitLine: {
353
+ lineStyle: {
354
+ color: "#DCDEE0",
355
+ },
356
+ },
357
+ splitNumber: 3,
358
+ },
359
+ ],
360
+ legend: {
361
+ data: nameArr.map((item, index) => {
362
+ return {
363
+ name: item,
364
+ itemStyle: {
365
+ color: echartColorArr[index],
366
+ },
367
+ icon: item === "实际"
368
+ ? "path://M304.43 532.76H221.4c-11.47 0-20.76-9.3-20.76-20.76s9.29-20.76 20.76-20.76h83.03c11.47 0 20.76 9.3 20.76 20.76s-9.29 20.76-20.76 20.76zM581.19 532.76H442.81c-11.47 0-20.76-9.3-20.76-20.76s9.29-20.76 20.76-20.76h138.38c11.47 0 20.76 9.3 20.76 20.76s-9.3 20.76-20.76 20.76zM802.59 532.76h-83.03c-11.47 0-20.76-9.3-20.76-20.76s9.29-20.76 20.76-20.76h83.03c11.47 0 20.76 9.3 20.76 20.76s-9.29 20.76-20.76 20.76z"
369
+ : "rect",
370
+ };
371
+ }),
372
+ textStyle: {
373
+ // color: "#646566",
374
+ color: legendTextColor,
375
+ },
376
+ left: legendLeft,
377
+ right: "20",
378
+ // formatter: (name) => {
379
+ // return shark(name,l)
380
+ // }
381
+ },
382
+ color: echartColorArr,
383
+ tooltip: {
384
+ trigger: "axis",
385
+ valueFormatter: (value) => value ? value.toFixed(2) + unit : value === 0 ? 0 + unit : "",
386
+ },
387
+ series: yArr
388
+ ?.map((item, index) => ({
389
+ data: item?.map((i) => (typeof i === "number" ? i : undefined)),
390
+ type: type || "line",
391
+ smooth: true,
392
+ name: nameArr[index],
393
+ lineStyle: {
394
+ // type: noDiff ? "solid" : index === 0 ? "dashed" : "solid",
395
+ type: specialLine
396
+ ? nameArr[index] === pickLine
397
+ ? "solid"
398
+ : "dashed"
399
+ : "solid",
400
+ color: echartColorArr[index],
401
+ },
402
+ step: step || "",
403
+ symbol: "none",
404
+ emphasis: {
405
+ itemStyle: {
406
+ color: "red",
407
+ },
408
+ },
409
+ areaStyle: areaStyle
410
+ ? {
411
+ color: areaStyle[index],
412
+ }
413
+ : null,
414
+ barWidth: barWidth,
415
+ itemStyle: barLinearGradientArr
416
+ ? {
417
+ barBorderRadius: [3, 3, 0, 0],
418
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
419
+ { offset: 0, color: barLinearGradientArr[1] },
420
+ { offset: 1, color: barLinearGradientArr[0] },
421
+ ]),
422
+ }
423
+ : {},
424
+ }))
425
+ .concat(addMaxBar
426
+ ? [
427
+ {
428
+ data: barArr,
429
+ type: "bar",
430
+ name: "max",
431
+ barWidth: "101%",
432
+ yAxisIndex: 1,
433
+ tooltip: {
434
+ show: false,
435
+ },
436
+ },
437
+ ]
438
+ : []),
439
+ };
440
+ return option;
441
+ }, [
442
+ echartColorArr,
443
+ addMaxBar,
444
+ x,
445
+ yArr,
446
+ nameArr,
447
+ noDiff,
448
+ nofoot,
449
+ step,
450
+ yAxis,
451
+ notFormat,
452
+ barColor,
453
+ ]);
454
+ const echartRef = useRef(null);
455
+ useEffect(() => {
456
+ if (echartRef.current) {
457
+ const ins = echartRef.current.getEchartsInstance();
458
+ ins.setOption({
459
+ ...ins.getOption(),
460
+ series: ins
461
+ .getOption()
462
+ .series.filter((item) => [...nameArr, "max"].includes(item.name)),
463
+ }, true, true);
464
+ }
465
+ }, [x, yArr, nameArr]);
466
+ const onEvents = {
467
+ " click": () => { },
468
+ };
469
+ return (_jsx(ReactECharts, { ref: echartRef, option: option, style: { height: h, width: w }, onEvents: onEvents }));
470
+ });
471
+ // 待快速跳转的日,周,月 选择器
472
+ function TsingrocDatePick(props) {
473
+ const { value, onChange: propsOnChange, dataType = "month", className, popupClassName, } = props;
474
+ const [dateValue, setDateValue] = useState(value);
475
+ const quickGo = (type) => {
476
+ const temp = dateValue.add(type, dataType);
477
+ setDateValue(temp);
478
+ propsOnChange && propsOnChange(temp);
479
+ };
480
+ const onChange = (value) => {
481
+ setDateValue(value);
482
+ propsOnChange && propsOnChange(value);
483
+ };
484
+ return (_jsxs("div", { children: [_jsx("div", { onClick: () => {
485
+ quickGo(-1);
486
+ }, className: `quick-jump ${className}`, style: { borderRight: "none", borderRadius: "2px 0 0 2px" }, children: _jsx(LeftOutlined, { className: "quick-icon" }) }), dataType === "day" && (_jsx(DatePicker, { value: dateValue, onChange: onChange })), dataType === "week" && (_jsx(DatePicker, { value: dateValue, onChange: onChange, picker: "week" })), dataType === "month" && (_jsx(DatePicker, { popupClassName: popupClassName, className: className, value: dateValue, onChange: onChange, picker: "month" })), _jsx("div", { onClick: () => {
487
+ quickGo(1);
488
+ }, className: `quick-jump ${className}`, style: { borderLeft: "none", borderRadius: "0 2px 2px 0" }, children: _jsx(RightOutlined, { className: "quick-icon" }) })] }));
489
+ }
490
+ // 雷达图
491
+ function RadarEchart(props) {
492
+ const { h = "100px", x = [], yAxis, arr = [], value = [] } = props;
493
+ const echartRef = useRef(null);
494
+ const option = {
495
+ // grid: {
496
+ // top: "20%",
497
+ // left: "40",
498
+ // right: "40",
499
+ // containLabel: true,
500
+ // },
501
+ radar: {
502
+ indicator: arr.map((item, key) => {
503
+ return { name: item, max: 1 };
504
+ }),
505
+ // indicator: [
506
+ // { name: 'Sales', max: 6500 },
507
+ // { name: 'Administration', max: 16000 },
508
+ // { name: 'Information Technology', max: 30000 },
509
+ // { name: 'Customer Support', max: 38000 },
510
+ // ],
511
+ radius: "60%",
512
+ splitArea: {
513
+ areaStyle: {
514
+ color: "rgba(119, 218, 155, 0)", // 设置分隔区域颜色为渐变色
515
+ },
516
+ },
517
+ splitLine: {
518
+ lineStyle: {
519
+ color: "rgba(64, 175, 239, 0.15)",
520
+ },
521
+ },
522
+ axisLine: {
523
+ // show: false,
524
+ lineStyle: {
525
+ with: 1,
526
+ color: "rgba(130, 144, 157, 0.18)",
527
+ },
528
+ },
529
+ axisName: {
530
+ show: true,
531
+ color: "#9FC7DD",
532
+ },
533
+ },
534
+ series: [
535
+ {
536
+ name: "Budget vs spending",
537
+ type: "radar",
538
+ data: [
539
+ {
540
+ value: value,
541
+ name: "Actual Spending",
542
+ },
543
+ ],
544
+ lineStyle: {
545
+ normal: {
546
+ color: "#77DA9B", // 设置线条颜色为橙色,透明度为0.5
547
+ },
548
+ },
549
+ areaStyle: {
550
+ color: "rgba(119, 218, 155, 0.3)",
551
+ },
552
+ symbol: "none",
553
+ },
554
+ ],
555
+ };
556
+ const onEvents = () => { };
557
+ return (_jsx(ReactECharts, { ref: echartRef, option: option, style: { height: h, width: "100%" }, onEvents: onEvents }));
558
+ }
559
+ // 饼图
560
+ function TsingrocPie(props) {
561
+ const { name = "饼图", valueArr = [
562
+ { value: 735, name: "Search Engine" },
563
+ { value: 735, name: "Direct" },
564
+ { value: 735, name: "Email" },
565
+ { value: 735, name: "Union Ads" },
566
+ { value: 735, name: "Video Ads" },
567
+ ], color = [
568
+ "#ECA926",
569
+ "#32ADF4",
570
+ "#DC7756",
571
+ "#62CE89",
572
+ "#4256B9",
573
+ "#00D0FF",
574
+ "#96D0DD",
575
+ ], } = props;
576
+ const option = {
577
+ color: color,
578
+ tooltip: {
579
+ trigger: "item",
580
+ },
581
+ legend: {
582
+ top: "5%",
583
+ left: "center",
584
+ show: false,
585
+ },
586
+ series: [
587
+ {
588
+ name: name,
589
+ type: "pie",
590
+ radius: ["40%", "70%"],
591
+ avoidLabelOverlap: false,
592
+ padAngle: 2,
593
+ itemStyle: {
594
+ borderRadius: 1,
595
+ },
596
+ label: {
597
+ show: false,
598
+ position: "center",
599
+ },
600
+ emphasis: {
601
+ label: {
602
+ show: true,
603
+ fontSize: 16,
604
+ fontWeight: "bold",
605
+ },
606
+ },
607
+ labelLine: {
608
+ show: false,
609
+ },
610
+ data: valueArr,
611
+ },
612
+ ],
613
+ };
614
+ return (_jsx("div", { style: { height: "100%" }, children: _jsxs("div", { style: { display: "flex", height: "100%" }, children: [_jsx("div", { style: { flex: 3 }, children: _jsx(ReactECharts, { style: { height: "100%" }, option: option }) }), _jsx("div", { style: { flex: 2, display: "flex", alignItems: "center" }, children: _jsx("div", { style: {}, children: valueArr.map((item, key) => {
615
+ return (_jsxs("div", { style: { fontSize: "14px", lineHeight: "20px" }, children: [_jsx("div", { style: {
616
+ display: "inline-block",
617
+ width: "6px",
618
+ height: "6px",
619
+ backgroundColor: color[key],
620
+ marginRight: "5px",
621
+ transform: "translateY(-1px)",
622
+ } }), _jsxs(Space, { children: [_jsxs("div", { style: { color: "#96A9BA" }, children: [item.name, ":"] }), _jsx("div", { style: { color: "#fff" }, children: item.value })] })] }, key));
623
+ }) }) })] }) }));
624
+ }
625
+ // 环形统计图
626
+ const CircularProgress = ({ progress, color = "#34A9D4" }) => {
627
+ // 确保进度值在0到100之间
628
+ const clampProgress = (value) => Math.max(0, Math.min(100, value));
629
+ // 计算圆的周长
630
+ const circumference = 2 * Math.PI * 15.91549430918954;
631
+ return (_jsxs("div", { style: { width: "100%", height: "100%", position: "relative" }, children: [_jsxs("svg", { width: "100%", height: "100%", viewBox: "0 0 42 42", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("circle", { className: "circle", cx: "21", cy: "21", r: "15.91549430918954", stroke: "#22405a", strokeWidth: "3", fill: "none" }), _jsx("circle", { className: "circle", cx: "21", cy: "21", r: "15.91549430918954", stroke: color,
632
+ // stroke="#ff0"
633
+ strokeWidth: "3", fill: "none", strokeDasharray: circumference, strokeDashoffset: circumference - (clampProgress(progress) / 100) * circumference })] }), _jsxs("div", { style: {
634
+ position: "absolute",
635
+ top: "50%",
636
+ transform: "translateY(-50%)",
637
+ textAlign: "center",
638
+ width: "100%",
639
+ }, children: [clampProgress(progress), "%"] })] }));
640
+ };
641
+ // 风向模拟
642
+ const WindFlow = React.memo(function WindFlowFunc(props) {
643
+ const { weatherData } = props;
644
+ const echartRef = useRef(null);
645
+ const { h = "150%" } = props;
646
+ const noise = createNoise2D(Math.random);
647
+ const noise2 = createNoise2D(Math.random);
648
+ // returns a value between -1 and 1
649
+ const valMin = Number.POSITIVE_INFINITY;
650
+ const valMax = Number.NEGATIVE_INFINITY;
651
+ const tempMap = {};
652
+ const orderArr = [];
653
+ weatherData.forEach((item) => {
654
+ const a = item.location.split(" ");
655
+ const x = a[0];
656
+ const y = a[1];
657
+ if (tempMap[x]) {
658
+ tempMap[x].push(item);
659
+ }
660
+ else {
661
+ orderArr.push(x);
662
+ tempMap[x] = [item];
663
+ }
664
+ });
665
+ orderArr.sort((a, b) => {
666
+ return a - b;
667
+ });
668
+ Object.keys(tempMap).forEach((key) => {
669
+ tempMap[key].sort((a, b) => {
670
+ return a.location.split(" ")[1] - b.location.split(" ")[1];
671
+ });
672
+ });
673
+ const retArr = [];
674
+ orderArr.forEach((key, index) => {
675
+ retArr[index] = tempMap[key];
676
+ });
677
+ console.log(retArr);
678
+ function generateData() {
679
+ const data = [];
680
+ // for (var i = 0; i <= 100; i++) {
681
+ // for (var j = 0; j <= 100; j++) {
682
+ // var dx = noise(i / 150, j / 150);
683
+ // var dy = noise2(i / 150, j / 150);
684
+ // var mag = Math.sqrt(dx * dx + dy * dy);
685
+ // valMax = Math.max(valMax, mag);
686
+ // valMin = Math.min(valMin, mag);
687
+ // // data.push([i, j, dx, dy, mag]);
688
+ // data.push([i, j, 0.2 + 0.01 * i, -0.9 + i * 0.01, 1])
689
+ // }
690
+ // }
691
+ // todo
692
+ retArr.forEach((item, i) => {
693
+ item.forEach((sub, j) => {
694
+ data.push([
695
+ i,
696
+ j,
697
+ -Math.cos(sub.wind_direction_80m * (Math.PI / 180)),
698
+ Math.sin(sub.wind_direction_80m * (Math.PI / 180)),
699
+ 1,
700
+ ]);
701
+ });
702
+ });
703
+ return data;
704
+ }
705
+ const data = generateData();
706
+ // const data = windData
707
+ const onEvents = {
708
+ " click": () => { },
709
+ };
710
+ const option = {
711
+ grid: {
712
+ left: 0,
713
+ top: 0,
714
+ bottom: 0,
715
+ right: 0,
716
+ },
717
+ visualMap: {
718
+ show: false,
719
+ min: valMin,
720
+ max: valMax,
721
+ dimension: 2,
722
+ inRange: {
723
+ color: ["#fff"],
724
+ },
725
+ },
726
+ xAxis: {
727
+ type: "value",
728
+ axisLine: {
729
+ lineStyle: {
730
+ color: "#fff",
731
+ },
732
+ },
733
+ splitLine: {
734
+ show: false,
735
+ lineStyle: {
736
+ color: "rgba(255,255,255,0.2)",
737
+ },
738
+ },
739
+ },
740
+ yAxis: {
741
+ type: "value",
742
+ axisLine: {
743
+ lineStyle: {
744
+ color: "#fff",
745
+ },
746
+ },
747
+ show: false,
748
+ splitLine: {
749
+ show: false,
750
+ lineStyle: {
751
+ color: "rgba(255,255,255,0.2)",
752
+ },
753
+ },
754
+ },
755
+ series: [
756
+ {
757
+ type: "flowGL",
758
+ data: data,
759
+ particleDensity: 20,
760
+ particleSize: 3,
761
+ // particleDensity: 15,
762
+ // particleSize: 3,
763
+ particleSpeed: 0.5,
764
+ itemStyle: {
765
+ opacity: 0.5,
766
+ },
767
+ },
768
+ // {
769
+ // type: 'custom',
770
+ // data: data,
771
+ // encode: {
772
+ // x: 0,
773
+ // y: 0
774
+ // },
775
+ // renderItem: function (params, api) {
776
+ // var x = api.value(0),
777
+ // y = api.value(1),
778
+ // dx = api.value(2),
779
+ // dy = api.value(3);
780
+ // var start = api.coord([x - dx / 2, y - dy / 2]);
781
+ // var end = api.coord([x + dx / 2, y + dy / 2]);
782
+ // return {
783
+ // type: 'line',
784
+ // shape: {
785
+ // x1: start[0],
786
+ // y1: start[1],
787
+ // x2: end[0],
788
+ // y2: end[1]
789
+ // },
790
+ // style: {
791
+ // lineWidth: 2,
792
+ // stroke: '#fff',
793
+ // opacity: 1
794
+ // }
795
+ // };
796
+ // }
797
+ // }
798
+ ],
799
+ };
800
+ return (_jsx(ReactECharts, { ref: echartRef, option: option, style: { height: h, width: "110%", marginTop: "-100px" }, onEvents: onEvents }));
801
+ });
802
+ // 箱线图
803
+ function BoxplotEchart(props) {
804
+ const { h = "100px", x = [], yAxis, yArr = [] } = props;
805
+ const echartRef = useRef(null);
806
+ const option = {
807
+ tooltip: {
808
+ trigger: "item",
809
+ axisPointer: {
810
+ type: "shadow",
811
+ },
812
+ },
813
+ grid: {
814
+ top: "30",
815
+ left: "40",
816
+ right: "40",
817
+ bottom: "20",
818
+ containLabel: true,
819
+ },
820
+ xAxis: {
821
+ type: "category",
822
+ boundaryGap: true,
823
+ splitArea: {
824
+ show: false,
825
+ },
826
+ splitLine: {
827
+ show: false,
828
+ },
829
+ data: x,
830
+ },
831
+ yAxis: {
832
+ type: "value",
833
+ max: 50,
834
+ min: -50,
835
+ name: yAxis || "km/s minus 299,000",
836
+ splitLine: {
837
+ lineStyle: {
838
+ color: "rgba(130, 144, 157, 0.18)",
839
+ },
840
+ },
841
+ splitNumber: 3,
842
+ },
843
+ series: [
844
+ {
845
+ name: "boxplot",
846
+ type: "boxplot",
847
+ data: yArr,
848
+ tooltip: {
849
+ formatter: (param) => [
850
+ "时间 " + param.name,
851
+ "最大值: " + param.data[5].toFixed(2) + "%",
852
+ "第三四分位数: " + param.data[4].toFixed(2) + "%",
853
+ "中位数: " + param.data[2].toFixed(2) + "%",
854
+ "第一四分位数: " + param.data[3].toFixed(2) + "%",
855
+ "最小值: " + param.data[1].toFixed(2) + "%",
856
+ ].join("<br/>"),
857
+ },
858
+ },
859
+ ],
860
+ };
861
+ const onEvents = () => { };
862
+ return (_jsx(ReactECharts, { ref: echartRef, option: option, style: { height: h, width: "100%" }, onEvents: onEvents }));
863
+ }
864
+ function EchartJustOneLine(props) {
865
+ const { x = [], y = [], h = "350px", styleObj = {}, bottom, left = "0%", isLine, w, top = "0%", } = props;
866
+ const option = {
867
+ grid: {
868
+ left: left,
869
+ right: "0",
870
+ top: top,
871
+ },
872
+ xAxis: {
873
+ type: "category",
874
+ data: x,
875
+ show: isLine,
876
+ axisLine: {
877
+ show: isLine,
878
+ },
879
+ },
880
+ yAxis: {
881
+ splitLine: {
882
+ show: false,
883
+ },
884
+ type: "value",
885
+ },
886
+ series: [
887
+ {
888
+ data: y,
889
+ type: "line",
890
+ smooth: true,
891
+ name: "电价",
892
+ symbol: "none",
893
+ lineStyle: {
894
+ color: styleObj.lineColor,
895
+ },
896
+ areaStyle: {
897
+ color: {
898
+ type: "linear",
899
+ x: 0,
900
+ y: 0,
901
+ x2: 0,
902
+ y2: 1,
903
+ colorStops: [
904
+ {
905
+ offset: 0,
906
+ color: styleObj.areaStyle ? styleObj.areaStyle[0] : "", // 0% 处的颜色
907
+ },
908
+ {
909
+ offset: 1,
910
+ color: styleObj.areaStyle ? styleObj.areaStyle[1] : "", // 100% 处的颜色
911
+ },
912
+ ],
913
+ global: false, // 缺省为 false
914
+ },
915
+ },
916
+ },
917
+ ],
918
+ };
919
+ if (bottom) {
920
+ option.grid.bottom = bottom;
921
+ }
922
+ const echartRef = useRef();
923
+ useEffect(() => {
924
+ if (echartRef.current) {
925
+ const ins = echartRef.current.getEchartsInstance();
926
+ ins.setOption(option);
927
+ }
928
+ }, [props]);
929
+ return (_jsx(ReactECharts, { ref: echartRef, option: option, style: { height: h, width: w } }));
930
+ }
931
+ function TsingrocMonthPick(props) {
932
+ const { value, onChange: propsOnChange, dataType = "month", className, popupClassName, } = props;
933
+ const [dateValue, setDateValue] = useState(value);
934
+ const quickGo = (type) => {
935
+ const temp = dateValue.add(type, dataType);
936
+ setDateValue(temp);
937
+ propsOnChange && propsOnChange(temp);
938
+ };
939
+ const onChange = (value) => {
940
+ setDateValue(value);
941
+ propsOnChange && propsOnChange(value);
942
+ };
943
+ return (_jsxs("div", { children: [_jsx("div", { onClick: () => {
944
+ quickGo(-1);
945
+ }, className: `quick-jump ${className}`, style: { borderRight: "none", borderRadius: "2px 0 0 2px" }, children: _jsx(LeftOutlined, { className: "quick-icon" }) }), dataType === "day" && (_jsx(DatePicker, { value: dateValue, onChange: onChange })), dataType === "week" && (_jsx(DatePicker, { value: dateValue, onChange: onChange, picker: "week" })), dataType === "month" && (_jsx(DatePicker, { popupClassName: popupClassName, className: className, value: dateValue, onChange: onChange, picker: "month" })), _jsx("div", { onClick: () => {
946
+ quickGo(1);
947
+ }, className: `quick-jump ${className}`, style: { borderLeft: "none", borderRadius: "0 2px 2px 0" }, children: _jsx(RightOutlined, { className: "quick-icon" }) })] }));
948
+ }
949
+ function ImageBac(props) {
950
+ const { children, width = "100%", height = "100%", url = "", style } = props;
951
+ let relativeUrl = "";
952
+ if (url.startsWith("@")) {
953
+ relativeUrl = url.replace("@", "../../../../..");
954
+ }
955
+ else {
956
+ relativeUrl = url;
957
+ }
958
+ return (_jsx("div", { style: {
959
+ ...style,
960
+ backgroundSize: "100% 100%",
961
+ width: width,
962
+ height: height,
963
+ backgroundImage: `url('${relativeUrl}')`,
964
+ }, children: children }));
965
+ }
966
+ export { ImageBac, EchartMult, RiskEchartMult, TsingrocDatePick, RadarEchart, TsingrocPie, CircularProgress, WindFlow, BoxplotEchart, EchartJustOneLine, TsingrocMonthPick, };
967
+ //# sourceMappingURL=tsingrocCom.js.map