twcpt 0.0.3 → 0.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.
Files changed (71) hide show
  1. package/dist/charts.cjs.js +1 -1
  2. package/dist/charts.d.ts +0 -7
  3. package/dist/charts.es.js +1 -9
  4. package/dist/components/j-tw-btn/index.d.ts +10 -10
  5. package/dist/components/j-tw-checkbox/index.d.ts +230 -0
  6. package/dist/components/j-tw-checkbox/types.d.ts +35 -0
  7. package/dist/components/j-tw-checkbox-group/index.d.ts +309 -0
  8. package/dist/components/j-tw-checkbox-group/types.d.ts +38 -0
  9. package/dist/components/j-tw-confirm-dialog/index.d.ts +704 -0
  10. package/dist/components/j-tw-confirm-dialog/jwConfirmDialog.d.ts +2 -0
  11. package/dist/components/j-tw-confirm-dialog/types.d.ts +79 -0
  12. package/dist/components/j-tw-date-picker/index.d.ts +64 -9
  13. package/dist/components/j-tw-date-picker/types.d.ts +15 -0
  14. package/dist/components/j-tw-dialog/index.d.ts +793 -0
  15. package/dist/components/j-tw-dialog/jwDialog.d.ts +38 -0
  16. package/dist/components/j-tw-dialog/types.d.ts +122 -0
  17. package/dist/components/j-tw-form/index.d.ts +368 -0
  18. package/dist/components/j-tw-form/types.d.ts +18 -0
  19. package/dist/components/j-tw-form-item/index.d.ts +248 -0
  20. package/dist/components/j-tw-form-item/types.d.ts +21 -0
  21. package/dist/components/j-tw-form-label/index.d.ts +66 -0
  22. package/dist/components/j-tw-input/index.d.ts +549 -0
  23. package/dist/components/j-tw-input/types.d.ts +77 -0
  24. package/dist/components/j-tw-messages/MessageItem.d.ts +84 -0
  25. package/dist/components/j-tw-messages/index.d.ts +110 -0
  26. package/dist/components/j-tw-messages/jwMessages.d.ts +2 -0
  27. package/dist/components/j-tw-messages/state.d.ts +23 -0
  28. package/dist/components/j-tw-messages/types.d.ts +31 -0
  29. package/dist/components/j-tw-radio/index.d.ts +168 -0
  30. package/dist/components/j-tw-radio/types.d.ts +29 -0
  31. package/dist/components/j-tw-radio-group/index.d.ts +244 -0
  32. package/dist/components/j-tw-radio-group/types.d.ts +37 -0
  33. package/dist/components/j-tw-select/index.d.ts +4451 -0
  34. package/dist/components/j-tw-select/types.d.ts +87 -0
  35. package/dist/components/j-tw-status-img/index.d.ts +36 -0
  36. package/dist/components/j-tw-status-img/types.d.ts +3 -0
  37. package/dist/components/j-tw-table/index.d.ts +480 -0
  38. package/dist/components/j-tw-table/types.d.ts +157 -0
  39. package/dist/components/j-tw-tree-select/TreeNode.d.ts +124 -0
  40. package/dist/components/j-tw-tree-select/index.d.ts +292 -0
  41. package/dist/components/j-tw-tree-select/types.d.ts +110 -0
  42. package/dist/components/j-tw-tree-select-btn/TreeNode.d.ts +107 -0
  43. package/dist/components/j-tw-tree-select-btn/index.d.ts +171 -22
  44. package/dist/components/j-tw-tree-select-btn/types.d.ts +5 -0
  45. package/dist/components/j-tw-tree-select-input/index.d.ts +5384 -0
  46. package/dist/components/j-tw-tree-select-input/types.d.ts +65 -0
  47. package/dist/global.d.ts +129 -49
  48. package/dist/index.css +1 -1
  49. package/dist/index.d.ts +41 -4
  50. package/dist/shims-svg.d.ts +4 -0
  51. package/dist/twcpt-styles.css +1 -1
  52. package/dist/twcpt.cjs.js +9 -5
  53. package/dist/twcpt.es.js +4057 -1653
  54. package/dist/types.d.ts +1 -1
  55. package/dist/utils/useBizRequest.d.ts +12 -0
  56. package/package.json +1 -3
  57. package/dist/charts-BRqaKjiE.js +0 -879
  58. package/dist/charts-lTMiYKQB.cjs +0 -1
  59. package/dist/components/j-ch-bar/index.d.ts +0 -50
  60. package/dist/components/j-ch-bar/types.d.ts +0 -42
  61. package/dist/components/j-ch-bar-line/index.d.ts +0 -49
  62. package/dist/components/j-ch-bar-line/types.d.ts +0 -42
  63. package/dist/components/j-ch-bubble/index.d.ts +0 -54
  64. package/dist/components/j-ch-bubble/types.d.ts +0 -51
  65. package/dist/components/j-ch-line/index.d.ts +0 -57
  66. package/dist/components/j-ch-line/types.d.ts +0 -42
  67. package/dist/components/j-ch-pie-doughnut/index.d.ts +0 -60
  68. package/dist/components/j-ch-pie-doughnut/types.d.ts +0 -55
  69. package/dist/components/j-ch-radar/index.d.ts +0 -49
  70. package/dist/components/j-ch-radar/types.d.ts +0 -42
  71. package/dist/utils/chart.d.ts +0 -28
