sea-chart 2.0.35 → 2.0.36

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 (84) hide show
  1. package/dist/api/index.js +17 -59
  2. package/dist/assets/css/sea-chart-d3-tooltip.css +0 -1
  3. package/dist/components/color-popover/color-rules-popover.js +4 -2
  4. package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +5 -4
  5. package/dist/components/icon/index.js +9 -13
  6. package/dist/components/number-input/index.js +7 -13
  7. package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +7 -3
  8. package/dist/components/popover/hide-column-popover/hide-column-popover.css +5 -1
  9. package/dist/components/popover/hide-column-popover/hide-column-popover.js +2 -4
  10. package/dist/components/popover/sort-popover/sort-popover.js +6 -7
  11. package/dist/components/statistic-record-dialog/index.js +9 -8
  12. package/dist/components/tooltip/index.js +26 -8
  13. package/dist/editor/index.js +5 -1
  14. package/dist/locale/lang/de.js +1 -0
  15. package/dist/locale/lang/en.js +1 -0
  16. package/dist/locale/lang/es.js +1 -0
  17. package/dist/locale/lang/fr.js +1 -0
  18. package/dist/locale/lang/pt.js +1 -0
  19. package/dist/locale/lang/ru.js +1 -0
  20. package/dist/locale/lang/zh_CN.js +1 -0
  21. package/dist/model/funnel.js +2 -2
  22. package/dist/model/map-bubble.js +4 -0
  23. package/dist/services/map-json.js +3 -0
  24. package/dist/settings/advance-bar-settings/data-settings.js +1 -1
  25. package/dist/settings/advance-bar-settings/style-settings.js +4 -3
  26. package/dist/settings/bar-settings/data-settings.js +1 -1
  27. package/dist/settings/bar-settings/style-settings.js +2 -2
  28. package/dist/settings/basic-number-card/data-settings.js +3 -2
  29. package/dist/settings/combination-settings/data-settings.js +0 -1
  30. package/dist/settings/combination-settings/style-settings.js +2 -2
  31. package/dist/settings/dashboard-settings/data-settings.js +3 -2
  32. package/dist/settings/funnel-settings/components/funnel-layer-setting.js +7 -7
  33. package/dist/settings/index.js +8 -3
  34. package/dist/settings/table-element-settings/components/data-filter.js +24 -25
  35. package/dist/settings/table-element-settings/index.css +1 -31
  36. package/dist/settings/table-settings/data-settings.js +3 -2
  37. package/dist/settings/time-comparison-settings/style-settings.js +2 -2
  38. package/dist/settings/widgets/basic-summary/index.js +8 -7
  39. package/dist/settings/widgets/common-data-settings.js +7 -6
  40. package/dist/settings/widgets/data-filter/index.js +30 -22
  41. package/dist/settings/widgets/group-by.js +4 -3
  42. package/dist/settings/widgets/summary-settings.js +3 -2
  43. package/dist/settings/widgets/y-axis-group-settings.js +3 -2
  44. package/dist/utils/cell-format-utils.js +9 -7
  45. package/dist/utils/chart-utils/base-utils.js +194 -86
  46. package/dist/utils/chart-utils/index.js +5 -3
  47. package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +5 -5
  48. package/dist/utils/chart-utils/original-data-utils/card-calculator.js +8 -2
  49. package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +12 -3
  50. package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +4 -1
  51. package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +1 -0
  52. package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +24 -3
  53. package/dist/utils/chart-utils/sql-statistics-utils.js +182 -177
  54. package/dist/utils/column-utils.js +20 -7
  55. package/dist/utils/contexts.js +5 -2
  56. package/dist/utils/index.js +25 -4
  57. package/dist/utils/row-record-utils.js +100 -20
  58. package/dist/utils/sql/column-2-sql-column.js +10 -10
  59. package/dist/utils/trend-utils.js +15 -2
  60. package/dist/view/index.css +2 -8
  61. package/dist/view/index.js +14 -9
  62. package/dist/view/wrapper/area-group.js +15 -7
  63. package/dist/view/wrapper/bar-compare.js +18 -2
  64. package/dist/view/wrapper/bar-custom-stack.js +35 -9
  65. package/dist/view/wrapper/bar-group.js +55 -26
  66. package/dist/view/wrapper/bar-stack.js +2 -2
  67. package/dist/view/wrapper/basic-number-card.js +27 -3
  68. package/dist/view/wrapper/chart-component.js +43 -440
  69. package/dist/view/wrapper/completeness-group.js +104 -49
  70. package/dist/view/wrapper/dashboard.js +68 -18
  71. package/dist/view/wrapper/horizontal-bar-group.js +26 -6
  72. package/dist/view/wrapper/horizontal-bar-stack.js +2 -2
  73. package/dist/view/wrapper/line-group.js +8 -3
  74. package/dist/view/wrapper/map-world-bubble.js +1 -0
  75. package/dist/view/wrapper/map-world.js +1 -0
  76. package/dist/view/wrapper/pie.js +1 -1
  77. package/dist/view/wrapper/ring.js +1 -1
  78. package/dist/view/wrapper/scatter.js +8 -6
  79. package/dist/view/wrapper/table/two-dimension-table.js +3 -2
  80. package/dist/view/wrapper/table-element/components/records-header/index.js +0 -1
  81. package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +3 -1
  82. package/dist/view/wrapper/table-element/index.js +16 -21
  83. package/dist/view/wrapper/trend.js +24 -1
  84. package/package.json +15 -12
