@visactor/vchart-extension 1.13.7-alpha.0 → 1.13.8-alpha.0

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 (43) hide show
  1. package/build/index.js +695 -0
  2. package/build/index.min.js +2 -2
  3. package/cjs/charts/ranking-list/constant.d.ts +2 -0
  4. package/cjs/charts/ranking-list/constant.js +75 -0
  5. package/cjs/charts/ranking-list/constant.js.map +1 -0
  6. package/cjs/charts/ranking-list/interface.d.ts +74 -0
  7. package/cjs/charts/ranking-list/interface.js +6 -0
  8. package/cjs/charts/ranking-list/interface.js.map +1 -0
  9. package/cjs/charts/ranking-list/ranking-list-transformer.d.ts +459 -0
  10. package/cjs/charts/ranking-list/ranking-list-transformer.js +382 -0
  11. package/cjs/charts/ranking-list/ranking-list-transformer.js.map +1 -0
  12. package/cjs/charts/ranking-list/ranking-list.d.ts +16 -0
  13. package/cjs/charts/ranking-list/ranking-list.js +34 -0
  14. package/cjs/charts/ranking-list/ranking-list.js.map +1 -0
  15. package/cjs/charts/ranking-list/utils.d.ts +7 -0
  16. package/cjs/charts/ranking-list/utils.js +51 -0
  17. package/cjs/charts/ranking-list/utils.js.map +1 -0
  18. package/cjs/components/bar-link/index.js +2 -1
  19. package/cjs/components/series-label/type.js +1 -2
  20. package/cjs/index.d.ts +1 -0
  21. package/cjs/index.js +3 -3
  22. package/cjs/index.js.map +1 -1
  23. package/esm/charts/ranking-list/constant.d.ts +2 -0
  24. package/esm/charts/ranking-list/constant.js +69 -0
  25. package/esm/charts/ranking-list/constant.js.map +1 -0
  26. package/esm/charts/ranking-list/interface.d.ts +74 -0
  27. package/esm/charts/ranking-list/interface.js +2 -0
  28. package/esm/charts/ranking-list/interface.js.map +1 -0
  29. package/esm/charts/ranking-list/ranking-list-transformer.d.ts +459 -0
  30. package/esm/charts/ranking-list/ranking-list-transformer.js +382 -0
  31. package/esm/charts/ranking-list/ranking-list-transformer.js.map +1 -0
  32. package/esm/charts/ranking-list/ranking-list.d.ts +16 -0
  33. package/esm/charts/ranking-list/ranking-list.js +27 -0
  34. package/esm/charts/ranking-list/ranking-list.js.map +1 -0
  35. package/esm/charts/ranking-list/utils.d.ts +7 -0
  36. package/esm/charts/ranking-list/utils.js +41 -0
  37. package/esm/charts/ranking-list/utils.js.map +1 -0
  38. package/esm/components/bar-link/index.js +2 -1
  39. package/esm/components/series-label/type.js +1 -2
  40. package/esm/index.d.ts +1 -0
  41. package/esm/index.js +2 -0
  42. package/esm/index.js.map +1 -1
  43. package/package.json +8 -8
package/build/index.js CHANGED
@@ -338,6 +338,699 @@
338
338
  }
339
339
  };
340
340
 
