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,6 +1,5 @@
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 { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS, CHART_THEME_COLOR, CHART_TYPE } from '../../constants';
6
5
  import { BaseUtils, isFunction } from '../../utils';
@@ -11,11 +10,6 @@ import ChartComponent from './chart-component';
11
10
  class Ring extends ChartComponent {
12
11
  constructor(props) {
13
12
  super(props);
14
- this.handleResize = () => {
15
- this.destroyChart();
16
- this.createChart();
17
- this.drawChart();
18
- };
19
13
  this.createChart = () => {
20
14
  const {
21
15
  chart
@@ -69,14 +63,14 @@ class Ring extends ChartComponent {
69
63
  if (!Array.isArray(newData) || newData.length === 0) return;
70
64
 
71
65
  // Color
72
- const colorDomain = new Set(data.map(d => d.name));
66
+ const colorDomain = new Set(newData.map(d => d.name));
73
67
  const colorRange = Array.from(colorDomain).map(name => colorMap[name === null || name === void 0 ? void 0 : name.trim()]);
74
68
  const color = d3.scaleOrdinal().domain(colorDomain).range(colorRange);
75
69
 
76
70
  // Ring and Arc
77
71
  const pie = d3.pie().sort(null).value(d => d.value);
78
- const arcs = pie(data);
79
- const arc = d3.arc().innerRadius(Math.min(chartWidth, chartHeight) / 2 * 0.7).outerRadius(Math.min(chartWidth, chartHeight) / 2 * 0.5);
72
+ const arcs = pie(newData);
73
+ const arc = d3.arc().innerRadius(Math.min(chartWidth, chartHeight) / 2 * 0.5).outerRadius(Math.min(chartWidth, chartHeight) / 2 * 0.7);
80
74
 
81
75
  // Draw Ring
82
76
  this.chart.append('g').attr('class', 'content-wrapper').selectAll().data(arcs).join('path').attr('stroke', 'white').attr('stroke-width', 2).attr('opacity', 1).attr('fill', d => color(d.data.name)).attr('d', arc).attr('data-groupName', d => d.data.name).call(g => {
@@ -133,13 +127,17 @@ class Ring extends ChartComponent {
133
127
  this.setAnnotationTotal(event.currentTarget.parentNode, {
134
128
  value: total
135
129
  });
130
+ }).call(g => {
131
+ this.animateArcGrowIn(g, arc);
132
+ this.animateFadeIn(this.chart.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
133
+ this.animateFadeIn(this.chart.selectAll('line'), this.transitionDuration, this.transitionDuration * 0.5);
136
134
  });
137
135
  if (show_legend) {
138
136
  this.setLegend({
139
137
  legendName: 'name',
140
138
  theme,
141
139
  legendPosition: 'center-right',
142
- data,
140
+ data: newData,
143
141
  colorScale: color
144
142
  });
145
143
  }
@@ -275,8 +273,7 @@ class Ring extends ChartComponent {
275
273
  componentDidMount() {
276
274
  this.createChart();
277
275
  this.drawChart();
278
- this.debouncedHandleResize = debounce(this.handleResize, 300);
279
- window.addEventListener('resize', this.debouncedHandleResize);
276
+ super.componentDidMount();
280
277
  }
281
278
  componentDidUpdate(prevProps) {
282
279
  super.componentDidUpdate(prevProps);
@@ -288,7 +285,7 @@ class Ring extends ChartComponent {
288
285
  }
289
286
  componentWillUnmount() {
290
287
  this.destroyChart();
291
- window.removeEventListener('resize', this.debouncedHandleResize);
288
+ super.componentWillUnmount();
292
289
  }
293
290
  render() {
294
291
  const {
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { cloneDeep, debounce } from 'lodash-es';
3
+ import { cloneDeep } from 'lodash-es';
4
4
  import * as d3 from 'd3';
5
- import classNames from 'classnames';
6
5
  import { getTableById, getTableColumnByKey } from 'dtable-utils';
7
6
  import { CHART_THEME_COLOR } from '../../constants';
8
7
  import { BaseUtils, isFunction } from '../../utils';
@@ -12,11 +11,6 @@ import ChartComponent from './chart-component';
12
11
  class Scatter extends ChartComponent {
13
12
  constructor(props) {
14
13
  super(props);
15
- this.handleResize = () => {
16
- this.destroyChart();
17
- this.createChart();
18
- this.drawChart();
19
- };
20
14
  this.createChart = () => {
21
15
  const {
22
16
  chart
@@ -28,8 +22,8 @@ class Scatter extends ChartComponent {
28
22
  } = chart.config;
29
23
  const initConfig = {
30
24
  insertPadding: 30,
31
- marginLeft: y_axis_show_label ? 20 : 0,
32
- 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,
33
27
  marginTop: y_axis_show_value ? 15 : 0,
34
28
  bottomLegendSpace: 0
35
29
  };
@@ -88,10 +82,10 @@ class Scatter extends ChartComponent {
88
82
  titleMarkColor: event.currentTarget.getAttribute('fill'),
89
83
  title: groupby || groupby === 0 ? groupby : intl.get('Empty'),
90
84
  items: [{
91
- name: selectedXAxisColumn.name,
85
+ name: selectedXAxisColumn === null || selectedXAxisColumn === void 0 ? void 0 : selectedXAxisColumn.name,
92
86
  value: name
93
87
  }, {
94
- name: selectedYAxisColumn.name,
88
+ name: selectedYAxisColumn === null || selectedYAxisColumn === void 0 ? void 0 : selectedYAxisColumn.name,
95
89
  value: value
96
90
  }]
97
91
  };
@@ -134,7 +128,7 @@ class Scatter extends ChartComponent {
134
128
  markLineWrapper.node() && markLineWrapper.node().remove();
135
129
  if (state === 'inActive') {
136
130
  // Remove stroke
137
- d3.select(event.currentTarget).attr('stroke', '').attr('storke-width', '');
131
+ d3.select(event.currentTarget).attr('stroke', '').attr('stroke-width', '');
138
132
  return;
139
133
  }
140
134
  if (state === 'active') {
@@ -229,7 +223,7 @@ class Scatter extends ChartComponent {
229
223
  const {
230
224
  groupby
231
225
  } = d;
232
- if (groupby && groupby[0] === 'groupby') {
226
+ if (!groupby) {
233
227
  return BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
234
228
  }
235
229
  return colorMap[d.groupby];
@@ -258,6 +252,9 @@ class Scatter extends ChartComponent {
258
252
  }).on('mouseleave', (event, data) => {
259
253
  this.hiddenTooltip();
260
254
  this.handleAcitveAndInActiveState('inActive', event);
255
+ }).call(g => {
256
+ this.animateCircleZoomIn(g);
257
+ this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
261
258
  });
262
259
  this.setLegend({
263
260
  legendName: 'groupby',
@@ -278,8 +275,7 @@ class Scatter extends ChartComponent {
278
275
  componentDidMount() {
279
276
  this.createChart();
280
277
  this.drawChart();
281
- this.debouncedHandleResize = debounce(this.handleResize, 300);
282
- window.addEventListener('resize', this.debouncedHandleResize);
278
+ super.componentDidMount();
283
279
  }
284
280
  componentDidUpdate(prevProps) {
285
281
  super.componentDidUpdate(prevProps);
@@ -291,22 +287,16 @@ class Scatter extends ChartComponent {
291
287
  }
292
288
  componentWillUnmount() {
293
289
  this.destroyChart();
294
- window.removeEventListener('resize', this.debouncedHandleResize);
290
+ super.componentWillUnmount();
295
291
  }
296
292
  render() {
297
- const {
298
- chart
299
- } = this.props;
300
293
  const {
301
294
  tooltipData,
302
295
  toolTipPosition
303
296
  } = this.state;
304
297
  return /*#__PURE__*/React.createElement("div", {
305
298
  ref: ref => this.container = ref,
306
- className: classNames('sea-chart-container', {
307
- 'show-x-axis-label': this.isShowXAxisLabel(chart),
308
- 'show-y-axis-label': this.isShowYAxisLabel(chart)
309
- })
299
+ className: "sea-chart-container"
310
300
  }, /*#__PURE__*/React.createElement(ToolTip, {
311
301
  tooltipData: tooltipData,
312
302
  toolTipPosition: toolTipPosition,
@@ -1,7 +1,7 @@
1
1
  import React, { Fragment } from 'react';
2
2
  import shallowEqual from 'shallowequal';
3
3
  import dayjs from 'dayjs';
4
- import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_RESULT_TYPE, getOption, getCollaborator, getNumberDisplayString, isNumber, isValidEmail, getCollaboratorsName } from 'dtable-utils';
4
+ import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_RESULT_TYPE, getOption, getCollaborator, getNumberDisplayString, isNumber, isValidEmail, getCollaboratorsName, isEmpty } from 'dtable-utils';
5
5
  import { getKnownCollaboratorByEmail, getColumnOptions, getDateColumnFormat, generateDefaultUser, getClientLinkDisplayString } from '../../../utils';
6
6
  import { Collaborator } from '../../../components';
7
7
  import intl from '../../../intl';
@@ -196,7 +196,7 @@ class PivotTableDisplayName extends React.Component {
196
196
  }
197
197
 
198
198
  // value is empty
199
- if (validValue[0] === null || validValue[0] === undefined) {
199
+ if (isEmpty(validValue[0])) {
200
200
  return /*#__PURE__*/React.createElement("div", {
201
201
  title: String(value),
202
202
  "aria-label": String(value)
@@ -22,7 +22,7 @@ import _PhoneNumberLink from "dtable-ui-component/lib/PhoneNumberLink";
22
22
  import _TextFormatter from "dtable-ui-component/lib/TextFormatter";
23
23
  import _toaster from "dtable-ui-component/lib/toaster";
24
24
  import React, { Fragment } from 'react';
25
- import { CellType, checkIsDisplayAsPhoneNumberColumn } from 'dtable-utils';
25
+ import { CellType, checkIsDisplayAsPhoneNumberColumn, isEmpty } from 'dtable-utils';
26
26
  import intl from '../../../../intl';
27
27
  import DtableFormulaFormatter from './formatters/formula-formatter';
28
28
  import LinkFormatter from './formatters/link-formatter';
@@ -151,7 +151,7 @@ class Formatter extends React.Component {
151
151
  }
152
152
  case CellType.NUMBER:
153
153
  {
154
- if (!cellValue && cellValue !== 0) return this.renderEmptyFormatter();
154
+ if (isEmpty(cellValue)) return this.renderEmptyFormatter();
155
155
  return /*#__PURE__*/React.createElement(_NumberFormatter, {
156
156
  value: cellValue,
157
157
  data: column.data || {},
@@ -76,10 +76,16 @@ class RecordsBody extends Component {
76
76
  this.setState({
77
77
  endRenderIndex
78
78
  });
79
- const resizeObserver = new ResizeObserver(() => {
79
+ this.resizeObserver = new ResizeObserver(() => {
80
80
  this.handleContainerResize();
81
81
  });
82
- resizeObserver.observe(this.tableElementResultContentRef);
82
+ this.resizeObserver.observe(this.tableElementResultContentRef);
83
+ }
84
+ componentWillUnmount() {
85
+ if (this.resizeObserver) {
86
+ this.resizeObserver.disconnect();
87
+ this.resizeObserver = null;
88
+ }
83
89
  }
84
90
  render() {
85
91
  const {
@@ -126,13 +126,11 @@ class Records extends Component {
126
126
  this.resultRef.scrollLeft += deltaX;
127
127
  };
128
128
  this.state = {
129
- scrollLeft: 0
130
- };
131
- this.resultContainerRef = null;
132
- this.state = {
129
+ scrollLeft: 0,
133
130
  displayColumns: [],
134
131
  headerDisplayColumns: []
135
132
  };
133
+ this.resultContainerRef = null;
136
134
  }
137
135
  componentDidUpdate(prevProps) {
138
136
  if (prevProps.shownColumns !== this.props.shownColumns) {
@@ -1,8 +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
- import classNames from 'classnames';
4
+ import { isEmpty } from 'dtable-utils';
6
5
  import { EMPTY_NAME } from '../../constants';
7
6
  import { BaseUtils, isFunction } from '../../utils';
8
7
  import intl from '../../intl';
@@ -11,11 +10,6 @@ import ChartComponent from './chart-component';
11
10
  class Treemap extends ChartComponent {
12
11
  constructor(props) {
13
12
  super(props);
14
- this.handleResize = () => {
15
- this.destroyChart();
16
- this.createChart();
17
- this.drawChart();
18
- };
19
13
  this.createChart = () => {
20
14
  const {
21
15
  chart
@@ -135,6 +129,9 @@ class Treemap extends ChartComponent {
135
129
  this.moveTooltip(event);
136
130
  }).on('mouseleave', event => {
137
131
  this.hiddenTooltip(event);
132
+ }).call(g => {
133
+ this.animateFadeIn(g);
134
+ this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
138
135
  });
139
136
  };
140
137
  this.getFullData = data => {
@@ -142,7 +139,7 @@ class Treemap extends ChartComponent {
142
139
  name: 'root',
143
140
  children: data.map(item => {
144
141
  let name = item.name;
145
- item.name = name || name === 0 ? name : intl.get(EMPTY_NAME);
142
+ item.name = isEmpty(name) ? intl.get(EMPTY_NAME) : name;
146
143
  if (name === '_Others') {
147
144
  item.name = intl.get('Others');
148
145
  }
@@ -160,8 +157,7 @@ class Treemap extends ChartComponent {
160
157
  componentDidMount() {
161
158
  this.createChart();
162
159
  this.drawChart();
163
- this.debouncedHandleResize = debounce(this.handleResize, 300);
164
- window.addEventListener('resize', this.debouncedHandleResize);
160
+ super.componentDidMount();
165
161
  }
166
162
  componentDidUpdate(prevProps) {
167
163
  super.componentDidUpdate(prevProps);
@@ -173,22 +169,16 @@ class Treemap extends ChartComponent {
173
169
  }
174
170
  componentWillUnmount() {
175
171
  this.destroyChart();
176
- window.removeEventListener('resize', this.debouncedHandleResize);
172
+ super.componentWillUnmount();
177
173
  }
178
174
  render() {
179
- const {
180
- chart
181
- } = this.props;
182
175
  const {
183
176
  tooltipData,
184
177
  toolTipPosition
185
178
  } = this.state;
186
179
  return /*#__PURE__*/React.createElement("div", {
187
180
  ref: ref => this.container = ref,
188
- className: classNames('sea-chart-container', {
189
- 'show-x-axis-label': this.isShowXAxisLabel(chart),
190
- 'show-y-axis-label': this.isShowYAxisLabel(chart)
191
- })
181
+ className: "sea-chart-container"
192
182
  }, /*#__PURE__*/React.createElement(ToolTip, {
193
183
  tooltipData: tooltipData,
194
184
  toolTipPosition: toolTipPosition,
@@ -1,5 +1,6 @@
1
1
  import React, { Component } from 'react';
2
- import classNames from 'classnames';
2
+ import classNames from "classnames";
3
+ import { isEmpty } from 'dtable-utils';
3
4
  import { BaseUtils } from '../../utils';
4
5
  import intl from '../../intl';
5
6
  import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_SUMMARY_TYPE, CHART_THEME_COLOR, TREND_TYPES } from '../../constants';
@@ -25,7 +26,7 @@ class Trend extends Component {
25
26
  }
26
27
  };
27
28
  this.formatData = data => {
28
- if (!data && data !== 0) return intl.get(EMPTY_NAME);
29
+ if (isEmpty(data)) return intl.get(EMPTY_NAME);
29
30
  const {
30
31
  chart,
31
32
  summaryColumn
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "2.0.42",
3
+ "version": "2.0.44",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@dnd-kit/core": "^6.1.0",
@@ -25,7 +25,7 @@
25
25
  "peerDependencies": {
26
26
  "@antv/scale": "0.3.14",
27
27
  "d3-composite-projections": "~1.4.*",
28
- "dtable-ui-component": "~6.0.*",
28
+ "dtable-ui-component": "~7.0.*",
29
29
  "dtable-utils": "~5.0.*",
30
30
  "prop-types": "15.8.1",
31
31
  "react": "^18.3.1",