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