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,728 +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 _customG = require("../../utils/custom-g2");
14
- var _utils = require("../../utils");
15
- var _constants = require("../../constants");
16
- var _intl = _interopRequireDefault(require("../../intl"));
17
- var _chartComponent = _interopRequireDefault(require("./chart-component"));
18
- const valueFieldMap = {
19
- value_left: ['Y_axis_(lift_side)', 'All'],
20
- value_right: ['Y_axis_(right_side)', 'All']
21
- };
22
- class Combination extends _chartComponent.default {
23
- constructor(props) {
24
- super(props);
25
- this.clearChart = () => {
26
- this.chart.annotation().clear(true);
27
- this.chart.clear(true);
28
- };
29
- this.drawChart = () => {
30
- let {
31
- result: data
32
- } = this.props;
33
- data = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
34
- this.draw(data);
35
- };
36
- this.draw = data => {
37
- if (!Array.isArray(data)) return;
38
- const {
39
- chart,
40
- globalTheme,
41
- tables,
42
- chartColorTheme,
43
- customRender
44
- } = this.props;
45
- const theme = _constants.CHART_THEME_COLOR[globalTheme];
46
- const {
47
- table_id,
48
- y_axis_left_summary_column,
49
- y_axis_right_summary_column,
50
- y_axis_left_summary_method,
51
- y_axis_right_summary_method,
52
- y_axis_left_summary_type,
53
- y_axis_right_summary_type,
54
- y_axis_left_group_by_multiple_numeric_column,
55
- y_axis_auto_range_left,
56
- y_axis_min_left,
57
- y_axis_max_left,
58
- y_axis_auto_range_right,
59
- y_axis_min_right,
60
- y_axis_max_right,
61
- display_data,
62
- display_data_field,
63
- label_font_size,
64
- line_type
65
- } = chart.config;
66
- const {
67
- display_goal_line,
68
- goal_value,
69
- goal_label
70
- } = chart.style_config || {};
71
- this.chart = new _customG.Chart({
72
- container: this.container,
73
- autoFit: true,
74
- width: '100%',
75
- height: '100%',
76
- appendPadding: [display_data ? 17 : 0, 0, 0, 0]
77
- });
78
- const isSmooth = line_type === _constants.CHART_LINE_TYPES[1] || !line_type;
79
- const showLeftValue = display_data && valueFieldMap['value_left'].includes(display_data_field);
80
- let showRightValue = display_data && valueFieldMap['value_right'].includes(display_data_field);
81
- // if display_data is open, default show right value
82
- if (display_data && !display_data_field) {
83
- showRightValue = true;
84
- }
85
-
86
- // y-axis label width:6 + 10
87
- const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
88
- const nameCountMap = data.reduce((acc, cur) => {
89
- if (!acc[cur.name]) {
90
- acc[cur.name] = 1;
91
- } else {
92
- acc[cur.name] += 1;
93
- }
94
- return acc;
95
- }, {});
96
- const nameNums = Object.keys(nameCountMap).length;
97
- const countValues = Object.values(nameCountMap).reduce((acc, value) => {
98
- acc[value] = (acc[value] || 0) + 1;
99
- return acc;
100
- }, {});
101
- const mostCommonCount = Object.entries(countValues).reduce((max, entry) => {
102
- return entry[1] > max[1] ? entry : max;
103
- }, ['', -Infinity])[0];
104
- const singleBarWidth = Math.round(chartWidth / (2 * nameNums * mostCommonCount));
105
- const singleBarRadius = Math.min(singleBarWidth / 5, 10);
106
- const currentTheme = _utils.BaseUtils.getCurrentTheme(chartColorTheme);
107
- this.colorMap = data.reduce((acc, cur, index) => {
108
- if (!acc[cur.group_name]) {
109
- acc[cur.group_name] = cur.color;
110
- }
111
- return acc;
112
- }, {});
113
- this.chart.data(data);
114
- this.chart.coordinate('rect');
115
- const table = (0, _dtableUtils.getTableById)(tables, table_id);
116
- const leftSummaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_left_summary_column) || {};
117
- const rightSummaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_right_summary_column) || {};
118
- // const xAxisColumn = getTableColumnByKey(table, x_axis_column_key);
119
-
120
- const leftTitle = this.getTitle(tables, table_id, y_axis_left_summary_type, y_axis_left_summary_column);
121
- const rightTitle = this.getTitle(tables, table_id, y_axis_right_summary_type, y_axis_right_summary_column);
122
- let leftValueScaleOptions = {
123
- formatter: value => {
124
- return _utils.BaseUtils.getSummaryValueDisplayString(leftSummaryColumn, value, y_axis_left_summary_method);
125
- }
126
- };
127
- let rightValueScaleOptions = {
128
- formatter: value => {
129
- return _utils.BaseUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method);
130
- }
131
- };
132
- if (!y_axis_auto_range_left) {
133
- leftValueScaleOptions = Object.assign(leftValueScaleOptions, {
134
- min: y_axis_min_left,
135
- max: y_axis_max_left
136
- });
137
- }
138
- if (!y_axis_auto_range_right) {
139
- rightValueScaleOptions = Object.assign(rightValueScaleOptions, {
140
- min: y_axis_min_right,
141
- max: y_axis_max_right
142
- });
143
- }
144
- this.chart.scale({
145
- name: {
146
- type: 'cat'
147
- },
148
- // Automatic adjustment of maximum and minimum values
149
- value_left: leftValueScaleOptions,
150
- value_right: rightValueScaleOptions
151
- });
152
- this.chart.axis('name', {
153
- line: {
154
- style: {
155
- stroke: theme.XAxisColor,
156
- lineWidth: 1
157
- }
158
- },
159
- tickLine: {
160
- length: 5,
161
- // color of the tick line
162
- stroke: theme.XAxisColor
163
- },
164
- label: {
165
- style: {
166
- fill: theme.textColor,
167
- fontSize: theme.fontSize
168
- },
169
- offset: 10,
170
- autoRotate: true,
171
- // rotate: data.length > 11 ? 0.3 : 0,
172
- formatter: name => {
173
- const isString = typeof name === 'string';
174
- if (!isString) name = String(name);
175
- if (name === 'undefined') {
176
- return _intl.default.get(_constants.EMPTY_NAME);
177
- }
178
- if (name.length > 10) {
179
- return `${name.slice(0, 10)}...`;
180
- }
181
- return name;
182
- }
183
- }
184
- });
185
- this.chart.axis('value_left', {
186
- label: {
187
- offset: 6,
188
- style: {
189
- fontSize: theme.fontSize,
190
- // fontSize: 66,
191
- fill: theme.textColor
192
- }
193
- },
194
- grid: {
195
- line: {
196
- style: {
197
- stroke: theme.gridColor,
198
- lineDash: [8, 3]
199
- }
200
- }
201
- }
202
- });
203
- this.chart.axis('value_right', {
204
- grid: null,
205
- label: {
206
- offset: 6,
207
- style: {
208
- fontSize: theme.fontSize,
209
- fill: theme.textColor
210
- }
211
- }
212
- });
213
- let legendPosition = 'top-right';
214
- // const leftLegendConfig = this.getLegendConfig(undefined, legendPosition);
215
- // this.chart.legend(leftLegendConfig);
216
- this.chart.legend({
217
- // custom: true,
218
- position: legendPosition,
219
- itemName: {
220
- style: {
221
- fill: theme.legendTextColor,
222
- fontSize: theme.legendFontSize
223
- },
224
- formatter: name => {
225
- if (!name && typeof name !== 'number') {
226
- return _intl.default.get(_constants.EMPTY_NAME);
227
- } else if (name === '_Others') {
228
- return _intl.default.get('Others');
229
- } else {
230
- return _intl.default.get(name) || name;
231
- }
232
- }
233
- },
234
- itemSpacing: 28,
235
- items: this.getLegend(leftSummaryColumn, rightSummaryColumn, table, currentTheme)
236
- });
237
- const adjust = y_axis_left_group_by_multiple_numeric_column ? {
238
- type: 'dodge',
239
- dodgeBy: 'group_name',
240
- dodgePadding: singleBarWidth / 3
241
- } : {
242
- type: 'dodge'
243
- };
244
- const interval = this.chart.interval().position('name*value_left').color('color', color => {
245
- if (!y_axis_left_group_by_multiple_numeric_column) {
246
- return currentTheme.colors[0];
247
- }
248
- return color;
249
- }).adjust(adjust).size(singleBarWidth).tooltip('name*value_left', (name, value) => {
250
- const {
251
- y_axis_left_group_by_multiple_numeric_column
252
- } = this.props.chart.config;
253
- const isMultiple = y_axis_left_group_by_multiple_numeric_column;
254
- let title = '';
255
- if (isMultiple) {
256
- title = name;
257
- } else {
258
- title = leftTitle;
259
- }
260
- return {
261
- title,
262
- value: _utils.BaseUtils.getSummaryValueDisplayString(leftSummaryColumn, value, y_axis_left_summary_method),
263
- name: !name && typeof name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : name
264
- };
265
- }).state({
266
- active: {
267
- style: {
268
- stroke: null
269
- }
270
- }
271
- }).style({
272
- fillOpacity: 1,
273
- radius: [singleBarRadius, singleBarRadius, 0, 0]
274
- }).label(showLeftValue ? 'value_left' : false, {
275
- style: {
276
- fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
277
- fill: theme.labelColor,
278
- stroke: '#fff',
279
- lineWidth: 1
280
- }
281
- });
282
- this.formatDataByName(data);
283
- if (!y_axis_left_group_by_multiple_numeric_column) {
284
- this.setToolTipForInterval();
285
- } else {
286
- this.setToolTipForInterval(true, leftSummaryColumn, y_axis_left_summary_method);
287
- }
288
- this.chart.line().position('name*value_right').color(currentTheme.colors[1]).shape(isSmooth ? 'smooth' : 'line').style({
289
- lineWidth: 2,
290
- opacity: 1
291
- }).tooltip(false);
292
- const point = this.chart.point().position('name*value_right').color(currentTheme.colors[1]).animate({
293
- appear: {
294
- animation: 'fadeIn',
295
- duration: 1000,
296
- easing: 'easeLinear'
297
- }
298
- }).shape('circle').size(3).style({
299
- stroke: 0,
300
- fillOpacity: 1
301
- }).label(showRightValue ? 'value_right' : false, {
302
- style: {
303
- fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
304
- fill: theme.labelColor,
305
- stroke: '#fff',
306
- lineWidth: 1
307
- }
308
- }).tooltip('name*value_right', (name, value) => {
309
- return {
310
- title: rightTitle,
311
- value: _utils.BaseUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method),
312
- name: !name && typeof name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : name
313
- };
314
- }).state({
315
- active: {
316
- style: {
317
- stroke: null
318
- }
319
- }
320
- });
321
- if (display_data) {
322
- this.chart.on('point:mouseenter', (0, _lodashEs.throttle)(e => {
323
- const currentName = e.data.data.name;
324
- if (this.currentName && this.currentName === currentName) return;
325
- this.currentName = currentName;
326
- this.chart.render(true);
327
- }, 100));
328
- this.chart.on('point:mouseleave', (0, _lodashEs.throttle)(e => {
329
- if (!this.currentName) return;
330
- this.currentName = null;
331
- this.chart.render(true);
332
- }, 100));
333
- }
334
- this.chart.on('element:click', e => {
335
- this.props.toggleRecords({
336
- ...e.data.data,
337
- isQueryBySql: true
338
- });
339
- });
340
- this.chart.on('interval:mouseenter', e => {
341
- if (this.isInsideInterval) return;
342
- this.isInsideInterval = true;
343
- interval.style('name*value_left', (name, value) => {
344
- const isHovered = value === e.data.data.value_left && name === e.data.data.name;
345
- return {
346
- fillOpacity: isHovered ? 1 : 0.3,
347
- radius: [singleBarRadius, singleBarRadius, 0, 0]
348
- };
349
- });
350
- interval.tooltip('name*value_left', (name, value) => {
351
- const {
352
- y_axis_left_group_by_multiple_numeric_column
353
- } = this.props.chart.config;
354
- const isMultiple = y_axis_left_group_by_multiple_numeric_column;
355
- let title = '';
356
- if (isMultiple) {
357
- title = name;
358
- } else {
359
- title = leftTitle;
360
- }
361
- return {
362
- title,
363
- value: _utils.BaseUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method),
364
- name: !name && typeof name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : name
365
- };
366
- });
367
- point.tooltip(false);
368
- this.setToolTipForInterval(true, leftSummaryColumn, y_axis_left_summary_method);
369
- this.chart.render(true);
370
- });
371
- this.chart.on('interval:mouseleave', e => {
372
- if (!this.isInsideInterval) return;
373
- this.isInsideInterval = false;
374
- interval.style('name*value_left', (name, value) => {
375
- return {
376
- fillOpacity: 1,
377
- radius: [singleBarRadius, singleBarRadius, 0, 0]
378
- };
379
- });
380
- interval.tooltip(false);
381
- point.tooltip('name*value_right', (name, value) => {
382
- return {
383
- title: rightTitle,
384
- value: _utils.BaseUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method),
385
- name: !name && typeof name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : name
386
- };
387
- });
388
- this.setToolTipForPointView();
389
- this.chart.render(true);
390
- });
391
- this.chart.on('point:mouseenter', (0, _lodashEs.throttle)(e => {
392
- if (this.isInsidePoint) return;
393
- this.isInsidePoint = true;
394
- // interval.style({
395
- // radius: [singleBarRadius, singleBarRadius, 0, 0],
396
- // fillOpacity: 0.3,
397
- // });
398
- point.style('name', name => {
399
- let r = 3;
400
- if (name === e.data.data.name) {
401
- r = 5;
402
- }
403
- return {
404
- r,
405
- stroke: 0,
406
- fillOpacity: 1
407
- };
408
- });
409
- this.chart.render(true);
410
- }, 100));
411
- this.chart.on('point:mouseleave', (0, _lodashEs.throttle)(e => {
412
- if (!this.isInsidePoint) return;
413
- this.isInsidePoint = false;
414
- // interval.style({
415
- // radius: [singleBarRadius, singleBarRadius, 0, 0],
416
- // fillOpacity: 1,
417
- // });
418
- point.style('name', name => {
419
- let r = 3;
420
- return {
421
- r,
422
- stroke: 0,
423
- fillOpacity: 1
424
- };
425
- });
426
- this.chart.render(true);
427
- }, 100));
428
- if (display_goal_line && goal_label && goal_value) {
429
- this.setDispalyGoalLine(goal_label, goal_value, chartWidth);
430
- }
431
- (0, _utils.isFunction)(customRender) && customRender(this.chart);
432
- this.chart.removeInteraction('legend-filter');
433
- requestAnimationFrame(() => {
434
- this.chart.render();
435
- this.renderAxisLabel();
436
- });
437
- };
438
- this.renderAxisLabel = () => {
439
- var _this$chart;
440
- if (!this.chart) return;
441
- let {
442
- chart,
443
- tables
444
- } = this.props;
445
- const {
446
- config
447
- } = chart;
448
- const {
449
- table_id,
450
- x_axis_column_key,
451
- show_y_axis_left_label,
452
- show_y_axis_right_label,
453
- x_axis_show_label,
454
- y_axis_left_label_position,
455
- y_axis_right_label_position,
456
- y_axis_left_summary_column,
457
- y_axis_right_summary_column,
458
- x_axis_label_position,
459
- y_axis_left_summary_type,
460
- y_axis_right_summary_type
461
- } = config;
462
- const table = (0, _dtableUtils.getTableById)(tables, table_id);
463
- const autoPadding = ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) || 0;
464
- const textColor = '#999';
465
- const xAxisID = `chart-x-axis-label_${chart.id}`;
466
- const chartContainer = this.chart.getCanvas().get('container');
467
- const xLabel = chartContainer.querySelector(`#${xAxisID}`);
468
- if (!xLabel && x_axis_show_label) {
469
- const div = document.createElement('div');
470
- div.id = xAxisID;
471
- div.className = 'chart-axis-label text-truncate';
472
- const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
473
- div.innerHTML = `${column ? column.name : ''}`;
474
- div.setAttribute('style', `color:${textColor}; width: 100%; text-align: ${x_axis_label_position}; bottom: -20px; position: absolute`);
475
- chartContainer.appendChild(div);
476
- }
477
- if (xLabel && x_axis_show_label) {
478
- xLabel.setAttribute('style', `color:${textColor}; width: 100%; text-align: ${x_axis_label_position}; bottom: -20px; position: absolute`);
479
- }
480
- if (xLabel && !x_axis_show_label) {
481
- xLabel.parentNode.removeChild(xLabel);
482
- }
483
- const yAxisLeftID = `chart-y-axis-left-label_${chart.id}`;
484
- const yAxisLeftLabel = chartContainer.querySelector(`#${yAxisLeftID}`);
485
- if (!yAxisLeftLabel && show_y_axis_left_label) {
486
- const div = document.createElement('div');
487
- div.id = yAxisLeftID;
488
- div.className = 'chart-axis-label text-truncate';
489
- if (y_axis_left_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
490
- div.innerHTML = _intl.default.get('Amount');
491
- } else {
492
- const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_left_summary_column) || {};
493
- div.innerHTML = column.name || '';
494
- }
495
- const containerHeight = chartContainer.offsetHeight;
496
- let textAlign = 'center';
497
- if (y_axis_left_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
498
- if (y_axis_left_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
499
- div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 + 12}px, ${(containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4}px) rotate(-90deg)`);
500
- chartContainer.appendChild(div);
501
- }
502
- if (yAxisLeftLabel && show_y_axis_left_label) {
503
- const containerHeight = chartContainer.offsetHeight;
504
- let textAlign = 'center';
505
- if (y_axis_left_label_position === 'bottom') textAlign = 'left';
506
- if (y_axis_left_label_position === 'top') textAlign = 'right';
507
- yAxisLeftLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 + 12}px, ${(containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4}px) rotate(-90deg)`);
508
- }
509
- if (yAxisLeftLabel && !show_y_axis_left_label) {
510
- yAxisLeftLabel.parentNode.removeChild(yAxisLeftLabel);
511
- }
512
- const yAxisRightID = `chart-y-axis-right-label_${chart.id}`;
513
- const yAxisRightLabel = chartContainer.querySelector(`#${yAxisRightID}`);
514
- if (!yAxisRightLabel && show_y_axis_right_label) {
515
- const div = document.createElement('div');
516
- div.id = yAxisRightID;
517
- div.className = 'chart-axis-label text-truncate';
518
- if (y_axis_right_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
519
- div.innerHTML = _intl.default.get('Amount');
520
- } else {
521
- const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_right_summary_column) || {};
522
- div.innerHTML = column.name || '';
523
- }
524
- const containerHeight = chartContainer.offsetHeight;
525
- let textAlign = 'center';
526
- if (y_axis_right_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
527
- if (y_axis_right_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
528
- div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: translate(${containerHeight / 2 + 12}px, ${(containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4}px) rotate(-90deg)`);
529
- chartContainer.appendChild(div);
530
- }
531
- if (yAxisRightLabel && show_y_axis_right_label) {
532
- const containerHeight = chartContainer.offsetHeight;
533
- let textAlign = 'center';
534
- if (y_axis_right_label_position === 'bottom') textAlign = 'left';
535
- if (y_axis_right_label_position === 'top') textAlign = 'right';
536
- yAxisRightLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: translate(${containerHeight / 2 + 12}px, ${(containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4}px) rotate(-90deg)`);
537
- }
538
- if (yAxisRightLabel && !show_y_axis_right_label) {
539
- yAxisRightLabel.parentNode.removeChild(yAxisRightLabel);
540
- }
541
- };
542
- this.drawLeftLegendSymbol = (x, y) => {
543
- // 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.
544
- const r = 3;
545
- // 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.
546
- const rectWidth = 14;
547
- y -= 1;
548
- x -= 5;
549
- return [['M', x - rectWidth / 2, y - r],
550
- // Start from the left edge of the left semi-circle
551
- ['L', x + rectWidth / 2, y - r],
552
- // Draw the top line to the left edge of the right semi-circle
553
- ['A', r, r, 0, 0, 1, x + rectWidth / 2, y + r],
554
- // Draw the right semi-circle
555
- ['L', x - rectWidth / 2, y + r],
556
- // Draw the bottom line back to the right edge of the left semi-circle
557
- ['A', r, r, 0, 0, 1, x - rectWidth / 2, y - r] // Draw the left semi-circle
558
- ];
559
- };
560
- this.drawRightLegendSymbol = (x, y) => {
561
- const r = 2;
562
- const size = 12;
563
- y -= 7;
564
- x -= 8;
565
- return [['M', x + r, y], ['L', x + size - r, y], ['A', r, r, 0, 0, 1, x + size, y + r], ['L', x + size, y + size - r], ['A', r, r, 0, 0, 1, x + size - r, y + size], ['L', x + r, y + size], ['A', r, r, 0, 0, 1, x, y + size - r], ['L', x, y + r], ['A', r, r, 0, 0, 1, x + r, y], ['Z']];
566
- };
567
- this.getLegend = (leftSummaryColumn, rightSummaryColumn, table, currentTheme) => {
568
- const {
569
- chart
570
- } = this.props;
571
- const {
572
- y_axis_left_group_by_multiple_numeric_column,
573
- y_axis_left_group_by_numeric_columns
574
- } = chart.config;
575
- const legendItems = [];
576
- if (!y_axis_left_group_by_multiple_numeric_column) {
577
- legendItems.push({
578
- value: 'value_left',
579
- name: leftSummaryColumn.name || _intl.default.get('Left'),
580
- marker: {
581
- symbol: this.drawLeftLegendSymbol,
582
- style: {
583
- fill: this.colorMap[leftSummaryColumn.name] || currentTheme.colors[0]
584
- }
585
- }
586
- }, {
587
- value: 'value_right',
588
- name: rightSummaryColumn.name || _intl.default.get('Right'),
589
- marker: {
590
- symbol: this.drawRightLegendSymbol,
591
- style: {
592
- fill: currentTheme.colors[1]
593
- }
594
- }
595
- });
596
- } else {
597
- legendItems.push({
598
- value: 'value_left',
599
- name: leftSummaryColumn.name || _intl.default.get('Left'),
600
- marker: {
601
- style: {
602
- fill: this.colorMap[leftSummaryColumn.name] || currentTheme.colors[0]
603
- },
604
- symbol: this.drawLeftLegendSymbol
605
- }
606
- });
607
- y_axis_left_group_by_numeric_columns.forEach((item, index) => {
608
- const column = (0, _dtableUtils.getTableColumnByKey)(table, item.column_key);
609
- if (column) {
610
- legendItems.push({
611
- value: 'group_name',
612
- name: column.name || _intl.default.get('Left'),
613
- marker: {
614
- symbol: this.drawLeftLegendSymbol,
615
- style: {
616
- fill: this.colorMap[column.name]
617
- }
618
- }
619
- });
620
- }
621
- });
622
- legendItems.push({
623
- value: 'value_right',
624
- name: rightSummaryColumn.name || _intl.default.get('Right'),
625
- marker: {
626
- symbol: this.drawRightLegendSymbol,
627
- style: {
628
- fill: currentTheme.colors[1]
629
- }
630
- }
631
- });
632
- }
633
- return legendItems;
634
- };
635
- this.setToolTipForInterval = (isGroup, summaryColumn, y_axis_summary_method) => {
636
- const {
637
- y_axis_left_group_by_multiple_numeric_column,
638
- y_axis_right_summary_method
639
- } = this.props.chart.config;
640
- const settings = this.getToolTipSettings(isGroup, summaryColumn, y_axis_summary_method);
641
- settings.showMarkers = false;
642
- settings.showTitle = true;
643
- if (isGroup) {
644
- settings.customItems = items => {
645
- const activeItem = items[0];
646
- const name = activeItem.data.name;
647
- const isMultiple = y_axis_left_group_by_multiple_numeric_column;
648
- return this.formatedDataByName[name].map(item => {
649
- const res = {
650
- color: item.color || _constants.CHART_STYLE_COLORS[0],
651
- data: item,
652
- name: !item.group_name && typeof item.group_name !== 'number' && isMultiple ? _intl.default.get(_constants.EMPTY_NAME) : item.group_name || item.name,
653
- title: isMultiple ? item.name : _intl.default.get(_constants.CHART_SUMMARY_SHOW[y_axis_right_summary_method]),
654
- value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, item.value_left, y_axis_summary_method)
655
- };
656
- return res;
657
- });
658
- };
659
- }
660
- this.chart.tooltip(settings);
661
- };
662
- this.setToolTipForPointView = () => {
663
- const settings = this.getToolTipSettings();
664
- settings.showTitle = true;
665
- settings.containerTpl = `<div class="g2-tooltip">
666
- <ul class="g2-tooltip-list"></ul>
667
- </div>`;
668
- settings.itemTpl = `<li class="g2-tooltip-list-item">
669
- <span class="g2-tooltip-marker" style="background-color:{color};display:inline-block;"></span>
670
- <span class="g2-tooltip-name">{name}</span>
671
- <span class="g2-tooltip-value">{value}</span>
672
- </li>`;
673
- this.chart.tooltip(settings);
674
- };
675
- this.isShowXAxisLabel = chart => {
676
- return !!(chart && chart.config && chart.config.x_axis_show_label);
677
- };
678
- this.isShowYAxisLeftLabel = chart => {
679
- return !!(chart && chart.config && chart.config.show_y_axis_left_label);
680
- };
681
- this.isShowYAxisRightLabel = chart => {
682
- return !!(chart && chart.config && chart.config.show_y_axis_right_label);
683
- };
684
- this.chart = null;
685
- }
686
- componentDidMount() {
687
- this.drawChart();
688
- this.renderAxisLabel(this.props.chart, this.props.tables);
689
- }
690
- componentDidUpdate(prevProps) {
691
- super.componentDidUpdate(prevProps);
692
- if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
693
- var _this$chart2;
694
- ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
695
- this.drawChart();
696
- this.renderAxisLabel(prevProps.chart, prevProps.tables);
697
- }
698
- }
699
- componentWillUnmount() {
700
- var _this$chart3;
701
- ((_this$chart3 = this.chart) === null || _this$chart3 === void 0 ? void 0 : _this$chart3.autoPadding) && this.chart.destroy();
702
- }
703
- render() {
704
- const {
705
- chart
706
- } = this.props;
707
- return /*#__PURE__*/_react.default.createElement("div", {
708
- className: (0, _classnames.default)('sea-chart-container ', {
709
- 'show-x-axis-label': this.isShowXAxisLabel(chart),
710
- 'show-y-axis-left-label': this.isShowYAxisLeftLabel(chart),
711
- 'show-y-axis-right-label': this.isShowYAxisRightLabel(chart)
712
- }),
713
- ref: ref => this.container = ref
714
- });
715
- }
716
- }
717
- Combination.propTypes = {
718
- canvasStyle: _propTypes.default.object,
719
- chart: _propTypes.default.object,
720
- summaryColumn: _propTypes.default.object,
721
- result: _propTypes.default.array,
722
- tables: _propTypes.default.array,
723
- globalTheme: _propTypes.default.string,
724
- chartColorTheme: _propTypes.default.string,
725
- toggleRecords: _propTypes.default.func,
726
- customRender: _propTypes.default.func
727
- };
728
- var _default = exports.default = Combination;