@visactor/vchart-extension 1.13.3-alpha.4 → 1.13.3-alpha.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 (43) hide show
  1. package/build/index.js +603 -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 +65 -0
  5. package/cjs/charts/ranking-list/constant.js.map +1 -0
  6. package/cjs/charts/ranking-list/interface.d.ts +55 -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 +472 -0
  10. package/cjs/charts/ranking-list/ranking-list-transformer.js +334 -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 +44 -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 +61 -0
  25. package/esm/charts/ranking-list/constant.js.map +1 -0
  26. package/esm/charts/ranking-list/interface.d.ts +55 -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 +472 -0
  30. package/esm/charts/ranking-list/ranking-list-transformer.js +334 -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 +32 -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 +5 -4
package/build/index.js CHANGED
@@ -338,6 +338,607 @@
338
338
  }
339
339
  };
340
340
 
341
+ const defaultSpec = {
342
+ width: 400,
343
+ height: 225,
344
+ labelLayout: 'top',
345
+ bar: {
346
+ height: 100,
347
+ style: {
348
+ cornerRadius: 5
349
+ }
350
+ },
351
+ barBackground: {
352
+ type: 'rect',
353
+ style: {
354
+ fill: 'rgba(255,255,255,0.1)',
355
+ cornerRadius: 5
356
+ }
357
+ },
358
+ rankingIcon: {
359
+ visible: true,
360
+ style: {
361
+ fill: 'rgba(253,253,253,0.5)',
362
+ size: 12
363
+ }
364
+ },
365
+ nameLabel: {
366
+ visible: true,
367
+ style: {
368
+ fontSize: 20,
369
+ fontWeight: 'normal',
370
+ fill: 'rgba(255,255,255,0.7)',
371
+ textBaseline: 'middle'
372
+ }
373
+ },
374
+ orderLabel: {
375
+ visible: true,
376
+ style: {
377
+ fontSize: 20,
378
+ fontWeight: 'normal',
379
+ fill: 'rgba(255,255,255,0.7)',
380
+ textBaseline: 'middle'
381
+ }
382
+ },
383
+ valueLabel: {
384
+ visible: true,
385
+ style: {
386
+ fontSize: 14,
387
+ fontWeight: 'normal',
388
+ fill: 'rgba(255,255,255,1)',
389
+ textBaseline: 'middle'
390
+ }
391
+ },
392
+ pageSize: 5,
393
+ scrollSize: 1,
394
+ animation: {
395
+ type: 'both',
396
+ interval: 4000,
397
+ duration: 2000,
398
+ easing: 'linear'
399
+ }
400
+ };
401
+
402
+ const applyVisible = (spec, keyList) => {
403
+ keyList.forEach(key => {
404
+ var _a, _b, _c, _d, _e, _f;
405
+ spec[key] = Object.assign(Object.assign({}, spec[key]), { style: Object.assign(Object.assign({}, (_a = spec[key]) === null || _a === void 0 ? void 0 : _a.style), { visible: (_f = (_d = (_c = (_b = spec[key]) === null || _b === void 0 ? void 0 : _b.style) === null || _c === void 0 ? void 0 : _c.visible) !== null && _d !== void 0 ? _d : (_e = spec[key]) === null || _e === void 0 ? void 0 : _e.visible) !== null && _f !== void 0 ? _f : true }) });
406
+ });
407
+ };
408
+ const mergeObjects = (objA, objB) => {
409
+ function recursiveMerge(target, source) {
410
+ for (const key in source) {
411
+ if (typeof source[key] === 'object' && source[key] !== null) {
412
+ if (!target.hasOwnProperty(key)) {
413
+ target[key] = Array.isArray(source[key]) ? [] : {};
414
+ }
415
+ recursiveMerge(target[key], source[key]);
416
+ }
417
+ else if (!target.hasOwnProperty(key) && typeof target === 'object') {
418
+ target[key] = source[key];
419
+ }
420
+ }
421
+ return target;
422
+ }
423
+ return recursiveMerge(objA, objB);
424
+ };
425
+ const computeDataRange = (data, field) => {
426
+ let dataMin, dataMax;
427
+ const datumX = data.map(d => d[field]).filter(d => typeof d !== 'undefined' && d !== null);
428
+ if (datumX.length === 0) {
429
+ dataMin = 0;
430
+ dataMax = 1;
431
+ }
432
+ else {
433
+ dataMin = Math.min(...datumX) - (Math.max(...datumX) - Math.min(...datumX)) / 3;
434
+ dataMax = (Math.max(...datumX) - dataMin) / 0.8 + dataMin;
435
+ const delta_value = 10;
436
+ const data = dataMin;
437
+ if (dataMin === dataMax) {
438
+ dataMin = data - delta_value;
439
+ dataMax = (4 * data + delta_value) / 4;
440
+ }
441
+ }
442
+ return { min: dataMin, max: dataMax };
443
+ };
444
+
445
+ const DATA_KEY = 'dataKey';
446
+ const ORDER_KEY = 'VCHART_ORDER';
447
+ const SUPPLY_DATA_KEY = 'SUPPLY_DATA_KEY';
448
+ const NAME_LABEL_PADDING_RIGHT = 10;
449
+ const NAME_ORDER_PADDING_RIGHT = 5;
450
+ const NAME_SYMBOL_PADDING_RIGHT = 8;
451
+ const CHART_PADDING_LEFT = 5;
452
+ const CHART_PADDING_RIGHT = 5;
453
+ const VALUE_LABEL_PADDING_LEFT = 5;
454
+ const LABEL_PADDING_BOTTOM = 5;
455
+ class RankingListChartSpecTransformer extends vchart.CommonChartSpecTransformer {
456
+ constructor() {
457
+ super(...arguments);
458
+ this.formatMap = {};
459
+ this.paginateDataArr = (spec) => {
460
+ const { data: arr, scrollSize = 1, pageSize = 5 } = spec;
461
+ const result = {};
462
+ let pageOrder = 0;
463
+ for (let i = 0; i < arr.length; i += scrollSize) {
464
+ pageOrder++;
465
+ result[`page${pageOrder}`] = arr.slice(i, i + pageSize);
466
+ if (i + pageSize - 1 >= arr.length - 1) {
467
+ arr.push(...Array.from({ length: i + pageSize - arr.length }, _ => {
468
+ return {
469
+ [spec.yField]: Math.random() * 100,
470
+ [spec.xField]: null,
471
+ [SUPPLY_DATA_KEY]: true
472
+ };
473
+ }));
474
+ break;
475
+ }
476
+ }
477
+ return {
478
+ orderCount: pageOrder,
479
+ result: result
480
+ };
481
+ };
482
+ this.processRankingData = (spec) => {
483
+ const result = [];
484
+ spec.data.forEach((datum, index) => (datum[ORDER_KEY] = index + 1 < 10 ? `0${index + 1}` : index + 1));
485
+ const pagerData = this.paginateDataArr(spec).result;
486
+ const orderCount = this.paginateDataArr(spec).orderCount;
487
+ const supplyCount = spec.pageSize - pagerData[`page${orderCount}`].length;
488
+ pagerData[`page${orderCount}`].push(...Array.from({ length: supplyCount }, _ => {
489
+ return {
490
+ [spec.yField]: Math.random() * 100,
491
+ [spec.xField]: null,
492
+ [SUPPLY_DATA_KEY]: true
493
+ };
494
+ }));
495
+ Object.keys(pagerData).forEach(order => {
496
+ result.push({
497
+ data: [
498
+ {
499
+ id: 'datas',
500
+ values: pagerData[order].map((d, i) => {
501
+ return Object.assign(Object.assign({}, d), { [DATA_KEY]: order + '_' + i + '_' + new Date().getTime() });
502
+ })
503
+ },
504
+ {
505
+ id: 'order',
506
+ values: [
507
+ {
508
+ order
509
+ }
510
+ ]
511
+ }
512
+ ]
513
+ });
514
+ });
515
+ return result;
516
+ };
517
+ }
518
+ transformSpec(spec) {
519
+ super.transformSpec(spec);
520
+ this.normalizeSpec(spec);
521
+ this.upgradeTextMeasure(spec);
522
+ this.upgradeFormatMap(spec);
523
+ this.processData(spec);
524
+ this.transformBaseSpec(spec);
525
+ this.transformAnimationSpec(spec);
526
+ this.transformAxesSpec(spec);
527
+ spec.extensionMark = [
528
+ this.generateBarBackground(spec),
529
+ ...this.generateDecorateHaloIcons(spec),
530
+ this.generateRankingIcon(spec),
531
+ this.generateNameLabel(spec),
532
+ this.generateOrderLabel(spec),
533
+ this.generateValueLabel(spec)
534
+ ];
535
+ this.transformPaddingSpec(spec);
536
+ super.transformSpec(spec);
537
+ }
538
+ normalizeSpec(spec) {
539
+ mergeObjects(spec, defaultSpec);
540
+ applyVisible(spec, [
541
+ 'barBackground',
542
+ 'rankingIcon',
543
+ 'decorateHaloIcon',
544
+ 'orderLabel',
545
+ 'nameLabel',
546
+ 'valueLabel'
547
+ ]);
548
+ }
549
+ upgradeTextMeasure(spec) {
550
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
551
+ (_a = this.nameLabelTextMeasure) === null || _a === void 0 ? void 0 : _a.release();
552
+ (_b = this.valueLabelTextMeasure) === null || _b === void 0 ? void 0 : _b.release();
553
+ (_c = this.orderLabelTextMeasure) === null || _c === void 0 ? void 0 : _c.release();
554
+ this.nameLabelTextMeasure = new vutils.TextMeasure({
555
+ defaultFontParams: (_e = (_d = spec.nameLabel) === null || _d === void 0 ? void 0 : _d.style) !== null && _e !== void 0 ? _e : {}
556
+ });
557
+ this.valueLabelTextMeasure = new vutils.TextMeasure({
558
+ defaultFontParams: (_g = (_f = spec.valueLabel) === null || _f === void 0 ? void 0 : _f.style) !== null && _g !== void 0 ? _g : {}
559
+ });
560
+ this.orderLabelTextMeasure = new vutils.TextMeasure({
561
+ defaultFontParams: (_j = (_h = spec.orderLabel) === null || _h === void 0 ? void 0 : _h.style) !== null && _j !== void 0 ? _j : {}
562
+ });
563
+ }
564
+ upgradeFormatMap(spec) {
565
+ this.formatMap[spec.yField] = spec.nameLabel.formatMethod;
566
+ this.formatMap[spec.xField] = spec.valueLabel.formatMethod;
567
+ this.formatMap[ORDER_KEY] = spec.orderLabel.formatMethod;
568
+ }
569
+ processData(spec) {
570
+ var _a;
571
+ if (!((_a = spec.data[0]) === null || _a === void 0 ? void 0 : _a.values)) {
572
+ this.dataSpecs = this.processRankingData(spec);
573
+ this.originalData = spec.data;
574
+ spec.data = this.dataSpecs[0].data;
575
+ }
576
+ }
577
+ transformBaseSpec(spec) {
578
+ var _a, _b, _c;
579
+ spec.type = 'common';
580
+ spec.dataKey = DATA_KEY;
581
+ spec.series = [
582
+ {
583
+ type: 'bar',
584
+ direction: 'horizontal',
585
+ xField: spec.xField,
586
+ yField: spec.yField,
587
+ barWidth: (_b = (_a = spec.bar) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 10,
588
+ 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) => {
589
+ var _a, _b;
590
+ if (datum[SUPPLY_DATA_KEY]) {
591
+ return false;
592
+ }
593
+ return (_b = (_a = spec.bar) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : true;
594
+ } }) })
595
+ }
596
+ ];
597
+ }
598
+ transformAnimationSpec(spec) {
599
+ const totalDuration = spec.animation.duration;
600
+ if (spec.animation) {
601
+ spec.player = Object.assign(Object.assign({}, spec.player), { specs: this.dataSpecs, auto: true, visible: false, interval: spec.animation.interval + spec.animation.duration / 2, loop: true });
602
+ spec.animationExit = this.getAnimationExit(spec, totalDuration);
603
+ spec.animationAppear = this.getAnimationEnter(spec, 'rect', totalDuration);
604
+ spec.animationEnter = this.getAnimationEnter(spec, 'rect', totalDuration);
605
+ }
606
+ }
607
+ transformAxesSpec(spec) {
608
+ const { min, max } = computeDataRange(this.originalData, spec.xField);
609
+ spec.axes = [
610
+ {
611
+ orient: 'left',
612
+ type: 'band',
613
+ visible: false,
614
+ inverse: true
615
+ },
616
+ {
617
+ orient: 'bottom',
618
+ label: { visible: true },
619
+ type: 'linear',
620
+ visible: false,
621
+ min,
622
+ max
623
+ }
624
+ ];
625
+ }
626
+ generateBarBackground(spec) {
627
+ const totalDuration = spec.animation.duration;
628
+ return {
629
+ type: spec.barBackground.type,
630
+ dataId: 'data',
631
+ visible: true,
632
+ dataKey: DATA_KEY,
633
+ zIndex: -99,
634
+ style: Object.assign(Object.assign({ x: (datum, ctx) => spec.barBackground.type === 'symbol' ? ctx.getRegion().getLayoutRect().width / 2 : 0, y: (datum, ctx) => {
635
+ return (ctx.valueToY([datum[spec.yField]]) +
636
+ ctx.yBandwidth() / 2 -
637
+ (spec.barBackground.type === 'symbol' ? 0 : spec.bar.height / 2));
638
+ }, 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) => {
639
+ if (datum[SUPPLY_DATA_KEY]) {
640
+ return false;
641
+ }
642
+ return spec.barBackground.style.visible;
643
+ } }),
644
+ animation: Boolean(spec.animation),
645
+ animationEnter: this.getAnimationEnter(spec, 'barBack', totalDuration),
646
+ animationExit: this.getAnimationExit(spec, totalDuration),
647
+ animationAppear: this.getAnimationEnter(spec, 'barBack', totalDuration)
648
+ };
649
+ }
650
+ generateDecorateHaloIcons(spec) {
651
+ const totalDuration = spec.animation.duration;
652
+ return spec.decorateHaloIcons.map((decorateHaloIcon) => {
653
+ return {
654
+ type: 'symbol',
655
+ dataId: 'data',
656
+ visible: true,
657
+ dataKey: DATA_KEY,
658
+ style: Object.assign(Object.assign({ x: (datum, ctx) => {
659
+ return ctx.valueToX([datum[spec.xField]]);
660
+ }, y: (datum, ctx) => {
661
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
662
+ } }, decorateHaloIcon.style), { visible: (datum) => {
663
+ if (datum[SUPPLY_DATA_KEY]) {
664
+ return false;
665
+ }
666
+ return decorateHaloIcon.style.visible;
667
+ } }),
668
+ animation: Boolean(spec.animation),
669
+ animationEnter: this.getAnimationEnter(spec, 'symbol', totalDuration),
670
+ animationExit: this.getAnimationExit(spec, totalDuration),
671
+ animationAppear: this.getAnimationEnter(spec, 'symbol', totalDuration)
672
+ };
673
+ });
674
+ }
675
+ generateRankingIcon(spec) {
676
+ const totalDuration = spec.animation.duration;
677
+ return {
678
+ type: 'symbol',
679
+ dataId: 'data',
680
+ visible: true,
681
+ dataKey: DATA_KEY,
682
+ style: Object.assign(Object.assign({ x: (datum) => {
683
+ if (spec.labelLayout === 'bothEnd') {
684
+ return -(NAME_LABEL_PADDING_RIGHT +
685
+ this.nameLabelTextMeasure.fullMeasure(this.formatDatum(spec.yField, datum)).width +
686
+ (spec.orderLabel.style.visible
687
+ ? NAME_ORDER_PADDING_RIGHT +
688
+ this.orderLabelTextMeasure.fullMeasure(this.formatDatum(ORDER_KEY, datum)).width
689
+ : 0) +
690
+ NAME_SYMBOL_PADDING_RIGHT);
691
+ }
692
+ return CHART_PADDING_LEFT;
693
+ }, y: (datum, ctx) => {
694
+ if (spec.labelLayout === 'bothEnd') {
695
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
696
+ }
697
+ return (ctx.valueToY([datum[spec.yField]]) +
698
+ ctx.yBandwidth() / 2 -
699
+ spec.bar.height / 2 -
700
+ LABEL_PADDING_BOTTOM -
701
+ Math.max(this.nameLabelTextMeasure.fullMeasure(this.formatDatum(spec.yField, datum)).height, this.orderLabelTextMeasure.fullMeasure(this.formatDatum(ORDER_KEY, datum)).height) /
702
+ 2);
703
+ } }, spec.rankingIcon.style), { lineWidth: 0, stroke: null, visible: (datum) => {
704
+ if (datum[SUPPLY_DATA_KEY]) {
705
+ return false;
706
+ }
707
+ return spec.rankingIcon.style.visible;
708
+ } }),
709
+ animation: Boolean(spec.animation),
710
+ animationEnter: this.getAnimationEnter(spec, 'text', totalDuration),
711
+ animationExit: this.getAnimationExit(spec, totalDuration),
712
+ animationAppear: this.getAnimationEnter(spec, 'text', totalDuration)
713
+ };
714
+ }
715
+ generateNameLabel(spec) {
716
+ const totalDuration = spec.animation.duration;
717
+ return {
718
+ type: 'text',
719
+ dataId: 'data',
720
+ dataKey: DATA_KEY,
721
+ style: Object.assign(Object.assign({ text: (datum) => this.formatDatum(spec.yField, datum), x: () => {
722
+ var _a;
723
+ if (spec.labelLayout === 'bothEnd') {
724
+ return -NAME_LABEL_PADDING_RIGHT;
725
+ }
726
+ return ((spec.rankingIcon.style.visible ? NAME_SYMBOL_PADDING_RIGHT + ((_a = spec.rankingIcon.style.size) !== null && _a !== void 0 ? _a : 10) : 0) +
727
+ (spec.orderLabel.style.visible
728
+ ? NAME_ORDER_PADDING_RIGHT + this.getMaxDataLabelLens(spec, ORDER_KEY, this.orderLabelTextMeasure)
729
+ : 0));
730
+ }, y: (datum, ctx) => {
731
+ if (spec.labelLayout === 'bothEnd') {
732
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
733
+ }
734
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2 - spec.bar.height / 2 - LABEL_PADDING_BOTTOM;
735
+ } }, spec.nameLabel.style), { textAlign: spec.labelLayout === 'bothEnd' ? 'right' : 'left', textBaseline: spec.labelLayout === 'bothEnd' ? 'middle' : 'bottom', visible: (datum) => {
736
+ if (datum[SUPPLY_DATA_KEY]) {
737
+ return false;
738
+ }
739
+ return spec.nameLabel.style.visible;
740
+ } }),
741
+ animation: Boolean(spec.animation),
742
+ animationEnter: this.getAnimationEnter(spec, 'text', totalDuration),
743
+ animationExit: this.getAnimationExit(spec, totalDuration),
744
+ animationAppear: this.getAnimationEnter(spec, 'text', totalDuration)
745
+ };
746
+ }
747
+ generateOrderLabel(spec) {
748
+ const totalDuration = spec.animation.duration;
749
+ return {
750
+ type: 'text',
751
+ dataId: 'data',
752
+ dataKey: DATA_KEY,
753
+ style: Object.assign(Object.assign({ text: (datum) => this.formatDatum(ORDER_KEY, datum), x: (datum) => {
754
+ var _a;
755
+ if (spec.labelLayout === 'bothEnd') {
756
+ return -(NAME_LABEL_PADDING_RIGHT +
757
+ this.nameLabelTextMeasure.fullMeasure(this.formatDatum(spec.yField, datum)).width +
758
+ NAME_ORDER_PADDING_RIGHT);
759
+ }
760
+ else {
761
+ return spec.rankingIcon.style.visible ? NAME_SYMBOL_PADDING_RIGHT + ((_a = spec.rankingIcon.style.size) !== null && _a !== void 0 ? _a : 10) : 0;
762
+ }
763
+ }, y: (datum, ctx) => {
764
+ if (spec.labelLayout === 'bothEnd') {
765
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
766
+ }
767
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2 - spec.bar.height / 2 - LABEL_PADDING_BOTTOM;
768
+ } }, spec.orderLabel.style), { textAlign: spec.labelLayout === 'bothEnd' ? 'right' : 'left', textBaseline: spec.labelLayout === 'bothEnd' ? 'middle' : 'bottom', visible: (datum) => {
769
+ if (datum[SUPPLY_DATA_KEY]) {
770
+ return false;
771
+ }
772
+ return spec.orderLabel.style.visible;
773
+ } }),
774
+ animation: Boolean(spec.animation),
775
+ animationEnter: this.getAnimationEnter(spec, 'text', totalDuration),
776
+ animationExit: this.getAnimationExit(spec, totalDuration),
777
+ animationAppear: this.getAnimationEnter(spec, 'text', totalDuration)
778
+ };
779
+ }
780
+ generateValueLabel(spec) {
781
+ const totalDuration = spec.animation.duration;
782
+ return {
783
+ type: 'text',
784
+ dataId: 'data',
785
+ visible: true,
786
+ dataKey: DATA_KEY,
787
+ style: Object.assign(Object.assign({ text: (datum) => this.formatDatum(spec.xField, datum), x: (datum, ctx) => {
788
+ if (spec.labelLayout === 'bothEnd') {
789
+ return (ctx.getRegion().getLayoutRect().width +
790
+ this.getMaxDataLabelLens(spec, spec.xField, this.nameLabelTextMeasure) +
791
+ VALUE_LABEL_PADDING_LEFT);
792
+ }
793
+ else {
794
+ return ctx.getRegion().getLayoutRect().width;
795
+ }
796
+ }, y: (datum, ctx) => {
797
+ if (spec.labelLayout === 'bothEnd') {
798
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2;
799
+ }
800
+ return ctx.valueToY([datum[spec.yField]]) + ctx.yBandwidth() / 2 - spec.bar.height / 2 - LABEL_PADDING_BOTTOM;
801
+ } }, spec.valueLabel.style), { textAlign: 'right', textBaseline: spec.labelLayout === 'bothEnd' ? 'middle' : 'bottom', visible: (datum) => {
802
+ if (datum[SUPPLY_DATA_KEY]) {
803
+ return false;
804
+ }
805
+ return spec.valueLabel.style.visible;
806
+ } }),
807
+ animation: Boolean(spec.animation),
808
+ animationEnter: this.getAnimationEnter(spec, 'text', totalDuration),
809
+ animationExit: this.getAnimationExit(spec, totalDuration),
810
+ animationAppear: this.getAnimationEnter(spec, 'text', totalDuration)
811
+ };
812
+ }
813
+ transformPaddingSpec(spec) {
814
+ var _a;
815
+ spec.padding = Object.assign({ left: spec.labelLayout === 'bothEnd'
816
+ ? NAME_LABEL_PADDING_RIGHT +
817
+ this.getMaxDataLabelLens(spec, spec.yField, this.nameLabelTextMeasure) +
818
+ (spec.orderLabel.style.visible
819
+ ? NAME_ORDER_PADDING_RIGHT + this.getMaxDataLabelLens(spec, ORDER_KEY, this.orderLabelTextMeasure)
820
+ : 0) +
821
+ (spec.rankingIcon.style.visible ? NAME_SYMBOL_PADDING_RIGHT + ((_a = spec.rankingIcon.style.size) !== null && _a !== void 0 ? _a : 10) : 0) +
822
+ CHART_PADDING_LEFT
823
+ : CHART_PADDING_LEFT, right: spec.labelLayout === 'bothEnd'
824
+ ? VALUE_LABEL_PADDING_LEFT +
825
+ this.getMaxDataLabelLens(spec, spec.yField, this.valueLabelTextMeasure) +
826
+ CHART_PADDING_RIGHT
827
+ : CHART_PADDING_RIGHT + 10, top: 0, bottom: 0 }, spec.padding);
828
+ }
829
+ getMaxDataLabelLens(spec, field, textMeasure) {
830
+ const textWidths = this.originalData.map(datum => datum[SUPPLY_DATA_KEY] ? 0 : textMeasure.fullMeasure(this.formatDatum(field, datum)).width);
831
+ return Math.max(...textWidths);
832
+ }
833
+ formatDatum(field, datum) {
834
+ var _a;
835
+ if ((_a = this.formatMap) === null || _a === void 0 ? void 0 : _a[field]) {
836
+ return this.formatMap[field](datum[field], datum);
837
+ }
838
+ else {
839
+ return datum[field];
840
+ }
841
+ }
842
+ getLabelWidth(padding, width) {
843
+ return width + padding;
844
+ }
845
+ getAnimationExit(spec, duration) {
846
+ if (spec.animation.type === 'grow') {
847
+ return {};
848
+ }
849
+ return {
850
+ type: 'moveOut',
851
+ options: {
852
+ direction: 'y',
853
+ orient: 'negative',
854
+ point: (datum, element, opt) => {
855
+ const channelAttr = element.getGraphicAttribute('y');
856
+ const barSpace = (spec.height / spec.pageSize - spec.bar.height) / 2;
857
+ return { y: channelAttr - opt.height + barSpace };
858
+ }
859
+ },
860
+ duration: spec.animation.type === 'both' ? duration / 2 : duration,
861
+ easing: spec.animation.easing
862
+ };
863
+ }
864
+ getAnimationEnter(spec, markType, totalDuration) {
865
+ const { animation } = spec;
866
+ const { type: animationType, easing } = animation;
867
+ const scrollDuration = animationType === 'both' ? totalDuration / 2 : totalDuration;
868
+ const growDuration = animationType === 'grow' ? totalDuration : totalDuration / 2;
869
+ const result = [];
870
+ if (animationType === 'scroll' || animationType === 'both') {
871
+ result.push({
872
+ type: 'moveIn',
873
+ options: {
874
+ direction: 'y',
875
+ orient: 'negative',
876
+ excludeChannels: ['y'],
877
+ point: (datum, element, opt) => {
878
+ const channelAttr = element.getGraphicAttribute('y');
879
+ const barSpace = (spec.height / spec.pageSize - spec.bar.height) / 2;
880
+ return { y: channelAttr + opt.height - barSpace };
881
+ }
882
+ },
883
+ duration: scrollDuration,
884
+ easing
885
+ });
886
+ }
887
+ if ((animationType === 'grow' || animationType === 'both') && markType !== 'text' && markType !== 'barBack') {
888
+ result.push({
889
+ channel: {
890
+ x: {
891
+ from: 0,
892
+ to: (datum, element) => {
893
+ return element.getGraphicItem().attribute.x;
894
+ }
895
+ }
896
+ },
897
+ duration: growDuration,
898
+ delay: animationType === 'both' ? scrollDuration : 0,
899
+ easing
900
+ });
901
+ }
902
+ return result;
903
+ }
904
+ }
905
+
906
+ class RankingList extends vchart.BaseChart {
907
+ constructor() {
908
+ super(...arguments);
909
+ this.type = 'rankingList';
910
+ this.transformerConstructor = RankingListChartSpecTransformer;
911
+ }
912
+ init() {
913
+ if (!this.isValid()) {
914
+ return;
915
+ }
916
+ super.init();
917
+ }
918
+ isValid() {
919
+ var _a, _b, _c, _d;
920
+ const { xField, yField, data } = this._spec;
921
+ if (!xField || !yField) {
922
+ (_b = (_a = this._option).onError) === null || _b === void 0 ? void 0 : _b.call(_a, 'Missing Required Config: `xField`, `yField` ');
923
+ return false;
924
+ }
925
+ if (!data) {
926
+ (_d = (_c = this._option).onError) === null || _d === void 0 ? void 0 : _d.call(_c, 'Data is required');
927
+ return false;
928
+ }
929
+ return true;
930
+ }
931
+ }
932
+ RankingList.type = 'rankingList';
933
+ RankingList.view = 'singleDefault';
934
+ RankingList.transformerConstructor = RankingListChartSpecTransformer;
935
+ const registerRankingList = (option) => {
936
+ const vchartConstructor = (option === null || option === void 0 ? void 0 : option.VChart) || vchart.VChart;
937
+ if (vchartConstructor) {
938
+ vchartConstructor.useChart([RankingList, vchart.BarChart]);
939
+ }
940
+ };
941
+
341
942
  const fields = (data, options) => {
342
943
  var _a, _b;
343
944
  if (!(null == options ? void 0 : options.fields)) return data;
@@ -10175,6 +10776,7 @@
10175
10776
  exports.DEFAULT_ARROW_TEXT_MARK_STYLE = DEFAULT_ARROW_TEXT_MARK_STYLE;
10176
10777
  exports.DEFAULT_FUNNEL_BACKGROUND_MARK_STYLE = DEFAULT_FUNNEL_BACKGROUND_MARK_STYLE;
10177
10778
  exports.RankingBar = RankingBar;
10779
+ exports.RankingList = RankingList;
10178
10780
  exports.SERIES_BREAK = SERIES_BREAK;
10179
10781
  exports.SeriesBreakComponent = SeriesBreakComponent;
10180
10782
  exports.SeriesLabelComponent = SeriesLabelComponent;
@@ -10187,6 +10789,7 @@
10187
10789
  exports.registerBarLink = registerBarLink;
10188
10790
  exports.registerConversionFunnelChart = registerConversionFunnelChart;
10189
10791
  exports.registerRankingBarChart = registerRankingBarChart;
10792
+ exports.registerRankingList = registerRankingList;
10190
10793
  exports.registerSeriesBreak = registerSeriesBreak;
10191
10794
  exports.registerSeriesLabel = registerSeriesLabel;
10192
10795