sea-chart 2.0.42 → 2.0.44

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 (60) hide show
  1. package/dist/components/color-popover/color-rules/rule-filters/number-input.js +2 -2
  2. package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +2 -2
  3. package/dist/components/tooltip/index.js +11 -4
  4. package/dist/constants/index.js +8 -3
  5. package/dist/context.js +10 -7
  6. package/dist/model/base-model.js +4 -0
  7. package/dist/model/combination.js +4 -0
  8. package/dist/model/horizontal-bar.js +4 -0
  9. package/dist/model/horizontal-group-bar.js +5 -1
  10. package/dist/model/stacked-horizontal-bar.js +4 -0
  11. package/dist/settings/advance-bar-settings/style-settings.js +24 -7
  12. package/dist/settings/bar-settings/style-settings.js +24 -7
  13. package/dist/settings/combination-settings/style-settings.js +35 -10
  14. package/dist/settings/time-comparison-settings/style-settings.js +24 -7
  15. package/dist/settings/widgets/axis-title-font-settings/index.js +39 -0
  16. package/dist/utils/cell-format-utils.js +2 -2
  17. package/dist/utils/chart-utils/base-utils.js +49 -13
  18. package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +4 -3
  19. package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +3 -3
  20. package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +2 -2
  21. package/dist/utils/chart-utils/sql-statistics-utils.js +64 -18
  22. package/dist/utils/row-record-utils.js +21 -5
  23. package/dist/utils/sql/column-2-sql-column.js +2 -0
  24. package/dist/view/index.css +0 -17
  25. package/dist/view/wrapper/area-group.js +14 -25
  26. package/dist/view/wrapper/area.js +14 -27
  27. package/dist/view/wrapper/bar-compare.js +10 -15
  28. package/dist/view/wrapper/bar-custom-stack.js +19 -81
  29. package/dist/view/wrapper/bar-group.js +15 -50
  30. package/dist/view/wrapper/bar-stack.js +12 -40
  31. package/dist/view/wrapper/bar.js +10 -23
  32. package/dist/view/wrapper/basic-number-card.js +9 -2
  33. package/dist/view/wrapper/chart-component.js +461 -76
  34. package/dist/view/wrapper/combination.js +17 -29
  35. package/dist/view/wrapper/completeness-group.js +13 -59
  36. package/dist/view/wrapper/completeness.js +14 -60
  37. package/dist/view/wrapper/dashboard.js +8 -14
  38. package/dist/view/wrapper/funnel.js +6 -18
  39. package/dist/view/wrapper/heat-map.js +80 -50
  40. package/dist/view/wrapper/horizontal-bar-group.js +14 -25
  41. package/dist/view/wrapper/horizontal-bar-stack.js +16 -61
  42. package/dist/view/wrapper/horizontal-bar.js +10 -25
  43. package/dist/view/wrapper/index.js +3 -0
  44. package/dist/view/wrapper/line-group.js +11 -21
  45. package/dist/view/wrapper/line.js +11 -23
  46. package/dist/view/wrapper/map-bubble.js +9 -14
  47. package/dist/view/wrapper/map-world-bubble.js +9 -14
  48. package/dist/view/wrapper/map-world.js +9 -14
  49. package/dist/view/wrapper/map.js +9 -13
  50. package/dist/view/wrapper/mirror.js +7 -20
  51. package/dist/view/wrapper/pie.js +9 -12
  52. package/dist/view/wrapper/ring.js +10 -13
  53. package/dist/view/wrapper/scatter.js +13 -23
  54. package/dist/view/wrapper/table/pivot-table-display-name.js +2 -2
  55. package/dist/view/wrapper/table-element/components/formatter.js +2 -2
  56. package/dist/view/wrapper/table-element/components/records-body.js +8 -2
  57. package/dist/view/wrapper/table-element/components/records.js +2 -4
  58. package/dist/view/wrapper/treemap.js +8 -18
  59. package/dist/view/wrapper/trend.js +3 -2
  60. package/package.json +2 -2
@@ -1,7 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import classNames from 'classnames';
4
- import { debounce } from 'lodash-es';
5
3
  import { CellType } from 'dtable-utils';
6
4
  import * as d3 from 'd3';
7
5
  import { CHART_LINE_TYPES, CHART_THEME_COLOR } from '../../constants';
