sea-chart 2.0.1 → 2.0.2

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 (94) hide show
  1. package/dist/components/cell-factory/SimpleCellFormatter.js +1 -1
  2. package/dist/components/cell-factory/link-content.js +4 -4
  3. package/dist/components/color-picker/index.js +1 -1
  4. package/dist/components/color-popover/color-rules/color-rule.js +1 -1
  5. package/dist/components/color-popover/color-rules/index.js +1 -1
  6. package/dist/components/color-popover/color-rules-popover.js +6 -6
  7. package/dist/components/color-popover/color-selector-popover.js +2 -2
  8. package/dist/components/color-setting/color-group-selector.js +1 -1
  9. package/dist/components/common-add-tool/index.js +2 -2
  10. package/dist/components/data-process-setter/hide-column-setter.js +1 -1
  11. package/dist/components/data-process-setter/sort-setter.js +2 -2
  12. package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +4 -4
  13. package/dist/components/icon/index.js +2 -2
  14. package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +1 -1
  15. package/dist/components/popover/hide-column-popover/hide-column-popover.js +1 -1
  16. package/dist/components/popover/sort-popover/sort-popover.js +1 -1
  17. package/dist/components/row-card/row-card-header-cell.js +2 -2
  18. package/dist/components/row-card/row-card-header.js +1 -1
  19. package/dist/components/row-card/row-card-item.js +2 -2
  20. package/dist/components/row-card/row-card.js +2 -2
  21. package/dist/components/statistic-record-dialog/index.js +1 -1
  22. package/dist/components/types-dialog/index.js +7 -7
  23. package/dist/context.js +2 -2
  24. package/dist/services/map-json.js +4 -4
  25. package/dist/settings/basic-number-card/style-settings.js +1 -1
  26. package/dist/settings/index.js +3 -3
  27. package/dist/settings/map-settings/map-style-settings.js +1 -1
  28. package/dist/settings/stacks-settings/index.js +1 -1
  29. package/dist/settings/style-settings.js +1 -1
  30. package/dist/settings/table-settings/data-settings.js +1 -1
  31. package/dist/settings/trend-settings/style-setting.js +2 -2
  32. package/dist/settings/widgets/chart-type/index.js +3 -3
  33. package/dist/settings/widgets/date-summary-item.js +2 -2
  34. package/dist/settings/widgets/numeric-summary-item.js +2 -2
  35. package/dist/settings/widgets/summary-settings.js +2 -2
  36. package/dist/settings/widgets/switch/index.js +1 -1
  37. package/dist/settings/widgets/y-axis-group-settings.js +1 -1
  38. package/dist/utils/chart-utils/base-utils.js +7 -7
  39. package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +1 -1
  40. package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +2 -2
  41. package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +1 -1
  42. package/dist/utils/chart-utils/sql-statistics-utils.js +9 -9
  43. package/dist/utils/collaborator-utils.js +1 -1
  44. package/dist/utils/collaborator.js +2 -2
  45. package/dist/utils/column-utils.js +12 -12
  46. package/dist/utils/common-utils.js +1 -1
  47. package/dist/utils/date-translate.js +1 -1
  48. package/dist/utils/object-utils.js +1 -1
  49. package/dist/utils/options-utils.js +2 -2
  50. package/dist/utils/row-record-utils.js +2 -2
  51. package/dist/utils/sql/chart-data-sql.js +58 -58
  52. package/dist/utils/sql/column-2-sql-column.js +18 -18
  53. package/dist/view/index.js +2 -5
  54. package/dist/view/title/index.js +2 -2
  55. package/dist/view/wrapper/bar.js +168 -93
  56. package/dist/view/wrapper/basic-number-card.js +8 -8
  57. package/dist/view/wrapper/chart-component.js +16 -52
  58. package/dist/view/wrapper/index.js +1 -237
  59. package/dist/view/wrapper/table/index.js +1 -1
  60. package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +3 -3
  61. package/dist/view/wrapper/table/pivot-table-display-name.js +1 -1
  62. package/dist/view/wrapper/table/two-dimension-table.js +8 -8
  63. package/dist/view/wrapper/table-element/components/formatter.js +2 -2
  64. package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +1 -1
  65. package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +17 -17
  66. package/dist/view/wrapper/table-element/components/link-formatter.js +17 -17
  67. package/dist/view/wrapper/table-element/components/record.js +3 -3
  68. package/dist/view/wrapper/table-element/components/records.js +4 -4
  69. package/dist/view/wrapper/table-element/components/utils.js +1 -1
  70. package/dist/view/wrapper/trend.js +18 -18
  71. package/package.json +5 -11
  72. package/dist/utils/custom-g2.js +0 -684
  73. package/dist/view/wrapper/area.js +0 -282
  74. package/dist/view/wrapper/bar-custom.js +0 -239
  75. package/dist/view/wrapper/bar-group.js +0 -274
  76. package/dist/view/wrapper/combination.js +0 -728
  77. package/dist/view/wrapper/compare.js +0 -383
  78. package/dist/view/wrapper/completeness.js +0 -174
  79. package/dist/view/wrapper/dashboard.js +0 -179
  80. package/dist/view/wrapper/funnel.js +0 -206
  81. package/dist/view/wrapper/heat-map.js +0 -434
  82. package/dist/view/wrapper/horizontal-bar-group.js +0 -226
  83. package/dist/view/wrapper/horizontal-bar.js +0 -175
  84. package/dist/view/wrapper/horizontal-component.js +0 -89
  85. package/dist/view/wrapper/line-group.js +0 -219
  86. package/dist/view/wrapper/line.js +0 -222
  87. package/dist/view/wrapper/map.js +0 -368
  88. package/dist/view/wrapper/mirror.js +0 -218
  89. package/dist/view/wrapper/pie.js +0 -253
  90. package/dist/view/wrapper/ring.js +0 -328
  91. package/dist/view/wrapper/scatter.js +0 -140
  92. package/dist/view/wrapper/treemap.js +0 -206
  93. package/dist/view/wrapper/world-map.js +0 -413
  94. package/dist/view/wrapper/wrappers-d3/bar.js +0 -262
