@visactor/vchart-extension 1.13.5-alpha.7 → 1.13.5-alpha.8

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