@@ -1,879 +0,0 @@
1
- import { defineComponent as g, ref as f, onMounted as m, watch as C, openBlock as x, createElementBlock as v, createElementVNode as y, normalizeStyle as k } from "vue";
2
- import { Chart as $ } from "chart.js/auto";
3
- function T(e) {
4
- return Object.prototype.toString.call(e) === "[object Object]";
5
- }
6
- function h(e, i) {
7
- if (!i)
8
- return { ...e };
9
- const a = { ...e };
10
- for (const l of Object.keys(i)) {
11
- const o = i[l], c = e[l];
12
- if (o !== void 0) {
13
- if (o === null) {
14
- a[l] = null;
15
- continue;
16
- }
17
- T(c) && T(o) ? a[l] = h(c, o) : a[l] = o;
18
- }
19
- }
20
- return a;
21
- }
22
- const q = g({
23
- name: "JChBar",
24
- props: {
25
- labels: {
26
- type: Array,
27
- default: () => [],
28
- required: !0
29
- },
30
- datasets: {
31
- type: Array,
32
- required: !0
33
- },
34
- options: {
35
- type: Object,
36
- default: () => ({}),
37
- required: !1
38
- },
39
- height: {
40
- type: Number,
41
- default: 300
42
- }
43
- },
44
- setup(e) {
45
- const i = f(null), a = f(null);
46
- let l = null;
47
- const o = (s) => {
48
- let t = s.querySelector("div.chartjs-tooltip");
49
- return t || (t = document.createElement("div"), t.className = "chartjs-tooltip", t.style.background = "#ffffff", t.style.borderRadius = "8px", t.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)", t.style.color = "#323232", t.style.opacity = "0", t.style.pointerEvents = "none", t.style.position = "absolute", t.style.transform = "translate(-50%, 0)", t.style.transition = "all .1s ease", t.style.padding = "8px 10px", t.style.font = "12px Open Sans, sans-serif", s.appendChild(t)), t;
50
- }, c = (s) => {
51
- const { chart: t, tooltip: r } = s, d = a.value;
52
- if (!d) return;
53
- const n = o(d);
54
- if (r.opacity === 0) {
55
- n.style.opacity = "0";
56
- return;
57
- }
58
- if (r.body) {
59
- const _ = r.title || [], A = r.body.map((u) => u.lines);
60
- if (n.innerHTML = "", _.length) {
61
- const u = document.createElement("div");
62
- u.style.fontWeight = "600", u.style.marginBottom = "4px", u.textContent = _.join(" "), n.appendChild(u);
63
- }
64
- A.forEach((u) => {
65
- const S = document.createElement("div");
66
- S.textContent = u.join(" "), n.appendChild(S);
67
- });
68
- }
69
- const { offsetLeft: b, offsetTop: w } = t.canvas;
70
- n.style.opacity = "1", n.style.left = `${b + r.caretX}px`, n.style.top = `${w + r.caretY}px`;
71
- }, p = () => {
72
- var d;
73
- l && l.destroy();
74
- const s = (d = i.value) == null ? void 0 : d.getContext("2d");
75
- if (!s) return;
76
- const t = {
77
- labels: e.labels,
78
- datasets: e.datasets.map((n) => ({
79
- ...n,
80
- type: "bar",
81
- borderWidth: n.borderWidth ?? 0,
82
- borderRadius: n.borderRadius ?? 4,
83
- maxBarThickness: n.maxBarThickness ?? 34,
84
- // 确保填充色使用传入的颜色,而不是渐变色
85
- backgroundColor: n.backgroundColor || "#3A416F"
86
- }))
87
- }, r = {
88
- responsive: !0,
89
- maintainAspectRatio: !1,
90
- plugins: {
91
- legend: {
92
- display: !0,
93
- // 关键修改:显示 Legend
94
- position: "bottom",
95
- labels: {
96
- color: "#969799",
97
- pointStyle: "rect",
98
- padding: 20,
99
- usePointStyle: !0,
100
- font: {
101
- size: 11,
102
- family: "Open Sans",
103
- style: "normal",
104
- lineHeight: 1
105
- }
106
- }
107
- },
108
- tooltip: {
109
- enabled: !1,
110
- external: c
111
- }
112
- },
113
- scales: {
114
- y: {
115
- border: { display: !1 },
116
- grid: {
117
- display: !0,
118
- drawOnChartArea: !0,
119
- drawTicks: !1,
120
- color: "#f5f6fa"
121
- // 使用实色细线
122
- },
123
- ticks: {
124
- display: !0,
125
- padding: 10,
126
- color: "#969799"
127
- }
128
- },
129
- x: {
130
- // 关键修改:移除 dash: [5, 5],实现实线分割线
131
- border: { display: !1 },
132
- grid: {
133
- display: !1,
134
- drawOnChartArea: !0,
135
- drawTicks: !0
136
- },
137
- ticks: {
138
- display: !0,
139
- color: "#969799",
140
- padding: 10
141
- }
142
- }
143
- }
144
- };
145
- l = new $(s, {
146
- type: "bar",
147
- data: t,
148
- options: h(r, e.options)
149
- });
150
- };
151
- return m(() => {
152
- p();
153
- }), C(
154
- [() => e.labels, () => e.datasets, () => e.height],
155
- () => {
156
- p();
157
- },
158
- { deep: !0 }
159
- ), {
160
- barChartCanvas: i,
161
- chartContainer: a
162
- };
163
- }
164
- }), O = (e, i) => {
165
- const a = e.__vccOpts || e;
166
- for (const [l, o] of i)
167
- a[l] = o;
168
- return a;
169
- }, H = {
170
- ref: "chartContainer",
171
- style: { position: "relative" }
172
- };
173
- function j(e, i, a, l, o, c) {
174
- return x(), v("div", H, [
175
- y("div", null, [
176
- y("canvas", {
177
- ref: "barChartCanvas",
178
- style: k([{ width: "100%" }, { height: e.height + "px", maxHeight: e.height + "px" }])
179
- }, null, 4)
180
- ])
181
- ], 512);
182
- }
183
- const Z = /* @__PURE__ */ O(q, [["render", j], ["__scopeId", "data-v-e2691574"]]), E = g({
184
- name: "JChBarLine",
185
- props: {
186
- labels: {
187
- type: Array,
188
- default: () => [],
189
- required: !0
190
- },
191
- datasets: {
192
- type: Array,
193
- required: !0
194
- },
195
- options: {
196
- type: Object,
197
- default: () => ({}),
198
- required: !1
199
- },
200
- height: {
201
- type: Number,
202
- default: 300
203
- // 默认高度 300px
204
- }
205
- },
206
- setup(e) {
207
- const i = f(null);
208
- let a = null;
209
- const l = () => {
210
- var t;
211
- a && a.destroy();
212
- const o = (t = i.value) == null ? void 0 : t.getContext("2d");
213
- if (!o) return;
214
- const c = e.datasets.map((r) => {
215
- let d = {};
216
- const n = r.type === "line" ? "line" : "bar";
217
- return r.type === "line" ? d = {
218
- type: "line",
219
- tension: 0.4,
220
- pointRadius: 0,
221
- borderWidth: 3,
222
- fill: !1,
223
- // 关键:取消填充
224
- backgroundColor: "transparent",
225
- maxBarThickness: void 0
226
- } : r.type === "bar" && (d = {
227
- type: "bar",
228
- borderWidth: 0,
229
- borderRadius: 4,
230
- borderSkipped: !1,
231
- fill: void 0,
232
- maxBarThickness: 34,
233
- backgroundColor: r.backgroundColor
234
- }), {
235
- type: n,
236
- ...r,
237
- ...d
238
- };
239
- }), p = {
240
- labels: e.labels,
241
- datasets: c
242
- }, s = {
243
- responsive: !0,
244
- maintainAspectRatio: !1,
245
- plugins: {
246
- legend: {
247
- display: !0,
248
- // 关键:显示 Legend
249
- position: "bottom",
250
- labels: {
251
- color: "#969799",
252
- pointStyle: "rect",
253
- padding: 20,
254
- usePointStyle: !0,
255
- font: {
256
- size: 11,
257
- family: "Open Sans",
258
- style: "normal",
259
- lineHeight: 1
260
- }
261
- }
262
- },
263
- tooltip: {
264
- borderWidth: 1,
265
- backgroundColor: "white",
266
- titleColor: "black",
267
- bodyColor: "black",
268
- borderColor: "#eeeeee",
269
- padding: 12,
270
- callbacks: {
271
- label: (r) => `${r.dataset.label || ""}: ${r.formattedValue}`
272
- }
273
- }
274
- },
275
- interaction: {
276
- intersect: !1,
277
- mode: "index"
278
- },
279
- scales: {
280
- y: {
281
- beginAtZero: !0,
282
- border: { display: !1 },
283
- grid: {
284
- display: !0,
285
- drawOnChartArea: !0,
286
- drawTicks: !1,
287
- color: "#f5f6fa"
288
- },
289
- ticks: {
290
- display: !0,
291
- padding: 10,
292
- color: "#969799",
293
- font: { size: 11, family: "Open Sans", style: "normal", lineHeight: 2 }
294
- }
295
- },
296
- x: {
297
- border: { display: !1 },
298
- grid: { display: !1, drawOnChartArea: !0, drawTicks: !0 },
299
- ticks: {
300
- display: !0,
301
- color: "#969799",
302
- padding: 10,
303
- font: { size: 11, family: "Open Sans", style: "normal", lineHeight: 2 },
304
- callback: (r, d) => {
305
- const n = e.labels[d];
306
- return n && n.length > 13 ? `${n.slice(0, 13)}...` : n;
307
- }
308
- }
309
- }
310
- }
311
- };
312
- a = new $(o, {
313
- data: p,
314
- options: h(s, e.options)
315
- });
316
- };
317
- return m(() => {
318
- l();
319
- }), C(
320
- [() => e.labels, () => e.datasets, () => e.height],
321
- () => {
322
- l();
323
- },
324
- { deep: !0 }
325
- ), {
326
- mixedChartCanvas: i
327
- };
328
- }
329
- });
330
- function W(e, i, a, l, o, c) {
331
- return x(), v("div", null, [
332
- y("canvas", {
333
- ref: "mixedChartCanvas",
334
- style: k([{ width: "100%" }, { height: e.height + "px", maxHeight: e.height + "px" }])
335
- }, null, 4)
336
- ]);
337
- }
338
- const M = /* @__PURE__ */ O(E, [["render", W]]), z = g({
339
- name: "JChBubble",
340
- props: {
341
- labels: {
342
- type: Array,
343
- default: () => [],
344
- required: !1
345
- },
346
- datasets: {
347
- type: Array,
348
- required: !0
349
- },
350
- options: {
351
- type: Object,
352
- default: () => ({}),
353
- required: !1
354
- },
355
- height: {
356
- type: Number,
357
- default: 300
358
- }
359
- },
360
- setup(e) {
361
- const i = f(null);
362
- let a = null;
363
- const l = () => {
364
- var s;
365
- a && a.destroy();
366
- const o = (s = i.value) == null ? void 0 : s.getContext("2d");
367
- if (!o) return;
368
- const c = {
369
- labels: e.labels,
370
- datasets: e.datasets.map((t) => ({
371
- ...t,
372
- // 确保类型正确,并设置透明度
373
- backgroundColor: t.backgroundColor || "rgba(54, 162, 235, 0.6)"
374
- }))
375
- }, p = {
376
- responsive: !0,
377
- maintainAspectRatio: !1,
378
- plugins: {
379
- legend: {
380
- display: !0,
381
- position: "bottom",
382
- labels: {
383
- color: "#969799",
384
- pointStyle: "rect",
385
- padding: 20,
386
- usePointStyle: !0,
387
- font: { size: 11, family: "Open Sans", style: "normal", lineHeight: 1 }
388
- }
389
- },
390
- tooltip: {
391
- borderWidth: 1,
392
- backgroundColor: "white",
393
- titleColor: "black",
394
- bodyColor: "black",
395
- borderColor: "#eeeeee",
396
- padding: 12,
397
- callbacks: {
398
- label: (t) => `${t.dataset.label || ""}: ${t.formattedValue}`
399
- }
400
- }
401
- },
402
- interaction: { intersect: !1, mode: "index" },
403
- scales: {
404
- y: {
405
- beginAtZero: !0,
406
- border: { display: !1 },
407
- grid: { display: !0, drawOnChartArea: !0, drawTicks: !1, color: "#f5f6fa" },
408
- ticks: {
409
- display: !0,
410
- padding: 10,
411
- color: "#969799",
412
- font: { size: 11, family: "Open Sans", style: "normal", lineHeight: 2 }
413
- }
414
- },
415
- x: {
416
- border: { display: !1 },
417
- grid: { display: !0, drawOnChartArea: !0, drawTicks: !0, color: "#f5f6fa" },
418
- ticks: {
419
- display: !0,
420
- color: "#969799",
421
- padding: 10,
422
- font: { size: 11, family: "Open Sans", style: "normal", lineHeight: 2 },
423
- callback: (t, r) => {
424
- const d = e.labels[r];
425
- return d ? typeof d == "string" && d.length > 13 ? `${d.slice(0, 13)}...` : d : t;
426
- }
427
- }
428
- }
429
- }
430
- };
431
- a = new $(o, {
432
- type: "bubble",
433
- data: c,
434
- options: h(p, e.options)
435
- });
436
- };
437
- return m(() => {
438
- l();
439
- }), C(
440
- [() => e.labels, () => e.datasets, () => e.height],
441
- () => {
442
- l();
443
- },
444
- { deep: !0 }
445
- ), {
446
- bubbleChartCanvas: i
447
- };
448
- }
449
- });
450
- function R(e, i, a, l, o, c) {
451
- return x(), v("div", null, [
452
- y("canvas", {
453
- ref: "bubbleChartCanvas",
454
- style: k([{ width: "100%" }, { height: e.height + "px", maxHeight: e.height + "px" }])
455
- }, null, 4)
456
- ]);
457
- }
458
- const F = /* @__PURE__ */ O(z, [["render", R]]), L = g({
459
- name: "JChLine",
460
- props: {
461
- labels: {
462
- type: Array,
463
- default: () => [],
464
- required: !0
465
- },
466
- datasets: {
467
- type: Array,
468
- required: !0
469
- },
470
- options: {
471
- type: Object,
472
- default: () => ({}),
473
- required: !1
474
- },
475
- height: {
476
- type: Number,
477
- default: 300
478
- },
479
- unitName: {
480
- type: String,
481
- default: ""
482
- }
483
- },
484
- setup(e) {
485
- const i = f(null);
486
- let a = null;
487
- const l = () => {
488
- var s;
489
- a && a.destroy();
490
- const o = (s = i.value) == null ? void 0 : s.getContext("2d");
491
- if (!o) return;
492
- const c = {
493
- labels: e.labels,
494
- // 使用 props.labels
495
- datasets: e.datasets.map((t) => ({
496
- ...t,
497
- tension: 0.4,
498
- pointRadius: 2,
499
- borderWidth: 3,
500
- fill: !1,
501
- backgroundColor: "transparent",
502
- type: "line"
503
- }))
504
- }, p = {
505
- responsive: !0,
506
- maintainAspectRatio: !1,
507
- plugins: {
508
- legend: {
509
- display: !0,
510
- position: "bottom",
511
- labels: {
512
- color: "#969799",
513
- pointStyle: "line",
514
- padding: 20,
515
- usePointStyle: !0,
516
- font: {
517
- size: 11,
518
- family: "Open Sans",
519
- style: "normal",
520
- lineHeight: 1
521
- }
522
- }
523
- },
524
- tooltip: {
525
- borderWidth: 1,
526
- backgroundColor: "white",
527
- // Set the background color to white
528
- titleColor: "black",
529
- // Set the title color to black
530
- bodyColor: "black",
531
- // Set the body color to black
532
- borderColor: "#eeeeee",
533
- // Optional: Add a border color
534
- padding: 12,
535
- callbacks: {
536
- label: (t) => `${t.dataset.label || ""}: ${t.formattedValue} ${e.unitName}`
537
- }
538
- }
539
- },
540
- interaction: { intersect: !1, mode: "index" },
541
- scales: {
542
- y: {
543
- beginAtZero: !0,
544
- border: {
545
- display: !1
546
- },
547
- grid: {
548
- display: !0,
549
- drawOnChartArea: !0,
550
- drawTicks: !1,
551
- color: "#f5f6fa"
552
- },
553
- ticks: {
554
- display: !0,
555
- padding: 10,
556
- color: "#969799",
557
- font: {
558
- size: 11,
559
- family: "Open Sans",
560
- style: "normal",
561
- lineHeight: 2
562
- }
563
- }
564
- },
565
- x: {
566
- border: {
567
- display: !1,
568
- dash: [5, 5]
569
- },
570
- grid: {
571
- display: !1,
572
- drawOnChartArea: !1,
573
- drawTicks: !1
574
- },
575
- ticks: {
576
- display: !0,
577
- color: "#969799",
578
- padding: 20,
579
- font: {
580
- size: 10,
581
- family: "Open Sans",
582
- style: "normal"
583
- },
584
- callback: (t, r, d) => {
585
- const n = e.labels[r];
586
- return n.length > 13 ? `${n.slice(0, 13)}...` : n;
587
- }
588
- }
589
- }
590
- }
591
- };
592
- a = new $(o, {
593
- type: "line",
594
- data: c,
595
- options: h(p, e.options)
596
- });
597
- };
598
- return m(() => {
599
- l();
600
- }), C(
601
- [() => e.labels, () => e.datasets],
602
- () => {
603
- l();
604
- },
605
- { deep: !0 }
606
- ), {
607
- lineChartCanvas: i
608
- };
609
- }
610
- }), B = { ref: "chartContainer" };
611
- function N(e, i, a, l, o, c) {
612
- return x(), v("div", B, [
613
- y("canvas", {
614
- ref: "lineChartCanvas",
615
- style: k([{ width: "100%" }, { height: e.height + "px", maxHeight: e.height + "px" }])
616
- }, null, 4)
617
- ], 512);
618
- }
619
- const G = /* @__PURE__ */ O(L, [["render", N], ["__scopeId", "data-v-1a079ae0"]]), P = g({
620
- name: "JChPieDoughnut",
621
- props: {
622
- type: {
623
- type: String,
624
- required: !0,
625
- validator: (e) => ["pie", "doughnut"].includes(e)
626
- },
627
- labels: {
628
- type: Array,
629
- default: () => [],
630
- required: !0
631
- },
632
- // 数据集类型统一为 ChartType
633
- datasets: {
634
- type: Array,
635
- required: !0
636
- },
637
- options: {
638
- type: Object,
639
- default: () => ({}),
640
- required: !1
641
- },
642
- height: {
643
- type: Number,
644
- default: 300
645
- }
646
- },
647
- setup(e) {
648
- const i = f(null), a = f(null);
649
- let l = null;
650
- const o = (s) => {
651
- let t = s.querySelector("div.chartjs-tooltip");
652
- return t || (t = document.createElement("div"), t.className = "chartjs-tooltip", t.style.background = "#ffffff", t.style.borderRadius = "8px", t.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)", t.style.color = "#323232", t.style.opacity = "0", t.style.pointerEvents = "none", t.style.position = "absolute", t.style.transform = "translate(-50%, 0)", t.style.transition = "all .1s ease", t.style.padding = "8px 10px", t.style.font = "12px Open Sans, sans-serif", s.appendChild(t)), t;
653
- }, c = (s) => {
654
- const { chart: t, tooltip: r } = s, d = a.value;
655
- if (!d) return;
656
- const n = o(d);
657
- if (r.opacity === 0) {
658
- n.style.opacity = "0";
659
- return;
660
- }
661
- if (r.body) {
662
- const _ = r.title || [], A = r.body.map((u) => u.lines);
663
- if (n.innerHTML = "", _.length) {
664
- const u = document.createElement("div");
665
- u.style.fontWeight = "600", u.style.marginBottom = "4px", u.textContent = _.join(" "), n.appendChild(u);
666
- }
667
- A.forEach((u) => {
668
- const S = document.createElement("div");
669
- S.textContent = u.join(" "), n.appendChild(S);
670
- });
671
- }
672
- const { offsetLeft: b, offsetTop: w } = t.canvas;
673
- n.style.opacity = "1", n.style.left = `${b + r.caretX}px`, n.style.top = `${w + r.caretY}px`;
674
- }, p = () => {
675
- var n;
676
- l && l.destroy();
677
- const s = (n = i.value) == null ? void 0 : n.getContext("2d");
678
- if (!s) return;
679
- const t = e.type, r = {
680
- labels: e.labels,
681
- datasets: e.datasets.map((b) => ({
682
- ...b,
683
- type: t,
684
- // 关键:动态设置 ChartDataSet 的类型
685
- borderWidth: b.borderWidth ?? 2
686
- }))
687
- }, d = {
688
- responsive: !0,
689
- maintainAspectRatio: !1,
690
- plugins: {
691
- legend: {
692
- display: !0,
693
- position: "bottom",
694
- labels: {
695
- color: "#969799",
696
- pointStyle: "rect",
697
- padding: 20,
698
- usePointStyle: !0,
699
- font: {
700
- size: 11,
701
- family: "Open Sans",
702
- style: "normal",
703
- lineHeight: 1
704
- }
705
- }
706
- },
707
- tooltip: {
708
- enabled: !1,
709
- external: c
710
- }
711
- },
712
- interaction: { intersect: !0, mode: "index" }
713
- };
714
- l = new $(s, {
715
- type: t,
716
- data: r,
717
- // 需要使用 'as any' 来避免 TypeScript 对不同 ChartOptions 类型的严格检查
718
- options: h(d, e.options)
719
- });
720
- };
721
- return m(() => {
722
- p();
723
- }), C(
724
- [() => e.labels, () => e.datasets, () => e.type],
725
- () => {
726
- p();
727
- },
728
- { deep: !0 }
729
- ), {
730
- chartCanvas: i,
731
- chartContainer: a
732
- };
733
- }
734
- }), D = {
735
- ref: "chartContainer",
736
- style: { position: "relative" }
737
- };
738
- function I(e, i, a, l, o, c) {
739
- return x(), v("div", D, [
740
- y("canvas", {
741
- ref: "chartCanvas",
742
- style: k([{ width: "100%" }, { height: e.height + "px", maxHeight: e.height + "px" }])
743
- }, null, 4)
744
- ], 512);
745
- }
746
- const K = /* @__PURE__ */ O(P, [["render", I]]), V = g({
747
- name: "JChRadar",
748
- props: {
749
- labels: {
750
- type: Array,
751
- default: () => [],
752
- required: !0
753
- },
754
- datasets: {
755
- type: Array,
756
- required: !0
757
- },
758
- options: {
759
- type: Object,
760
- default: () => ({}),
761
- required: !1
762
- },
763
- height: {
764
- type: Number,
765
- default: 300
766
- }
767
- },
768
- setup(e) {
769
- const i = f(null);
770
- let a = null;
771
- const l = () => {
772
- var s;
773
- a && a.destroy();
774
- const o = (s = i.value) == null ? void 0 : s.getContext("2d");
775
- if (!o) return;
776
- const c = {
777
- labels: e.labels,
778
- datasets: e.datasets.map((t) => ({
779
- ...t,
780
- type: "radar",
781
- fill: t.fill ?? !0,
782
- backgroundColor: t.backgroundColor || "rgba(58,65,111,0.2)",
783
- borderColor: t.borderColor || "rgba(58,65,111,1)",
784
- borderWidth: t.borderWidth ?? 2
785
- }))
786
- }, p = {
787
- responsive: !0,
788
- maintainAspectRatio: !1,
789
- plugins: {
790
- legend: {
791
- display: !0,
792
- // 关键修改:显示 Legend,这对于雷达图非常重要
793
- position: "bottom",
794
- labels: {
795
- color: "#969799",
796
- pointStyle: "rect",
797
- padding: 20,
798
- usePointStyle: !0,
799
- font: {
800
- size: 11,
801
- family: "Open Sans",
802
- style: "normal",
803
- lineHeight: 1
804
- }
805
- }
806
- },
807
- tooltip: {
808
- borderWidth: 1,
809
- backgroundColor: "white",
810
- titleColor: "black",
811
- bodyColor: "black",
812
- borderColor: "#eeeeee",
813
- padding: 12,
814
- callbacks: {
815
- label: (t) => `${t.dataset.label || ""}: ${t.formattedValue}`
816
- }
817
- }
818
- },
819
- interaction: { intersect: !1, mode: "index" },
820
- scales: {
821
- r: {
822
- beginAtZero: !0,
823
- angleLines: {
824
- color: "#f5f6fa"
825
- // 蜘蛛网线的颜色
826
- },
827
- grid: {
828
- color: "#f5f6fa"
829
- // 圆圈线的颜色
830
- },
831
- pointLabels: {
832
- color: "#969799",
833
- // 轴标签的颜色
834
- font: { size: 11, family: "Open Sans" }
835
- },
836
- ticks: {
837
- display: !1
838
- // 隐藏刻度值
839
- }
840
- }
841
- }
842
- };
843
- a = new $(o, {
844
- type: "radar",
845
- data: c,
846
- options: h(p, e.options)
847
- });
848
- };
849
- return m(() => {
850
- l();
851
- }), C(
852
- [() => e.labels, () => e.datasets, () => e.height],
853
- () => {
854
- l();
855
- },
856
- { deep: !0 }
857
- ), {
858
- radarChartCanvas: i
859
- };
860
- }
861
- });
862
- function J(e, i, a, l, o, c) {
863
- return x(), v("div", null, [
864
- y("canvas", {
865
- ref: "radarChartCanvas",
866
- style: k([{ width: "100%" }, { height: e.height + "px", maxHeight: e.height + "px" }])
867
- }, null, 4)
868
- ]);
869
- }
870
- const Q = /* @__PURE__ */ O(V, [["render", J]]);
871
- export {
872
- O as _,
873
- M as a,
874
- F as b,
875
- G as c,
876
- K as d,
877
- Q as e,
878
- Z as i
879
- };