@@ -37,7 +37,7 @@ class ChartComponent extends _react.Component {
37
37
  }
38
38
  }, 300);
39
39
  this.destroyChart = () => {
40
- this.chart.node() && this.chart.node().remove();
40
+ this.chart && this.chart.node() && this.chart.node().remove();
41
41
  };
42
42
  this.getTitle = (tables, table_id, yAxisType, yAxisKey) => {
43
43
  return yAxisType === _constants.CHART_SUMMARY_TYPE.COUNT ? _intl.default.get('Amount') : this.getAxisLabel(tables, table_id, yAxisKey);
@@ -213,22 +213,6 @@ class ChartComponent extends _react.Component {
213
213
  });
214
214
  });
215
215
  };
216
- this.drawLabels = function () {
217
- let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
218
- if (!_this.chart) return;
219
- const {
220
- width
221
- } = _this.chart.coordinateBBox;
222
- _this.labelCount = data.length;
223
- if (Math.floor(width / _this.labelCount) <= 20) {
224
- let displayLabels = _this.getChartDisplayLabels(width, 20, data);
225
- _this.labelCount = displayLabels.length;
226
- _this.chart.scale('name', {
227
- type: 'cat',
228
- ticks: displayLabels
229
- });
230
- }
231
- };
232
216
  this.renderAxisLabel = (chart, tables, chartContainer) => {
233
217
  if (!this.chart || !chart) return;
234
218
  let {
@@ -293,7 +277,8 @@ class ChartComponent extends _react.Component {
293
277
  const div = document.createElement('div');
294
278
  div.id = yAxisID;
295
279
  div.className = 'chart-axis-label';
296
- if (y_axis_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
280
+ // SCATTER always has y_axis_column_key
281
+ if (y_axis_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT && type !== _constants.CHART_TYPE.SCATTER) {
297
282
  div.innerHTML = _intl.default.get('Amount');
298
283
  } else {
299
284
  const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
@@ -461,186 +446,6 @@ class ChartComponent extends _react.Component {
461
446
  this.isShowHorizontalAxisLabel = chart => {
462
447
  return !!(chart && chart.config && chart.config.show_horizontal_axis_label);
463
448
  };
464
- // Automatic adjustment of maximum and minimum values
465
- this.autoAdjustDataOptions = function (chart) {
466
- let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
467
- let summaryColumn = arguments.length > 2 ? arguments[2] : undefined;
468
- if (!_this.chart || !chart) return;
469
- let valueScaleOptions = {};
470
- const {
471
- config
472
- } = chart;
473
- const {
474
- y_axis_auto_range,
475
- y_axis_min,
476
- y_axis_max,
477
- y_axis_summary_method
478
- } = config;
479
- if (summaryColumn) {
480
- valueScaleOptions['formatter'] = value => {
481
- return _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method);
482
- };
483
- }
484
- if (y_axis_auto_range === undefined || y_axis_auto_range) {
485
- valueScaleOptions['nice'] = true;
486
- } else {
487
- valueScaleOptions['min'] = y_axis_min;
488
- valueScaleOptions['max'] = y_axis_max;
489
- // set the filter rule
490
- _this.chart.filter('value', value => {
491
- return value >= y_axis_min;
492
- });
493
- // filter the data
494
- _this.chart.filterData(data);
495
- }
496
- _this.chart.scale({
497
- name: {
498
- type: 'cat'
499
- },
500
- value: valueScaleOptions
501
- });
502
- };
503
- // set axis label and tooltip
504
- this.setNameLabelAndTooltip = function () {
505
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.CHART_THEME_COLOR['light'];
506
- let labelCount = arguments.length > 1 ? arguments[1] : undefined;
507
- if (!_this.chart) return;
508
- _this.chart.axis('name', {
509
- line: {
510
- style: {
511
- stroke: theme.XAxisColor,
512
- lineWidth: 1
513
- }
514
- },
515
- tickLine: {
516
- length: 5,
517
- // color of the tick line
518
- stroke: theme.XAxisColor
519
- },
520
- label: {
521
- style: {
522
- fill: theme.textColor,
523
- fontSize: theme.fontSize
524
- },
525
- offset: 10,
526
- autoRotate: true,
527
- rotate: labelCount > 11 ? 0.3 : 0,
528
- formatter: name => {
529
- const isString = typeof name === 'string';
530
- if (!isString) name = String(name);
531
- if (name === 'undefined') {
532
- return _intl.default.get(_constants.EMPTY_NAME);
533
- }
534
- if (name.length > 10) {
535
- return (0, _utils.formatXAxisLabel)(name);
536
- }
537
- return name;
538
- }
539
- }
540
- });
541
- };
542
- // set value label
543
- this.setValueLabel = function () {
544
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.CHART_THEME_COLOR['light'];
545
- if (!_this.chart) return;
546
- _this.chart.axis('value', {
547
- label: {
548
- offset: 6,
549
- style: {
550
- fontSize: theme.fontSize,
551
- fill: theme.textColor
552
- }
553
- },
554
- grid: {
555
- line: {
556
- style: {
557
- stroke: theme.gridColor,
558
- lineDash: [8, 3]
559
- }
560
- }
561
- }
562
- });
563
- };
564
- this.labelFormatter = name => {
565
- let label = name;
566
- if (name.length > 10) {
567
- label = "".concat(name.slice(0, 10), "...");
568
- }
569
- if (name === '' || name === 'undefined') {
570
- label = _intl.default.get(_constants.EMPTY_NAME);
571
- }
572
- return label;
573
- };
574
- this.getLegendConfig = function () {
575
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.CHART_THEME_COLOR['light'];
576
- let legendPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top-right';
577
- return {
578
- // custom: true,
579
- position: legendPosition,
580
- itemName: {
581
- style: {
582
- // fill: theme.textColor,
583
- fill: theme.legendTextColor,
584
- fontSize: theme.legendFontSize
585
- },
586
- formatter: name => {
587
- if (!name && typeof name !== 'number' || name.trim() === 'undefined' || name.trim() === 'null') {
588
- return _intl.default.get(_constants.EMPTY_NAME);
589
- } else if (name === '_Others') {
590
- return _intl.default.get('Others');
591
- } else {
592
- return _intl.default.get(name) || name;
593
- }
594
- }
595
- },
596
- pageNavigator: {
597
- text: {
598
- style: {
599
- fill: theme.legendTextColor
600
- }
601
- },
602
- marker: {
603
- style: {
604
- fill: theme.legendPageNavigatorMarkerColor,
605
- inactiveFill: theme.legendPageNavigatorMarkerColor,
606
- inactiveOpacity: 0.45
607
- }
608
- }
609
- },
610
- itemHeight: 30,
611
- marker: {
612
- symbol:
613
- // 'square',
614
- // use cavans to custom legend,returns a path command array
615
- (x, y) => {
616
- x = x + 6;
617
- y = y - 1;
618
- // The total width of the capsule is 20px, and its height is 6px. Thus, the radius of the semi-circle is half the height, which is 3px.
619
- const r = 3;
620
- // The width of the rectangular part in the middle of the capsule is the total width minus the diameters of the two semi-circles, which is 14px.
621
- const rectWidth = 14;
622
- return [['M', x - rectWidth / 2, y - r],
623
- // Start from the left edge of the left semi-circle
624
- ['L', x + rectWidth / 2, y - r],
625
- // Draw the top line to the left edge of the right semi-circle
626
- ['A', r, r, 0, 0, 1, x + rectWidth / 2, y + r],
627
- // Draw the right semi-circle
628
- ['L', x - rectWidth / 2, y + r],
629
- // Draw the bottom line back to the right edge of the left semi-circle
630
- ['A', r, r, 0, 0, 1, x - rectWidth / 2, y - r] // Draw the left semi-circle
631
- ];
632
- },
633
- style: style => {
634
- // fill legend with stroke color
635
- if (style.stroke) {
636
- style.fill = style.stroke;
637
- }
638
- return style;
639
- },
640
- spacing: 15
641
- }
642
- };
643
- };
644
449
  this.formatterLegendName = name => {
645
450
  if (!name && typeof name !== 'number' || name.trim() === 'undefined' || name.trim() === 'null') {
646
451
  return _intl.default.get(_constants.EMPTY_NAME);
@@ -650,85 +455,7 @@ class ChartComponent extends _react.Component {
650
455
  return _intl.default.get(name) || name;
651
456
  }
652
457
  };
653
- // set legend for heat map
654
- this.setLegendForHeatMap = _ref => {
655
- let {
656
- exampleColors,
657
- themeColors
658
- } = _ref;
659
- const legendOffsetY = 3;
660
- const legendItemTextWidth = 32;
661
- const legendItemWidth = 12;
662
- const legendItemHeight = 12;
663
- const legendItemGap = 3;
664
- const legendItemRadius = 2;
665
- const legendWrapper = this.chart.append('g').attr('class', 'legend-heat-map-wrapper').attr('transform', "translate(0, ".concat(legendOffsetY, ")"));
666
-
667
- // less
668
- legendWrapper.append('text').attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(_intl.default.get('Less'));
669
- // rect
670
- exampleColors.forEach((color, index) => {
671
- legendWrapper.append('rect').attr('x', legendItemTextWidth + index * legendItemWidth + index * legendItemGap).attr('width', legendItemWidth).attr('height', legendItemHeight).attr('rx', legendItemRadius).attr('fill', color).attr('stroke', _style.FILL_BORDER_COLOR_MAP[color]).attr('stroke-width', 1);
672
- });
673
- // more
674
- legendWrapper.append('text').attr('x', 182).attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(_intl.default.get('More'));
675
- };
676
- // set continuous legend
677
- this.setContinuousLegend = _ref2 => {
678
- var _this$chart$node2;
679
- let {
680
- previewType,
681
- theme,
682
- colorRange = [],
683
- legendDirection,
684
- legendSize,
685
- legendTextRange,
686
- bubbleColor,
687
- type
688
- } = _ref2;
689
- const {
690
- width: chartWidth,
691
- height: chartHeight,
692
- insertPadding
693
- } = this.chartBoundingClientRect;
694
- const legendRectWidth = legendDirection === 'vertical' ? 12 : Math.min(legendSize * 100, chartWidth - insertPadding * 2);
695
- const legendRectHeight = legendDirection === 'vertical' ? Math.min(legendSize * 100, chartHeight - insertPadding * 2) : 12;
696
- const legendTextOffset = 2;
697
- const legendTextHeightSpace = legendDirection === 'vertical' ? 0 : 14 + legendTextOffset;
698
- if (![_constants.CHART_TYPE.MAP_BUBBLE, _constants.CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
699
- var _this$chart$node;
700
- // add linearGradient
701
- const gradient = this.chart.append('defs').attr('class', 'linear-gradient-wrapper').append('linearGradient').attr("id", "gradient-".concat((_this$chart$node = this.chart.node()) === null || _this$chart$node === void 0 ? void 0 : _this$chart$node.id, "-").concat(previewType)).attr("x1", '0%').attr("y1", '0%').attr("x2", legendDirection === 'vertical' ? '0%' : '100%').attr("y2", legendDirection === 'vertical' ? '100%' : '0%');
702
- gradient.append('stop').attr('offset', '0%').attr('stop-color', "".concat(colorRange[0]));
703
- gradient.append('stop').attr('offset', '50%').attr('stop-color', "".concat(colorRange[4]));
704
- gradient.append('stop').attr('offset', '100%').attr('stop-color', "".concat(colorRange[8]));
705
- }
706
-
707
- // add legend
708
- const continuousLegendWrapper = this.chart.append('g').attr('class', 'legend-continuous-wrapper').attr('transform', "translate(0, ".concat(chartHeight - legendRectHeight - legendTextHeightSpace, ")"));
709
- continuousLegendWrapper.append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('fill', [_constants.CHART_TYPE.MAP_BUBBLE, _constants.CHART_TYPE.WORLD_MAP_BUBBLE].includes(type) ? bubbleColor : "url(#gradient-".concat((_this$chart$node2 = this.chart.node()) === null || _this$chart$node2 === void 0 ? void 0 : _this$chart$node2.id, "-").concat(previewType, ")")).call(g => {
710
- if ([_constants.CHART_TYPE.MAP_BUBBLE, _constants.CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
711
- continuousLegendWrapper.append('polygon').attr('points', "0,0 ".concat(legendRectWidth - 0.5, ",0 0,").concat(legendRectHeight - 0.5)).attr('fill', '#fff').attr('stroke', '#fff');
712
- }
713
- });
714
- continuousLegendWrapper.append('text').attr('class', 'range-start').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).text(legendTextRange[0]).call(g => {
715
- const {
716
- height
717
- } = g.node().getBoundingClientRect();
718
- g.attr('x', legendDirection === 'vertical' ? legendRectWidth + legendTextOffset : legendTextOffset);
719
- g.attr('y', legendDirection === 'vertical' ? height : height + legendRectHeight);
720
- });
721
- continuousLegendWrapper.append('text').attr('class', 'range-end').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).text(legendTextRange[1]).call(g => {
722
- const {
723
- width,
724
- height
725
- } = g.node().getBoundingClientRect();
726
- g.attr('x', legendDirection === 'vertical' ? legendRectWidth + legendTextOffset : legendRectWidth - width);
727
- g.attr('y', legendDirection === 'vertical' ? legendRectHeight - legendTextOffset : height + legendRectHeight);
728
- });
729
- };
730
- // set legend
731
- this.setLegend = _ref3 => {
458
+ this.setLegend = _ref => {
732
459
  var _chart$config, _chart$config2;
733
460
  let {
734
461
  legendName,
@@ -738,7 +465,7 @@ class ChartComponent extends _react.Component {
738
465
  colorScale,
739
466
  groupColumn,
740
467
  chart
741
- } = _ref3;
468
+ } = _ref;
742
469
  if (!this.chart) return;
743
470
  this.legendConfig = {
744
471
  legendRectWidth: [_constants.CHART_TYPE.SCATTER, _constants.CHART_TYPE.MIRROR].includes(chart === null || chart === void 0 ? void 0 : (_chart$config = chart.config) === null || _chart$config === void 0 ? void 0 : _chart$config.type) ? 8 : 20,
@@ -772,6 +499,7 @@ class ChartComponent extends _react.Component {
772
499
  // legend offset bottom and When there is only one line of legend, it is displayed in the center (for scatter chart)
773
500
  if (bottomLegendSpace) {
774
501
  queueMicrotask(() => {
502
+ if (!legendWrapper.node()) return;
775
503
  const {
776
504
  width,
777
505
  height
@@ -854,18 +582,18 @@ class ChartComponent extends _react.Component {
854
582
  } = g.node().parentNode.getBoundingClientRect();
855
583
  groupTranslateY = groupTranslateY + height + legendItemMargin;
856
584
  }
857
- g.attr('transform', "translate(".concat(groupTranslateX, ", ").concat(groupTranslateY, ")"));
585
+ g.attr('transform', "translate(".concat(groupTranslateX, ",").concat(groupTranslateY, ")"));
858
586
  });
859
587
  }
860
588
  };
861
- this.renderLegend = _ref4 => {
589
+ this.renderLegend = _ref2 => {
862
590
  let {
863
591
  legendWrapper,
864
592
  groupData,
865
593
  colorScale,
866
594
  theme,
867
595
  text
868
- } = _ref4;
596
+ } = _ref2;
869
597
  const {
870
598
  legendItemPaddingTop,
871
599
  legendItemTextPaddingTop,
@@ -891,15 +619,15 @@ class ChartComponent extends _react.Component {
891
619
  d3.select(item).remove();
892
620
  });
893
621
  }
894
- legendWrapper.selectAll().data(groupData).join('g').attr('data-groupName', _ref5 => {
895
- let [groupName] = _ref5;
622
+ legendWrapper.selectAll().data(groupData).join('g').attr('data-groupName', _ref3 => {
623
+ let [groupName] = _ref3;
896
624
  return groupName;
897
- }).append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('y', legendItemPaddingTop).attr('rx', r).attr('fill', _ref6 => {
898
- let [groupName] = _ref6;
625
+ }).append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('y', legendItemPaddingTop).attr('rx', r).attr('fill', _ref4 => {
626
+ let [groupName] = _ref4;
899
627
  if (colorScale) return colorScale(groupName);
900
628
  return this.colorMap[groupName] || _constants.CHART_STYLE_COLORS[0];
901
- }).attr('data-text', _ref7 => {
902
- let [groupName] = _ref7;
629
+ }).attr('data-text', _ref5 => {
630
+ let [groupName] = _ref5;
903
631
  return groupName;
904
632
  }).call(g => {
905
633
  // Add text
@@ -1117,19 +845,6 @@ class ChartComponent extends _react.Component {
1117
845
  if (type === _constants.CHART_TYPE.MIRROR) return 0;
1118
846
  return 3;
1119
847
  };
1120
- // theta is pie or ring chart
1121
- this.setLegendForTheta = function (legendName) {
1122
- let theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.CHART_THEME_COLOR['light'];
1123
- let legendPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'bottom';
1124
- let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1125
- if (!_this.chart) return;
1126
- const basicLegendConfig = _this.getLegendConfig(theme, legendPosition);
1127
- if (offsetX) {
1128
- basicLegendConfig.offsetX = offsetX;
1129
- }
1130
- basicLegendConfig.itemName.style.fontSize = theme.fontSize;
1131
- _this.chart.legend(legendName, basicLegendConfig);
1132
- };
1133
848
  this.calcEquilateralTriangle = (cx, cy, size, direction) => {
1134
849
  const height = size * Math.sqrt(3) / 2;
1135
850
  if (direction === 'bottom') {
@@ -1256,131 +971,6 @@ class ChartComponent extends _react.Component {
1256
971
  }
1257
972
  return statisticNewData;
1258
973
  };
1259
- this.getToolTipSettings = (isGroup, summaryColumn, y_axis_summary_method, useSingleSelectColumnColor) => {
1260
- const obj = {
1261
- showMarkers: false,
1262
- containerTpl: "<div class=\"g2-tooltip\">\n <div class=\"g2-tooltip-title\">{title}</div>\n <ul class=\"g2-tooltip-list\"></ul>\n </div>",
1263
- itemTpl: "<li class=\"g2-tooltip-list-item\">\n <span class=\"g2-tooltip-marker\" style=\"background-color:{color};display:inline-block;\"></span>\n <span class=\"g2-tooltip-name\">{name}</span>\n <span class=\"g2-tooltip-value\">{value}</span>\n </li>",
1264
- domStyles: {
1265
- 'g2-tooltip': {
1266
- boxSizing: 'border-box',
1267
- minWidth: '178px',
1268
- borderRadius: '3px',
1269
- border: '1px solid #e2e2e2',
1270
- backgroundColor: '#fff',
1271
- padding: '16px',
1272
- paddingTop: '8px',
1273
- paddingBottom: '8px',
1274
- marginLeft: '20px',
1275
- boxShadow: '0px 0px 1px 1px rgba(0,0,0,0.1)'
1276
- },
1277
- 'g2-tooltip-title': {
1278
- color: '#333333',
1279
- fontSize: '14px',
1280
- paddingBottom: '10px',
1281
- maxWidth: '160px',
1282
- whiteSpace: 'nowrap',
1283
- overflow: 'hidden',
1284
- lineHeight: '14px',
1285
- textOverflow: 'ellipsis'
1286
- },
1287
- 'g2-tooltip-list-item': {
1288
- marginTop: '8px',
1289
- marginBottom: '8px',
1290
- display: 'flex'
1291
- },
1292
- 'g2-tooltip-marker': {
1293
- width: '12px',
1294
- height: '12px',
1295
- borderRadius: '2px',
1296
- marginRight: '8px'
1297
- },
1298
- 'g2-tooltip-name': {
1299
- display: 'inline-block',
1300
- fontSize: '12px',
1301
- minWidth: '80px',
1302
- whiteSpace: 'nowrap',
1303
- overflow: 'hidden',
1304
- lineHeight: '12px',
1305
- textOverflow: 'ellipsis'
1306
- },
1307
- 'g2-tooltip-value': {
1308
- fontSize: '12px'
1309
- }
1310
- }
1311
- };
1312
- if (isGroup) {
1313
- obj.customItems = items => {
1314
- const activeItem = items[0];
1315
- const name = activeItem.data.name;
1316
- return this.formatedDataByName[name].map(item => {
1317
- return {
1318
- color: useSingleSelectColumnColor ? item.group_color : this.colorMap[item.group_name] || _constants.CHART_STYLE_COLORS[0],
1319
- data: item,
1320
- name: !item.group_name && typeof item.group_name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : item.group_name,
1321
- title: item.name,
1322
- value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, item.value, y_axis_summary_method)
1323
- };
1324
- });
1325
- };
1326
- }
1327
- return obj;
1328
- };
1329
- this.setToolTip = (isGroup, summaryColumn, y_axis_summary_method, useSingleSelectColumnColor) => {
1330
- const settings = this.getToolTipSettings(isGroup, summaryColumn, y_axis_summary_method, useSingleSelectColumnColor);
1331
- this.chart.tooltip(settings);
1332
- };
1333
- this.setToolTipForLine = () => {
1334
- const settings = this.getToolTipSettings();
1335
- const lineToolTipSettings = {
1336
- showCrosshairs: true,
1337
- showTitle: true,
1338
- shared: true,
1339
- showMarkers: true,
1340
- marker: {
1341
- strokeOpacity: 0,
1342
- r: 5
1343
- },
1344
- crosshairs: {
1345
- line: {
1346
- fill: '#F3F3F3'
1347
- }
1348
- }
1349
- };
1350
- this.chart.tooltip({
1351
- ...settings,
1352
- ...lineToolTipSettings
1353
- });
1354
- };
1355
- this.setToolTipForArea = () => {
1356
- const settings = this.getToolTipSettings();
1357
- const lineToolTipSettings = {
1358
- showCrosshairs: true,
1359
- showTitle: true,
1360
- shared: true,
1361
- showMarkers: true,
1362
- marker: {
1363
- strokeOpacity: 0,
1364
- r: 6
1365
- },
1366
- crosshairs: {
1367
- line: {
1368
- fill: '#F3F3F3'
1369
- }
1370
- }
1371
- };
1372
- this.chart.tooltip({
1373
- ...settings,
1374
- ...lineToolTipSettings
1375
- });
1376
- };
1377
- // theta is pie or ring chart
1378
- this.setToolTipForTheta = () => {
1379
- const settings = this.getToolTipSettings();
1380
- settings.showTitle = false;
1381
- settings.containerTpl = "<div class=\"g2-tooltip\">\n <ul class=\"g2-tooltip-list\"></ul>\n </div>";
1382
- this.chart.tooltip(settings);
1383
- };
1384
974
  this.isShowXAxisLabel = chart => {
1385
975
  return !!(chart && chart.config && chart.config.x_axis_show_label);
1386
976
  };
@@ -1411,7 +1001,7 @@ class ChartComponent extends _react.Component {
1411
1001
  annotationWrapper.append('text').attr('x', chartWidth - insertPadding - 30).attr('y', yScale(goal_value) - 10).attr('fill', '#666').text(goal_label);
1412
1002
  });
1413
1003
  };
1414
- this.addLabelToRectTop = _ref8 => {
1004
+ this.addLabelToRectTop = _ref6 => {
1415
1005
  let {
1416
1006
  container,
1417
1007
  x,
@@ -1420,15 +1010,16 @@ class ChartComponent extends _react.Component {
1420
1010
  theme,
1421
1011
  label_font_size,
1422
1012
  text
1423
- } = _ref8;
1013
+ } = _ref6;
1424
1014
  d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('y', Number(y) - 10).attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
1015
+ if (!g.node()) return;
1425
1016
  const {
1426
1017
  width
1427
1018
  } = g.node().getBoundingClientRect();
1428
1019
  g.attr('x', Number(x) + Number(xWidth) / 2 - width / 2);
1429
1020
  });
1430
1021
  };
1431
- this.addLabelToRectRight = _ref9 => {
1022
+ this.addLabelToRectRight = _ref7 => {
1432
1023
  let {
1433
1024
  container,
1434
1025
  x,
@@ -1438,7 +1029,7 @@ class ChartComponent extends _react.Component {
1438
1029
  theme,
1439
1030
  label_font_size,
1440
1031
  text
1441
- } = _ref9;
1032
+ } = _ref7;
1442
1033
  d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('x', Number(x) + Number(xWidth) + 10).attr('y', Number(y)).attr('fill', theme.labelColor).attr('dominant-baseline', 'hanging').attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
1443
1034
  if (g.node()) {
1444
1035
  var _g$node;
@@ -1449,7 +1040,7 @@ class ChartComponent extends _react.Component {
1449
1040
  }
1450
1041
  });
1451
1042
  };
1452
- this.addLabelToRectCenter = _ref10 => {
1043
+ this.addLabelToRectCenter = _ref8 => {
1453
1044
  let {
1454
1045
  chartType,
1455
1046
  container,
@@ -1460,8 +1051,9 @@ class ChartComponent extends _react.Component {
1460
1051
  theme,
1461
1052
  label_font_size,
1462
1053
  text
1463
- } = _ref10;
1054
+ } = _ref8;
1464
1055
  d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
1056
+ if (!g.node()) return;
1465
1057
  const {
1466
1058
  width,
1467
1059
  height
@@ -1502,25 +1094,32 @@ class ChartComponent extends _react.Component {
1502
1094
  }
1503
1095
  };
1504
1096
  // Use clipPath to make rectangle rounded corners
1505
- this.addClipPath = _ref11 => {
1097
+ this.addClipPath = _ref9 => {
1506
1098
  let {
1507
1099
  rect,
1508
1100
  parentNode,
1509
1101
  attr,
1510
- rectId
1511
- } = _ref11;
1102
+ rectId,
1103
+ borderRadiusVal
1104
+ } = _ref9;
1512
1105
  const {
1513
1106
  borderRadius
1514
1107
  } = this.chartBoundingClientRect;
1515
1108
  const clipRect = d3.select(rect.cloneNode());
1516
1109
  if (attr === 'x') {
1517
- const borderRadiusVal = Number(rect.getAttribute('height')) * borderRadius;
1518
- clipRect.attr('rx', borderRadiusVal);
1519
- clipRect.attr('x', Number(rect.getAttribute('x')) - borderRadiusVal).attr('width', Number(rect.getAttribute('width')) + borderRadiusVal);
1110
+ const rectHeight = Number(rect.getAttribute('height'));
1111
+ const rectWidth = Number(rect.getAttribute('width'));
1112
+ const computedBorderRadius = Math.min(rectHeight * borderRadius, rectWidth / 2);
1113
+ const safeBorderRadius = Math.min(borderRadiusVal !== null && borderRadiusVal !== void 0 ? borderRadiusVal : computedBorderRadius, rectWidth / 2, rectHeight / 2);
1114
+ clipRect.attr('rx', safeBorderRadius);
1115
+ clipRect.attr('x', Number(rect.getAttribute('x')) - safeBorderRadius).attr('width', rectWidth + safeBorderRadius);
1520
1116
  } else {
1521
- const borderRadiusVal = Number(rect.getAttribute('width')) * borderRadius;
1522
- clipRect.attr('rx', borderRadiusVal);
1523
- clipRect.attr('height', Number(rect.getAttribute('height')) + borderRadiusVal);
1117
+ const rectWidth = Number(rect.getAttribute('width'));
1118
+ const rectHeight = Number(rect.getAttribute('height'));
1119
+ const computedBorderRadius = Math.min(rectWidth * borderRadius, rectHeight / 2);
1120
+ const safeBorderRadius = Math.min(borderRadiusVal !== null && borderRadiusVal !== void 0 ? borderRadiusVal : computedBorderRadius, rectWidth / 2, rectHeight / 2);
1121
+ clipRect.attr('rx', safeBorderRadius);
1122
+ clipRect.attr('height', rectHeight + safeBorderRadius);
1524
1123
  }
1525
1124
  const clipPath = d3.select(parentNode).append('clipPath').attr('opacity', 1).attr('id', rectId);
1526
1125
  clipPath.node().appendChild(clipRect.node());
@@ -1574,6 +1173,7 @@ class ChartComponent extends _react.Component {
1574
1173
  // Hide overlapping ticks
1575
1174
  for (let i = 0; i < allTicks.length; i++) {
1576
1175
  const curText = d3.select(allTicks[i]).select('text').node();
1176
+ if (!curText) continue;
1577
1177
  const {
1578
1178
  right: curRight,
1579
1179
  bottom: curBottom
@@ -1638,6 +1238,7 @@ class ChartComponent extends _react.Component {
1638
1238
  viewBox[0] = "-".concat(width - insertPadding);
1639
1239
  viewBox[viewBox.length - 2] = "".concat(Number(viewWidth) + (width - insertPadding));
1640
1240
  queueMicrotask(() => {
1241
+ if (!this.chart) return;
1641
1242
  this.chart.attr('viewBox', viewBox.join(','));
1642
1243
  });
1643
1244
  }
@@ -1670,6 +1271,7 @@ class ChartComponent extends _react.Component {
1670
1271
  const viewHeight = viewBox[viewBox.length - 1];
1671
1272
  viewBox[viewBox.length - 1] = "".concat(Number(viewHeight) + (height - insertPadding));
1672
1273
  queueMicrotask(() => {
1274
+ if (!this.chart) return;
1673
1275
  this.chart.attr('viewBox', viewBox.join(','));
1674
1276
  });
1675
1277
  }
@@ -1681,6 +1283,7 @@ class ChartComponent extends _react.Component {
1681
1283
  ticks.forEach(tick => {
1682
1284
  var _d3$select$select;
1683
1285
  const text = (_d3$select$select = d3.select(tick).select('text')) === null || _d3$select$select === void 0 ? void 0 : _d3$select$select.node();
1286
+ if (!text) return;
1684
1287
  d3.select(tick).select('line').attr('data-name', text.innerHTML);
1685
1288
  });
1686
1289
  }