sea-chart 2.0.43 → 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.
- package/dist/api/index.js +4 -11
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +4 -11
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +27 -35
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +11 -18
- package/dist/components/color-popover/color-rules/color-rule.js +25 -33
- package/dist/components/color-popover/color-rules/index.js +6 -14
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +10 -18
- package/dist/components/color-popover/color-rules-popover.js +26 -34
- package/dist/components/color-popover/color-selector-popover.js +10 -18
- package/dist/components/color-setting/color-group-selector.js +12 -20
- package/dist/components/common-add-tool/index.js +6 -13
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +12 -19
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +16 -24
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +42 -50
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +4 -11
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +4 -11
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +25 -33
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +54 -64
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +15 -22
- package/dist/components/row-card/row-card-header.js +14 -21
- package/dist/components/row-card/row-card-item.js +33 -41
- package/dist/components/row-card/row-card.js +15 -23
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +21 -21
- package/dist/components/types-dialog/index.js +56 -64
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +149 -273
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +20 -24
- package/dist/editor/index.js +8 -15
- package/dist/index.js +13 -104
- package/dist/intl.js +10 -17
- package/dist/locale/index.js +16 -23
- package/dist/locale/lang/de.js +1 -7
- package/dist/locale/lang/en.js +1 -7
- package/dist/locale/lang/es.js +1 -7
- package/dist/locale/lang/fr.js +1 -7
- package/dist/locale/lang/pt.js +1 -7
- package/dist/locale/lang/ru.js +1 -7
- package/dist/locale/lang/zh_CN.js +1 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +8 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +19 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +15 -18
- package/dist/model/horizontal-group-bar.js +14 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +12 -19
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +15 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +7 -13
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +83 -74
- package/dist/settings/bar-settings/data-settings.js +39 -47
- package/dist/settings/bar-settings/index.js +3 -20
- package/dist/settings/bar-settings/style-settings.js +69 -60
- package/dist/settings/basic-number-card/data-settings.js +49 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +18 -26
- package/dist/settings/combination-settings/data-settings.js +55 -63
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +94 -77
- package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
- package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
- package/dist/settings/completeness-settings/index.js +3 -20
- package/dist/settings/completeness-settings/style-settings.js +19 -26
- package/dist/settings/dashboard-settings/data-settings.js +43 -51
- package/dist/settings/dashboard-settings/index.js +2 -13
- package/dist/settings/data-settings.js +72 -79
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
- package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
- package/dist/settings/funnel-settings/data-settings.js +23 -31
- package/dist/settings/funnel-settings/index.js +3 -20
- package/dist/settings/funnel-settings/style-settings.js +11 -19
- package/dist/settings/heat-map-settings/data-settings.js +18 -26
- package/dist/settings/heat-map-settings/index.js +3 -20
- package/dist/settings/heat-map-settings/style-settings.js +18 -26
- package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
- package/dist/settings/horizontal-bar-settings/index.js +3 -20
- package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
- package/dist/settings/index.js +52 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +26 -34
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +64 -72
- package/dist/settings/table-element-settings/components/data-filter.js +30 -38
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +111 -119
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +62 -53
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +17 -25
- package/dist/settings/widgets/axis-title-font-settings/index.js +39 -0
- package/dist/settings/widgets/basic-summary/index.js +55 -63
- package/dist/settings/widgets/chart-type/index.js +18 -26
- package/dist/settings/widgets/color-settings/index.js +72 -80
- package/dist/settings/widgets/common-data-settings.js +21 -29
- package/dist/settings/widgets/data-filter/index.js +35 -43
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +24 -32
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +51 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +23 -31
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +72 -80
- package/dist/settings/widgets/switch/index.js +8 -15
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +63 -71
- package/dist/utils/cell-format-utils.js +18 -28
- package/dist/utils/cell-value-utils.js +5 -12
- package/dist/utils/chart-utils/base-utils.js +362 -334
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +80 -86
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +32 -39
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +91 -97
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
- package/dist/utils/chart-utils/sql-statistics-utils.js +284 -246
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +18 -30
- package/dist/utils/collaborator.js +4 -13
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +65 -92
- package/dist/utils/common-utils.js +27 -52
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +11 -19
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +1 -7
- package/dist/utils/options-utils.js +8 -16
- package/dist/utils/row-record-utils.js +182 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +49 -55
- package/dist/utils/sql/column-2-sql-column.js +146 -154
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.css +0 -17
- package/dist/view/index.js +89 -95
- package/dist/view/title/index.js +15 -23
- package/dist/view/wrapper/area-group.js +53 -72
- package/dist/view/wrapper/area.js +51 -72
- package/dist/view/wrapper/bar-compare.js +43 -56
- package/dist/view/wrapper/bar-custom-stack.js +50 -120
- package/dist/view/wrapper/bar-group.js +51 -94
- package/dist/view/wrapper/bar-stack.js +54 -90
- package/dist/view/wrapper/bar.js +45 -66
- package/dist/view/wrapper/basic-number-card.js +25 -26
- package/dist/view/wrapper/chart-component.js +539 -162
- package/dist/view/wrapper/combination.js +63 -83
- package/dist/view/wrapper/completeness-group.js +42 -96
- package/dist/view/wrapper/completeness.js +42 -96
- package/dist/view/wrapper/dashboard.js +33 -47
- package/dist/view/wrapper/funnel.js +36 -56
- package/dist/view/wrapper/heat-map.js +126 -104
- package/dist/view/wrapper/horizontal-bar-group.js +57 -76
- package/dist/view/wrapper/horizontal-bar-stack.js +56 -109
- package/dist/view/wrapper/horizontal-bar.js +45 -68
- package/dist/view/wrapper/index.js +110 -115
- package/dist/view/wrapper/line-group.js +48 -66
- package/dist/view/wrapper/line.js +47 -67
- package/dist/view/wrapper/map-bubble.js +46 -59
- package/dist/view/wrapper/map-world-bubble.js +45 -58
- package/dist/view/wrapper/map-world.js +47 -60
- package/dist/view/wrapper/map.js +48 -60
- package/dist/view/wrapper/mirror.js +40 -61
- package/dist/view/wrapper/pie.js +48 -59
- package/dist/view/wrapper/ring.js +52 -63
- package/dist/view/wrapper/scatter.js +49 -67
- package/dist/view/wrapper/table/index.js +13 -21
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +50 -58
- package/dist/view/wrapper/table/pivot-table-display-name.js +83 -91
- package/dist/view/wrapper/table/two-dimension-table.js +76 -84
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +96 -105
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +22 -31
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/record.js +10 -17
- package/dist/view/wrapper/table-element/components/records-body.js +17 -19
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +23 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
- package/dist/view/wrapper/table-element/components/utils.js +5 -15
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +39 -57
- package/dist/view/wrapper/trend.js +41 -48
- package/package.json +1 -1
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
16
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
17
|
-
var _constants = require("../../constants");
|
|
18
|
-
var _utils = require("../../utils");
|
|
19
|
-
var _colorRules = require("../../constants/color-rules");
|
|
20
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
21
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
22
|
-
class BarGroup extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { CellType, isEmpty } from 'dtable-utils';
|
|
4
|
+
import { cloneDeep } from 'lodash-es';
|
|
5
|
+
import * as d3 from 'd3';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
import { EMPTY_NAME, CHART_THEME_COLOR, CHART_STYLE_COLORS } from '../../constants';
|
|
9
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
10
|
+
import { SUPPORT_SINGLE_SELECT_THEMES_OPTIONS } from '../../constants/color-rules';
|
|
11
|
+
import ToolTip from '../../components/tooltip';
|
|
12
|
+
import ChartComponent from './chart-component';
|
|
13
|
+
class BarGroup extends ChartComponent {
|
|
23
14
|
constructor(props) {
|
|
24
15
|
super(props);
|
|
25
|
-
this.handleResize = () => {
|
|
26
|
-
this.destroyChart();
|
|
27
|
-
this.createChart();
|
|
28
|
-
this.drawChart();
|
|
29
|
-
};
|
|
30
16
|
this.createChart = () => {
|
|
31
17
|
const {
|
|
32
18
|
chart
|
|
@@ -39,8 +25,8 @@ class BarGroup extends _chartComponent.default {
|
|
|
39
25
|
const initConfig = {
|
|
40
26
|
insertPadding: 30,
|
|
41
27
|
borderRadius: 0.2,
|
|
42
|
-
marginLeft: y_axis_show_label ?
|
|
43
|
-
marginBottom: x_axis_show_label ?
|
|
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,
|
|
44
30
|
marginTop: y_axis_show_value ? 15 : 0
|
|
45
31
|
};
|
|
46
32
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
@@ -56,11 +42,11 @@ class BarGroup extends _chartComponent.default {
|
|
|
56
42
|
const {
|
|
57
43
|
column_groupby_column_key
|
|
58
44
|
} = chart.config || {};
|
|
59
|
-
data =
|
|
45
|
+
data = BaseUtils.formatEmptyName(data, column_groupby_column_key, intl.get(EMPTY_NAME));
|
|
60
46
|
if (!Array.isArray(data)) return;
|
|
61
47
|
this.draw(data);
|
|
62
48
|
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
63
|
-
|
|
49
|
+
isFunction(customRender) && customRender(this.chart);
|
|
64
50
|
};
|
|
65
51
|
this.draw = data => {
|
|
66
52
|
const {
|
|
@@ -93,17 +79,17 @@ class BarGroup extends _chartComponent.default {
|
|
|
93
79
|
y_axis_min,
|
|
94
80
|
y_axis_auto_range
|
|
95
81
|
} = chart.config;
|
|
96
|
-
const theme =
|
|
82
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
97
83
|
const column_groupby_column = this.getColumn(tables, table_id, column_groupby_column_key);
|
|
98
|
-
const useSingleSelectColumnColor = (column_groupby_column === null || column_groupby_column === void 0 ? void 0 : column_groupby_column.type) ===
|
|
84
|
+
const useSingleSelectColumnColor = (column_groupby_column === null || column_groupby_column === void 0 ? void 0 : column_groupby_column.type) === CellType.SINGLE_SELECT && color_theme === SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
99
85
|
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme, 'group_name', columnGroupbyColumn, chart); // use single select column color
|
|
100
86
|
|
|
101
87
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, d3.max(data, d => d.value)] : [y_axis_min, y_axis_max]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
102
88
|
|
|
103
89
|
// Y axis
|
|
104
|
-
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', `translate(${insertPadding},0)`).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d =>
|
|
90
|
+
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', `translate(${insertPadding},0)`).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(summaryColumn, d, y_axis_summary_method))).call(g => this.drawYaxis(g, theme));
|
|
105
91
|
const fx = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.25).paddingOuter(0.1);
|
|
106
|
-
const sortedData =
|
|
92
|
+
const sortedData = BaseUtils.sortDataByGroupName(cloneDeep(data), 'group_name', columnGroupbyColumn, chart);
|
|
107
93
|
|
|
108
94
|
// X axis
|
|
109
95
|
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', `translate(0,${chartHeight - insertPadding})`).call(d3.axisBottom(fx).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
@@ -128,37 +114,12 @@ class BarGroup extends _chartComponent.default {
|
|
|
128
114
|
const rectSelection = d3.select(groupNode).selectAll('rect').data(dum).join('rect').attr('opacity', 1).attr('x', d => localX(d.group_name)).attr('y', d => y(d.value)).attr('width', localX.bandwidth()).attr('height', d => y(0) - y(d.value)).attr('fill', d => {
|
|
129
115
|
var _this$colorMap$colorK;
|
|
130
116
|
const colorKey = d.group_name || d.group_name === 0 ? d.group_name : '';
|
|
131
|
-
return (_this$colorMap$colorK = this.colorMap[colorKey]) !== null && _this$colorMap$colorK !== void 0 ? _this$colorMap$colorK :
|
|
132
|
-
}).attr('data-value', d => d.value).attr('data-groupName', d => d.name)
|
|
133
|
-
|
|
134
|
-
borderRadius
|
|
135
|
-
} = this.chartBoundingClientRect;
|
|
136
|
-
const rectNodes = rectSelection.nodes();
|
|
137
|
-
const validRectNodes = rectNodes.filter(rect => {
|
|
138
|
-
const rectWidth = Number(rect.getAttribute('width'));
|
|
139
|
-
const rectHeight = Number(rect.getAttribute('height'));
|
|
140
|
-
return rectWidth > 0 && rectHeight > 0;
|
|
141
|
-
});
|
|
142
|
-
let groupBorderRadius;
|
|
143
|
-
if (validRectNodes.length > 0) {
|
|
144
|
-
groupBorderRadius = Infinity;
|
|
145
|
-
validRectNodes.forEach(rect => {
|
|
146
|
-
const rectWidth = Number(rect.getAttribute('width'));
|
|
147
|
-
const rectHeight = Number(rect.getAttribute('height'));
|
|
148
|
-
const computedBorderRadius = Math.min(rectWidth * borderRadius, rectHeight / 2, rectWidth / 2);
|
|
149
|
-
groupBorderRadius = Math.min(groupBorderRadius, computedBorderRadius);
|
|
150
|
-
});
|
|
151
|
-
if (!Number.isFinite(groupBorderRadius)) {
|
|
152
|
-
groupBorderRadius = 0;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
rectNodes.forEach(rect => {
|
|
117
|
+
return (_this$colorMap$colorK = this.colorMap[colorKey]) !== null && _this$colorMap$colorK !== void 0 ? _this$colorMap$colorK : CHART_STYLE_COLORS[0];
|
|
118
|
+
}).attr('data-value', d => d.value).attr('data-groupName', d => d.name);
|
|
119
|
+
rectSelection.nodes().forEach(rect => {
|
|
156
120
|
const parentNode = rect.parentNode;
|
|
157
121
|
this.addClipPath({
|
|
158
|
-
rect
|
|
159
|
-
parentNode,
|
|
160
|
-
rectId: rect.getAttribute('data-slugid'),
|
|
161
|
-
borderRadiusVal: Number.isFinite(groupBorderRadius) ? groupBorderRadius : undefined
|
|
122
|
+
rect
|
|
162
123
|
});
|
|
163
124
|
if (y_axis_show_value) {
|
|
164
125
|
this.addLabelToRectTop({
|
|
@@ -168,7 +129,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
168
129
|
y: Number(rect.getAttribute('y')),
|
|
169
130
|
theme,
|
|
170
131
|
label_font_size,
|
|
171
|
-
text:
|
|
132
|
+
text: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(rect.dataset.value), y_axis_summary_method)
|
|
172
133
|
});
|
|
173
134
|
}
|
|
174
135
|
});
|
|
@@ -183,6 +144,9 @@ class BarGroup extends _chartComponent.default {
|
|
|
183
144
|
}).on('mouseleave', event => {
|
|
184
145
|
this.hiddenTooltip();
|
|
185
146
|
this.handleAcitveAndInActiveState('active', event);
|
|
147
|
+
}).call(g => {
|
|
148
|
+
this.animateRectGrowInY(g);
|
|
149
|
+
this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
186
150
|
});
|
|
187
151
|
if (display_goal_line && goal_label && goal_value) {
|
|
188
152
|
this.setDispalyGoalLine(goal_label, goal_value, insertPadding, y);
|
|
@@ -205,7 +169,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
205
169
|
const {
|
|
206
170
|
y_axis_summary_method
|
|
207
171
|
} = chart.config;
|
|
208
|
-
const isGroupByDate = [
|
|
172
|
+
const isGroupByDate = [CellType.DATE, CellType.CTIME, CellType.MTIME].includes((_this$props$columnGro = this.props.columnGroupbyColumn) === null || _this$props$columnGro === void 0 ? void 0 : _this$props$columnGro.type);
|
|
209
173
|
const {
|
|
210
174
|
offsetX,
|
|
211
175
|
offsetY
|
|
@@ -213,14 +177,14 @@ class BarGroup extends _chartComponent.default {
|
|
|
213
177
|
const curGroup = event.target.parentNode;
|
|
214
178
|
let [curGroupName, data] = curGroup.__data__;
|
|
215
179
|
const newTooltipData = {
|
|
216
|
-
title:
|
|
180
|
+
title: isEmpty(curGroupName) ? intl.get(EMPTY_NAME) : curGroupName,
|
|
217
181
|
items: data.map(item => {
|
|
218
182
|
const rawGroupName = item.group_name;
|
|
219
|
-
const groupName = rawGroupName
|
|
183
|
+
const groupName = isEmpty(rawGroupName) ? intl.get(EMPTY_NAME) : isGroupByDate ? dayjs(rawGroupName).format('YYYY-MM-DD') : rawGroupName;
|
|
220
184
|
return {
|
|
221
185
|
color: this.colorMap[groupName],
|
|
222
186
|
name: groupName,
|
|
223
|
-
value:
|
|
187
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(item.value), y_axis_summary_method)
|
|
224
188
|
};
|
|
225
189
|
})
|
|
226
190
|
};
|
|
@@ -266,12 +230,11 @@ class BarGroup extends _chartComponent.default {
|
|
|
266
230
|
componentDidMount() {
|
|
267
231
|
this.createChart();
|
|
268
232
|
this.drawChart();
|
|
269
|
-
|
|
270
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
233
|
+
super.componentDidMount();
|
|
271
234
|
}
|
|
272
235
|
componentDidUpdate(prevProps) {
|
|
273
236
|
super.componentDidUpdate(prevProps);
|
|
274
|
-
if (
|
|
237
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
275
238
|
this.destroyChart();
|
|
276
239
|
this.createChart();
|
|
277
240
|
this.drawChart();
|
|
@@ -279,23 +242,17 @@ class BarGroup extends _chartComponent.default {
|
|
|
279
242
|
}
|
|
280
243
|
componentWillUnmount() {
|
|
281
244
|
this.destroyChart();
|
|
282
|
-
|
|
245
|
+
super.componentWillUnmount();
|
|
283
246
|
}
|
|
284
247
|
render() {
|
|
285
|
-
const {
|
|
286
|
-
chart
|
|
287
|
-
} = this.props;
|
|
288
248
|
const {
|
|
289
249
|
tooltipData,
|
|
290
250
|
toolTipPosition
|
|
291
251
|
} = this.state;
|
|
292
|
-
return /*#__PURE__*/
|
|
252
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
293
253
|
ref: ref => this.container = ref,
|
|
294
|
-
className:
|
|
295
|
-
|
|
296
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
297
|
-
})
|
|
298
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
254
|
+
className: "sea-chart-container"
|
|
255
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
299
256
|
tooltipData: tooltipData,
|
|
300
257
|
toolTipPosition: toolTipPosition,
|
|
301
258
|
chart: this.chart
|
|
@@ -303,16 +260,16 @@ class BarGroup extends _chartComponent.default {
|
|
|
303
260
|
}
|
|
304
261
|
}
|
|
305
262
|
BarGroup.propTypes = {
|
|
306
|
-
canvasStyle:
|
|
307
|
-
chart:
|
|
308
|
-
groupbyColumn:
|
|
309
|
-
columnGroupbyColumn:
|
|
310
|
-
summaryColumn:
|
|
311
|
-
result:
|
|
312
|
-
tables:
|
|
313
|
-
globalTheme:
|
|
314
|
-
chartColorTheme:
|
|
315
|
-
toggleRecords:
|
|
316
|
-
customRender:
|
|
263
|
+
canvasStyle: PropTypes.object,
|
|
264
|
+
chart: PropTypes.object,
|
|
265
|
+
groupbyColumn: PropTypes.object,
|
|
266
|
+
columnGroupbyColumn: PropTypes.object,
|
|
267
|
+
summaryColumn: PropTypes.object,
|
|
268
|
+
result: PropTypes.array,
|
|
269
|
+
tables: PropTypes.array,
|
|
270
|
+
globalTheme: PropTypes.string,
|
|
271
|
+
chartColorTheme: PropTypes.string,
|
|
272
|
+
toggleRecords: PropTypes.func,
|
|
273
|
+
customRender: PropTypes.func
|
|
317
274
|
};
|
|
318
|
-
|
|
275
|
+
export default BarGroup;
|
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
16
|
-
var _columnUtils = require("../../utils/column-utils");
|
|
17
|
-
var _constants = require("../../constants");
|
|
18
|
-
var _utils = require("../../utils");
|
|
19
|
-
var _colorRules = require("../../constants/color-rules");
|
|
20
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
21
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
22
|
-
class BarStack extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { CellType } from 'dtable-utils';
|
|
4
|
+
import { isNaN, cloneDeep } from 'lodash-es';
|
|
5
|
+
import * as d3 from 'd3';
|
|
6
|
+
import intl from '../../intl';
|
|
7
|
+
import { sortDataByGroupSum } from '../../utils/column-utils';
|
|
8
|
+
import { EMPTY_NAME, CHART_THEME_COLOR, CHART_STYLE_COLORS } from '../../constants';
|
|
9
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
10
|
+
import { SUPPORT_SINGLE_SELECT_THEMES_OPTIONS } from '../../constants/color-rules';
|
|
11
|
+
import ToolTip from '../../components/tooltip';
|
|
12
|
+
import ChartComponent from './chart-component';
|
|
13
|
+
class BarStack extends ChartComponent {
|
|
23
14
|
constructor(props) {
|
|
24
15
|
super(props);
|
|
25
|
-
this.handleResize = () => {
|
|
26
|
-
this.destroyChart();
|
|
27
|
-
this.createChart();
|
|
28
|
-
this.drawChart();
|
|
29
|
-
};
|
|
30
16
|
this.createChart = () => {
|
|
31
17
|
const {
|
|
32
18
|
chart
|
|
@@ -39,8 +25,8 @@ class BarStack extends _chartComponent.default {
|
|
|
39
25
|
const initConfig = {
|
|
40
26
|
insertPadding: 30,
|
|
41
27
|
borderRadius: 0.2,
|
|
42
|
-
marginLeft: y_axis_show_label ?
|
|
43
|
-
marginBottom: x_axis_show_label ?
|
|
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,
|
|
44
30
|
marginTop: display_each_block_data ? 15 : 0
|
|
45
31
|
};
|
|
46
32
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
@@ -56,12 +42,12 @@ class BarStack extends _chartComponent.default {
|
|
|
56
42
|
let {
|
|
57
43
|
result: data
|
|
58
44
|
} = this.props;
|
|
59
|
-
data =
|
|
45
|
+
data = BaseUtils.formatEmptyName(data, chart.config.column_groupby_column_key, intl.get('Empty'));
|
|
60
46
|
if (!Array.isArray(data)) return;
|
|
61
|
-
sort_type && (data =
|
|
47
|
+
sort_type && (data = sortDataByGroupSum(data, sort_type));
|
|
62
48
|
this.draw(data);
|
|
63
49
|
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
64
|
-
|
|
50
|
+
isFunction(customRender) && customRender(this.chart);
|
|
65
51
|
};
|
|
66
52
|
this.draw = data => {
|
|
67
53
|
const {
|
|
@@ -88,9 +74,9 @@ class BarStack extends _chartComponent.default {
|
|
|
88
74
|
y_axis_min,
|
|
89
75
|
y_axis_auto_range
|
|
90
76
|
} = chart.config;
|
|
91
|
-
const theme =
|
|
77
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
92
78
|
const column_groupby_column = this.getColumn(tables, table_id, column_groupby_column_key);
|
|
93
|
-
const useSingleSelectColumnColor = (column_groupby_column === null || column_groupby_column === void 0 ? void 0 : column_groupby_column.type) ===
|
|
79
|
+
const useSingleSelectColumnColor = (column_groupby_column === null || column_groupby_column === void 0 ? void 0 : column_groupby_column.type) === CellType.SINGLE_SELECT && color_theme === SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
94
80
|
// use single select column color
|
|
95
81
|
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme, 'group_name', columnGroupbyColumn, chart);
|
|
96
82
|
const {
|
|
@@ -99,7 +85,7 @@ class BarStack extends _chartComponent.default {
|
|
|
99
85
|
insertPadding,
|
|
100
86
|
marginTop
|
|
101
87
|
} = this.chartBoundingClientRect;
|
|
102
|
-
const sortedData =
|
|
88
|
+
const sortedData = BaseUtils.sortDataByGroupName(cloneDeep(data), 'group_name', columnGroupbyColumn, chart).reverse();
|
|
103
89
|
const series = d3.stack().keys(d3.union(sortedData.map(d => d.group_name))).value((_ref, key) => {
|
|
104
90
|
var _group$get;
|
|
105
91
|
let [_, group] = _ref;
|
|
@@ -109,7 +95,7 @@ class BarStack extends _chartComponent.default {
|
|
|
109
95
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min, y_axis_max]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
110
96
|
|
|
111
97
|
// Y axis
|
|
112
|
-
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', `translate(${insertPadding},0)`).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d =>
|
|
98
|
+
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', `translate(${insertPadding},0)`).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(summaryColumn, d, y_axis_summary_method))).call(g => this.drawYaxis(g, theme));
|
|
113
99
|
const x = d3.scaleBand().domain(d3.group(data, d => d.name).keys()).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
114
100
|
|
|
115
101
|
// X axis
|
|
@@ -131,8 +117,8 @@ class BarStack extends _chartComponent.default {
|
|
|
131
117
|
return data;
|
|
132
118
|
}).join('rect').attr('opacity', 1).attr('x', d => x(d.data[0])).attr('y', d => y(d[1])).attr('height', d => {
|
|
133
119
|
const height = y(d[0]) - y(d[1]);
|
|
134
|
-
return
|
|
135
|
-
}).attr('width', x.bandwidth()).attr('fill', d => this.colorMap[d.key] ||
|
|
120
|
+
return isNaN(height) ? 0 : height;
|
|
121
|
+
}).attr('width', x.bandwidth()).attr('fill', d => this.colorMap[d.key] || CHART_STYLE_COLORS[0]).attr('data-value', d => {
|
|
136
122
|
const {
|
|
137
123
|
data,
|
|
138
124
|
key
|
|
@@ -153,7 +139,6 @@ class BarStack extends _chartComponent.default {
|
|
|
153
139
|
if (Number(firstEl.getAttribute('height')) === 0) {
|
|
154
140
|
firstEl = reverseGroup.slice(1).find(item => Number(item.getAttribute('height')) !== 0);
|
|
155
141
|
}
|
|
156
|
-
// Add mask rect
|
|
157
142
|
firstEl && this.addMaskRect((_firstEl = firstEl) === null || _firstEl === void 0 ? void 0 : _firstEl.parentNode, firstEl, x.bandwidth());
|
|
158
143
|
});
|
|
159
144
|
const [topG] = g._parents.slice(-1);
|
|
@@ -167,8 +152,11 @@ class BarStack extends _chartComponent.default {
|
|
|
167
152
|
if (y_axis_show_value) {
|
|
168
153
|
this.handleLabelToRectCenter(g, x.bandwidth());
|
|
169
154
|
}
|
|
155
|
+
this.animateFadeIn(this.contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
156
|
+
this.animateStackGrowInY(g);
|
|
170
157
|
}).on('click', (event, data) => {
|
|
171
|
-
|
|
158
|
+
const resultItem = data.data[1].get(data.key);
|
|
159
|
+
this.toggleRecords(resultItem);
|
|
172
160
|
}).on('mouseover', event => {
|
|
173
161
|
this.showTooltip(event);
|
|
174
162
|
this.handleAcitveAndInActiveState('inActive', event);
|
|
@@ -210,18 +198,18 @@ class BarStack extends _chartComponent.default {
|
|
|
210
198
|
} = this.props;
|
|
211
199
|
const {
|
|
212
200
|
y_axis_summary_method
|
|
213
|
-
} = chart;
|
|
201
|
+
} = chart.config;
|
|
214
202
|
const offsetX = d3.pointer(event)[0];
|
|
215
203
|
const offsetY = d3.pointer(event)[1];
|
|
216
204
|
const curRect = event.currentTarget;
|
|
217
205
|
const curGroup = curRect.parentNode;
|
|
218
206
|
const curGroupName = event.currentTarget.getAttribute('data-groupName');
|
|
219
207
|
const newTooltipData = {
|
|
220
|
-
title: !curGroupName && typeof curGroupName !== 'number' ?
|
|
208
|
+
title: !curGroupName && typeof curGroupName !== 'number' ? intl.get(EMPTY_NAME) : curGroupName,
|
|
221
209
|
items: [{
|
|
222
210
|
color: this.colorMap[curGroup.getAttribute('data-key')],
|
|
223
211
|
name: curGroup.getAttribute('data-key'),
|
|
224
|
-
value:
|
|
212
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(curRect.getAttribute('data-value')), y_axis_summary_method)
|
|
225
213
|
}]
|
|
226
214
|
};
|
|
227
215
|
this.setState({
|
|
@@ -255,24 +243,7 @@ class BarStack extends _chartComponent.default {
|
|
|
255
243
|
this.setActiveAndInActiveState(state, allGroup, curGroupName);
|
|
256
244
|
};
|
|
257
245
|
this.addMaskRect = (topG, rect, xWidth) => {
|
|
258
|
-
|
|
259
|
-
borderRadius
|
|
260
|
-
} = this.chartBoundingClientRect;
|
|
261
|
-
// Add mask rect
|
|
262
|
-
d3.select(topG).append('foreignObject').attr('x', rect.getAttribute('x')).attr('y', rect.getAttribute('y')).attr('opacity', rect.getAttribute('opacity')).attr('width', xWidth).attr('height', rect.getAttribute('height')).attr('data-groupName', rect.getAttribute('data-groupName')).attr('data-value', rect.getAttribute('data-value')).on('click', (event, data) => {
|
|
263
|
-
this.props.toggleRecords(data);
|
|
264
|
-
}).on('mouseover', event => {
|
|
265
|
-
this.showTooltip(event);
|
|
266
|
-
this.handleAcitveAndInActiveState('inActive', event);
|
|
267
|
-
}).on('mousemove', event => {
|
|
268
|
-
this.moveTooltip(event);
|
|
269
|
-
}).on('mouseleave', (event, data) => {
|
|
270
|
-
this.hiddenTooltip();
|
|
271
|
-
this.handleAcitveAndInActiveState('active', event);
|
|
272
|
-
}).append('xhtml:div').attr('style', `width: 100%; height: 100%; background-color: ${rect.getAttribute('fill')}; border-radius: ${xWidth * borderRadius}px ${xWidth * borderRadius}px 0px 0px`);
|
|
273
|
-
|
|
274
|
-
// Remove old rect
|
|
275
|
-
d3.select(rect).remove();
|
|
246
|
+
return this.addRoundedClip(rect, 'y', xWidth);
|
|
276
247
|
};
|
|
277
248
|
this.addLabelByEachStack = (data, topG, rect, x) => {
|
|
278
249
|
const {
|
|
@@ -284,7 +255,7 @@ class BarStack extends _chartComponent.default {
|
|
|
284
255
|
label_font_size,
|
|
285
256
|
y_axis_summary_method
|
|
286
257
|
} = chart.config;
|
|
287
|
-
const theme =
|
|
258
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
288
259
|
const groupData = d3.group(data, d => d.name);
|
|
289
260
|
const group_name = rect.getAttribute('data-groupName');
|
|
290
261
|
let stackSum = 0;
|
|
@@ -296,7 +267,7 @@ class BarStack extends _chartComponent.default {
|
|
|
296
267
|
y: Number(rect.getAttribute('y')),
|
|
297
268
|
theme,
|
|
298
269
|
label_font_size,
|
|
299
|
-
text:
|
|
270
|
+
text: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(stackSum), y_axis_summary_method)
|
|
300
271
|
});
|
|
301
272
|
};
|
|
302
273
|
this.handleLabelToRectCenter = (g, xWidth) => {
|
|
@@ -309,7 +280,7 @@ class BarStack extends _chartComponent.default {
|
|
|
309
280
|
label_font_size,
|
|
310
281
|
y_axis_summary_method
|
|
311
282
|
} = chart.config;
|
|
312
|
-
const theme =
|
|
283
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
313
284
|
g._parents.forEach(group => {
|
|
314
285
|
Array.from(group.children).forEach(rect => {
|
|
315
286
|
// The height is 0, and the label is not displayed.
|
|
@@ -322,7 +293,7 @@ class BarStack extends _chartComponent.default {
|
|
|
322
293
|
yheight: Number(rect.getAttribute('height')),
|
|
323
294
|
theme,
|
|
324
295
|
label_font_size,
|
|
325
|
-
text:
|
|
296
|
+
text: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(rect.getAttribute('data-value')), y_axis_summary_method)
|
|
326
297
|
});
|
|
327
298
|
});
|
|
328
299
|
});
|
|
@@ -336,12 +307,11 @@ class BarStack extends _chartComponent.default {
|
|
|
336
307
|
componentDidMount() {
|
|
337
308
|
this.createChart();
|
|
338
309
|
this.drawChart();
|
|
339
|
-
|
|
340
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
310
|
+
super.componentDidMount();
|
|
341
311
|
}
|
|
342
312
|
componentDidUpdate(prevProps) {
|
|
343
313
|
super.componentDidUpdate(prevProps);
|
|
344
|
-
if (
|
|
314
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
345
315
|
this.destroyChart();
|
|
346
316
|
this.createChart();
|
|
347
317
|
this.drawChart();
|
|
@@ -349,23 +319,17 @@ class BarStack extends _chartComponent.default {
|
|
|
349
319
|
}
|
|
350
320
|
componentWillUnmount() {
|
|
351
321
|
this.destroyChart();
|
|
352
|
-
|
|
322
|
+
super.componentWillUnmount();
|
|
353
323
|
}
|
|
354
324
|
render() {
|
|
355
|
-
const {
|
|
356
|
-
chart
|
|
357
|
-
} = this.props;
|
|
358
325
|
const {
|
|
359
326
|
tooltipData,
|
|
360
327
|
toolTipPosition
|
|
361
328
|
} = this.state;
|
|
362
|
-
return /*#__PURE__*/
|
|
329
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
363
330
|
ref: ref => this.container = ref,
|
|
364
|
-
className:
|
|
365
|
-
|
|
366
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
367
|
-
})
|
|
368
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
331
|
+
className: "sea-chart-container"
|
|
332
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
369
333
|
tooltipData: tooltipData,
|
|
370
334
|
toolTipPosition: toolTipPosition,
|
|
371
335
|
chart: this.chart
|
|
@@ -373,16 +337,16 @@ class BarStack extends _chartComponent.default {
|
|
|
373
337
|
}
|
|
374
338
|
}
|
|
375
339
|
BarStack.propTypes = {
|
|
376
|
-
canvasStyle:
|
|
377
|
-
chart:
|
|
378
|
-
groupbyColumn:
|
|
379
|
-
columnGroupbyColumn:
|
|
380
|
-
summaryColumn:
|
|
381
|
-
result:
|
|
382
|
-
tables:
|
|
383
|
-
globalTheme:
|
|
384
|
-
chartColorTheme:
|
|
385
|
-
toggleRecords:
|
|
386
|
-
customRender:
|
|
340
|
+
canvasStyle: PropTypes.object,
|
|
341
|
+
chart: PropTypes.object,
|
|
342
|
+
groupbyColumn: PropTypes.object,
|
|
343
|
+
columnGroupbyColumn: PropTypes.object,
|
|
344
|
+
summaryColumn: PropTypes.object,
|
|
345
|
+
result: PropTypes.array,
|
|
346
|
+
tables: PropTypes.array,
|
|
347
|
+
globalTheme: PropTypes.string,
|
|
348
|
+
chartColorTheme: PropTypes.string,
|
|
349
|
+
toggleRecords: PropTypes.func,
|
|
350
|
+
customRender: PropTypes.func
|
|
387
351
|
};
|
|
388
|
-
|
|
352
|
+
export default BarStack;
|