@@ -13,11 +11,6 @@ import ChartComponent from './chart-component';
13
11
  class AreaGroup extends ChartComponent {
14
12
  constructor(props) {
15
13
  super(props);
16
- this.handleResize = () => {
17
- this.destroyChart();
18
- this.createChart();
19
- this.drawChart();
20
- };
21
14
  this.createChart = () => {
22
15
  const {
23
16
  chart
@@ -29,8 +22,8 @@ class AreaGroup extends ChartComponent {
29
22
  } = chart.config;
30
23
  const initConfig = {
31
24
  insertPadding: 30,
32
- marginLeft: y_axis_show_label ? 20 : 0,
33
- marginBottom: x_axis_show_label ? 20 : 0,
25
+ marginLeft: y_axis_show_label ? this.getAxisTitleHeight(chart.config.y_axis_label_font_size) : 0,
26
+ marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0,
34
27
  marginTop: y_axis_show_value ? 15 : 0
35
28
  };
36
29
  this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
@@ -114,6 +107,7 @@ class AreaGroup extends ChartComponent {
114
107
  circleData[index]['x'] = xVal;
115
108
  circleData[index]['name'] = d.name;
116
109
  circleData[index]['group_name'] = group_name;
110
+ circleData[index]['originalData'] = d;
117
111
  return xVal;
118
112
  }).y((d, index) => {
119
113
  const yVal = y(d.value);
@@ -146,7 +140,7 @@ class AreaGroup extends ChartComponent {
146
140
  } = _ref3;
147
141
  circleData.forEach(item => {
148
142
  if (Object.keys(item).length !== 0) {
149
- contentWrapper.append('circle').attr('cx', item.x).attr('cy', item.y).attr('r', 3).attr('fill', this.colorMap[group_name]).attr('opacity', y_axis_show_value ? 1 : 0).attr('data-text', item.value).attr('data-name', item.name).call(g => {
143
+ contentWrapper.append('circle').datum(item).attr('cx', item.x).attr('cy', item.y).attr('r', 3).attr('fill', this.colorMap[group_name]).attr('opacity', y_axis_show_value ? 1 : 0).attr('data-text', item.value).attr('data-name', item.name).call(g => {
150
144
  // circle label
151
145
  if (y_axis_show_value) {
152
146
  const curCircleEl = g.node();
@@ -160,11 +154,15 @@ class AreaGroup extends ChartComponent {
160
154
  });
161
155
  }
162
156
  }).on('click', (event, data) => {
163
- this.props.toggleRecords(data);
157
+ this.props.toggleRecords(data.originalData || data);
164
158
  });
165
159
  }
166
160
  });
167
161
  });
162
+ this.animateFadeIn(contentWrapper.selectAll('.line'));
163
+ this.animateFadeIn(contentWrapper.selectAll('.area'));
164
+ this.animateFadeIn(contentWrapper.selectAll('circle'), this.transitionDuration, this.transitionDuration * 0.5);
165
+ this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
168
166
  this.chart.on('mouseover', event => {
169
167
  this.updateCircleAndTickStyle({
170
168
  event,
@@ -244,8 +242,8 @@ class AreaGroup extends ChartComponent {
244
242
  d3.select(circle).attr('r', 3);
245
243
  }
246
244
  });
247
- contentWrapper.selectAll('.area').transition().duration(this.areaTransitionDuration).attr('opacity', 0.1);
248
- contentWrapper.selectAll('.line').transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
245
+ contentWrapper.selectAll('.area').transition().duration(this.interactionDuration).attr('opacity', 0.1);
246
+ contentWrapper.selectAll('.line').transition().duration(this.interactionDuration).attr('opacity', 0.3);
249
247
  // line
250
248
  const theme = CHART_THEME_COLOR[globalTheme];
251
249
  this.clearOldVerticalAnnotation(contentWrapper);
@@ -260,8 +258,8 @@ class AreaGroup extends ChartComponent {
260
258
  }
261
259
  d3.select(circle).attr('r', 3);
262
260
  });
263
- contentWrapper.selectAll('.area').transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
264
- contentWrapper.selectAll('.line').transition().duration(this.areaTransitionDuration).attr('opacity', 1);
261
+ contentWrapper.selectAll('.area').transition().duration(this.interactionDuration).attr('opacity', 0.3);
262
+ contentWrapper.selectAll('.line').transition().duration(this.interactionDuration).attr('opacity', 1);
265
263
  // line
266
264
  this.clearOldVerticalAnnotation(contentWrapper);
267
265
  }
@@ -363,8 +361,6 @@ class AreaGroup extends ChartComponent {
363
361
  componentDidMount() {
364
362
  this.createChart();
365
363
  this.drawChart();
366
- this.debouncedHandleResize = debounce(this.handleResize, 300);
367
- window.addEventListener('resize', this.debouncedHandleResize);
368
364
  super.componentDidMount();
369
365
  }
370
366
  componentDidUpdate(prevProps) {
@@ -377,23 +373,16 @@ class AreaGroup extends ChartComponent {
377
373
  }
378
374
  componentWillUnmount() {
379
375
  this.destroyChart();
380
- window.removeEventListener('resize', this.debouncedHandleResize);
381
376
  super.componentWillUnmount();
382
377
  }
383
378
  render() {
384
- const {
385
- chart
386
- } = this.props;
387
379
  const {
388
380
  tooltipData,
389
381
  toolTipPosition
390
382
  } = this.state;
391
383
  return /*#__PURE__*/React.createElement("div", {
392
384
  ref: ref => this.container = ref,
393
- className: classNames('sea-chart-container', {
394
- 'show-x-axis-label': this.isShowXAxisLabel(chart),
395
- 'show-y-axis-label': this.isShowYAxisLabel(chart)
396
- })
385
+ className: "sea-chart-container"
397
386
  }, /*#__PURE__*/React.createElement(ToolTip, {
398
387
  tooltipData: tooltipData,
399
388
  toolTipPosition: toolTipPosition,
@@ -1,7 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import classNames from 'classnames';
4
- import { debounce } from 'lodash-es';
5
3
  import * as d3 from 'd3';
6
4
  import { CHART_LINE_TYPES, CHART_STYLE_COLORS, CHART_THEME_COLOR, TYPE_COLOR_USING } from '../../constants';
7
5
  import intl from '../../intl';
@@ -11,11 +9,6 @@ import ChartComponent from './chart-component';
11
9
  class Area extends ChartComponent {
12
10
  constructor(props) {
13
11
  super(props);
14
- this.handleResize = () => {
15
- this.destroyChart();
16
- this.createChart();
17
- this.drawChart();
18
- };
19
12
  this.createChart = () => {
20
13
  const {
21
14
  chart
@@ -27,8 +20,8 @@ class Area extends ChartComponent {
27
20
  } = chart.config;
28
21
  const initConfig = {
29
22
  insertPadding: 30,
30
- marginLeft: y_axis_show_label ? 20 : 0,
31
- marginBottom: x_axis_show_label ? 20 : 0,
23
+ marginLeft: y_axis_show_label ? this.getAxisTitleHeight(chart.config.y_axis_label_font_size) : 0,
24
+ marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0,
32
25
  marginTop: y_axis_show_value ? 15 : 0
33
26
  };
34
27
  this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
@@ -103,6 +96,7 @@ class Area extends ChartComponent {
103
96
  const xVal = x(d.name) + x.bandwidth() / 2;
104
97
  circleData[index]['x'] = xVal;
105
98
  circleData[index]['name'] = d.name;
99
+ circleData[index]['originalData'] = d;
106
100
  return xVal;
107
101
  }).y((d, index) => {
108
102
  const yVal = y(d.value);
@@ -110,18 +104,18 @@ class Area extends ChartComponent {
110
104
  circleData[index]['value'] = d.value;
111
105
  return yVal;
112
106
  }).curve(line_type === CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
113
- this.Line = contentWrapper.append('path').attr('opacity', 1).attr('fill', 'none').attr('stroke', this.getAreaColor()).attr('stroke-width', 2).attr('d', () => line(data));
107
+ this.Line = contentWrapper.append('path').attr('opacity', 1).attr('fill', 'none').attr('stroke', this.getAreaColor()).attr('stroke-width', 2).attr('d', () => line(data)).call(g => this.animateFadeIn(g, this.transitionDuration));
114
108
 
115
109
  // Area
116
110
  const area = d3.area().x(d => {
117
111
  const xVal = x(d.name) + x.bandwidth() / 2;
118
112
  return xVal;
119
113
  }).y0(y(0)).y1(d => y(d.value)).curve(line_type === CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
120
- this.Area = contentWrapper.append('path').attr('fill', this.getAreaColor()).attr('d', () => area(data)).attr('opacity', '0.3');
114
+ this.Area = contentWrapper.append('path').attr('fill', this.getAreaColor()).attr('d', () => area(data)).attr('opacity', '0.3').call(g => this.animateFadeIn(g, this.transitionDuration));
121
115
 
122
116
  // circle
123
117
  circleData.forEach(item => {
124
- contentWrapper.append('circle').attr('cx', item.x).attr('cy', item.y).attr('r', 3).attr('fill', this.getAreaColor()).attr('opacity', y_axis_show_value ? 1 : 0).attr('data-text', item.value).attr('data-name', item.name).call(g => {
118
+ contentWrapper.append('circle').datum(item).attr('cx', item.x).attr('cy', item.y).attr('r', 3).attr('fill', this.getAreaColor()).attr('opacity', y_axis_show_value ? 1 : 0).attr('data-text', item.value).attr('data-name', item.name).call(g => {
125
119
  // circle label
126
120
  if (y_axis_show_value) {
127
121
  const curCircleEl = g.node();
@@ -135,9 +129,11 @@ class Area extends ChartComponent {
135
129
  });
136
130
  }
137
131
  }).on('click', (event, data) => {
138
- this.props.toggleRecords(data);
132
+ this.props.toggleRecords(data.originalData || data);
139
133
  });
140
134
  });
135
+ this.animateFadeIn(contentWrapper.selectAll('circle'), this.transitionDuration, this.transitionDuration * 0.5);
136
+ this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
141
137
  this.chart.on('mouseover', event => {
142
138
  this.updateCircleAndTickStyle({
143
139
  event,
@@ -204,8 +200,8 @@ class Area extends ChartComponent {
204
200
  d3.select(circle).attr('r', 3);
205
201
  }
206
202
  });
207
- this.Area.transition().duration(this.areaTransitionDuration).attr('opacity', 0.1);
208
- this.Line.transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
203
+ this.Area.transition().duration(this.interactionDuration).attr('opacity', 0.1);
204
+ this.Line.transition().duration(this.interactionDuration).attr('opacity', 0.3);
209
205
  // line
210
206
  const theme = CHART_THEME_COLOR[globalTheme];
211
207
  this.clearOldVerticalAnnotation(contentWrapper);
@@ -220,8 +216,8 @@ class Area extends ChartComponent {
220
216
  }
221
217
  d3.select(circle).attr('r', 3);
222
218
  });
223
- this.Area.transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
224
- this.Line.transition().duration(this.areaTransitionDuration).attr('opacity', 1);
219
+ this.Area.transition().duration(this.interactionDuration).attr('opacity', 0.3);
220
+ this.Line.transition().duration(this.interactionDuration).attr('opacity', 1);
225
221
  // line
226
222
  this.clearOldVerticalAnnotation(contentWrapper);
227
223
  }
@@ -329,8 +325,6 @@ class Area extends ChartComponent {
329
325
  componentDidMount() {
330
326
  this.createChart();
331
327
  this.drawChart();
332
- this.debouncedHandleResize = debounce(this.handleResize, 300);
333
- window.addEventListener('resize', this.debouncedHandleResize);
334
328
  super.componentDidMount();
335
329
  }
336
330
  componentDidUpdate(prevProps) {
@@ -343,23 +337,16 @@ class Area extends ChartComponent {
343
337
  }
344
338
  componentWillUnmount() {
345
339
  this.destroyChart();
346
- window.removeEventListener('resize', this.debouncedHandleResize);
347
340
  super.componentWillUnmount();
348
341
  }
349
342
  render() {
350
- const {
351
- chart
352
- } = this.props;
353
343
  const {
354
344
  tooltipData,
355
345
  toolTipPosition
356
346
  } = this.state;
357
347
  return /*#__PURE__*/React.createElement("div", {
358
348
  ref: ref => this.container = ref,
359
- className: classNames('sea-chart-container', {
360
- 'show-x-axis-label': this.isShowXAxisLabel(chart),
361
- 'show-y-axis-label': this.isShowYAxisLabel(chart)
362
- })
349
+ className: "sea-chart-container"
363
350
  }, /*#__PURE__*/React.createElement(ToolTip, {
364
351
  tooltipData: tooltipData,
365
352
  toolTipPosition: toolTipPosition,
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import * as d3 from 'd3';
4
- import classNames from 'classnames';
5
4
  import { getNumberDisplayString } from 'dtable-utils';
6
5
  import { CHART_SUMMARY_SHOW, TITLE_AMOUNT, TITLE_INCREASE, CHART_THEME_COLOR } from '../../constants';
7
6
  import { BaseUtils } from '../../utils/chart-utils';
@@ -22,8 +21,8 @@ class BarCompare extends ChartComponent {
22
21
  const initConfig = {
23
22
  insertPadding: 30,
24
23
  borderRadius: 0.2,
25
- marginLeft: y_axis_show_label ? 20 : 0,
26
- marginBottom: x_axis_show_label ? 20 : 0
24
+ marginLeft: y_axis_show_label ? this.getAxisTitleHeight(chart.config.y_axis_label_font_size) : 0,
25
+ marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0
27
26
  };
28
27
  this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
29
28
  };
@@ -85,14 +84,11 @@ class BarCompare extends ChartComponent {
85
84
  .selectAll().data(_ref2 => {
86
85
  let [a, d] = _ref2;
87
86
  return d;
88
- }).join('rect').attr('opacity', 1).attr('x', (d, index) => index * x.bandwidth()).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value) === 0 ? 0 : y(0) - y(d.value)).attr('fill', d => color(d.group_name)).attr('data-value', d => d.value).attr('data-groupName', d => d.name).attr('data-slugid', d => d.slugId).call(g => {
87
+ }).join('rect').attr('opacity', 1).attr('x', (d, index) => index * x.bandwidth()).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value) === 0 ? 0 : y(0) - y(d.value)).attr('fill', d => color(d.group_name)).attr('data-value', d => d.value).attr('data-groupName', d => d.name).call(g => {
89
88
  g.nodes().forEach(rect => {
90
- const parentNode = rect.parentNode;
91
89
  // add rect borderRadius
92
90
  this.addClipPath({
93
- rect,
94
- parentNode,
95
- rectId: rect.getAttribute('data-slugid')
91
+ rect
96
92
  });
97
93
  });
98
94
  }).on('click', (event, data) => {
@@ -105,6 +101,9 @@ class BarCompare extends ChartComponent {
105
101
  }).on('mouseleave', event => {
106
102
  this.hiddenTooltip();
107
103
  this.handleAcitveAndInActiveState('active', event);
104
+ }).call(g => {
105
+ this.animateRectGrowInY(g);
106
+ this.animateFadeIn(this.chart.select('.content-wrapper').selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
108
107
  });
109
108
  if (display_increase) {
110
109
  const increaseData = this.getIncreaseData(data);
@@ -303,6 +302,7 @@ class BarCompare extends ChartComponent {
303
302
  componentDidMount() {
304
303
  this.createChart();
305
304
  this.drawChart();
305
+ super.componentDidMount();
306
306
  }
307
307
  componentDidUpdate(prevProps) {
308
308
  super.componentDidUpdate(prevProps);
@@ -314,21 +314,16 @@ class BarCompare extends ChartComponent {
314
314
  }
315
315
  componentWillUnmount() {
316
316
  this.destroyChart();
317
+ super.componentWillUnmount();
317
318
  }
318
319
  render() {
319
- const {
320
- chart
321
- } = this.props;
322
320
  const {
323
321
  tooltipData,
324
322
  toolTipPosition
325
323
  } = this.state;
326
324
  return /*#__PURE__*/React.createElement("div", {
327
325
  ref: ref => this.container = ref,
328
- className: classNames('sea-chart-container', {
329
- 'show-x-axis-label': this.isShowXAxisLabel(chart),
330
- 'show-y-axis-label': this.isShowYAxisLabel(chart)
331
- })
326
+ className: "sea-chart-container"
332
327
  }, /*#__PURE__*/React.createElement(ToolTip, {
333
328
  tooltipData: tooltipData,
334
329
  toolTipPosition: toolTipPosition,
@@ -1,9 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { debounce } from 'lodash-es';
4
3
  import * as d3 from 'd3';
5
4
  import slugid from 'slugid';
6
- import classNames from 'classnames';
7
5
  import intl from '../../intl';
8
6
  import { BaseUtils } from '../../utils/chart-utils';
9
7
  import { EMPTY_NAME, CHART_THEME_COLOR } from '../../constants';
@@ -12,11 +10,6 @@ import ChartComponent from './chart-component';
12
10
  class BarCustom extends ChartComponent {
13
11
  constructor(props) {
14
12
  super(props);
15
- this.handleResize = debounce(() => {
16
- this.destroyChart();
17
- this.createChart();
18
- this.drawChart();
19
- }, 300);
20
13
  this.createChart = () => {
21
14
  const {
22
15
  chart
@@ -28,8 +21,8 @@ class BarCustom extends ChartComponent {
28
21
  const initConfig = {
29
22
  insertPadding: 30,
30
23
  borderRadius: 0.2,
31
- marginLeft: y_axis_show_label ? 20 : 0,
32
- marginBottom: x_axis_show_label ? 20 : 0
24
+ marginLeft: y_axis_show_label ? this.getAxisTitleHeight(chart.config.y_axis_label_font_size) : 0,
25
+ marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0
33
26
  };
34
27
  this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
35
28
  };
@@ -174,9 +167,6 @@ class BarCustom extends ChartComponent {
174
167
  const height = y(d[0][0]) - y(d[0][1]);
175
168
  return isNaN(height) ? 0 : height;
176
169
  }).attr('fill', d => color(d.key)).attr('data-value', d => d.stackData.value).attr('data-rectId', d => d.stackData.slugId).attr('data-groupName', d => d.stackData.group_name).attr('data-title', d => d.stackData.name).call(g => {
177
- const {
178
- borderRadius
179
- } = this.chartBoundingClientRect;
180
170
  const xWidth = x.bandwidth();
181
171
  const stackGroupNodes = Array.from(g._parents);
182
172
  const nameGroups = [];
@@ -188,28 +178,19 @@ class BarCustom extends ChartComponent {
188
178
  });
189
179
  nameGroups.forEach(nameGroup => {
190
180
  const stackGroups = Array.from(nameGroup.children);
191
- let groupBorderRadius = Infinity;
192
- stackGroups.forEach(stackGroup => {
193
- const topRect = Array.from(stackGroup.children).reverse().find(rect => Number(rect.getAttribute('height')) !== 0);
194
- if (!topRect) return;
195
- const rectHeight = Number(topRect.getAttribute('height'));
196
- const computedBorderRadius = Math.min(xWidth * borderRadius, rectHeight / 2, xWidth / 2);
197
- groupBorderRadius = Math.min(groupBorderRadius, computedBorderRadius);
198
- });
199
- if (!Number.isFinite(groupBorderRadius)) {
200
- groupBorderRadius = 0;
201
- }
202
181
  stackGroups.forEach(stackGroup => {
203
182
  const topRect = Array.from(stackGroup.children).reverse().find(rect => Number(rect.getAttribute('height')) !== 0);
204
183
  if (!topRect) return;
205
- this.addMaskRect(stackGroup, topRect, xWidth, color, groupBorderRadius);
184
+ this.addMaskRect(stackGroup, topRect, xWidth);
206
185
  });
207
186
  });
208
187
  if (display_each_block_data) {
209
188
  this.handleLabelToRectCenter(g, xWidth);
210
189
  }
190
+ this.animateFadeIn(this.chart.select('.content-wrapper').selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
191
+ this.animateStackGrowInY(g, rect => rect.parentNode.getAttribute('data-slugid'));
211
192
  }).on('click', (event, data) => {
212
- this.props.toggleRecords(data);
193
+ this.props.toggleRecords(data.stackData);
213
194
  }).on('mouseover', event => {
214
195
  this.showTooltip(event, color);
215
196
  this.handleStacksAcitveAndInActiveState('inActive', event);
@@ -241,7 +222,6 @@ class BarCustom extends ChartComponent {
241
222
  const theme = CHART_THEME_COLOR[globalTheme];
242
223
  Array.from(g._parents).forEach(group => {
243
224
  Array.from(group.children).forEach(rect => {
244
- // The height is 0, and the label is not displayed.
245
225
  if (Number(rect.getAttribute('height')) === 0) return;
246
226
  this.addLabelToRectCenter({
247
227
  container: rect.parentNode,
@@ -256,28 +236,8 @@ class BarCustom extends ChartComponent {
256
236
  });
257
237
  });
258
238
  };
259
- this.addMaskRect = (topG, rect, xWidth, colorScale, borderRadiusVal) => {
260
- const {
261
- borderRadius
262
- } = this.chartBoundingClientRect;
263
- const rectHeight = Number(rect.getAttribute('height'));
264
- const computedBorderRadius = Math.min(xWidth * borderRadius, rectHeight / 2, xWidth / 2);
265
- const safeBorderRadius = Math.min(borderRadiusVal !== null && borderRadiusVal !== void 0 ? borderRadiusVal : computedBorderRadius, rectHeight / 2, xWidth / 2);
266
- // Add mask rect
267
- d3.select(topG).append('foreignObject').attr('class', 'stack-wrapper').attr('opacity', rect.getAttribute('opacity')).attr('x', rect.getAttribute('x')).attr('data-x', topG.parentNode.getAttribute('data-transform')).attr('y', rect.getAttribute('y')).attr('width', xWidth).attr('height', rect.getAttribute('height')).attr('data-groupName', rect.getAttribute('data-groupName')).attr('data-value', rect.getAttribute('data-value')).attr('data-title', rect.getAttribute('data-title')).attr('data-rectId', rect.getAttribute('data-rectId')).on('click', (event, data) => {
268
- this.props.toggleRecords(data);
269
- }).on('mouseover', event => {
270
- this.showTooltip(event, colorScale, true);
271
- this.handleStacksAcitveAndInActiveState('inActive', event);
272
- }).on('mousemove', event => {
273
- this.moveTooltip(event, true);
274
- }).on('mouseleave', (event, data) => {
275
- this.hiddenTooltip();
276
- this.handleStacksAcitveAndInActiveState('active', event);
277
- }).append('xhtml:div').attr('class', 'stack').attr('data-rectId', rect.getAttribute('data-rectId')).attr('style', `width: 100%; height: 100%; background-color: ${rect.getAttribute('fill')}; border-radius: ${safeBorderRadius}px ${safeBorderRadius}px 0px 0px`);
278
-
279
- // Remove old rect
280
- d3.select(rect).remove();
239
+ this.addMaskRect = (topG, rect, xWidth) => {
240
+ return this.addRoundedClip(rect, 'y', xWidth);
281
241
  };
282
242
  this.handleStacksAcitveAndInActiveState = (state, event) => {
283
243
  const rectsWrapper = event.currentTarget.parentNode.parentNode.parentNode;
@@ -286,10 +246,8 @@ class BarCustom extends ChartComponent {
286
246
  allGroup.forEach(group => {
287
247
  Array.from(group.children).forEach(rectGroup => {
288
248
  Array.from(rectGroup.children).forEach(rect => {
289
- const isDiv = rect.getAttribute('class') === 'stack-wrapper';
290
- const curRect = isDiv ? rect.children[0] : rect;
291
- if (curRect.getAttribute('class') === 'stack') {
292
- isDiv ? d3.select(curRect.parentNode).transition().duration(this.transitionDuration).attr('opacity', 1) : d3.select(curRect).transition().duration(this.transitionDuration).attr('opacity', 1);
249
+ if (rect.getAttribute('class') === 'stack') {
250
+ d3.select(rect).transition().duration(this.interactionDuration).attr('opacity', 1);
293
251
  }
294
252
  });
295
253
  });
@@ -300,27 +258,19 @@ class BarCustom extends ChartComponent {
300
258
  allGroup.forEach(group => {
301
259
  Array.from(group.children).forEach(rectGroup => {
302
260
  Array.from(rectGroup.children).forEach(rect => {
303
- const isDiv = rect.getAttribute('class') === 'stack-wrapper';
304
- const curRect = isDiv ? rect.children[0] : rect;
305
- if (curRect.getAttribute('class') === 'stack' && curRect.getAttribute('data-rectId') !== curRectId) {
306
- isDiv ? d3.select(curRect.parentNode).transition().duration(this.transitionDuration).attr('opacity', 0.3) : d3.select(curRect).transition().duration(this.transitionDuration).attr('opacity', 0.3);
261
+ if (rect.getAttribute('class') === 'stack' && rect.getAttribute('data-rectId') !== curRectId) {
262
+ d3.select(rect).transition().duration(this.interactionDuration).attr('opacity', 0.3);
307
263
  }
308
264
  });
309
265
  });
310
266
  });
311
267
  }
312
268
  };
313
- this.showTooltip = (event, colorScale, isDiv) => {
314
- let {
269
+ this.showTooltip = (event, colorScale) => {
270
+ const {
315
271
  offsetX,
316
272
  offsetY
317
273
  } = event;
318
- if (isDiv) {
319
- const initX = Number(event.currentTarget.getAttribute('data-x'));
320
- const initY = Number(event.currentTarget.getAttribute('y'));
321
- offsetX = offsetX + initX;
322
- offsetY = offsetY + initY;
323
- }
324
274
  const title = event.currentTarget.getAttribute('data-title');
325
275
  const name = event.currentTarget.getAttribute('data-groupName');
326
276
  const value = event.currentTarget.getAttribute('data-value');
@@ -342,17 +292,11 @@ class BarCustom extends ChartComponent {
342
292
  }
343
293
  });
344
294
  };
345
- this.moveTooltip = (event, isDiv) => {
346
- let {
295
+ this.moveTooltip = event => {
296
+ const {
347
297
  offsetX,
348
298
  offsetY
349
299
  } = event;
350
- if (isDiv) {
351
- const initX = Number(event.currentTarget.getAttribute('data-x'));
352
- const initY = Number(event.currentTarget.getAttribute('y'));
353
- offsetX = offsetX + initX;
354
- offsetY = offsetY + initY;
355
- }
356
300
  this.setState({
357
301
  toolTipPosition: {
358
302
  offsetX,
@@ -374,7 +318,7 @@ class BarCustom extends ChartComponent {
374
318
  componentDidMount() {
375
319
  this.createChart();
376
320
  this.drawChart();
377
- window.addEventListener('resize', this.handleResize);
321
+ super.componentDidMount();
378
322
  }
379
323
  componentDidUpdate(prevProps) {
380
324
  super.componentDidUpdate(prevProps);
@@ -386,22 +330,16 @@ class BarCustom extends ChartComponent {
386
330
  }
387
331
  componentWillUnmount() {
388
332
  this.destroyChart();
389
- window.removeEventListener('resize', this.handleResize);
333
+ super.componentWillUnmount();
390
334
  }
391
335
  render() {
392
- const {
393
- chart
394
- } = this.props;
395
336
  const {
396
337
  tooltipData,
397
338
  toolTipPosition
398
339
  } = this.state;
399
340
  return /*#__PURE__*/React.createElement("div", {
400
341
  ref: ref => this.container = ref,
401
- className: classNames('sea-chart-container', {
402
- 'show-x-axis-label': this.isShowXAxisLabel(chart),
403
- 'show-y-axis-label': this.isShowYAxisLabel(chart)
404
- })
342
+ className: "sea-chart-container"
405
343
  }, /*#__PURE__*/React.createElement(ToolTip, {
406
344
  tooltipData: tooltipData,
407
345
  toolTipPosition: toolTipPosition,
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { CellType } from 'dtable-utils';
4
- import { debounce, cloneDeep } from 'lodash-es';
3
+ import { CellType, isEmpty } from 'dtable-utils';
4
+ import { cloneDeep } from 'lodash-es';
5
5
  import * as d3 from 'd3';
6
- import classNames from 'classnames';
7
6
  import dayjs from 'dayjs';
8
7
  import intl from '../../intl';
9
8
  import { EMPTY_NAME, CHART_THEME_COLOR, CHART_STYLE_COLORS } from '../../constants';
@@ -14,11 +13,6 @@ import ChartComponent from './chart-component';
14
13
  class BarGroup extends ChartComponent {
15
14
  constructor(props) {
16
15
  super(props);
17
- this.handleResize = () => {
18
- this.destroyChart();
19
- this.createChart();
20
- this.drawChart();
21
- };
22
16
  this.createChart = () => {
23
17
  const {
24
18
  chart
@@ -31,8 +25,8 @@ class BarGroup extends ChartComponent {
31
25
  const initConfig = {
32
26
  insertPadding: 30,
33
27
  borderRadius: 0.2,
34
- marginLeft: y_axis_show_label ? 20 : 0,
35
- marginBottom: x_axis_show_label ? 20 : 0,
28
+ marginLeft: y_axis_show_label ? this.getAxisTitleHeight(chart.config.y_axis_label_font_size) : 0,
29
+ marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0,
36
30
  marginTop: y_axis_show_value ? 15 : 0
37
31
  };
38
32
  this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
@@ -121,36 +115,11 @@ class BarGroup extends ChartComponent {
121
115
  var _this$colorMap$colorK;
122
116
  const colorKey = d.group_name || d.group_name === 0 ? d.group_name : '';
123
117
  return (_this$colorMap$colorK = this.colorMap[colorKey]) !== null && _this$colorMap$colorK !== void 0 ? _this$colorMap$colorK : CHART_STYLE_COLORS[0];
124
- }).attr('data-value', d => d.value).attr('data-groupName', d => d.name).attr('data-slugid', d => d.slugId);
125
- const {
126
- borderRadius
127
- } = this.chartBoundingClientRect;
128
- const rectNodes = rectSelection.nodes();
129
- const validRectNodes = rectNodes.filter(rect => {
130
- const rectWidth = Number(rect.getAttribute('width'));
131
- const rectHeight = Number(rect.getAttribute('height'));
132
- return rectWidth > 0 && rectHeight > 0;
133
- });
134
- let groupBorderRadius;
135
- if (validRectNodes.length > 0) {
136
- groupBorderRadius = Infinity;
137
- validRectNodes.forEach(rect => {
138
- const rectWidth = Number(rect.getAttribute('width'));
139
- const rectHeight = Number(rect.getAttribute('height'));
140
- const computedBorderRadius = Math.min(rectWidth * borderRadius, rectHeight / 2, rectWidth / 2);
141
- groupBorderRadius = Math.min(groupBorderRadius, computedBorderRadius);
142
- });
143
- if (!Number.isFinite(groupBorderRadius)) {
144
- groupBorderRadius = 0;
145
- }
146
- }
147
- rectNodes.forEach(rect => {
118
+ }).attr('data-value', d => d.value).attr('data-groupName', d => d.name);
119
+ rectSelection.nodes().forEach(rect => {
148
120
  const parentNode = rect.parentNode;
149
121
  this.addClipPath({
150
- rect,
151
- parentNode,
152
- rectId: rect.getAttribute('data-slugid'),
153
- borderRadiusVal: Number.isFinite(groupBorderRadius) ? groupBorderRadius : undefined
122
+ rect
154
123
  });
155
124
  if (y_axis_show_value) {
156
125
  this.addLabelToRectTop({
@@ -175,6 +144,9 @@ class BarGroup extends ChartComponent {
175
144
  }).on('mouseleave', event => {
176
145
  this.hiddenTooltip();
177
146
  this.handleAcitveAndInActiveState('active', event);
147
+ }).call(g => {
148
+ this.animateRectGrowInY(g);
149
+ this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
178
150
  });
179
151
  if (display_goal_line && goal_label && goal_value) {
180
152
  this.setDispalyGoalLine(goal_label, goal_value, insertPadding, y);
@@ -205,10 +177,10 @@ class BarGroup extends ChartComponent {
205
177
  const curGroup = event.target.parentNode;
206
178
  let [curGroupName, data] = curGroup.__data__;
207
179
  const newTooltipData = {
208
- title: !curGroupName && typeof curGroupName !== 'number' ? intl.get(EMPTY_NAME) : curGroupName,
180
+ title: isEmpty(curGroupName) ? intl.get(EMPTY_NAME) : curGroupName,
209
181
  items: data.map(item => {
210
182
  const rawGroupName = item.group_name;
211
- const groupName = rawGroupName === null || rawGroupName === undefined || rawGroupName === '' ? intl.get(EMPTY_NAME) : isGroupByDate ? dayjs(rawGroupName).format('YYYY-MM-DD') : rawGroupName;
183
+ const groupName = isEmpty(rawGroupName) ? intl.get(EMPTY_NAME) : isGroupByDate ? dayjs(rawGroupName).format('YYYY-MM-DD') : rawGroupName;
212
184
  return {
213
185
  color: this.colorMap[groupName],
214
186
  name: groupName,
@@ -258,8 +230,7 @@ class BarGroup extends ChartComponent {
258
230
  componentDidMount() {
259
231
  this.createChart();
260
232
  this.drawChart();
261
- this.debouncedHandleResize = debounce(this.handleResize, 300);
262
- window.addEventListener('resize', this.debouncedHandleResize);
233
+ super.componentDidMount();
263
234
  }
264
235
  componentDidUpdate(prevProps) {
265
236
  super.componentDidUpdate(prevProps);
@@ -271,22 +242,16 @@ class BarGroup extends ChartComponent {
271
242
  }
272
243
  componentWillUnmount() {
273
244
  this.destroyChart();
274
- window.removeEventListener('resize', this.debouncedHandleResize);
245
+ super.componentWillUnmount();
275
246
  }
276
247
  render() {
277
- const {
278
- chart
279
- } = this.props;
280
248
  const {
281
249
  tooltipData,
282
250
  toolTipPosition
283
251
  } = this.state;
284
252
  return /*#__PURE__*/React.createElement("div", {
285
253
  ref: ref => this.container = ref,
286
- className: classNames('sea-chart-container', {
287
- 'show-x-axis-label': this.isShowXAxisLabel(chart),
288
- 'show-y-axis-label': this.isShowYAxisLabel(chart)
289
- })
254
+ className: "sea-chart-container"
290
255
  }, /*#__PURE__*/React.createElement(ToolTip, {
291
256
  tooltipData: tooltipData,
292
257
  toolTipPosition: toolTipPosition,