jvs-ppt-ui 0.0.30 → 0.0.32
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/dist/lib/jvs-ppt-ui.es.js +36629 -34003
- package/dist/lib/jvs-ppt-ui.umd.js +105 -114
- package/dist/lib/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CanvasArea.vue +9 -1
- package/src/components/ChartTypeSelector.vue +69 -29
- package/src/components/Header.vue +44 -3
- package/src/components/PitchImportDialog.vue +459 -0
- package/src/components/SidebarRight.vue +75 -35
- package/src/components/StyleBuilderDialog.vue +276 -105
- package/src/components/SvgChart.vue +1242 -833
- package/src/components/canvas/elements/CanvasGroupElement.vue +16 -2
- package/src/components/canvas/elements/CanvasMediaElement.vue +2 -1
- package/src/components/sidebar/dialogs/ChartDataEditorDialog.vue +1040 -0
- package/src/components/sidebar/panels/SidebarChartFormatPanel.vue +1479 -641
- package/src/components/sidebar/panels/SidebarDesignPanel.vue +32 -0
- package/src/composables/presetThemes.ts +49 -1
- package/src/composables/sidebar/useSidebarChart.ts +357 -194
- package/src/composables/useSlides.ts +25 -2
- package/src/style.css +2 -2
- package/src/utils/pitchConverter.ts +1226 -0
|
@@ -1,833 +1,1242 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed } from 'vue'
|
|
3
|
-
import type { SlideElement } from '../composables/useSlides'
|
|
4
|
-
|
|
5
|
-
const props = defineProps<{
|
|
6
|
-
element: SlideElement
|
|
7
|
-
}>()
|
|
8
|
-
|
|
9
|
-
const chartType = computed(() => {
|
|
10
|
-
let t = (props.element.chartType as string) || 'bar'
|
|
11
|
-
if (t === 'doughnutChart' || t === 'ring') t = 'donut'
|
|
12
|
-
if (t === 'pieChart' || t === 'pie3DChart') t = 'pie'
|
|
13
|
-
if (t === 'barChart' || t === 'bar3DChart') t = 'bar'
|
|
14
|
-
if (t === 'lineChart' || t === 'line3DChart') t = 'line'
|
|
15
|
-
if (t === 'areaChart' || t === 'area3DChart') t = 'area'
|
|
16
|
-
return t
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
if (props.element.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
return
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
label: string
|
|
294
|
-
|
|
295
|
-
percent
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
} else {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
font-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import type { SlideElement } from '../composables/useSlides'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
element: SlideElement
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const chartType = computed(() => {
|
|
10
|
+
let t = (props.element.chartType as string) || 'bar'
|
|
11
|
+
if (t === 'doughnutChart' || t === 'ring') t = 'donut'
|
|
12
|
+
if (t === 'pieChart' || t === 'pie3DChart') t = 'pie'
|
|
13
|
+
if (t === 'barChart' || t === 'bar3DChart') t = 'bar'
|
|
14
|
+
if (t === 'lineChart' || t === 'line3DChart') t = 'line'
|
|
15
|
+
if (t === 'areaChart' || t === 'area3DChart') t = 'area'
|
|
16
|
+
return t
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const isPieFamily = computed(() =>
|
|
20
|
+
['pie', 'donut', 'rose-pie', 'rose-donut'].includes(chartType.value)
|
|
21
|
+
)
|
|
22
|
+
const isBarFamily = computed(() =>
|
|
23
|
+
['bar', 'stacked-bar', 'percent-bar'].includes(chartType.value)
|
|
24
|
+
)
|
|
25
|
+
const isHBarFamily = computed(() =>
|
|
26
|
+
['horizontal-bar', 'stacked-horizontal-bar'].includes(chartType.value)
|
|
27
|
+
)
|
|
28
|
+
const isLineFamily = computed(() =>
|
|
29
|
+
['line', 'compare-line', 'step-line'].includes(chartType.value)
|
|
30
|
+
)
|
|
31
|
+
const isAreaFamily = computed(() =>
|
|
32
|
+
['area', 'stacked-area'].includes(chartType.value)
|
|
33
|
+
)
|
|
34
|
+
const isVerticalCartesian = computed(() =>
|
|
35
|
+
isBarFamily.value || isLineFamily.value || isAreaFamily.value || chartType.value === 'scatter'
|
|
36
|
+
)
|
|
37
|
+
const isCartesian = computed(() =>
|
|
38
|
+
isVerticalCartesian.value || isHBarFamily.value
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const chartColors = computed(() => {
|
|
42
|
+
if (props.element.style?.chartColors && Array.isArray(props.element.style.chartColors) && props.element.style.chartColors.length > 0) {
|
|
43
|
+
const valid = props.element.style.chartColors.filter((c: any) => c && typeof c === 'string')
|
|
44
|
+
if (valid.length > 0) return valid
|
|
45
|
+
}
|
|
46
|
+
if (props.element.themeColors && Array.isArray(props.element.themeColors) && props.element.themeColors.length > 0) {
|
|
47
|
+
const valid = props.element.themeColors.filter((c: any) => c && typeof c === 'string')
|
|
48
|
+
if (valid.length > 0) return valid
|
|
49
|
+
}
|
|
50
|
+
if ((props.element as any).colors && Array.isArray((props.element as any).colors)) {
|
|
51
|
+
const valid = (props.element as any).colors.filter((c: any) => c && typeof c === 'string')
|
|
52
|
+
if (valid.length > 0) return valid
|
|
53
|
+
}
|
|
54
|
+
return ['#4f46e5', '#06b6d4', '#f59e0b', '#10b981', '#ec4899', '#8b5cf6', '#ef4444', '#14b8a6']
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const textColor = computed(() => props.element.style?.color || props.element.style?.textColor || props.element.textColor || props.element.labelColor || '#64748b')
|
|
58
|
+
const fontFamily = computed(() => props.element.style?.fontFamily || props.element.fontFamily || 'system-ui, sans-serif')
|
|
59
|
+
const gridColor = computed(() => props.element.style?.gridColor || props.element.gridColor || '#e2e8f0')
|
|
60
|
+
|
|
61
|
+
const showAxes = computed(() => props.element.showAxes !== false)
|
|
62
|
+
const showGridlines = computed(() => props.element.showGridlines !== false)
|
|
63
|
+
const showLegend = computed(() => {
|
|
64
|
+
if (props.element.showLegend !== undefined) return Boolean(props.element.showLegend)
|
|
65
|
+
if ((props.element as any).options?.showLegend !== undefined) return Boolean((props.element as any).options.showLegend)
|
|
66
|
+
return true
|
|
67
|
+
})
|
|
68
|
+
const showTitle = computed(() => Boolean((props.element as any).showTitle))
|
|
69
|
+
const chartTitleText = computed(() => (props.element as any).chartTitle || (props.element as any).title || '图表标题')
|
|
70
|
+
|
|
71
|
+
const showAxisTitles = computed(() => isCartesian.value && Boolean((props.element as any).showAxisTitles))
|
|
72
|
+
const xAxisTitleText = computed(() => (props.element as any).xAxisTitle || (isHBarFamily.value ? '数值' : '分类'))
|
|
73
|
+
const yAxisTitleText = computed(() => (props.element as any).yAxisTitle || (isHBarFamily.value ? '分类' : '数值'))
|
|
74
|
+
|
|
75
|
+
const showDataLabels = computed(() => {
|
|
76
|
+
if ((props.element as any).showDataLabels !== undefined) {
|
|
77
|
+
return Boolean((props.element as any).showDataLabels)
|
|
78
|
+
}
|
|
79
|
+
if (isPieFamily.value) {
|
|
80
|
+
if ((props.element as any).showPercent !== undefined) return Boolean((props.element as any).showPercent)
|
|
81
|
+
if ((props.element as any).options?.showPercent !== undefined) return Boolean((props.element as any).options.showPercent)
|
|
82
|
+
return true
|
|
83
|
+
}
|
|
84
|
+
return false
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
const showDataTable = computed(() => Boolean((props.element as any).showDataTable))
|
|
88
|
+
const showErrorBars = computed(() => isCartesian.value && Boolean((props.element as any).showErrorBars))
|
|
89
|
+
|
|
90
|
+
const legendPosition = computed(() => props.element.legendPosition || 'bottom')
|
|
91
|
+
|
|
92
|
+
const isLegendTop = computed(() => legendPosition.value.startsWith('top'))
|
|
93
|
+
const isLegendBottom = computed(() => legendPosition.value.startsWith('bottom'))
|
|
94
|
+
const isLegendLeft = computed(() => legendPosition.value.startsWith('left'))
|
|
95
|
+
const isLegendRight = computed(() => legendPosition.value.startsWith('right'))
|
|
96
|
+
|
|
97
|
+
const defaultData = {
|
|
98
|
+
labels: ['一月', '二月', '三月', '四月', '五月'],
|
|
99
|
+
datasets: [
|
|
100
|
+
{ label: '系列1', data: [30, 45, 55, 60, 80] },
|
|
101
|
+
{ label: '系列2', data: [20, 30, 40, 45, 65] }
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const defaultPieData = {
|
|
106
|
+
labels: ['分类A', '分类B', '分类C', '分类D'],
|
|
107
|
+
datasets: [
|
|
108
|
+
{ label: '占比', data: [35, 25, 20, 20] }
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const defaultRadarData = {
|
|
113
|
+
labels: ['指标A', '指标B', '指标C', '指标D', '指标E'],
|
|
114
|
+
datasets: [
|
|
115
|
+
{ label: '系列1', data: [80, 70, 90, 60, 85] },
|
|
116
|
+
{ label: '系列2', data: [60, 80, 75, 80, 70] }
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const data = computed(() => {
|
|
121
|
+
const d = props.element.data
|
|
122
|
+
if (!d) {
|
|
123
|
+
if (isPieFamily.value) return defaultPieData
|
|
124
|
+
if (chartType.value === 'radar') return defaultRadarData
|
|
125
|
+
return defaultData
|
|
126
|
+
}
|
|
127
|
+
if (!d.datasets || d.datasets.length === 0) {
|
|
128
|
+
if ((d as any).series && Array.isArray((d as any).series)) {
|
|
129
|
+
const legends = (d as any).legends || []
|
|
130
|
+
const datasets = ((d as any).series as any[]).map((s: any, idx: number) => ({
|
|
131
|
+
label: legends[idx] || `系列${idx + 1}`,
|
|
132
|
+
data: Array.isArray(s) ? s : [s]
|
|
133
|
+
}))
|
|
134
|
+
return {
|
|
135
|
+
...d,
|
|
136
|
+
datasets
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return d
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const labels = computed(() => data.value.labels || [])
|
|
144
|
+
const datasets = computed(() => data.value.datasets || [])
|
|
145
|
+
|
|
146
|
+
// Find max value in all datasets for scaling (supports stacked charts)
|
|
147
|
+
const maxVal = computed(() => {
|
|
148
|
+
if (chartType.value === 'percent-bar') return 100
|
|
149
|
+
if (['stacked-bar', 'stacked-horizontal-bar', 'stacked-area'].includes(chartType.value)) {
|
|
150
|
+
const colSums = labels.value.map((_, i) =>
|
|
151
|
+
datasets.value.reduce((acc, ds) => acc + Math.max(0, Number(ds.data?.[i]) || 0), 0)
|
|
152
|
+
)
|
|
153
|
+
const maxSum = Math.max(...colSums, 10)
|
|
154
|
+
return Math.ceil(maxSum * 1.15)
|
|
155
|
+
}
|
|
156
|
+
const allNums = datasets.value.flatMap(d => d.data)
|
|
157
|
+
const max = Math.max(...allNums, 10)
|
|
158
|
+
return Math.ceil(max * 1.15)
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
// Ticks and Grid lines for Cartesian charts
|
|
162
|
+
const gridTicks = computed(() => {
|
|
163
|
+
const isPct = chartType.value === 'percent-bar'
|
|
164
|
+
const max = maxVal.value
|
|
165
|
+
return [0, 0.25, 0.5, 0.75, 1.0].map(p => ({
|
|
166
|
+
val: isPct ? `${Math.round(p * 100)}%` : Math.round(p * max),
|
|
167
|
+
rawVal: Math.round(p * max),
|
|
168
|
+
pct: p
|
|
169
|
+
}))
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
// Dimensions
|
|
173
|
+
const width = computed(() => {
|
|
174
|
+
if (typeof props.element.width === 'number' && props.element.width > 0) return props.element.width
|
|
175
|
+
const wStr = props.element.style?.width
|
|
176
|
+
if (wStr && typeof wStr === 'string' && !wStr.endsWith('%')) {
|
|
177
|
+
const val = parseFloat(wStr)
|
|
178
|
+
if (!isNaN(val) && val > 0) return val
|
|
179
|
+
}
|
|
180
|
+
return 400
|
|
181
|
+
})
|
|
182
|
+
const height = computed(() => {
|
|
183
|
+
if (typeof props.element.height === 'number' && props.element.height > 0) return props.element.height
|
|
184
|
+
const hStr = props.element.style?.height
|
|
185
|
+
if (hStr && typeof hStr === 'string' && !hStr.endsWith('%')) {
|
|
186
|
+
const val = parseFloat(hStr)
|
|
187
|
+
if (!isNaN(val) && val > 0) return val
|
|
188
|
+
}
|
|
189
|
+
return 300
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
// Data table dimensions
|
|
193
|
+
const dataTableRowH = 16
|
|
194
|
+
const dataTableRowsCount = computed(() => {
|
|
195
|
+
if (!showDataTable.value) return 0
|
|
196
|
+
const seriesCount = isPieFamily.value ? 1 : Math.min(datasets.value.length, 3)
|
|
197
|
+
return seriesCount + 1
|
|
198
|
+
})
|
|
199
|
+
const dataTableHeight = computed(() => dataTableRowsCount.value * dataTableRowH)
|
|
200
|
+
|
|
201
|
+
// Layout margins for Cartesian charts
|
|
202
|
+
const padding = computed(() => {
|
|
203
|
+
let top = showTitle.value ? 52 : 36
|
|
204
|
+
let bottom = 38
|
|
205
|
+
let left = 45
|
|
206
|
+
let right = 25
|
|
207
|
+
|
|
208
|
+
if (isHBarFamily.value) {
|
|
209
|
+
left = 65
|
|
210
|
+
right = 35
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (showAxisTitles.value) {
|
|
214
|
+
left += 18
|
|
215
|
+
bottom += 18
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (showLegend.value) {
|
|
219
|
+
if (isLegendTop.value) {
|
|
220
|
+
top += 24
|
|
221
|
+
} else if (isLegendBottom.value) {
|
|
222
|
+
bottom += 24
|
|
223
|
+
} else if (isLegendLeft.value) {
|
|
224
|
+
left += 95
|
|
225
|
+
} else if (isLegendRight.value) {
|
|
226
|
+
right += 95
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (showDataTable.value) {
|
|
231
|
+
bottom += dataTableHeight.value + 12
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return { top, right, bottom, left }
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
const chartWidth = computed(() => Math.max(60, width.value - padding.value.left - padding.value.right))
|
|
238
|
+
const chartHeight = computed(() => Math.max(50, height.value - padding.value.top - padding.value.bottom))
|
|
239
|
+
|
|
240
|
+
// Math helpers for circular charts (Pie, Donut, Rose, Radar)
|
|
241
|
+
const cx = computed(() => {
|
|
242
|
+
const baseCx = width.value / 2
|
|
243
|
+
if (showLegend.value) {
|
|
244
|
+
if (isLegendLeft.value) {
|
|
245
|
+
return width.value * 0.58
|
|
246
|
+
} else if (isLegendRight.value) {
|
|
247
|
+
return width.value * 0.42
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return baseCx
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
const cy = computed(() => {
|
|
254
|
+
const topOffset = showTitle.value ? 26 : 0
|
|
255
|
+
const bottomOffset = showDataTable.value ? dataTableHeight.value + 10 : 0
|
|
256
|
+
const availH = height.value - topOffset - bottomOffset
|
|
257
|
+
let baseCy = topOffset + (showLegend.value ? availH * 0.44 : availH * 0.5)
|
|
258
|
+
if (showLegend.value) {
|
|
259
|
+
if (isLegendTop.value) {
|
|
260
|
+
baseCy = topOffset + availH * 0.56
|
|
261
|
+
} else if (isLegendBottom.value) {
|
|
262
|
+
baseCy = topOffset + availH * 0.43
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return baseCy
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
const radius = computed(() => {
|
|
269
|
+
let w = width.value
|
|
270
|
+
let h = height.value - (showTitle.value ? 26 : 0) - (showDataTable.value ? dataTableHeight.value + 12 : 0)
|
|
271
|
+
if (showLegend.value) {
|
|
272
|
+
if (isLegendLeft.value || isLegendRight.value) {
|
|
273
|
+
w -= 100
|
|
274
|
+
} else if (isLegendTop.value || isLegendBottom.value) {
|
|
275
|
+
h -= 40
|
|
276
|
+
}
|
|
277
|
+
return Math.max(32, Math.min(w * 0.4, h * 0.32) || 75)
|
|
278
|
+
}
|
|
279
|
+
return Math.max(36, Math.min(w * 0.44, h * 0.42) || 80)
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
const innerRadius = computed(() => {
|
|
283
|
+
const hole = parseFloat((props.element as any).holeSize || (props.element as any).options?.holeSize)
|
|
284
|
+
const defaultHole = chartType.value === 'rose-donut' ? 0.36 : 0.72
|
|
285
|
+
const ratio = (!isNaN(hole) && hole > 0 && hole < 100) ? (hole / 100) : defaultHole
|
|
286
|
+
return radius.value * ratio
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
// Pie / Donut / Rose-Pie / Rose-Donut Slice generator
|
|
290
|
+
interface Slice {
|
|
291
|
+
d: string
|
|
292
|
+
color: string
|
|
293
|
+
label: string
|
|
294
|
+
value: number
|
|
295
|
+
percent: string
|
|
296
|
+
labelX: number
|
|
297
|
+
labelY: number
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const pieSlices = computed<Slice[]>(() => {
|
|
301
|
+
const vals = (datasets.value[0]?.data || []).map(v => Math.max(0, Number(v) || 0))
|
|
302
|
+
const total = vals.reduce((a, b) => a + b, 0) || 1
|
|
303
|
+
const maxSliceVal = Math.max(...vals, 1)
|
|
304
|
+
let startAngle = 0
|
|
305
|
+
const isDonut = chartType.value === 'donut' || chartType.value === 'rose-donut'
|
|
306
|
+
const isRose = chartType.value === 'rose-pie' || chartType.value === 'rose-donut'
|
|
307
|
+
const innerRadiusVal = isDonut ? innerRadius.value : 0
|
|
308
|
+
|
|
309
|
+
return vals.map((val, i) => {
|
|
310
|
+
const pct = val / total
|
|
311
|
+
const angle = isRose ? (360 / (vals.length || 1)) : (pct * 360)
|
|
312
|
+
const endAngle = startAngle + angle
|
|
313
|
+
const pctText = (pct * 100).toFixed(0) + '%'
|
|
314
|
+
|
|
315
|
+
const outerR = isRose
|
|
316
|
+
? innerRadiusVal + (radius.value - innerRadiusVal) * (0.28 + 0.72 * (val / maxSliceVal))
|
|
317
|
+
: radius.value
|
|
318
|
+
|
|
319
|
+
let dPath = ''
|
|
320
|
+
const rad1 = (startAngle - 90) * Math.PI / 180
|
|
321
|
+
const rad2 = (endAngle - 90) * Math.PI / 180
|
|
322
|
+
|
|
323
|
+
if (!isRose && pct >= 0.999) {
|
|
324
|
+
if (isDonut) {
|
|
325
|
+
dPath = `M ${cx.value} ${cy.value - outerR} A ${outerR} ${outerR} 0 1 1 ${cx.value - 0.01} ${cy.value - outerR} ` +
|
|
326
|
+
`L ${cx.value - 0.01} ${cy.value - innerRadiusVal} A ${innerRadiusVal} ${innerRadiusVal} 0 1 0 ${cx.value} ${cy.value - innerRadiusVal} Z`
|
|
327
|
+
} else {
|
|
328
|
+
dPath = `M ${cx.value} ${cy.value - outerR} A ${outerR} ${outerR} 0 1 1 ${cx.value - 0.01} ${cy.value - outerR} Z`
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
const xo1 = cx.value + outerR * Math.cos(rad1)
|
|
332
|
+
const yo1 = cy.value + outerR * Math.sin(rad1)
|
|
333
|
+
const xo2 = cx.value + outerR * Math.cos(rad2)
|
|
334
|
+
const yo2 = cy.value + outerR * Math.sin(rad2)
|
|
335
|
+
const largeArc = angle > 180 ? 1 : 0
|
|
336
|
+
|
|
337
|
+
if (isDonut) {
|
|
338
|
+
const xi1 = cx.value + innerRadiusVal * Math.cos(rad1)
|
|
339
|
+
const yi1 = cy.value + innerRadiusVal * Math.sin(rad1)
|
|
340
|
+
const xi2 = cx.value + innerRadiusVal * Math.cos(rad2)
|
|
341
|
+
const yi2 = cy.value + innerRadiusVal * Math.sin(rad2)
|
|
342
|
+
dPath = `M ${xo1} ${yo1} A ${outerR} ${outerR} 0 ${largeArc} 1 ${xo2} ${yo2} L ${xi2} ${yi2} A ${innerRadiusVal} ${innerRadiusVal} 0 ${largeArc} 0 ${xi1} ${yi1} Z`
|
|
343
|
+
} else {
|
|
344
|
+
dPath = `M ${cx.value} ${cy.value} L ${xo1} ${yo1} A ${outerR} ${outerR} 0 ${largeArc} 1 ${xo2} ${yo2} Z`
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const midAngle = (startAngle + endAngle) / 2
|
|
349
|
+
const midRad = (midAngle - 90) * Math.PI / 180
|
|
350
|
+
const labelR = isDonut ? (outerR + innerRadiusVal) / 2 : outerR * 0.65
|
|
351
|
+
const lx = cx.value + labelR * Math.cos(midRad)
|
|
352
|
+
const ly = cy.value + labelR * Math.sin(midRad)
|
|
353
|
+
|
|
354
|
+
const slice: Slice = {
|
|
355
|
+
d: dPath,
|
|
356
|
+
color: chartColors.value[i % chartColors.value.length],
|
|
357
|
+
label: labels.value[i] || `分类${i + 1}`,
|
|
358
|
+
value: val,
|
|
359
|
+
percent: pctText,
|
|
360
|
+
labelX: lx,
|
|
361
|
+
labelY: ly,
|
|
362
|
+
}
|
|
363
|
+
startAngle = endAngle
|
|
364
|
+
return slice
|
|
365
|
+
})
|
|
366
|
+
})
|
|
367
|
+
|
|
368
|
+
// Stacked Bar & Percent Bar segments generator
|
|
369
|
+
const stackedBarGroups = computed(() => {
|
|
370
|
+
const N = labels.value.length || 1
|
|
371
|
+
const groupW = chartWidth.value / N
|
|
372
|
+
const barW = Math.min(38, groupW * 0.52)
|
|
373
|
+
const isPct = chartType.value === 'percent-bar'
|
|
374
|
+
|
|
375
|
+
return labels.value.map((label, i) => {
|
|
376
|
+
const colTotal = datasets.value.reduce((acc, ds) => acc + Math.max(0, Number(ds.data?.[i]) || 0), 0) || 1
|
|
377
|
+
let currentBottomY = padding.value.top + chartHeight.value
|
|
378
|
+
|
|
379
|
+
const segments = datasets.value.map((ds, j) => {
|
|
380
|
+
const val = Math.max(0, Number(ds.data?.[i]) || 0)
|
|
381
|
+
const ratio = isPct ? (val / colTotal) : (val / maxVal.value)
|
|
382
|
+
const h = ratio * chartHeight.value
|
|
383
|
+
const y = currentBottomY - h
|
|
384
|
+
currentBottomY = y
|
|
385
|
+
return {
|
|
386
|
+
x: padding.value.left + i * groupW + (groupW - barW) / 2,
|
|
387
|
+
y,
|
|
388
|
+
width: barW,
|
|
389
|
+
height: Math.max(0, h),
|
|
390
|
+
color: chartColors.value[j % chartColors.value.length],
|
|
391
|
+
val,
|
|
392
|
+
displayVal: isPct ? `${Math.round((val / colTotal) * 100)}%` : `${val}`
|
|
393
|
+
}
|
|
394
|
+
})
|
|
395
|
+
|
|
396
|
+
return {
|
|
397
|
+
label,
|
|
398
|
+
centerX: padding.value.left + i * groupW + groupW / 2,
|
|
399
|
+
topY: currentBottomY,
|
|
400
|
+
colTotal,
|
|
401
|
+
segments
|
|
402
|
+
}
|
|
403
|
+
})
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
// Stacked Horizontal Bar segments generator
|
|
407
|
+
const stackedHBarGroups = computed(() => {
|
|
408
|
+
const N = labels.value.length || 1
|
|
409
|
+
const rowH = chartHeight.value / N
|
|
410
|
+
const barH = Math.min(26, rowH * 0.55)
|
|
411
|
+
|
|
412
|
+
return labels.value.map((label, i) => {
|
|
413
|
+
let currentLeftX = padding.value.left
|
|
414
|
+
const segments = datasets.value.map((ds, j) => {
|
|
415
|
+
const val = Math.max(0, Number(ds.data?.[i]) || 0)
|
|
416
|
+
const w = (val / maxVal.value) * chartWidth.value
|
|
417
|
+
const x = currentLeftX
|
|
418
|
+
currentLeftX += w
|
|
419
|
+
return {
|
|
420
|
+
x,
|
|
421
|
+
y: padding.value.top + i * rowH + (rowH - barH) / 2,
|
|
422
|
+
width: Math.max(0, w),
|
|
423
|
+
height: barH,
|
|
424
|
+
color: chartColors.value[j % chartColors.value.length],
|
|
425
|
+
val
|
|
426
|
+
}
|
|
427
|
+
})
|
|
428
|
+
return {
|
|
429
|
+
label,
|
|
430
|
+
centerY: padding.value.top + i * rowH + rowH / 2,
|
|
431
|
+
endX: currentLeftX,
|
|
432
|
+
segments
|
|
433
|
+
}
|
|
434
|
+
})
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
interface LegendItem {
|
|
438
|
+
label: string
|
|
439
|
+
color: string
|
|
440
|
+
percent?: string
|
|
441
|
+
x: number
|
|
442
|
+
y: number
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const legendItems = computed<LegendItem[]>(() => {
|
|
446
|
+
if (!showLegend.value) return []
|
|
447
|
+
|
|
448
|
+
let rawItems: { label: string; color: string; percent?: string }[] = []
|
|
449
|
+
if (isPieFamily.value) {
|
|
450
|
+
rawItems = pieSlices.value.slice(0, 6).map(slice => ({
|
|
451
|
+
label: slice.label,
|
|
452
|
+
color: slice.color,
|
|
453
|
+
percent: slice.percent
|
|
454
|
+
}))
|
|
455
|
+
} else {
|
|
456
|
+
rawItems = datasets.value.slice(0, 6).map((ds, j) => ({
|
|
457
|
+
label: ds.label,
|
|
458
|
+
color: chartColors.value[j % chartColors.value.length]
|
|
459
|
+
}))
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const pos = legendPosition.value
|
|
463
|
+
const W = width.value
|
|
464
|
+
const H = height.value
|
|
465
|
+
const topTitleSpace = showTitle.value ? 26 : 0
|
|
466
|
+
const bottomTableSpace = showDataTable.value ? dataTableHeight.value + 10 : 0
|
|
467
|
+
|
|
468
|
+
const itemsCount = rawItems.length
|
|
469
|
+
|
|
470
|
+
if (isLegendLeft.value || isLegendRight.value) {
|
|
471
|
+
const stepY = 22
|
|
472
|
+
const totalHeight = itemsCount * stepY
|
|
473
|
+
|
|
474
|
+
let startX = isLegendLeft.value ? 20 : W - 110
|
|
475
|
+
|
|
476
|
+
let startY = 40 + topTitleSpace
|
|
477
|
+
if (pos.endsWith('top')) {
|
|
478
|
+
startY = 36 + topTitleSpace
|
|
479
|
+
} else if (pos.endsWith('bottom')) {
|
|
480
|
+
startY = H - totalHeight - 20 - bottomTableSpace
|
|
481
|
+
} else {
|
|
482
|
+
startY = (H - totalHeight) / 2
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return rawItems.map((item, idx) => ({
|
|
486
|
+
...item,
|
|
487
|
+
x: startX,
|
|
488
|
+
y: startY + idx * stepY
|
|
489
|
+
}))
|
|
490
|
+
} else {
|
|
491
|
+
const stepX = Math.min(90, Math.floor((W - 40) / Math.max(itemsCount, 1)))
|
|
492
|
+
const totalWidth = itemsCount * stepX
|
|
493
|
+
|
|
494
|
+
let startY = isLegendTop.value ? (20 + topTitleSpace) : (H - 18 - bottomTableSpace)
|
|
495
|
+
|
|
496
|
+
let startX = 20
|
|
497
|
+
if (pos.endsWith('left')) {
|
|
498
|
+
startX = 20
|
|
499
|
+
} else if (pos.endsWith('right')) {
|
|
500
|
+
startX = W - totalWidth - 20
|
|
501
|
+
} else {
|
|
502
|
+
startX = (W - totalWidth) / 2
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return rawItems.map((item, idx) => ({
|
|
506
|
+
...item,
|
|
507
|
+
x: startX + idx * stepX,
|
|
508
|
+
y: startY
|
|
509
|
+
}))
|
|
510
|
+
}
|
|
511
|
+
})
|
|
512
|
+
|
|
513
|
+
// Smooth curve helper
|
|
514
|
+
function buildSmoothPath(points: { x: number; y: number }[]): string {
|
|
515
|
+
if (points.length === 0) return ''
|
|
516
|
+
if (points.length === 1) return `M ${points[0].x.toFixed(1)},${points[0].y.toFixed(1)}`
|
|
517
|
+
let d = `M ${points[0].x.toFixed(1)},${points[0].y.toFixed(1)}`
|
|
518
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
519
|
+
const p0 = points[i]
|
|
520
|
+
const p1 = points[i + 1]
|
|
521
|
+
const midX = ((p0.x + p1.x) / 2).toFixed(1)
|
|
522
|
+
d += ` C ${midX},${p0.y.toFixed(1)} ${midX},${p1.y.toFixed(1)} ${p1.x.toFixed(1)},${p1.y.toFixed(1)}`
|
|
523
|
+
}
|
|
524
|
+
return d
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Line & Area Paths generator
|
|
528
|
+
interface LinePath {
|
|
529
|
+
dLine: string
|
|
530
|
+
dSmooth: string
|
|
531
|
+
dArea: string
|
|
532
|
+
color: string
|
|
533
|
+
points: { x: number; y: number; val: number }[]
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const linePaths = computed<LinePath[]>(() => {
|
|
537
|
+
const N = labels.value.length
|
|
538
|
+
if (N === 0) return []
|
|
539
|
+
const dx = N > 1 ? chartWidth.value / (N - 1) : chartWidth.value
|
|
540
|
+
const max = maxVal.value
|
|
541
|
+
const isStackedArea = chartType.value === 'stacked-area'
|
|
542
|
+
const cumulativeVals = new Array(N).fill(0)
|
|
543
|
+
|
|
544
|
+
return datasets.value.map((ds, j) => {
|
|
545
|
+
const points = (ds.data || []).map((rawVal, i) => {
|
|
546
|
+
const val = Number(rawVal) || 0
|
|
547
|
+
cumulativeVals[i] += val
|
|
548
|
+
const plotVal = isStackedArea ? cumulativeVals[i] : val
|
|
549
|
+
const x = padding.value.left + i * dx
|
|
550
|
+
const y = padding.value.top + chartHeight.value - (plotVal / max) * chartHeight.value
|
|
551
|
+
return { x, y, val }
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
if (points.length === 0) return null
|
|
555
|
+
|
|
556
|
+
const linePointsStr = points.map(p => `${p.x.toFixed(1)},${p.y.toFixed(1)}`).join(' L ')
|
|
557
|
+
const dLine = `M ${linePointsStr}`
|
|
558
|
+
const dSmooth = buildSmoothPath(points)
|
|
559
|
+
|
|
560
|
+
const startX = points[0]?.x || padding.value.left
|
|
561
|
+
const endX = points[points.length - 1]?.x || (padding.value.left + chartWidth.value)
|
|
562
|
+
const bottomY = padding.value.top + chartHeight.value
|
|
563
|
+
const baseCurve = isStackedArea ? dSmooth : dLine
|
|
564
|
+
const dArea = `${baseCurve} L ${endX.toFixed(1)},${bottomY} L ${startX.toFixed(1)},${bottomY} Z`
|
|
565
|
+
|
|
566
|
+
return {
|
|
567
|
+
dLine,
|
|
568
|
+
dSmooth,
|
|
569
|
+
dArea,
|
|
570
|
+
color: chartColors.value[j % chartColors.value.length],
|
|
571
|
+
points
|
|
572
|
+
}
|
|
573
|
+
}).filter((lp): lp is LinePath => lp !== null)
|
|
574
|
+
})
|
|
575
|
+
|
|
576
|
+
// Radar Grid levels and axis vectors
|
|
577
|
+
const radarAxis = computed(() => {
|
|
578
|
+
const N = labels.value.length || 1
|
|
579
|
+
const angle = 360 / N
|
|
580
|
+
return labels.value.map((label, i) => {
|
|
581
|
+
const rad = (i * angle - 90) * Math.PI / 180
|
|
582
|
+
return {
|
|
583
|
+
label,
|
|
584
|
+
lineX: cx.value + radius.value * Math.cos(rad),
|
|
585
|
+
lineY: cy.value + radius.value * Math.sin(rad),
|
|
586
|
+
labelX: cx.value + (radius.value + 18) * Math.cos(rad),
|
|
587
|
+
labelY: cy.value + (radius.value + 18) * Math.sin(rad) + 4,
|
|
588
|
+
align: Math.cos(rad) > 0.05 ? 'start' : Math.cos(rad) < -0.05 ? 'end' : 'middle'
|
|
589
|
+
}
|
|
590
|
+
})
|
|
591
|
+
})
|
|
592
|
+
|
|
593
|
+
const radarLevels = computed(() => {
|
|
594
|
+
const N = labels.value.length
|
|
595
|
+
if (N === 0) return []
|
|
596
|
+
const angle = 360 / N
|
|
597
|
+
return [1, 2, 3, 4].map(level => {
|
|
598
|
+
const r = radius.value * (level / 4)
|
|
599
|
+
const points = Array.from({ length: N }).map((_, i) => {
|
|
600
|
+
const rad = (i * angle - 90) * Math.PI / 180
|
|
601
|
+
const x = cx.value + r * Math.cos(rad)
|
|
602
|
+
const y = cy.value + r * Math.sin(rad)
|
|
603
|
+
return `${x.toFixed(1)},${y.toFixed(1)}`
|
|
604
|
+
}).join(' ')
|
|
605
|
+
return points
|
|
606
|
+
})
|
|
607
|
+
})
|
|
608
|
+
|
|
609
|
+
const radarPolygons = computed(() => {
|
|
610
|
+
const N = labels.value.length || 1
|
|
611
|
+
const angle = 360 / N
|
|
612
|
+
const max = maxVal.value
|
|
613
|
+
|
|
614
|
+
return datasets.value.map((ds, j) => {
|
|
615
|
+
const vertexList = ds.data.map((val, i) => {
|
|
616
|
+
const rad = (i * angle - 90) * Math.PI / 180
|
|
617
|
+
const r_val = radius.value * (val / max)
|
|
618
|
+
const x = cx.value + r_val * Math.cos(rad)
|
|
619
|
+
const y = cy.value + r_val * Math.sin(rad)
|
|
620
|
+
return { x, y, val }
|
|
621
|
+
})
|
|
622
|
+
const points = vertexList.map(v => `${v.x.toFixed(1)},${v.y.toFixed(1)}`).join(' ')
|
|
623
|
+
|
|
624
|
+
return {
|
|
625
|
+
points,
|
|
626
|
+
vertices: vertexList,
|
|
627
|
+
color: chartColors.value[j % chartColors.value.length]
|
|
628
|
+
}
|
|
629
|
+
})
|
|
630
|
+
})
|
|
631
|
+
</script>
|
|
632
|
+
|
|
633
|
+
<template>
|
|
634
|
+
<svg
|
|
635
|
+
:viewBox="`0 0 ${width} ${height}`"
|
|
636
|
+
:style="{ width: '100%', height: '100%', display: 'block', overflow: 'visible', userSelect: 'none', fontFamily: fontFamily, '--ppt-font-family': fontFamily }"
|
|
637
|
+
>
|
|
638
|
+
<!-- Chart Title (All chart types) -->
|
|
639
|
+
<text
|
|
640
|
+
v-if="showTitle"
|
|
641
|
+
:x="width / 2"
|
|
642
|
+
y="22"
|
|
643
|
+
text-anchor="middle"
|
|
644
|
+
font-size="14"
|
|
645
|
+
font-weight="700"
|
|
646
|
+
:fill="textColor"
|
|
647
|
+
:font-family="fontFamily"
|
|
648
|
+
>
|
|
649
|
+
{{ chartTitleText }}
|
|
650
|
+
</text>
|
|
651
|
+
|
|
652
|
+
<!-- Background Gridlines (Cartesian vertical-Y charts) -->
|
|
653
|
+
<g v-if="isVerticalCartesian && showGridlines">
|
|
654
|
+
<line
|
|
655
|
+
v-for="tick in gridTicks"
|
|
656
|
+
:key="'grid-' + tick.pct"
|
|
657
|
+
:x1="padding.left"
|
|
658
|
+
:y1="padding.top + chartHeight - tick.pct * chartHeight"
|
|
659
|
+
:x2="padding.left + chartWidth"
|
|
660
|
+
:y2="padding.top + chartHeight - tick.pct * chartHeight"
|
|
661
|
+
:stroke="gridColor"
|
|
662
|
+
stroke-width="1"
|
|
663
|
+
:stroke-dasharray="tick.pct === 0 ? '' : '4 4'"
|
|
664
|
+
/>
|
|
665
|
+
</g>
|
|
666
|
+
|
|
667
|
+
<!-- Y-Axis Ticks & Axis Baseline (Cartesian vertical-Y charts, controlled by showAxes) -->
|
|
668
|
+
<g v-if="isVerticalCartesian && showAxes">
|
|
669
|
+
<line
|
|
670
|
+
:x1="padding.left"
|
|
671
|
+
:y1="padding.top + chartHeight"
|
|
672
|
+
:x2="padding.left + chartWidth"
|
|
673
|
+
:y2="padding.top + chartHeight"
|
|
674
|
+
:stroke="gridColor"
|
|
675
|
+
stroke-width="1.2"
|
|
676
|
+
/>
|
|
677
|
+
<text
|
|
678
|
+
v-for="tick in gridTicks"
|
|
679
|
+
:key="'label-' + tick.pct"
|
|
680
|
+
:x="padding.left - 8"
|
|
681
|
+
:y="padding.top + chartHeight - tick.pct * chartHeight + 4"
|
|
682
|
+
text-anchor="end"
|
|
683
|
+
font-size="10"
|
|
684
|
+
font-weight="500"
|
|
685
|
+
:fill="textColor"
|
|
686
|
+
:font-family="fontFamily"
|
|
687
|
+
>
|
|
688
|
+
{{ tick.val }}
|
|
689
|
+
</text>
|
|
690
|
+
</g>
|
|
691
|
+
|
|
692
|
+
<!-- Axis Titles (Cartesian charts only) -->
|
|
693
|
+
<g v-if="showAxisTitles">
|
|
694
|
+
<text
|
|
695
|
+
:x="padding.left + chartWidth / 2"
|
|
696
|
+
:y="padding.top + chartHeight + (showAxes ? 30 : 16)"
|
|
697
|
+
text-anchor="middle"
|
|
698
|
+
font-size="10"
|
|
699
|
+
font-weight="600"
|
|
700
|
+
:fill="textColor"
|
|
701
|
+
:font-family="fontFamily"
|
|
702
|
+
>
|
|
703
|
+
{{ xAxisTitleText }}
|
|
704
|
+
</text>
|
|
705
|
+
<text
|
|
706
|
+
:x="14"
|
|
707
|
+
:y="padding.top + chartHeight / 2"
|
|
708
|
+
text-anchor="middle"
|
|
709
|
+
font-size="10"
|
|
710
|
+
font-weight="600"
|
|
711
|
+
:fill="textColor"
|
|
712
|
+
:font-family="fontFamily"
|
|
713
|
+
:transform="`rotate(-90, 14, ${padding.top + chartHeight / 2})`"
|
|
714
|
+
>
|
|
715
|
+
{{ yAxisTitleText }}
|
|
716
|
+
</text>
|
|
717
|
+
</g>
|
|
718
|
+
|
|
719
|
+
<!-- 1A. Grouped Column/Bar Chart ('bar') -->
|
|
720
|
+
<g v-if="chartType === 'bar'">
|
|
721
|
+
<g v-for="(label, i) in labels" :key="'col-group-' + i">
|
|
722
|
+
<text v-if="showAxes"
|
|
723
|
+
:x="padding.left + i * (chartWidth / labels.length) + (chartWidth / labels.length) / 2"
|
|
724
|
+
:y="padding.top + chartHeight + 15"
|
|
725
|
+
text-anchor="middle"
|
|
726
|
+
font-size="10"
|
|
727
|
+
font-weight="500"
|
|
728
|
+
:fill="textColor"
|
|
729
|
+
:font-family="fontFamily"
|
|
730
|
+
>
|
|
731
|
+
{{ label }}
|
|
732
|
+
</text>
|
|
733
|
+
|
|
734
|
+
<g v-for="(ds, j) in datasets" :key="'bar-' + i + '-' + j">
|
|
735
|
+
<rect
|
|
736
|
+
:x="padding.left + i * (chartWidth / labels.length) + ((chartWidth / labels.length) * 0.15) + (j * ((chartWidth / labels.length) * 0.7 / datasets.length))"
|
|
737
|
+
:y="padding.top + chartHeight - ((ds.data[i] || 0) / maxVal) * chartHeight"
|
|
738
|
+
:width="((chartWidth / labels.length) * 0.7 / datasets.length) * 0.9"
|
|
739
|
+
:height="((ds.data[i] || 0) / maxVal) * chartHeight"
|
|
740
|
+
:fill="chartColors[j % chartColors.length]"
|
|
741
|
+
rx="2"
|
|
742
|
+
/>
|
|
743
|
+
<g v-if="showErrorBars && (ds.data[i] || 0) > 0">
|
|
744
|
+
<line
|
|
745
|
+
:x1="padding.left + i * (chartWidth / labels.length) + ((chartWidth / labels.length) * 0.15) + (j * ((chartWidth / labels.length) * 0.7 / datasets.length)) + (((chartWidth / labels.length) * 0.7 / datasets.length) * 0.45)"
|
|
746
|
+
:y1="padding.top + chartHeight - ((ds.data[i] || 0) * 1.08 / maxVal) * chartHeight"
|
|
747
|
+
:x2="padding.left + i * (chartWidth / labels.length) + ((chartWidth / labels.length) * 0.15) + (j * ((chartWidth / labels.length) * 0.7 / datasets.length)) + (((chartWidth / labels.length) * 0.7 / datasets.length) * 0.45)"
|
|
748
|
+
:y2="padding.top + chartHeight - ((ds.data[i] || 0) * 0.92 / maxVal) * chartHeight"
|
|
749
|
+
stroke="#334155"
|
|
750
|
+
stroke-width="1.2"
|
|
751
|
+
/>
|
|
752
|
+
</g>
|
|
753
|
+
<text
|
|
754
|
+
v-if="showDataLabels"
|
|
755
|
+
:x="padding.left + i * (chartWidth / labels.length) + ((chartWidth / labels.length) * 0.15) + (j * ((chartWidth / labels.length) * 0.7 / datasets.length)) + (((chartWidth / labels.length) * 0.7 / datasets.length) * 0.45)"
|
|
756
|
+
:y="padding.top + chartHeight - ((ds.data[i] || 0) / maxVal) * chartHeight - 5"
|
|
757
|
+
text-anchor="middle"
|
|
758
|
+
font-size="9"
|
|
759
|
+
font-weight="600"
|
|
760
|
+
:fill="textColor"
|
|
761
|
+
:font-family="fontFamily"
|
|
762
|
+
>
|
|
763
|
+
{{ ds.data[i] ?? 0 }}
|
|
764
|
+
</text>
|
|
765
|
+
</g>
|
|
766
|
+
</g>
|
|
767
|
+
</g>
|
|
768
|
+
|
|
769
|
+
<!-- 1B. Stacked Bar & Percent Bar ('stacked-bar' | 'percent-bar') -->
|
|
770
|
+
<g v-if="chartType === 'stacked-bar' || chartType === 'percent-bar'">
|
|
771
|
+
<g v-for="(grp, i) in stackedBarGroups" :key="'sbar-grp-' + i">
|
|
772
|
+
<text v-if="showAxes"
|
|
773
|
+
:x="grp.centerX"
|
|
774
|
+
:y="padding.top + chartHeight + 15"
|
|
775
|
+
text-anchor="middle"
|
|
776
|
+
font-size="10"
|
|
777
|
+
font-weight="500"
|
|
778
|
+
:fill="textColor"
|
|
779
|
+
:font-family="fontFamily"
|
|
780
|
+
>
|
|
781
|
+
{{ grp.label }}
|
|
782
|
+
</text>
|
|
783
|
+
<g v-for="(seg, j) in grp.segments" :key="'sbar-seg-' + i + '-' + j">
|
|
784
|
+
<rect
|
|
785
|
+
:x="seg.x"
|
|
786
|
+
:y="seg.y"
|
|
787
|
+
:width="seg.width"
|
|
788
|
+
:height="seg.height"
|
|
789
|
+
:fill="seg.color"
|
|
790
|
+
stroke="#ffffff"
|
|
791
|
+
stroke-width="0.8"
|
|
792
|
+
rx="1.5"
|
|
793
|
+
/>
|
|
794
|
+
<text
|
|
795
|
+
v-if="showDataLabels && seg.height > 12"
|
|
796
|
+
:x="grp.centerX"
|
|
797
|
+
:y="seg.y + seg.height / 2 + 3"
|
|
798
|
+
text-anchor="middle"
|
|
799
|
+
font-size="8.5"
|
|
800
|
+
font-weight="600"
|
|
801
|
+
fill="#ffffff"
|
|
802
|
+
>
|
|
803
|
+
{{ seg.displayVal }}
|
|
804
|
+
</text>
|
|
805
|
+
</g>
|
|
806
|
+
</g>
|
|
807
|
+
</g>
|
|
808
|
+
|
|
809
|
+
<!-- 2. Horizontal Bar Family ('horizontal-bar' | 'stacked-horizontal-bar') -->
|
|
810
|
+
<g v-if="isHBarFamily">
|
|
811
|
+
<g v-if="showGridlines">
|
|
812
|
+
<line
|
|
813
|
+
v-for="tick in gridTicks"
|
|
814
|
+
:key="'grid-v-' + tick.pct"
|
|
815
|
+
:x1="padding.left + tick.pct * chartWidth"
|
|
816
|
+
:y1="padding.top"
|
|
817
|
+
:x2="padding.left + tick.pct * chartWidth"
|
|
818
|
+
:y2="padding.top + chartHeight"
|
|
819
|
+
:stroke="gridColor"
|
|
820
|
+
stroke-width="1"
|
|
821
|
+
:stroke-dasharray="tick.pct === 0 ? '' : '4 4'"
|
|
822
|
+
/>
|
|
823
|
+
</g>
|
|
824
|
+
<g v-if="showAxes">
|
|
825
|
+
<text
|
|
826
|
+
v-for="tick in gridTicks"
|
|
827
|
+
:key="'v-label-' + tick.pct"
|
|
828
|
+
:x="padding.left + tick.pct * chartWidth"
|
|
829
|
+
:y="padding.top + chartHeight + 15"
|
|
830
|
+
text-anchor="middle"
|
|
831
|
+
font-size="10"
|
|
832
|
+
font-weight="500"
|
|
833
|
+
:fill="textColor"
|
|
834
|
+
:font-family="fontFamily"
|
|
835
|
+
>
|
|
836
|
+
{{ tick.val }}
|
|
837
|
+
</text>
|
|
838
|
+
</g>
|
|
839
|
+
|
|
840
|
+
<!-- Grouped Horizontal Bar -->
|
|
841
|
+
<template v-if="chartType === 'horizontal-bar'">
|
|
842
|
+
<g v-for="(label, i) in labels" :key="'row-group-' + i">
|
|
843
|
+
<text v-if="showAxes"
|
|
844
|
+
:x="padding.left - 8"
|
|
845
|
+
:y="padding.top + i * (chartHeight / labels.length) + (chartHeight / labels.length) / 2 + 4"
|
|
846
|
+
text-anchor="end"
|
|
847
|
+
font-size="10"
|
|
848
|
+
font-weight="500"
|
|
849
|
+
:fill="textColor"
|
|
850
|
+
:font-family="fontFamily"
|
|
851
|
+
>
|
|
852
|
+
{{ label }}
|
|
853
|
+
</text>
|
|
854
|
+
|
|
855
|
+
<g v-for="(ds, j) in datasets" :key="'hbar-' + i + '-' + j">
|
|
856
|
+
<rect
|
|
857
|
+
:x="padding.left"
|
|
858
|
+
:y="padding.top + i * (chartHeight / labels.length) + ((chartHeight / labels.length) * 0.15) + (j * ((chartHeight / labels.length) * 0.7 / datasets.length))"
|
|
859
|
+
:width="((ds.data[i] || 0) / maxVal) * chartWidth"
|
|
860
|
+
:height="((chartHeight / labels.length) * 0.7 / datasets.length) * 0.9"
|
|
861
|
+
:fill="chartColors[j % chartColors.length]"
|
|
862
|
+
rx="2"
|
|
863
|
+
/>
|
|
864
|
+
<text
|
|
865
|
+
v-if="showDataLabels"
|
|
866
|
+
:x="padding.left + ((ds.data[i] || 0) / maxVal) * chartWidth + 5"
|
|
867
|
+
:y="padding.top + i * (chartHeight / labels.length) + ((chartHeight / labels.length) * 0.15) + (j * ((chartHeight / labels.length) * 0.7 / datasets.length)) + (((chartHeight / labels.length) * 0.7 / datasets.length) * 0.45) + 3"
|
|
868
|
+
text-anchor="start"
|
|
869
|
+
font-size="9"
|
|
870
|
+
font-weight="600"
|
|
871
|
+
:fill="textColor"
|
|
872
|
+
:font-family="fontFamily"
|
|
873
|
+
>
|
|
874
|
+
{{ ds.data[i] ?? 0 }}
|
|
875
|
+
</text>
|
|
876
|
+
</g>
|
|
877
|
+
</g>
|
|
878
|
+
</template>
|
|
879
|
+
|
|
880
|
+
<!-- Stacked Horizontal Bar -->
|
|
881
|
+
<template v-else>
|
|
882
|
+
<g v-for="(grp, i) in stackedHBarGroups" :key="'shbar-grp-' + i">
|
|
883
|
+
<text v-if="showAxes"
|
|
884
|
+
:x="padding.left - 8"
|
|
885
|
+
:y="grp.centerY + 4"
|
|
886
|
+
text-anchor="end"
|
|
887
|
+
font-size="10"
|
|
888
|
+
font-weight="500"
|
|
889
|
+
:fill="textColor"
|
|
890
|
+
:font-family="fontFamily"
|
|
891
|
+
>
|
|
892
|
+
{{ grp.label }}
|
|
893
|
+
</text>
|
|
894
|
+
<g v-for="(seg, j) in grp.segments" :key="'shbar-seg-' + i + '-' + j">
|
|
895
|
+
<rect
|
|
896
|
+
:x="seg.x"
|
|
897
|
+
:y="seg.y"
|
|
898
|
+
:width="seg.width"
|
|
899
|
+
:height="seg.height"
|
|
900
|
+
:fill="seg.color"
|
|
901
|
+
stroke="#ffffff"
|
|
902
|
+
stroke-width="0.8"
|
|
903
|
+
rx="1.5"
|
|
904
|
+
/>
|
|
905
|
+
<text
|
|
906
|
+
v-if="showDataLabels && seg.width > 18"
|
|
907
|
+
:x="seg.x + seg.width / 2"
|
|
908
|
+
:y="grp.centerY + 3"
|
|
909
|
+
text-anchor="middle"
|
|
910
|
+
font-size="8.5"
|
|
911
|
+
font-weight="600"
|
|
912
|
+
fill="#ffffff"
|
|
913
|
+
>
|
|
914
|
+
{{ seg.val }}
|
|
915
|
+
</text>
|
|
916
|
+
</g>
|
|
917
|
+
</g>
|
|
918
|
+
</template>
|
|
919
|
+
</g>
|
|
920
|
+
|
|
921
|
+
<!-- 3. Line Chart Family ('line' | 'compare-line' | 'step-line') -->
|
|
922
|
+
<g v-if="isLineFamily">
|
|
923
|
+
<text v-if="showAxes"
|
|
924
|
+
v-for="(label, i) in labels"
|
|
925
|
+
:key="'line-lbl-' + i"
|
|
926
|
+
:x="padding.left + i * (chartWidth / (labels.length - 1 || 1))"
|
|
927
|
+
:y="padding.top + chartHeight + 15"
|
|
928
|
+
text-anchor="middle"
|
|
929
|
+
font-size="10"
|
|
930
|
+
font-weight="500"
|
|
931
|
+
:fill="textColor"
|
|
932
|
+
:font-family="fontFamily"
|
|
933
|
+
>
|
|
934
|
+
{{ label }}
|
|
935
|
+
</text>
|
|
936
|
+
|
|
937
|
+
<g v-for="(lp, j) in linePaths" :key="'line-p-' + j">
|
|
938
|
+
<path
|
|
939
|
+
:d="chartType === 'line' ? lp.dSmooth : lp.dLine"
|
|
940
|
+
fill="none"
|
|
941
|
+
:stroke="lp.color"
|
|
942
|
+
stroke-width="3"
|
|
943
|
+
stroke-linecap="round"
|
|
944
|
+
stroke-linejoin="round"
|
|
945
|
+
/>
|
|
946
|
+
<g v-for="(pt, i) in lp.points" :key="'circle-' + i">
|
|
947
|
+
<line
|
|
948
|
+
v-if="showErrorBars"
|
|
949
|
+
:x1="pt.x"
|
|
950
|
+
:y1="pt.y - 8"
|
|
951
|
+
:x2="pt.x"
|
|
952
|
+
:y2="pt.y + 8"
|
|
953
|
+
stroke="#334155"
|
|
954
|
+
stroke-width="1.2"
|
|
955
|
+
/>
|
|
956
|
+
<circle
|
|
957
|
+
v-if="chartType !== 'step-line'"
|
|
958
|
+
:cx="pt.x"
|
|
959
|
+
:cy="pt.y"
|
|
960
|
+
r="4.5"
|
|
961
|
+
fill="#ffffff"
|
|
962
|
+
:stroke="lp.color"
|
|
963
|
+
stroke-width="2.5"
|
|
964
|
+
/>
|
|
965
|
+
<text
|
|
966
|
+
v-if="showDataLabels"
|
|
967
|
+
:x="pt.x"
|
|
968
|
+
:y="pt.y - 8"
|
|
969
|
+
text-anchor="middle"
|
|
970
|
+
font-size="9"
|
|
971
|
+
font-weight="600"
|
|
972
|
+
:fill="textColor"
|
|
973
|
+
:font-family="fontFamily"
|
|
974
|
+
>
|
|
975
|
+
{{ pt.val }}
|
|
976
|
+
</text>
|
|
977
|
+
</g>
|
|
978
|
+
</g>
|
|
979
|
+
</g>
|
|
980
|
+
|
|
981
|
+
<!-- 4. Area Chart Family ('area' | 'stacked-area') -->
|
|
982
|
+
<g v-if="isAreaFamily">
|
|
983
|
+
<text v-if="showAxes"
|
|
984
|
+
v-for="(label, i) in labels"
|
|
985
|
+
:key="'area-lbl-' + i"
|
|
986
|
+
:x="padding.left + i * (chartWidth / (labels.length - 1 || 1))"
|
|
987
|
+
:y="padding.top + chartHeight + 15"
|
|
988
|
+
text-anchor="middle"
|
|
989
|
+
font-size="10"
|
|
990
|
+
font-weight="500"
|
|
991
|
+
:fill="textColor"
|
|
992
|
+
:font-family="fontFamily"
|
|
993
|
+
>
|
|
994
|
+
{{ label }}
|
|
995
|
+
</text>
|
|
996
|
+
|
|
997
|
+
<g v-for="(lp, j) in linePaths" :key="'area-p-' + j">
|
|
998
|
+
<path
|
|
999
|
+
:d="lp.dArea"
|
|
1000
|
+
:fill="lp.color"
|
|
1001
|
+
:fill-opacity="chartType === 'stacked-area' ? 0.35 : 0.18"
|
|
1002
|
+
/>
|
|
1003
|
+
<path
|
|
1004
|
+
:d="chartType === 'stacked-area' ? lp.dSmooth : lp.dLine"
|
|
1005
|
+
fill="none"
|
|
1006
|
+
:stroke="lp.color"
|
|
1007
|
+
stroke-width="2.5"
|
|
1008
|
+
stroke-linecap="round"
|
|
1009
|
+
stroke-linejoin="round"
|
|
1010
|
+
/>
|
|
1011
|
+
<g v-for="(pt, i) in lp.points" :key="'acircle-' + i">
|
|
1012
|
+
<line
|
|
1013
|
+
v-if="showErrorBars"
|
|
1014
|
+
:x1="pt.x"
|
|
1015
|
+
:y1="pt.y - 8"
|
|
1016
|
+
:x2="pt.x"
|
|
1017
|
+
:y2="pt.y + 8"
|
|
1018
|
+
stroke="#334155"
|
|
1019
|
+
stroke-width="1.2"
|
|
1020
|
+
/>
|
|
1021
|
+
<circle
|
|
1022
|
+
:cx="pt.x"
|
|
1023
|
+
:cy="pt.y"
|
|
1024
|
+
r="3.5"
|
|
1025
|
+
:fill="lp.color"
|
|
1026
|
+
/>
|
|
1027
|
+
<text
|
|
1028
|
+
v-if="showDataLabels"
|
|
1029
|
+
:x="pt.x"
|
|
1030
|
+
:y="pt.y - 7"
|
|
1031
|
+
text-anchor="middle"
|
|
1032
|
+
font-size="9"
|
|
1033
|
+
font-weight="600"
|
|
1034
|
+
:fill="textColor"
|
|
1035
|
+
:font-family="fontFamily"
|
|
1036
|
+
>
|
|
1037
|
+
{{ pt.val }}
|
|
1038
|
+
</text>
|
|
1039
|
+
</g>
|
|
1040
|
+
</g>
|
|
1041
|
+
</g>
|
|
1042
|
+
|
|
1043
|
+
<!-- 5. Scatter Chart -->
|
|
1044
|
+
<g v-if="chartType === 'scatter'">
|
|
1045
|
+
<text v-if="showAxes"
|
|
1046
|
+
v-for="(label, i) in labels"
|
|
1047
|
+
:key="'scat-lbl-' + i"
|
|
1048
|
+
:x="padding.left + i * (chartWidth / (labels.length - 1 || 1))"
|
|
1049
|
+
:y="padding.top + chartHeight + 15"
|
|
1050
|
+
text-anchor="middle"
|
|
1051
|
+
font-size="10"
|
|
1052
|
+
font-weight="500"
|
|
1053
|
+
:fill="textColor"
|
|
1054
|
+
:font-family="fontFamily"
|
|
1055
|
+
>
|
|
1056
|
+
{{ label }}
|
|
1057
|
+
</text>
|
|
1058
|
+
|
|
1059
|
+
<g v-for="(lp, j) in linePaths" :key="'scat-g-' + j">
|
|
1060
|
+
<g v-for="(pt, i) in lp.points" :key="'pt-' + i">
|
|
1061
|
+
<line
|
|
1062
|
+
v-if="showErrorBars"
|
|
1063
|
+
:x1="pt.x"
|
|
1064
|
+
:y1="pt.y - 10"
|
|
1065
|
+
:x2="pt.x"
|
|
1066
|
+
:y2="pt.y + 10"
|
|
1067
|
+
stroke="#334155"
|
|
1068
|
+
stroke-width="1.2"
|
|
1069
|
+
/>
|
|
1070
|
+
<circle
|
|
1071
|
+
:cx="pt.x"
|
|
1072
|
+
:cy="pt.y"
|
|
1073
|
+
r="6.5"
|
|
1074
|
+
:fill="lp.color"
|
|
1075
|
+
fill-opacity="0.8"
|
|
1076
|
+
/>
|
|
1077
|
+
<text
|
|
1078
|
+
v-if="showDataLabels"
|
|
1079
|
+
:x="pt.x"
|
|
1080
|
+
:y="pt.y - 9"
|
|
1081
|
+
text-anchor="middle"
|
|
1082
|
+
font-size="9"
|
|
1083
|
+
font-weight="600"
|
|
1084
|
+
:fill="textColor"
|
|
1085
|
+
:font-family="fontFamily"
|
|
1086
|
+
>
|
|
1087
|
+
{{ pt.val }}
|
|
1088
|
+
</text>
|
|
1089
|
+
</g>
|
|
1090
|
+
</g>
|
|
1091
|
+
</g>
|
|
1092
|
+
|
|
1093
|
+
<!-- 6 & 7. Pie / Donut / Rose-Pie / Rose-Donut Chart -->
|
|
1094
|
+
<g v-if="isPieFamily">
|
|
1095
|
+
<g v-for="(slice, i) in pieSlices" :key="'pie-slice-g-' + i">
|
|
1096
|
+
<path
|
|
1097
|
+
:d="slice.d"
|
|
1098
|
+
:fill="slice.color"
|
|
1099
|
+
stroke="#ffffff"
|
|
1100
|
+
stroke-width="1.5"
|
|
1101
|
+
/>
|
|
1102
|
+
<text
|
|
1103
|
+
v-if="showDataLabels && slice.percent && slice.value > 0"
|
|
1104
|
+
:x="slice.labelX"
|
|
1105
|
+
:y="slice.labelY"
|
|
1106
|
+
text-anchor="middle"
|
|
1107
|
+
dominant-baseline="central"
|
|
1108
|
+
fill="#ffffff"
|
|
1109
|
+
font-size="11"
|
|
1110
|
+
font-weight="bold"
|
|
1111
|
+
:font-family="fontFamily"
|
|
1112
|
+
style="pointer-events: none; user-select: none;"
|
|
1113
|
+
>
|
|
1114
|
+
{{ slice.percent }}
|
|
1115
|
+
</text>
|
|
1116
|
+
</g>
|
|
1117
|
+
</g>
|
|
1118
|
+
|
|
1119
|
+
<!-- 8. Radar Chart -->
|
|
1120
|
+
<g v-if="chartType === 'radar'">
|
|
1121
|
+
<g v-if="showGridlines">
|
|
1122
|
+
<polygon
|
|
1123
|
+
v-for="(lvlPoints, lvlIdx) in radarLevels"
|
|
1124
|
+
:key="'radar-lvl-' + lvlIdx"
|
|
1125
|
+
:points="lvlPoints"
|
|
1126
|
+
fill="none"
|
|
1127
|
+
:stroke="gridColor"
|
|
1128
|
+
stroke-width="1"
|
|
1129
|
+
/>
|
|
1130
|
+
<line
|
|
1131
|
+
v-for="(axis, i) in radarAxis"
|
|
1132
|
+
:key="'radar-axis-' + i"
|
|
1133
|
+
:x1="cx"
|
|
1134
|
+
:y1="cy"
|
|
1135
|
+
:x2="axis.lineX"
|
|
1136
|
+
:y2="axis.lineY"
|
|
1137
|
+
:stroke="gridColor"
|
|
1138
|
+
stroke-width="1"
|
|
1139
|
+
/>
|
|
1140
|
+
</g>
|
|
1141
|
+
|
|
1142
|
+
<text v-if="showAxes"
|
|
1143
|
+
v-for="(axis, i) in radarAxis"
|
|
1144
|
+
:key="'radar-txt-' + i"
|
|
1145
|
+
:x="axis.labelX"
|
|
1146
|
+
:y="axis.labelY"
|
|
1147
|
+
:text-anchor="axis.align"
|
|
1148
|
+
font-size="9"
|
|
1149
|
+
font-weight="500"
|
|
1150
|
+
:fill="textColor"
|
|
1151
|
+
:font-family="fontFamily"
|
|
1152
|
+
>
|
|
1153
|
+
{{ axis.label }}
|
|
1154
|
+
</text>
|
|
1155
|
+
|
|
1156
|
+
<g v-for="(poly, j) in radarPolygons" :key="'radar-poly-' + j">
|
|
1157
|
+
<polygon
|
|
1158
|
+
:points="poly.points"
|
|
1159
|
+
:fill="poly.color"
|
|
1160
|
+
fill-opacity="0.25"
|
|
1161
|
+
:stroke="poly.color"
|
|
1162
|
+
stroke-width="2.5"
|
|
1163
|
+
stroke-linejoin="round"
|
|
1164
|
+
/>
|
|
1165
|
+
<template v-if="showDataLabels">
|
|
1166
|
+
<text
|
|
1167
|
+
v-for="(vtx, vi) in poly.vertices"
|
|
1168
|
+
:key="'radar-val-' + j + '-' + vi"
|
|
1169
|
+
:x="vtx.x"
|
|
1170
|
+
:y="vtx.y - 5"
|
|
1171
|
+
text-anchor="middle"
|
|
1172
|
+
font-size="9"
|
|
1173
|
+
font-weight="600"
|
|
1174
|
+
:fill="textColor"
|
|
1175
|
+
:font-family="fontFamily"
|
|
1176
|
+
>
|
|
1177
|
+
{{ vtx.val }}
|
|
1178
|
+
</text>
|
|
1179
|
+
</template>
|
|
1180
|
+
</g>
|
|
1181
|
+
</g>
|
|
1182
|
+
|
|
1183
|
+
<!-- Embedded Data Table (when showDataTable is enabled) -->
|
|
1184
|
+
<g v-if="showDataTable" :transform="`translate(${padding.left}, ${height - dataTableHeight - 4})`">
|
|
1185
|
+
<rect x="0" y="0" :width="chartWidth" :height="dataTableRowH" fill="#f8fafc" :stroke="gridColor" stroke-width="0.8" />
|
|
1186
|
+
<text
|
|
1187
|
+
v-for="(lbl, cIdx) in labels"
|
|
1188
|
+
:key="'dt-h-' + cIdx"
|
|
1189
|
+
:x="60 + (cIdx + 0.5) * ((chartWidth - 60) / (labels.length || 1))"
|
|
1190
|
+
:y="11"
|
|
1191
|
+
text-anchor="middle"
|
|
1192
|
+
font-size="9"
|
|
1193
|
+
font-weight="600"
|
|
1194
|
+
:fill="textColor"
|
|
1195
|
+
>
|
|
1196
|
+
{{ lbl }}
|
|
1197
|
+
</text>
|
|
1198
|
+
<g
|
|
1199
|
+
v-for="(ds, rIdx) in (isPieFamily ? datasets.slice(0, 1) : datasets.slice(0, 3))"
|
|
1200
|
+
:key="'dt-r-' + rIdx"
|
|
1201
|
+
:transform="`translate(0, ${(rIdx + 1) * dataTableRowH})`"
|
|
1202
|
+
>
|
|
1203
|
+
<rect x="0" y="0" :width="chartWidth" :height="dataTableRowH" fill="#ffffff" :stroke="gridColor" stroke-width="0.8" />
|
|
1204
|
+
<text x="6" y="11" font-size="9" font-weight="600" :fill="textColor">
|
|
1205
|
+
{{ ds.label || `系列${rIdx + 1}` }}
|
|
1206
|
+
</text>
|
|
1207
|
+
<text
|
|
1208
|
+
v-for="(lbl, cIdx) in labels"
|
|
1209
|
+
:key="'dt-c-' + rIdx + '-' + cIdx"
|
|
1210
|
+
:x="60 + (cIdx + 0.5) * ((chartWidth - 60) / (labels.length || 1))"
|
|
1211
|
+
:y="11"
|
|
1212
|
+
text-anchor="middle"
|
|
1213
|
+
font-size="9"
|
|
1214
|
+
:fill="textColor"
|
|
1215
|
+
>
|
|
1216
|
+
{{ ds.data[cIdx] ?? 0 }}
|
|
1217
|
+
</text>
|
|
1218
|
+
</g>
|
|
1219
|
+
</g>
|
|
1220
|
+
|
|
1221
|
+
<!-- Unified Chart Legends for all chart types -->
|
|
1222
|
+
<g v-if="showLegend">
|
|
1223
|
+
<g
|
|
1224
|
+
v-for="(item, idx) in legendItems"
|
|
1225
|
+
:key="'legend-' + idx"
|
|
1226
|
+
:transform="`translate(${item.x}, ${item.y})`"
|
|
1227
|
+
>
|
|
1228
|
+
<rect x="0" y="-8" width="10" height="10" rx="2" :fill="item.color" />
|
|
1229
|
+
<text
|
|
1230
|
+
x="16"
|
|
1231
|
+
y="1"
|
|
1232
|
+
font-size="10"
|
|
1233
|
+
font-weight="600"
|
|
1234
|
+
:fill="textColor"
|
|
1235
|
+
:font-family="fontFamily"
|
|
1236
|
+
>
|
|
1237
|
+
{{ item.label }}{{ item.percent ? ` (${item.percent})` : '' }}
|
|
1238
|
+
</text>
|
|
1239
|
+
</g>
|
|
1240
|
+
</g>
|
|
1241
|
+
</svg>
|
|
1242
|
+
</template>
|