@@ -1,383 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _dtableUtils = require("dtable-utils");
12
- var _lodashEs = require("lodash-es");
13
- var _constants = require("../../constants");
14
- var _chartUtils = require("../../utils/chart-utils");
15
- var _intl = _interopRequireDefault(require("../../intl"));
16
- var _chartComponent = _interopRequireDefault(require("./chart-component"));
17
- class Compare extends _chartComponent.default {
18
- constructor(props) {
19
- super(props);
20
- this.createChart = () => {
21
- const {
22
- chart
23
- } = this.props;
24
- const {
25
- display_data,
26
- display_increase_percentage
27
- } = chart.config;
28
- const appendPadding = [display_data || display_increase_percentage ? 17 : 0, 0, 0, 0];
29
- this.initChart(this.container, {
30
- appendPadding
31
- });
32
- this.chart.on('interval:click', e => {
33
- this.props.toggleRecords(e.data.data);
34
- });
35
- };
36
- this.clearChart = () => {
37
- this.chart.annotation().clear(true);
38
- this.chart.clear(true);
39
- };
40
- this.drawChart = () => {
41
- let {
42
- result: data
43
- } = this.props;
44
- data = _chartUtils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
45
- if (!Array.isArray(data)) return;
46
- this.loadData(data);
47
- this.draw(data);
48
- requestAnimationFrame(() => {
49
- this.chart.render();
50
- });
51
- };
52
- this.draw = data => {
53
- const {
54
- chart,
55
- globalTheme,
56
- chartColorTheme
57
- } = this.props;
58
- const theme = _constants.CHART_THEME_COLOR[globalTheme];
59
- const {
60
- table_id,
61
- y_axis_summary_type,
62
- y_axis_column_key,
63
- y_axis_summary_method,
64
- summaryColumn,
65
- display_data,
66
- label_font_size,
67
- display_increase
68
- } = chart.config;
69
- let summaryColumnData = _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
70
- if (y_axis_summary_type === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
71
- const table = (0, _dtableUtils.getTableById)(table_id);
72
- const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
73
- summaryColumnData = summaryColumn.data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT;
74
- }
75
-
76
- // x axis
77
- const {
78
- width
79
- } = this.chart.coordinateBBox;
80
- const chartData = this.getChartGroupData(data);
81
- this.labelCount = chartData.length;
82
- const ticks = this.getChartDisplayLabels(width, 20, chartData);
83
- if (ticks.length > 0) {
84
- this.chart.scale('name', {
85
- ticks
86
- });
87
- }
88
-
89
- // set Coord type
90
- this.chart.coordinate('rect');
91
- this.handleAutoRange(chart, summaryColumnData);
92
- this.chart.scale({
93
- group_name: {
94
- type: 'cat'
95
- }
96
- });
97
-
98
- // set the single bar width and radius
99
- let singleBarWidth, singleBarRadius;
100
- // y-axis label width:6 + 10
101
- const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
102
- const maxCountGroup = (0, _lodashEs.maxBy)(chartData, 'currentGroupCount');
103
- singleBarWidth = Math.round(chartWidth / (2 * chartData.length * maxCountGroup.currentGroupCount));
104
- singleBarRadius = Math.min(singleBarWidth / 5, 10);
105
- const interval = this.chart.interval().label(display_data ? 'formatted_value' : false, {
106
- style: {
107
- fontSize: _chartUtils.BaseUtils.getLabelFontSize(label_font_size),
108
- fill: theme.textColor,
109
- ...this.labelStroke
110
- }
111
- }).position('name*value').color('group_name', _chartUtils.BaseUtils.getCurrentTheme(chartColorTheme).colors).tooltip('name*formatted_value*raw_name', (name, value, raw_name) => {
112
- const nameContent = !raw_name && typeof raw_name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : raw_name;
113
- const titleContent = y_axis_summary_type === 'count' ? _intl.default.get(_constants.TITLE_AMOUNT) : _intl.default.get(_constants.CHART_SUMMARY_SHOW[y_axis_summary_method]);
114
- return {
115
- value,
116
- title: titleContent,
117
- name: nameContent
118
- };
119
- }).adjust({
120
- type: 'dodge',
121
- marginRatio: 0
122
- }).state({
123
- active: {
124
- style: {
125
- stroke: null
126
- }
127
- }
128
- }).style({
129
- radius: [singleBarRadius, singleBarRadius, 0, 0]
130
- });
131
- if (display_increase) {
132
- this.drawIncreaseLine({
133
- theme
134
- });
135
- }
136
- this.chart.on('interval:mouseenter', e => {
137
- if (this.isInsideInterval) return;
138
- this.isInsideInterval = true;
139
- this.setToolTipForInterval();
140
- interval.style('name*value', (name, value) => {
141
- const isHovered = name === e.data.data.name;
142
- return {
143
- fillOpacity: isHovered ? 1 : 0.3,
144
- radius: [singleBarRadius, singleBarRadius, 0, 0]
145
- };
146
- });
147
- interval.tooltip('name*formatted_value*raw_name', (name, value, raw_name) => {
148
- const nameContent = !raw_name && typeof raw_name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : raw_name;
149
- const titleContent = y_axis_summary_type === 'count' ? _intl.default.get(_constants.TITLE_AMOUNT) : _intl.default.get(_constants.CHART_SUMMARY_SHOW[y_axis_summary_method]);
150
- return {
151
- value,
152
- title: titleContent,
153
- name: nameContent
154
- };
155
- });
156
- this.point && this.point.tooltip(false);
157
- this.chart.render(true);
158
- });
159
- this.chart.on('interval:mouseleave', e => {
160
- if (!this.isInsideInterval) return;
161
- this.isInsideInterval = false;
162
- this.setToolTipForLine();
163
- interval.style('name*value', () => {
164
- return {
165
- fillOpacity: 1,
166
- radius: [singleBarRadius, singleBarRadius, 0, 0]
167
- };
168
- });
169
- this.point && this.point.tooltip('name*increase_value', (name, value) => {
170
- return {
171
- title: _intl.default.get(_constants.TITLE_INCREASE),
172
- value: (0, _dtableUtils.getNumberDisplayString)(value || 0, {
173
- format: 'percent'
174
- }),
175
- name: !name && typeof name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : name
176
- };
177
- });
178
- interval.tooltip(false);
179
- this.chart.render(true);
180
- });
181
- this.setColorMap(data, chartColorTheme);
182
- this.formatDataByName(data);
183
- this.setToolTip(true, summaryColumn, y_axis_summary_method);
184
- this.setLegend('group_name', theme, 'top-right');
185
-
186
- // x and y
187
- this.setNameLabelAndTooltip(theme, this.labelCount);
188
- this.setValueLabel(theme);
189
- };
190
- this.setToolTipForInterval = () => {
191
- const {
192
- chart,
193
- summaryColumn
194
- } = this.props;
195
- const {
196
- y_axis_summary_method
197
- } = chart.config;
198
- this.setToolTip(true, summaryColumn, y_axis_summary_method);
199
- };
200
- this.setToolTipForLine = () => {
201
- const {
202
- chart,
203
- summaryColumn
204
- } = this.props;
205
- const {
206
- y_axis_summary_method
207
- } = chart.config;
208
- const settings = this.getToolTipSettings(false, summaryColumn, y_axis_summary_method);
209
- this.chart.tooltip(settings);
210
- };
211
- this.drawIncreaseLine = _ref => {
212
- let {
213
- theme
214
- } = _ref;
215
- const {
216
- chart
217
- } = this.props;
218
- const {
219
- increase_line_color,
220
- display_increase_percentage,
221
- label_font_size
222
- } = chart.config;
223
- this.chart.line().position('name*increase_value').color(increase_line_color || '#fbd44a').shape('smooth').style({
224
- lineWidth: 2,
225
- opacity: 1
226
- }).tooltip(false);
227
- const point = this.chart.point().label(display_increase_percentage ? 'increase_value' : false, value => {
228
- return {
229
- content: (0, _dtableUtils.getNumberDisplayString)(value || 0, {
230
- format: 'percent'
231
- }),
232
- style: {
233
- fontSize: _chartUtils.BaseUtils.getLabelFontSize(label_font_size),
234
- fill: theme.labelColor,
235
- ...this.labelStroke
236
- }
237
- };
238
- }).color(increase_line_color || '#fbd44a').animate({
239
- appear: {
240
- animation: 'fadeIn',
241
- duration: 1000,
242
- easing: 'easeLinear'
243
- }
244
- }).position('name*increase_value').shape('circle').size(3).style({
245
- stroke: 0,
246
- fillOpacity: 1
247
- }).tooltip('name*increase_value', (name, value) => {
248
- return {
249
- title: _intl.default.get(_constants.TITLE_INCREASE),
250
- value: (0, _dtableUtils.getNumberDisplayString)(value || 0, {
251
- format: 'percent'
252
- }),
253
- name: !name && typeof name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : name
254
- };
255
- });
256
- this.chart.on('point:mouseenter', (0, _lodashEs.throttle)(e => {
257
- if (this.isInsidePoint) return;
258
- this.isInsidePoint = true;
259
- point.style('name', name => {
260
- let r = 3;
261
- if (name === e.data.data.name) {
262
- r = 5;
263
- }
264
- return {
265
- r,
266
- stroke: 0,
267
- fillOpacity: 1
268
- };
269
- });
270
- this.chart.render(true);
271
- }, 100));
272
- this.chart.on('point:mouseleave', (0, _lodashEs.throttle)(e => {
273
- if (!this.isInsidePoint) return;
274
- this.isInsidePoint = false;
275
- point.style('name', name => {
276
- let r = 3;
277
- return {
278
- r,
279
- stroke: 0,
280
- fillOpacity: 1
281
- };
282
- });
283
- this.chart.render(true);
284
- }, 100));
285
- this.point = point;
286
- this.chart.axis('increase_value', {
287
- label: null,
288
- grid: null
289
- });
290
- };
291
- this.handleAutoRange = (data, summaryColumnData) => {
292
- const {
293
- chart
294
- } = this.props;
295
- const {
296
- y_axis_summary_method,
297
- y_axis_auto_range,
298
- y_axis_min,
299
- y_axis_max
300
- } = chart.config;
301
- let valueScaleOptions = {
302
- formatter: value => {
303
- if (y_axis_summary_method === _constants.CHART_SUMMARY_TYPE.DISTINCT_VALUES) {
304
- return value;
305
- }
306
- return (0, _dtableUtils.getNumberDisplayString)(value, summaryColumnData);
307
- }
308
- };
309
-
310
- // eslint-disable-next-line
311
- if (y_axis_auto_range === undefined || y_axis_auto_range === null || y_axis_auto_range) {
312
- valueScaleOptions = Object.assign(valueScaleOptions, {
313
- nice: true
314
- });
315
- } else {
316
- valueScaleOptions = Object.assign(valueScaleOptions, {
317
- min: y_axis_min,
318
- max: y_axis_max
319
- });
320
-
321
- // set the filter rule
322
- this.chart.filter('value', value => {
323
- return value >= y_axis_min;
324
- });
325
-
326
- // filter the data
327
- this.chart.filterData(data);
328
- }
329
- this.chart.scale({
330
- // Set the type of the name column so that g2 can draw correctly
331
- name: {
332
- type: 'cat'
333
- },
334
- value: valueScaleOptions
335
- });
336
- };
337
- this.chart = null;
338
- }
339
- componentDidMount() {
340
- this.createChart();
341
- this.drawChart();
342
- this.renderAxisLabel(this.props.chart, this.props.tables);
343
- }
344
- componentDidUpdate(prevProps) {
345
- super.componentDidUpdate(prevProps);
346
- if (_chartUtils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
347
- var _this$chart;
348
- ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
349
- this.createChart();
350
- this.drawChart();
351
- this.renderAxisLabel(this.props.chart, this.props.tables);
352
- }
353
- }
354
- componentWillUnmount() {
355
- var _this$chart2;
356
- ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
357
- }
358
- render() {
359
- const {
360
- chart
361
- } = this.props;
362
- return /*#__PURE__*/_react.default.createElement("div", {
363
- className: (0, _classnames.default)('sea-chart-container ', {
364
- 'show-x-axis-label': this.isShowXAxisLabel(chart),
365
- 'show-y-axis-label': this.isShowYAxisLabel(chart)
366
- }),
367
- ref: ref => this.container = ref
368
- });
369
- }
370
- }
371
- Compare.propTypes = {
372
- canvasStyle: _propTypes.default.object,
373
- chart: _propTypes.default.object,
374
- groupbyColumn: _propTypes.default.object,
375
- columnGroupbyColumn: _propTypes.default.object,
376
- summaryColumn: _propTypes.default.object,
377
- result: _propTypes.default.array,
378
- tables: _propTypes.default.array,
379
- globalTheme: _propTypes.default.string,
380
- chartColorTheme: _propTypes.default.string,
381
- toggleRecords: _propTypes.default.func
382
- };
383
- var _default = exports.default = Compare;
@@ -1,174 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = Completeness;
9
- var _classnames = _interopRequireDefault(require("classnames"));
10
- var _react = _interopRequireWildcard(require("react"));
11
- var _lodashEs = require("lodash-es");
12
- var _utils = require("../../utils");
13
- var _intl = _interopRequireDefault(require("../../intl"));
14
- var _constants = require("../../constants");
15
- var _chartComponent = _interopRequireDefault(require("./chart-component"));
16
- function Completeness(_ref) {
17
- var _chartRef$current, _chartRef$current2;
18
- let {
19
- chart,
20
- toggleRecords,
21
- result: data,
22
- tables,
23
- summaryColumn,
24
- globalTheme,
25
- chartColorTheme
26
- } = _ref;
27
- const chartRef = (0, _react.useRef)(null);
28
- const chartContainerRef = (0, _react.useRef)(null);
29
- (0, _react.useEffect)(() => {
30
- if (!chartRef.current) {
31
- const chartComponent = new _chartComponent.default({});
32
- chartRef.current = chartComponent;
33
- }
34
- const currentChart = chartRef.current;
35
- currentChart.initLabelStroke(globalTheme);
36
- let chartPaddingTop;
37
- // avoid closure trap
38
- function createChart() {
39
- var _style_config$title;
40
- let {
41
- style_config,
42
- config
43
- } = chart;
44
- chartPaddingTop = (_style_config$title = style_config.title) !== null && _style_config$title !== void 0 && _style_config$title.text ? 17 : 0;
45
- const chartPaddingRight = config !== null && config !== void 0 && config.show_percentage ? 45 : 0;
46
- const appendPadding = [chartPaddingTop, chartPaddingRight, 0, 0];
47
- currentChart.initChart(chartContainerRef.current, {
48
- appendPadding
49
- });
50
- currentChart.chart.on('interval:click', e => {
51
- toggleRecords(e.data.data);
52
- });
53
- }
54
- function drawChart() {
55
- const currentData = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
56
- if (!Array.isArray(currentData)) return;
57
- currentChart.loadData(currentData);
58
- draw(currentData);
59
- requestAnimationFrame(() => {
60
- currentChart.chart.render();
61
- currentChart.renderAxisLabel(chart, tables);
62
- });
63
- }
64
- function draw(data) {
65
- const theme = _constants.CHART_THEME_COLOR[globalTheme];
66
- const {
67
- label_font_size,
68
- column_groupby_column_key,
69
- type
70
- } = chart.config;
71
- const isGroup = type === _constants.CHART_TYPE.COMPLETENESS_GROUP ? true : false;
72
- let currentIdx = 0;
73
- const colors = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors;
74
- const colorMap = data.reduce((acc, cur) => {
75
- if (cur.groupby && !acc[cur.groupby]) {
76
- acc[cur.groupby] = colors[currentIdx++ % colors.length];
77
- }
78
- return acc;
79
- }, {});
80
- const cb1 = group_name => {
81
- return group_name === 'rest' ? '#bdbdbd' : colors[0];
82
- };
83
- const cb2 = (groupby, group_name) => {
84
- if (group_name === 'rest') {
85
- return '#bdbdbd';
86
- }
87
- if (isGroup && column_groupby_column_key) {
88
- return colorMap[groupby];
89
- }
90
- return colors[0];
91
- };
92
- const colorField = isGroup ? 'groupby*group_name' : 'group_name';
93
- const colorFieldCb = isGroup ? cb2 : cb1;
94
- const adjustType = isGroup ? [{
95
- type: 'dodge',
96
- dodgeBy: 'groupby',
97
- marginRatio: 0.33
98
- }, {
99
- type: 'stack'
100
- }] : {
101
- type: 'stack'
102
- };
103
- const newData = currentChart.getChartGroupData(data, true);
104
- let singleBarRadius, singleBarWidth;
105
- const chartHeight = currentChart.chart.height - 6 - 10 - chartPaddingTop - 30;
106
- if (!isGroup) {
107
- singleBarWidth = Math.round(chartHeight / (2 * newData.length));
108
- } else {
109
- const maxGroupCount = (0, _lodashEs.maxBy)(newData, 'currentGroupCount');
110
- singleBarWidth = Math.round(chartHeight / (2 * newData.length * maxGroupCount.currentGroupCount));
111
- }
112
- singleBarRadius = Math.min(singleBarWidth / 5, 10);
113
- isGroup ? currentChart.markLastForCompleteness(data) : currentChart.markFirstOrLast(data, 'last');
114
- let {
115
- show_percentage
116
- } = chart.config;
117
- show_percentage = (0, _utils.isBoolean)(show_percentage) ? show_percentage : true;
118
- currentChart.drawLabels(newData);
119
-
120
- // set Coord type
121
- currentChart.chart.coordinate('rect').transpose();
122
- currentChart.autoAdjustDataOptions(chart, data, summaryColumn);
123
- currentChart.chart.interval().label(show_percentage ? 'value' : false, {
124
- position: 'right',
125
- offset: 6,
126
- content: v => {
127
- if (v.group_name === 'rest' && v.completedRate !== 'empty') return v.completedRate + '%';
128
- return '';
129
- },
130
- style: {
131
- fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
132
- fill: theme.labelColor,
133
- ...currentChart.labelStroke
134
- }
135
- }).position('name*value').size(singleBarWidth).color(colorField, colorFieldCb).adjust(adjustType).tooltip('name*group_name*value', (name, group_name, value) => {
136
- return {
137
- title: name,
138
- name: _intl.default.get(group_name),
139
- value: value
140
- };
141
- }).state({
142
- active: {
143
- style: {
144
- stroke: null
145
- }
146
- }
147
- }).style('isLast', isLast => {
148
- if (isLast) {
149
- return {
150
- radius: [singleBarRadius, singleBarRadius, 0, 0]
151
- };
152
- }
153
- });
154
- currentChart.setToolTip();
155
- currentChart.setNameLabelAndTooltip(theme, currentChart.labelCount);
156
- currentChart.setValueLabel(theme);
157
- currentChart.chart.interaction('element-highlight');
158
- currentChart.setLegend(isGroup ? 'groupby' : 'group_name', theme, 'top-right');
159
- }
160
- createChart();
161
- drawChart();
162
- return () => {
163
- currentChart.chart.destroy();
164
- };
165
- // eslint-disable-next-line react-hooks/exhaustive-deps
166
- }, [chart, chartColorTheme, data, globalTheme, summaryColumn, tables]);
167
- return /*#__PURE__*/_react.default.createElement("div", {
168
- className: (0, _classnames.default)('sea-chart-completeness-chart sea-chart-container', {
169
- 'show-x-axis-label': (_chartRef$current = chartRef.current) === null || _chartRef$current === void 0 ? void 0 : _chartRef$current.isShowXAxisLabel(chart),
170
- 'show-y-axis-label': (_chartRef$current2 = chartRef.current) === null || _chartRef$current2 === void 0 ? void 0 : _chartRef$current2.isShowYAxisLabel(chart)
171
- }),
172
- ref: chartContainerRef
173
- });
174
- }