341
+ const cornerRadius = 5;
342
+ const animationDuration = 1000;
343
+ const fontSize = 20;
344
+ const pageSize = 5;
345
+ const scrollSize = 1;
346
+ const primaryFontColor = '#21252c';
347
+ const shadowColor = 'rgba(33,37,44,0.1)';
348
+ const defaultSpec = {
349
+ labelLayout: 'top',
350
+ bar: {
351
+ style: {
352
+ cornerRadius
353
+ }
354
+ },
355
+ barBackground: {
356
+ type: 'rect',
357
+ style: {
358
+ fill: shadowColor,
359
+ cornerRadius
360
+ }
361
+ },
362
+ rankingIcon: {
363
+ visible: true,
364
+ style: {
365
+ fill: primaryFontColor,
366
+ size: fontSize
367
+ }
368
+ },
369
+ nameLabel: {
370
+ visible: true,
371
+ style: {
372
+ fontSize: fontSize,
373
+ fontWeight: 'normal',
374
+ fill: primaryFontColor,
375
+ textBaseline: 'middle'
376
+ }
377
+ },
378
+ orderLabel: {
379
+ visible: true,
380
+ style: {
381
+ fontSize: fontSize,
382
+ fontWeight: 'normal',
383
+ fill: primaryFontColor,
384
+ textBaseline: 'middle'
385
+ }
386
+ },
387
+ valueLabel: {
388
+ visible: true,
389
+ style: {
390
+ fontSize: fontSize,
391
+ fontWeight: 'normal',
392
+ fill: primaryFontColor,
393
+ textBaseline: 'middle'
394
+ }
395
+ },
396
+ pageSize,
397
+ scrollSize,
398
+ animationAppear: {
399
+ enable: true,
400
+ type: 'grow',
401
+ duration: animationDuration,
402
+ easing: 'linear'
403
+ },
404
+ animationUpdate: {
405
+ enable: true,
406
+ type: 'grow',
407
+ duration: animationDuration,
408
+ easing: 'linear'
409
+ },
410
+ animationNormal: {
411
+ interval: animationDuration
412
+ }
413
+ };
414
+
415
+ const applyVisible = (spec, keyList) => {
416
+ keyList.forEach(key => {
417
+ var _a, _b, _c, _d, _e, _f, _g;
418
+ if (vutils.isArray(spec[key])) {
419
+ (_a = spec[key]) === null || _a === void 0 ? void 0 : _a.forEach((s, i) => {
420
+ var _a, _b, _c;
421
+ spec[key][i] = Object.assign(Object.assign({}, s), { style: Object.assign(Object.assign({}, s === null || s === void 0 ? void 0 : s.style), { visible: (_c = (_b = (_a = s === null || s === void 0 ? void 0 : s.style) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : s === null || s === void 0 ? void 0 : s.visible) !== null && _c !== void 0 ? _c : true }) });
422
+ });
423
+ }
424
+ else {
425
+ spec[key] = Object.assign(Object.assign({}, spec[key]), { style: Object.assign(Object.assign({}, (_b = spec[key]) === null || _b === void 0 ? void 0 : _b.style), { visible: (_g = (_e = (_d = (_c = spec[key]) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.visible) !== null && _e !== void 0 ? _e : (_f = spec[key]) === null || _f === void 0 ? void 0 : _f.visible) !== null && _g !== void 0 ? _g : true }) });
426
+ }
427
+ });
428
+ };
429
+ const mergeObjects = (objA, objB) => {
430
+ function recursiveMerge(target, source) {
431
+ for (const key in source) {
432
+ if (key !== '__proto__' &&
433
+ key !== 'constructor' &&
434
+ key !== 'prototype' &&
435
+ typeof source[key] === 'object' &&
436
+ source[key] !== null) {
437
+ if (!target.hasOwnProperty(key)) {
438
+ target[key] = Array.isArray(source[key]) ? [] : {};
439
+ }
440
+ recursiveMerge(target[key], source[key]);
441
+ }
442
+ else if (!target.hasOwnProperty(key) && typeof target === 'object') {
443
+ target[key] = source[key];
444
+ }
445
+ }
446
+ return target;
447
+ }
448
+ return recursiveMerge(objA, objB);
449
+ };
450
+ const computeDataRange = (data, field) => {
451
+ let dataMin, dataMax;
452
+ const datumX = data.map(d => d[field]).filter(d => typeof d !== 'undefined' && d !== null);
453
+ if (datumX.length === 0) {
454
+ dataMin = 0;
455
+ dataMax = 1;
456
+ }
457
+ else {
458
+ dataMin = Math.min(...datumX) - (Math.max(...datumX) - Math.min(...datumX)) / 3;
459
+ dataMax = (Math.max(...datumX) - dataMin) / 0.8 + dataMin;
460
+ const delta_value = 10;
461
+ const data = dataMin;
462
+ if (dataMin === dataMax) {
463
+ dataMin = data - delta_value;
464
+ dataMax = (4 * data + delta_value) / 4;
465
+ }
466
+ }
467
+ return { min: dataMin, max: dataMax };
468
+ };
469
+
470
+ const DATA_KEY = 'dataKey';
471
+ const ORDER_KEY = 'VCHART_ORDER';
472
+ const SUPPLY_DATA_KEY = 'SUPPLY_DATA_KEY';
473
+ const NAME_LABEL_PADDING_RIGHT = 10;
474
+ const NAME_ORDER_PADDING_RIGHT = 5;
475
+ const NAME_SYMBOL_PADDING_RIGHT = 8;
476
+ const CHART_PADDING_LEFT = 5;
477
+ const CHART_PADDING_RIGHT = 5;
478
+ const VALUE_LABEL_PADDING_LEFT = 5;
479
+ const LABEL_PADDING_BOTTOM = 5;
480
+ class RankingListChartSpecTransformer extends vchart.CommonChartSpecTransformer {
481
+ constructor() {
482
+ super(...arguments);
483
+ this.formatMap = {};
484
+ this.paginateDataArr = (spec) => {
485
+ const { scrollSize = 1, pageSize = 5 } = spec;
486
+ const arr = this.originalData;
487
+ const result = {};
488
+ let pageOrder = 0;
489
+ for (let i = 0; i < arr.length; i += scrollSize) {
490
+ pageOrder++;
491
+ result[`page${pageOrder}`] = arr.slice(i, i + pageSize);
492
+ if (i + pageSize - 1 >= arr.length - 1) {
493
+ arr.push(...Array.from({ length: i + pageSize - arr.length }, _ => {
494
+ return {
495
+ [spec.yField]: Math.random() * 100,
496
+ [spec.xField]: null,
497
+ [SUPPLY_DATA_KEY]: true
498
+ };
499
+ }));
500
+ break;
501
+ }
502
+ }
503
+ return {
504
+ orderCount: pageOrder,
505
+ result: result
506
+ };
507
+ };
508
+ this.processRankingData = (spec) => {
509
+ const result = [];
510
+ spec.data.forEach((datum, index) => (datum[ORDER_KEY] = index + 1 < 10 ? `0${index + 1}` : index + 1));
511
+ const pagerData = this.paginateDataArr(spec).result;
512
+ const orderCount = this.paginateDataArr(spec).orderCount;
513
+ this.orderCount = orderCount;
514
+ const supplyCount = spec.pageSize - pagerData[`page${orderCount}`].length;
515
+ pagerData[`page${orderCount}`].push(...Array.from({ length: supplyCount }, _ => {
516
+ return {
517
+ [spec.yField]: Math.random() * 100,
518
+ [spec.xField]: null,
519
+ [SUPPLY_DATA_KEY]: true
520
+ };
521
+ }));
522
+ Object.keys(pagerData).forEach(order => {
523
+ result.push({
524
+ data: [
525
+ {
526
+ id: 'datas',
527
+ values: pagerData[order].map(d => {
528
+ return Object.assign(Object.assign({}, d), { [DATA_KEY]: d[spec.yField] });
529
+ })
530
+ },
531
+ {
532
+ id: 'order',
533
+ values: [
534
+ {
535
+ order
536
+ }
537
+ ]
538
+ }
539
+ ]
540
+ });
541
+ });
542
+ return result;
543
+ };
544
+ }
545
+ isSpecValid(spec) {
546
+ const { xField, yField, data } = spec;
547
+ if (!xField || !yField || !data || data.length === 0) {
548
+ return false;
549
+ }
550
+ return true;
551
+ }
552
+ transformSpec(spec) {
553
+ var _a;
554
+ super.transformSpec(spec);
555
+ if (!this.isSpecValid(spec)) {
556
+ spec.series = [];
557
+ return;
558
+ }
559
+ this.normalizeSpec(spec);
560
+ this.upgradeTextMeasure(spec);
561
+ this.upgradeFormatMap(spec);
562
+ this.processData(spec);
563
+ this.transformBaseSpec(spec);
564
+ this.transformAnimationSpec(spec);
565
+ this.transformAxesSpec(spec);
566
+ spec.extensionMark = [
567
+ this.generateBarBackground(spec),
568
+ ...this.generateDecorateHaloIcons(spec),
569
+ this.generateRankingIcon(spec),
570
+ this.generateNameLabel(spec),
571
+ this.generateOrderLabel(spec),
572
+ this.generateValueLabel(spec)
573
+ ];
574
+ this.transformPaddingSpec(spec);
575
+ (_a = spec.customTransformSpec) === null || _a === void 0 ? void 0 : _a.call(spec, spec);
576
+ super.transformSpec(spec);
577
+ }
578
+ normalizeSpec(spec) {
579
+ mergeObjects(spec, defaultSpec);
580
+ applyVisible(spec, [
581
+ 'barBackground',
582
+ 'rankingIcon',
583
+ 'decorateHaloIcons',
584
+ 'orderLabel',
585
+ 'nameLabel',
586
+ 'valueLabel'
587
+ ]);
588
+ }
589
+ upgradeTextMeasure(spec) {
590
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
591
+ (_a = this.nameLabelTextMeasure) === null || _a === void 0 ? void 0 : _a.release();
592
+ (_b = this.valueLabelTextMeasure) === null || _b === void 0 ? void 0 : _b.release();
593
+ (_c = this.orderLabelTextMeasure) === null || _c === void 0 ? void 0 : _c.release();
594
+ this.nameLabelTextMeasure = new vutils.TextMeasure({
595
+ defaultFontParams: (_e = (_d = spec.nameLabel) === null || _d === void 0 ? void 0 : _d.style) !== null && _e !== void 0 ? _e : {}
596
+ });
597
+ this.valueLabelTextMeasure = new vutils.TextMeasure({
598
+ defaultFontParams: (_g = (_f = spec.valueLabel) === null || _f === void 0 ? void 0 : _f.style) !== null && _g !== void 0 ? _g : {}
599
+ });
600
+ this.orderLabelTextMeasure = new vutils.TextMeasure({
601
+ defaultFontParams: (_j = (_h = spec.orderLabel) === null || _h === void 0 ? void 0 : _h.style) !== null && _j !== void 0 ? _j : {}
602
+ });
603
+ }
604
+ upgradeFormatMap(spec) {
605
+ this.formatMap[spec.yField] = spec.nameLabel.formatMethod;
606
+ this.formatMap[spec.xField] = spec.valueLabel.formatMethod;
607
+ this.formatMap[ORDER_KEY] = spec.orderLabel.formatMethod;
608
+ }
609
+ processData(spec) {
610
+ var _a;
611
+ if (!((_a = spec.data[0]) === null || _a === void 0 ? void 0 : _a.values)) {
612
+ this.originalData = spec.data;
613
+ this.originalSpec = vutils.cloneDeep(spec);
614
+ this.dataSpecs = this.processRankingData(spec);
615
+ spec.data = this.dataSpecs[0].data;
616
+ }
617
+ }
618
+ transformBaseSpec(spec) {
619
+ var _a, _b, _c;
620
+ spec.type = 'common';
621
+ spec.dataKey = DATA_KEY;
622
+ spec.series = [
623
+ {
624
+ type: 'bar',
625
+ direction: 'horizontal',
626
+ xField: spec.xField,
627
+ yField: spec.yField,
628
+ barWidth: (_b = (_a = spec.bar) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 10,
629
+ bar: Object.assign(Object.assign({}, spec.bar), { style: Object.assign(Object.assign({}, (_c = spec.bar) === null || _c === void 0 ? void 0 : _c.style), { x1: 0, visible: (datum) => {
630
+ var _a, _b;
631
+ if (datum[SUPPLY_DATA_KEY]) {
632
+ return false;
633
+ }
634
+ return (_b = (_a = spec.bar) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : true;
635
+ } }) })
636
+ }
637
+ ];
638
+ }
639
+ transformAnimationSpec(spec) {
640
+ var _a, _b, _c;
641
+ if (spec.animationUpdate.enable && this.orderCount > 1) {
642
+ spec.player = Object.assign({ specs: this.dataSpecs, auto: true, visible: false, interval: ((_b = (_a = spec.animationNormal) === null || _a === void 0 ? void 0 : _a.interval) !== null && _b !== void 0 ? _b : 1000) + ((_c = spec.animationUpdate.duration) !== null && _c !== void 0 ? _c : 1000) / 2, loop: true }, spec.player);
643
+ spec.animationExit = this.getAnimationExit(this.originalSpec);
644
+ spec.animationEnter = this.getAnimationEnter(this.originalSpec);
645
+ spec.animationUpdate = this.getAnimationUpdate(this.originalSpec);
646
+ }
647
+ spec.animationNormal = this.originalSpec.animationNormal;
648
+ spec.animationAppear = this.getAnimationAppear(this.originalSpec, 'rect');
649
+ }
650
+ transformAxesSpec(spec) {
651
+ const { min, max } = computeDataRange(this.originalData, spec.xField);
652
+ spec.axes = [
653
+ {
654
+ orient: 'left',
655
+ type: 'band',
656
+ visible: false,
657
+ inverse: true,
658
+ paddingOuter: 0.5
659
+ },
660
+ {
661
+ orient: 'bottom',
662
+ label: { visible: true },
663
+ type: 'linear',
664
+ visible: false,
665
+ min,
666
+ max
667
+ }
668
+ ];
669
+ }
670
+ generateBarBackground(spec) {
671
+ var _a;
672
+ return {
673
+ type: spec.barBackground.type,
674
+ dataId: 'data',
675
+ visible: true,
676
+ dataKey: DATA_KEY,
677
+ zIndex: -99,
678
+ state: (_a = spec.barBackground) === null || _a === void 0 ? void 0 : _a.state,
679
+ style: Object.assign(Object.assign({ x: (datum, ctx) => spec.barBackground.type === 'symbol' ? ctx.getRegion().getLayoutRect().width / 2 : 0, y: (datum, ctx) => {
680
+ return (ctx.valueToY([datum[spec.yField]]) +
681
+ ctx.yBandwidth() / 2 -
682
+ (spec.barBackground.type === 'symbol' ? 0 : spec.bar.height / 2));
683
+ }, size: (datum, ctx) => [ctx.getRegion().getLayoutRect().width, spec.bar.height], width: (datum, ctx) => ctx.getRegion().getLayoutRect().width, height: spec.bar.height }, spec.barBackground.style), { visible: (datum) => {
684
+ if (datum[SUPPLY_DATA_KEY]) {
685
+ return false;
686
+ }
687
+ return spec.barBackground.style.visible;
688
+ } }),
689
+ animation: true,
690
+ animationEnter: this.getAnimationEnter(this.originalSpec),
691
+ animationExit: this.getAnimationExit(this.originalSpec),
692
+ animationAppear: this.getAnimationAppear(this.originalSpec, 'barBack'),
693
+ animationUpdate: this.getAnimationUpdate(this.originalSpec)
694
+ };
695
+ }
696
+ generateDecorateHaloIcons(spec) {
697
+ var _a;
698
+ return (_a = spec.decorateHaloIcons) === null || _a === void 0 ? void 0 : _a.map((decorateHaloIcon) => {
699
+ return {
700
+ type: 'symbol',
701
+ dataId: 'data',
702
+ visible: true,
703
+ dataKey: DATA_KEY,
704
+ state: decorateHaloIcon === null || decorateHaloIcon === void 0 ? void 0 : decorateHaloIcon.state,
705
+ style: Object.assign(Object.assign({ x: (datum, ctx) => {
706
+ if (datum[spec.xField] === undefined || datum[spec.xField] === null) {
707
+ return undefined;
708
+ }
709
+ return ctx.valueToX([datum[spec.xField]]);
710
+ }, y: (datum, ctx) => {
711
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
712
+ } }, decorateHaloIcon.style), { visible: (datum) => {
713
+ if (datum[SUPPLY_DATA_KEY]) {
714
+ return false;
715
+ }
716
+ return decorateHaloIcon.style.visible;
717
+ } }),
718
+ animation: true,
719
+ animationEnter: this.getAnimationEnter(this.originalSpec),
720
+ animationExit: this.getAnimationExit(this.originalSpec),
721
+ animationAppear: this.getAnimationAppear(this.originalSpec, 'symbol'),
722
+ animationUpdate: this.getAnimationUpdate(this.originalSpec)
723
+ };
724
+ });
725
+ }
726
+ generateRankingIcon(spec) {
727
+ return {
728
+ type: 'symbol',
729
+ dataId: 'data',
730
+ visible: true,
731
+ dataKey: DATA_KEY,
732
+ state: spec.rankingIcon.state,
733
+ style: Object.assign(Object.assign({ x: (datum) => {
734
+ if (spec.labelLayout === 'bothEnd') {
735
+ return -(NAME_LABEL_PADDING_RIGHT +
736
+ this.nameLabelTextMeasure.fullMeasure(this.formatDatum(spec.yField, datum)).width +
737
+ (spec.orderLabel.style.visible
738
+ ? NAME_ORDER_PADDING_RIGHT +
739
+ this.orderLabelTextMeasure.fullMeasure(this.formatDatum(ORDER_KEY, datum)).width
740
+ : 0) +
741
+ NAME_SYMBOL_PADDING_RIGHT);
742
+ }
743
+ return CHART_PADDING_LEFT;
744
+ }, y: (datum, ctx) => {
745
+ if (spec.labelLayout === 'bothEnd') {
746
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
747
+ }
748
+ return (ctx.valueToY([datum[spec.yField]]) +
749
+ ctx.yBandwidth() / 2 -
750
+ spec.bar.height / 2 -
751
+ LABEL_PADDING_BOTTOM -
752
+ Math.max(this.nameLabelTextMeasure.fullMeasure(this.formatDatum(spec.yField, datum)).height, this.orderLabelTextMeasure.fullMeasure(this.formatDatum(ORDER_KEY, datum)).height) /
753
+ 2);
754
+ } }, spec.rankingIcon.style), { lineWidth: 0, stroke: null, visible: (datum) => {
755
+ if (datum[SUPPLY_DATA_KEY]) {
756
+ return false;
757
+ }
758
+ return spec.rankingIcon.style.visible;
759
+ } }),
760
+ animation: true,
761
+ animationEnter: this.getAnimationEnter(this.originalSpec),
762
+ animationExit: this.getAnimationExit(this.originalSpec),
763
+ animationAppear: this.getAnimationAppear(this.originalSpec, 'text'),
764
+ animationUpdate: this.getAnimationUpdate(this.originalSpec)
765
+ };
766
+ }
767
+ generateNameLabel(spec) {
768
+ var _a;
769
+ return {
770
+ type: 'text',
771
+ dataId: 'data',
772
+ dataKey: DATA_KEY,
773
+ state: (_a = spec.nameLabel) === null || _a === void 0 ? void 0 : _a.state,
774
+ style: Object.assign(Object.assign({ text: (datum) => this.formatDatum(spec.yField, datum), x: () => {
775
+ var _a;
776
+ if (spec.labelLayout === 'bothEnd') {
777
+ return -NAME_LABEL_PADDING_RIGHT;
778
+ }
779
+ return ((spec.rankingIcon.style.visible ? NAME_SYMBOL_PADDING_RIGHT + ((_a = spec.rankingIcon.style.size) !== null && _a !== void 0 ? _a : 10) : 0) +
780
+ (spec.orderLabel.style.visible
781
+ ? NAME_ORDER_PADDING_RIGHT + this.getMaxDataLabelLens(spec, ORDER_KEY, this.orderLabelTextMeasure)
782
+ : 0));
783
+ }, y: (datum, ctx) => {
784
+ if (spec.labelLayout === 'bothEnd') {
785
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
786
+ }
787
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2 - spec.bar.height / 2 - LABEL_PADDING_BOTTOM;
788
+ } }, spec.nameLabel.style), { textAlign: spec.labelLayout === 'bothEnd' ? 'right' : 'left', textBaseline: spec.labelLayout === 'bothEnd' ? 'middle' : 'bottom', visible: (datum) => {
789
+ if (datum[SUPPLY_DATA_KEY]) {
790
+ return false;
791
+ }
792
+ return spec.nameLabel.style.visible;
793
+ } }),
794
+ animation: true,
795
+ animationEnter: this.getAnimationEnter(this.originalSpec),
796
+ animationExit: this.getAnimationExit(this.originalSpec),
797
+ animationAppear: this.getAnimationAppear(this.originalSpec, 'text'),
798
+ animationUpdate: this.getAnimationUpdate(this.originalSpec)
799
+ };
800
+ }
801
+ generateOrderLabel(spec) {
802
+ var _a;
803
+ return {
804
+ type: 'text',
805
+ dataId: 'data',
806
+ dataKey: DATA_KEY,
807
+ state: (_a = spec.orderLabel) === null || _a === void 0 ? void 0 : _a.state,
808
+ style: Object.assign(Object.assign({ text: (datum) => this.formatDatum(ORDER_KEY, datum), x: (datum) => {
809
+ var _a;
810
+ if (spec.labelLayout === 'bothEnd') {
811
+ return -(NAME_LABEL_PADDING_RIGHT +
812
+ this.nameLabelTextMeasure.fullMeasure(this.formatDatum(spec.yField, datum)).width +
813
+ NAME_ORDER_PADDING_RIGHT);
814
+ }
815
+ else {
816
+ return spec.rankingIcon.style.visible ? NAME_SYMBOL_PADDING_RIGHT + ((_a = spec.rankingIcon.style.size) !== null && _a !== void 0 ? _a : 10) : 0;
817
+ }
818
+ }, y: (datum, ctx) => {
819
+ if (spec.labelLayout === 'bothEnd') {
820
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
821
+ }
822
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2 - spec.bar.height / 2 - LABEL_PADDING_BOTTOM;
823
+ } }, spec.orderLabel.style), { textAlign: spec.labelLayout === 'bothEnd' ? 'right' : 'left', textBaseline: spec.labelLayout === 'bothEnd' ? 'middle' : 'bottom', visible: (datum) => {
824
+ if (datum[SUPPLY_DATA_KEY]) {
825
+ return false;
826
+ }
827
+ return spec.orderLabel.style.visible;
828
+ } }),
829
+ animation: true,
830
+ animationEnter: this.getAnimationEnter(this.originalSpec),
831
+ animationExit: this.getAnimationExit(this.originalSpec),
832
+ animationAppear: this.getAnimationAppear(this.originalSpec, 'text'),
833
+ animationUpdate: this.getAnimationUpdate(this.originalSpec)
834
+ };
835
+ }
836
+ generateValueLabel(spec) {
837
+ var _a;
838
+ return {
839
+ type: 'text',
840
+ dataId: 'data',
841
+ visible: true,
842
+ dataKey: DATA_KEY,
843
+ state: (_a = spec.valueLabel) === null || _a === void 0 ? void 0 : _a.state,
844
+ style: Object.assign(Object.assign({ text: (datum) => this.formatDatum(spec.xField, datum), x: (datum, ctx) => {
845
+ if (spec.labelLayout === 'bothEnd') {
846
+ return (ctx.getRegion().getLayoutRect().width +
847
+ VALUE_LABEL_PADDING_LEFT);
848
+ }
849
+ else {
850
+ return ctx.getRegion().getLayoutRect().width;
851
+ }
852
+ }, y: (datum, ctx) => {
853
+ if (spec.labelLayout === 'bothEnd') {
854
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
855
+ }
856
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2 - spec.bar.height / 2 - LABEL_PADDING_BOTTOM;
857
+ } }, spec.valueLabel.style), { textAlign: spec.labelLayout === 'bothEnd' ? 'left' : 'right', textBaseline: spec.labelLayout === 'bothEnd' ? 'middle' : 'bottom', visible: (datum) => {
858
+ if (datum[SUPPLY_DATA_KEY]) {
859
+ return false;
860
+ }
861
+ return spec.valueLabel.style.visible;
862
+ } }),
863
+ animation: true,
864
+ animationEnter: this.getAnimationEnter(this.originalSpec),
865
+ animationExit: this.getAnimationExit(this.originalSpec),
866
+ animationAppear: this.getAnimationAppear(this.originalSpec, 'text'),
867
+ animationUpdate: this.getAnimationUpdate(this.originalSpec)
868
+ };
869
+ }
870
+ transformPaddingSpec(spec) {
871
+ var _a;
872
+ const maxHaloIconSize = spec.decorateHaloIcons.length > 0
873
+ ? Math.max(...spec.decorateHaloIcons.map((icon) => { var _a, _b; return (_b = (_a = icon.style) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : 18; }))
874
+ : 0;
875
+ spec.padding = Object.assign({ left: spec.labelLayout === 'bothEnd'
876
+ ? NAME_LABEL_PADDING_RIGHT +
877
+ this.getMaxDataLabelLens(spec, spec.yField, this.nameLabelTextMeasure) +
878
+ (spec.orderLabel.style.visible
879
+ ? NAME_ORDER_PADDING_RIGHT + this.getMaxDataLabelLens(spec, ORDER_KEY, this.orderLabelTextMeasure)
880
+ : 0) +
881
+ (spec.rankingIcon.style.visible ? NAME_SYMBOL_PADDING_RIGHT + ((_a = spec.rankingIcon.style.size) !== null && _a !== void 0 ? _a : 10) : 0) +
882
+ CHART_PADDING_LEFT
883
+ : CHART_PADDING_LEFT + maxHaloIconSize / 2, right: spec.labelLayout === 'bothEnd'
884
+ ? VALUE_LABEL_PADDING_LEFT +
885
+ this.getMaxDataLabelLens(spec, spec.xField, this.valueLabelTextMeasure) +
886
+ CHART_PADDING_RIGHT
887
+ : CHART_PADDING_RIGHT + 10, top: 0, bottom: 0 }, spec.padding);
888
+ }
889
+ getMaxDataLabelLens(spec, field, textMeasure) {
890
+ const textWidths = this.originalData.map(datum => datum[SUPPLY_DATA_KEY] ? 0 : textMeasure.fullMeasure(this.formatDatum(field, datum)).width);
891
+ return Math.max(...textWidths);
892
+ }
893
+ formatDatum(field, datum) {
894
+ var _a;
895
+ if ((_a = this.formatMap) === null || _a === void 0 ? void 0 : _a[field]) {
896
+ return this.formatMap[field](datum[field], datum);
897
+ }
898
+ else {
899
+ return datum[field];
900
+ }
901
+ }
902
+ getLabelWidth(padding, width) {
903
+ return width + padding;
904
+ }
905
+ getAnimationExit(spec) {
906
+ var _a, _b, _c, _d, _e;
907
+ if (((_a = spec.animationUpdate) === null || _a === void 0 ? void 0 : _a.enable) === false) {
908
+ return false;
909
+ }
910
+ return {
911
+ type: 'moveOut',
912
+ options: {
913
+ direction: 'y',
914
+ orient: 'negative',
915
+ point: (datum, element) => {
916
+ const channelAttr = element.getGraphicAttribute('y');
917
+ const barSpace = spec.height / (spec.pageSize + 1);
918
+ return { y: channelAttr - barSpace * Math.min(spec.scrollSize, spec.pageSize) };
919
+ }
920
+ },
921
+ duration: (_c = (_b = spec.animationUpdate) === null || _b === void 0 ? void 0 : _b.duration) !== null && _c !== void 0 ? _c : 1000,
922
+ easing: (_e = (_d = spec.animationUpdate) === null || _d === void 0 ? void 0 : _d.easing) !== null && _e !== void 0 ? _e : 'linear'
923
+ };
924
+ }
925
+ getAnimationEnter(spec) {
926
+ var _a, _b, _c, _d, _e;
927
+ if (((_a = spec.animationUpdate) === null || _a === void 0 ? void 0 : _a.enable) === false) {
928
+ return false;
929
+ }
930
+ return {
931
+ type: 'moveIn',
932
+ options: {
933
+ direction: 'y',
934
+ orient: 'negative',
935
+ excludeChannels: ['y'],
936
+ point: (datum, element) => {
937
+ const channelAttr = element.getGraphicAttribute('y');
938
+ return { y: channelAttr + (spec.height / (spec.pageSize + 1)) * Math.min(spec.scrollSize, spec.pageSize) };
939
+ }
940
+ },
941
+ duration: (_c = (_b = spec.animationUpdate) === null || _b === void 0 ? void 0 : _b.duration) !== null && _c !== void 0 ? _c : 1000,
942
+ easing: (_e = (_d = spec.animationUpdate) === null || _d === void 0 ? void 0 : _d.easing) !== null && _e !== void 0 ? _e : 'linear'
943
+ };
944
+ }
945
+ getAnimationAppear(spec, markType) {
946
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
947
+ if (((_a = spec.animationAppear) === null || _a === void 0 ? void 0 : _a.enable) === false) {
948
+ return false;
949
+ }
950
+ if (markType === 'rect') {
951
+ return {
952
+ type: 'growWidthIn',
953
+ oneByOne: false,
954
+ duration: (_c = (_b = spec.animationAppear) === null || _b === void 0 ? void 0 : _b.duration) !== null && _c !== void 0 ? _c : 1000,
955
+ easing: (_e = (_d = spec.animationAppear) === null || _d === void 0 ? void 0 : _d.easing) !== null && _e !== void 0 ? _e : 'linear',
956
+ options: {}
957
+ };
958
+ }
959
+ else if (markType === 'symbol') {
960
+ return {
961
+ channel: {
962
+ x: {
963
+ from: 0,
964
+ to: (datum, element) => {
965
+ return element.getGraphicItem().attribute.x;
966
+ }
967
+ }
968
+ },
969
+ duration: (_g = (_f = spec.animationAppear) === null || _f === void 0 ? void 0 : _f.duration) !== null && _g !== void 0 ? _g : 1000,
970
+ easing: (_j = (_h = spec.animationAppear) === null || _h === void 0 ? void 0 : _h.easing) !== null && _j !== void 0 ? _j : 'linear'
971
+ };
972
+ }
973
+ else {
974
+ return {
975
+ channel: {
976
+ opacity: {
977
+ from: 0,
978
+ to: 1
979
+ }
980
+ },
981
+ duration: (_l = (_k = spec.animationAppear) === null || _k === void 0 ? void 0 : _k.duration) !== null && _l !== void 0 ? _l : 1000,
982
+ easing: (_o = (_m = spec.animationAppear) === null || _m === void 0 ? void 0 : _m.easing) !== null && _o !== void 0 ? _o : 'linear'
983
+ };
984
+ }
985
+ }
986
+ getAnimationUpdate(spec) {
987
+ var _a, _b, _c, _d;
988
+ if (spec.animationUpdate.enable === false) {
989
+ return false;
990
+ }
991
+ return {
992
+ duration: (_b = (_a = spec.animationUpdate) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 1000,
993
+ easing: (_d = (_c = spec.animationUpdate) === null || _c === void 0 ? void 0 : _c.easing) !== null && _d !== void 0 ? _d : 'linear'
994
+ };
995
+ }
996
+ }
997
+
998
+ class RankingList extends vchart.BaseChart {
999
+ constructor() {
1000
+ super(...arguments);
1001
+ this.type = 'rankingList';
1002
+ this.transformerConstructor = RankingListChartSpecTransformer;
1003
+ }
1004
+ init() {
1005
+ if (!this.isValid()) {
1006
+ return;
1007
+ }
1008
+ super.init();
1009
+ }
1010
+ isValid() {
1011
+ var _a, _b, _c, _d;
1012
+ const { xField, yField, data } = this._spec;
1013
+ if (!xField || !yField) {
1014
+ (_b = (_a = this._option).onError) === null || _b === void 0 ? void 0 : _b.call(_a, 'Missing Required Config: `xField`, `yField` ');
1015
+ return false;
1016
+ }
1017
+ if (!data) {
1018
+ (_d = (_c = this._option).onError) === null || _d === void 0 ? void 0 : _d.call(_c, 'Data is required');
1019
+ return false;
1020
+ }
1021
+ return true;
1022
+ }
1023
+ }
1024
+ RankingList.type = 'rankingList';
1025
+ RankingList.view = 'singleDefault';
1026
+ RankingList.transformerConstructor = RankingListChartSpecTransformer;
1027
+ const registerRankingList = (option) => {
1028
+ const vchartConstructor = (option === null || option === void 0 ? void 0 : option.VChart) || vchart.VChart;
1029
+ if (vchartConstructor) {
1030
+ vchartConstructor.useChart([RankingList, vchart.BarChart]);
1031
+ }
1032
+ };
1033
+
341
1034
  const fields = (data, options) => {
342
1035
  var _a, _b;
343
1036
  if (!(null == options ? void 0 : options.fields)) return data;
@@ -10656,6 +11349,7 @@
10656
11349
  exports.DEFAULT_ARROW_TEXT_MARK_STYLE = DEFAULT_ARROW_TEXT_MARK_STYLE;
10657
11350
  exports.DEFAULT_FUNNEL_BACKGROUND_MARK_STYLE = DEFAULT_FUNNEL_BACKGROUND_MARK_STYLE;
10658
11351
  exports.RankingBar = RankingBar;
11352
+ exports.RankingList = RankingList;
10659
11353
  exports.SERIES_BREAK = SERIES_BREAK;
10660
11354
  exports.SeriesBreakComponent = SeriesBreakComponent;
10661
11355
  exports.SeriesLabelComponent = SeriesLabelComponent;
@@ -10668,6 +11362,7 @@
10668
11362
  exports.registerBarLink = registerBarLink;
10669
11363
  exports.registerConversionFunnelChart = registerConversionFunnelChart;
10670
11364
  exports.registerRankingBarChart = registerRankingBarChart;
11365
+ exports.registerRankingList = registerRankingList;
10671
11366
  exports.registerSeriesBreak = registerSeriesBreak;
10672
11367
  exports.registerSeriesLabel = registerSeriesLabel;
10673
11368