sea-chart 2.0.43 → 2.0.45
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 +57 -74
- package/dist/view/wrapper/area.js +51 -72
- package/dist/view/wrapper/bar-compare.js +47 -58
- package/dist/view/wrapper/bar-custom-stack.js +53 -121
- package/dist/view/wrapper/bar-group.js +55 -96
- package/dist/view/wrapper/bar-stack.js +58 -92
- 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 +600 -166
- package/dist/view/wrapper/combination.js +79 -87
- package/dist/view/wrapper/completeness-group.js +46 -98
- package/dist/view/wrapper/completeness.js +45 -97
- package/dist/view/wrapper/dashboard.js +33 -47
- package/dist/view/wrapper/funnel.js +65 -64
- package/dist/view/wrapper/heat-map.js +126 -104
- package/dist/view/wrapper/horizontal-bar-group.js +61 -78
- package/dist/view/wrapper/horizontal-bar-stack.js +60 -111
- package/dist/view/wrapper/horizontal-bar.js +45 -68
- package/dist/view/wrapper/index.js +110 -115
- package/dist/view/wrapper/line-group.js +52 -68
- 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 +45 -64
- package/dist/view/wrapper/pie.js +51 -59
- package/dist/view/wrapper/ring.js +57 -64
- package/dist/view/wrapper/scatter.js +53 -69
- 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,13 +42,15 @@ 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 => {
|
|
52
|
+
const fullData = data;
|
|
53
|
+
data = this.getVisibleLegendData(data, 'group_name');
|
|
66
54
|
const {
|
|
67
55
|
chart,
|
|
68
56
|
globalTheme,
|
|
@@ -93,17 +81,17 @@ class BarGroup extends _chartComponent.default {
|
|
|
93
81
|
y_axis_min,
|
|
94
82
|
y_axis_auto_range
|
|
95
83
|
} = chart.config;
|
|
96
|
-
const theme =
|
|
84
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
97
85
|
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) ===
|
|
99
|
-
useSingleSelectColumnColor ? this.setSingleSelectColorMap(
|
|
86
|
+
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;
|
|
87
|
+
useSingleSelectColumnColor ? this.setSingleSelectColorMap(fullData) : this.setColorMap(fullData, chartColorTheme, 'group_name', columnGroupbyColumn, chart); // use single select column color
|
|
100
88
|
|
|
101
89
|
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
90
|
|
|
103
91
|
// 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 =>
|
|
92
|
+
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
93
|
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 =
|
|
94
|
+
const sortedData = BaseUtils.sortDataByGroupName(cloneDeep(data), 'group_name', columnGroupbyColumn, chart);
|
|
107
95
|
|
|
108
96
|
// X axis
|
|
109
97
|
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 +116,12 @@ class BarGroup extends _chartComponent.default {
|
|
|
128
116
|
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
117
|
var _this$colorMap$colorK;
|
|
130
118
|
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 => {
|
|
119
|
+
return (_this$colorMap$colorK = this.colorMap[colorKey]) !== null && _this$colorMap$colorK !== void 0 ? _this$colorMap$colorK : CHART_STYLE_COLORS[0];
|
|
120
|
+
}).attr('data-value', d => d.value).attr('data-groupName', d => d.name);
|
|
121
|
+
rectSelection.nodes().forEach(rect => {
|
|
156
122
|
const parentNode = rect.parentNode;
|
|
157
123
|
this.addClipPath({
|
|
158
|
-
rect
|
|
159
|
-
parentNode,
|
|
160
|
-
rectId: rect.getAttribute('data-slugid'),
|
|
161
|
-
borderRadiusVal: Number.isFinite(groupBorderRadius) ? groupBorderRadius : undefined
|
|
124
|
+
rect
|
|
162
125
|
});
|
|
163
126
|
if (y_axis_show_value) {
|
|
164
127
|
this.addLabelToRectTop({
|
|
@@ -168,7 +131,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
168
131
|
y: Number(rect.getAttribute('y')),
|
|
169
132
|
theme,
|
|
170
133
|
label_font_size,
|
|
171
|
-
text:
|
|
134
|
+
text: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(rect.dataset.value), y_axis_summary_method)
|
|
172
135
|
});
|
|
173
136
|
}
|
|
174
137
|
});
|
|
@@ -183,6 +146,9 @@ class BarGroup extends _chartComponent.default {
|
|
|
183
146
|
}).on('mouseleave', event => {
|
|
184
147
|
this.hiddenTooltip();
|
|
185
148
|
this.handleAcitveAndInActiveState('active', event);
|
|
149
|
+
}).call(g => {
|
|
150
|
+
this.animateRectGrowInY(g);
|
|
151
|
+
this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
186
152
|
});
|
|
187
153
|
if (display_goal_line && goal_label && goal_value) {
|
|
188
154
|
this.setDispalyGoalLine(goal_label, goal_value, insertPadding, y);
|
|
@@ -191,7 +157,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
191
157
|
legendName: 'group_name',
|
|
192
158
|
theme,
|
|
193
159
|
legendPosition: 'top-right',
|
|
194
|
-
data,
|
|
160
|
+
data: fullData,
|
|
195
161
|
groupColumn: this.props.columnGroupbyColumn,
|
|
196
162
|
chart
|
|
197
163
|
});
|
|
@@ -205,7 +171,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
205
171
|
const {
|
|
206
172
|
y_axis_summary_method
|
|
207
173
|
} = chart.config;
|
|
208
|
-
const isGroupByDate = [
|
|
174
|
+
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
175
|
const {
|
|
210
176
|
offsetX,
|
|
211
177
|
offsetY
|
|
@@ -213,14 +179,14 @@ class BarGroup extends _chartComponent.default {
|
|
|
213
179
|
const curGroup = event.target.parentNode;
|
|
214
180
|
let [curGroupName, data] = curGroup.__data__;
|
|
215
181
|
const newTooltipData = {
|
|
216
|
-
title:
|
|
182
|
+
title: isEmpty(curGroupName) ? intl.get(EMPTY_NAME) : curGroupName,
|
|
217
183
|
items: data.map(item => {
|
|
218
184
|
const rawGroupName = item.group_name;
|
|
219
|
-
const groupName = rawGroupName
|
|
185
|
+
const groupName = isEmpty(rawGroupName) ? intl.get(EMPTY_NAME) : isGroupByDate ? dayjs(rawGroupName).format('YYYY-MM-DD') : rawGroupName;
|
|
220
186
|
return {
|
|
221
187
|
color: this.colorMap[groupName],
|
|
222
188
|
name: groupName,
|
|
223
|
-
value:
|
|
189
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(item.value), y_axis_summary_method)
|
|
224
190
|
};
|
|
225
191
|
})
|
|
226
192
|
};
|
|
@@ -266,12 +232,11 @@ class BarGroup extends _chartComponent.default {
|
|
|
266
232
|
componentDidMount() {
|
|
267
233
|
this.createChart();
|
|
268
234
|
this.drawChart();
|
|
269
|
-
|
|
270
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
235
|
+
super.componentDidMount();
|
|
271
236
|
}
|
|
272
237
|
componentDidUpdate(prevProps) {
|
|
273
238
|
super.componentDidUpdate(prevProps);
|
|
274
|
-
if (
|
|
239
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
275
240
|
this.destroyChart();
|
|
276
241
|
this.createChart();
|
|
277
242
|
this.drawChart();
|
|
@@ -279,23 +244,17 @@ class BarGroup extends _chartComponent.default {
|
|
|
279
244
|
}
|
|
280
245
|
componentWillUnmount() {
|
|
281
246
|
this.destroyChart();
|
|
282
|
-
|
|
247
|
+
super.componentWillUnmount();
|
|
283
248
|
}
|
|
284
249
|
render() {
|
|
285
|
-
const {
|
|
286
|
-
chart
|
|
287
|
-
} = this.props;
|
|
288
250
|
const {
|
|
289
251
|
tooltipData,
|
|
290
252
|
toolTipPosition
|
|
291
253
|
} = this.state;
|
|
292
|
-
return /*#__PURE__*/
|
|
254
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
293
255
|
ref: ref => this.container = ref,
|
|
294
|
-
className:
|
|
295
|
-
|
|
296
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
297
|
-
})
|
|
298
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
256
|
+
className: "sea-chart-container"
|
|
257
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
299
258
|
tooltipData: tooltipData,
|
|
300
259
|
toolTipPosition: toolTipPosition,
|
|
301
260
|
chart: this.chart
|
|
@@ -303,16 +262,16 @@ class BarGroup extends _chartComponent.default {
|
|
|
303
262
|
}
|
|
304
263
|
}
|
|
305
264
|
BarGroup.propTypes = {
|
|
306
|
-
canvasStyle:
|
|
307
|
-
chart:
|
|
308
|
-
groupbyColumn:
|
|
309
|
-
columnGroupbyColumn:
|
|
310
|
-
summaryColumn:
|
|
311
|
-
result:
|
|
312
|
-
tables:
|
|
313
|
-
globalTheme:
|
|
314
|
-
chartColorTheme:
|
|
315
|
-
toggleRecords:
|
|
316
|
-
customRender:
|
|
265
|
+
canvasStyle: PropTypes.object,
|
|
266
|
+
chart: PropTypes.object,
|
|
267
|
+
groupbyColumn: PropTypes.object,
|
|
268
|
+
columnGroupbyColumn: PropTypes.object,
|
|
269
|
+
summaryColumn: PropTypes.object,
|
|
270
|
+
result: PropTypes.array,
|
|
271
|
+
tables: PropTypes.array,
|
|
272
|
+
globalTheme: PropTypes.string,
|
|
273
|
+
chartColorTheme: PropTypes.string,
|
|
274
|
+
toggleRecords: PropTypes.func,
|
|
275
|
+
customRender: PropTypes.func
|
|
317
276
|
};
|
|
318
|
-
|
|
277
|
+
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,14 +42,16 @@ 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 => {
|
|
53
|
+
const fullData = data;
|
|
54
|
+
data = this.getVisibleLegendData(data, 'group_name');
|
|
67
55
|
const {
|
|
68
56
|
chart,
|
|
69
57
|
globalTheme,
|
|
@@ -88,18 +76,18 @@ class BarStack extends _chartComponent.default {
|
|
|
88
76
|
y_axis_min,
|
|
89
77
|
y_axis_auto_range
|
|
90
78
|
} = chart.config;
|
|
91
|
-
const theme =
|
|
79
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
92
80
|
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) ===
|
|
81
|
+
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
82
|
// use single select column color
|
|
95
|
-
useSingleSelectColumnColor ? this.setSingleSelectColorMap(
|
|
83
|
+
useSingleSelectColumnColor ? this.setSingleSelectColorMap(fullData) : this.setColorMap(fullData, chartColorTheme, 'group_name', columnGroupbyColumn, chart);
|
|
96
84
|
const {
|
|
97
85
|
width: chartWidth,
|
|
98
86
|
height: chartHeight,
|
|
99
87
|
insertPadding,
|
|
100
88
|
marginTop
|
|
101
89
|
} = this.chartBoundingClientRect;
|
|
102
|
-
const sortedData =
|
|
90
|
+
const sortedData = BaseUtils.sortDataByGroupName(cloneDeep(data), 'group_name', columnGroupbyColumn, chart).reverse();
|
|
103
91
|
const series = d3.stack().keys(d3.union(sortedData.map(d => d.group_name))).value((_ref, key) => {
|
|
104
92
|
var _group$get;
|
|
105
93
|
let [_, group] = _ref;
|
|
@@ -109,7 +97,7 @@ class BarStack extends _chartComponent.default {
|
|
|
109
97
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min, y_axis_max]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
110
98
|
|
|
111
99
|
// 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 =>
|
|
100
|
+
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
101
|
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
102
|
|
|
115
103
|
// X axis
|
|
@@ -131,8 +119,8 @@ class BarStack extends _chartComponent.default {
|
|
|
131
119
|
return data;
|
|
132
120
|
}).join('rect').attr('opacity', 1).attr('x', d => x(d.data[0])).attr('y', d => y(d[1])).attr('height', d => {
|
|
133
121
|
const height = y(d[0]) - y(d[1]);
|
|
134
|
-
return
|
|
135
|
-
}).attr('width', x.bandwidth()).attr('fill', d => this.colorMap[d.key] ||
|
|
122
|
+
return isNaN(height) ? 0 : height;
|
|
123
|
+
}).attr('width', x.bandwidth()).attr('fill', d => this.colorMap[d.key] || CHART_STYLE_COLORS[0]).attr('data-value', d => {
|
|
136
124
|
const {
|
|
137
125
|
data,
|
|
138
126
|
key
|
|
@@ -153,7 +141,6 @@ class BarStack extends _chartComponent.default {
|
|
|
153
141
|
if (Number(firstEl.getAttribute('height')) === 0) {
|
|
154
142
|
firstEl = reverseGroup.slice(1).find(item => Number(item.getAttribute('height')) !== 0);
|
|
155
143
|
}
|
|
156
|
-
// Add mask rect
|
|
157
144
|
firstEl && this.addMaskRect((_firstEl = firstEl) === null || _firstEl === void 0 ? void 0 : _firstEl.parentNode, firstEl, x.bandwidth());
|
|
158
145
|
});
|
|
159
146
|
const [topG] = g._parents.slice(-1);
|
|
@@ -167,8 +154,11 @@ class BarStack extends _chartComponent.default {
|
|
|
167
154
|
if (y_axis_show_value) {
|
|
168
155
|
this.handleLabelToRectCenter(g, x.bandwidth());
|
|
169
156
|
}
|
|
157
|
+
this.animateFadeIn(this.contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
158
|
+
this.animateStackGrowInY(g);
|
|
170
159
|
}).on('click', (event, data) => {
|
|
171
|
-
|
|
160
|
+
const resultItem = data.data[1].get(data.key);
|
|
161
|
+
this.toggleRecords(resultItem);
|
|
172
162
|
}).on('mouseover', event => {
|
|
173
163
|
this.showTooltip(event);
|
|
174
164
|
this.handleAcitveAndInActiveState('inActive', event);
|
|
@@ -185,7 +175,7 @@ class BarStack extends _chartComponent.default {
|
|
|
185
175
|
legendName: 'group_name',
|
|
186
176
|
theme,
|
|
187
177
|
legendPosition: 'top-right',
|
|
188
|
-
data,
|
|
178
|
+
data: fullData,
|
|
189
179
|
groupColumn: this.props.columnGroupbyColumn,
|
|
190
180
|
chart
|
|
191
181
|
});
|
|
@@ -210,18 +200,18 @@ class BarStack extends _chartComponent.default {
|
|
|
210
200
|
} = this.props;
|
|
211
201
|
const {
|
|
212
202
|
y_axis_summary_method
|
|
213
|
-
} = chart;
|
|
203
|
+
} = chart.config;
|
|
214
204
|
const offsetX = d3.pointer(event)[0];
|
|
215
205
|
const offsetY = d3.pointer(event)[1];
|
|
216
206
|
const curRect = event.currentTarget;
|
|
217
207
|
const curGroup = curRect.parentNode;
|
|
218
208
|
const curGroupName = event.currentTarget.getAttribute('data-groupName');
|
|
219
209
|
const newTooltipData = {
|
|
220
|
-
title: !curGroupName && typeof curGroupName !== 'number' ?
|
|
210
|
+
title: !curGroupName && typeof curGroupName !== 'number' ? intl.get(EMPTY_NAME) : curGroupName,
|
|
221
211
|
items: [{
|
|
222
212
|
color: this.colorMap[curGroup.getAttribute('data-key')],
|
|
223
213
|
name: curGroup.getAttribute('data-key'),
|
|
224
|
-
value:
|
|
214
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(curRect.getAttribute('data-value')), y_axis_summary_method)
|
|
225
215
|
}]
|
|
226
216
|
};
|
|
227
217
|
this.setState({
|
|
@@ -255,24 +245,7 @@ class BarStack extends _chartComponent.default {
|
|
|
255
245
|
this.setActiveAndInActiveState(state, allGroup, curGroupName);
|
|
256
246
|
};
|
|
257
247
|
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();
|
|
248
|
+
return this.addRoundedClip(rect, 'y', xWidth);
|
|
276
249
|
};
|
|
277
250
|
this.addLabelByEachStack = (data, topG, rect, x) => {
|
|
278
251
|
const {
|
|
@@ -284,7 +257,7 @@ class BarStack extends _chartComponent.default {
|
|
|
284
257
|
label_font_size,
|
|
285
258
|
y_axis_summary_method
|
|
286
259
|
} = chart.config;
|
|
287
|
-
const theme =
|
|
260
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
288
261
|
const groupData = d3.group(data, d => d.name);
|
|
289
262
|
const group_name = rect.getAttribute('data-groupName');
|
|
290
263
|
let stackSum = 0;
|
|
@@ -296,7 +269,7 @@ class BarStack extends _chartComponent.default {
|
|
|
296
269
|
y: Number(rect.getAttribute('y')),
|
|
297
270
|
theme,
|
|
298
271
|
label_font_size,
|
|
299
|
-
text:
|
|
272
|
+
text: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(stackSum), y_axis_summary_method)
|
|
300
273
|
});
|
|
301
274
|
};
|
|
302
275
|
this.handleLabelToRectCenter = (g, xWidth) => {
|
|
@@ -309,7 +282,7 @@ class BarStack extends _chartComponent.default {
|
|
|
309
282
|
label_font_size,
|
|
310
283
|
y_axis_summary_method
|
|
311
284
|
} = chart.config;
|
|
312
|
-
const theme =
|
|
285
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
313
286
|
g._parents.forEach(group => {
|
|
314
287
|
Array.from(group.children).forEach(rect => {
|
|
315
288
|
// The height is 0, and the label is not displayed.
|
|
@@ -322,7 +295,7 @@ class BarStack extends _chartComponent.default {
|
|
|
322
295
|
yheight: Number(rect.getAttribute('height')),
|
|
323
296
|
theme,
|
|
324
297
|
label_font_size,
|
|
325
|
-
text:
|
|
298
|
+
text: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(rect.getAttribute('data-value')), y_axis_summary_method)
|
|
326
299
|
});
|
|
327
300
|
});
|
|
328
301
|
});
|
|
@@ -336,12 +309,11 @@ class BarStack extends _chartComponent.default {
|
|
|
336
309
|
componentDidMount() {
|
|
337
310
|
this.createChart();
|
|
338
311
|
this.drawChart();
|
|
339
|
-
|
|
340
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
312
|
+
super.componentDidMount();
|
|
341
313
|
}
|
|
342
314
|
componentDidUpdate(prevProps) {
|
|
343
315
|
super.componentDidUpdate(prevProps);
|
|
344
|
-
if (
|
|
316
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
345
317
|
this.destroyChart();
|
|
346
318
|
this.createChart();
|
|
347
319
|
this.drawChart();
|
|
@@ -349,23 +321,17 @@ class BarStack extends _chartComponent.default {
|
|
|
349
321
|
}
|
|
350
322
|
componentWillUnmount() {
|
|
351
323
|
this.destroyChart();
|
|
352
|
-
|
|
324
|
+
super.componentWillUnmount();
|
|
353
325
|
}
|
|
354
326
|
render() {
|
|
355
|
-
const {
|
|
356
|
-
chart
|
|
357
|
-
} = this.props;
|
|
358
327
|
const {
|
|
359
328
|
tooltipData,
|
|
360
329
|
toolTipPosition
|
|
361
330
|
} = this.state;
|
|
362
|
-
return /*#__PURE__*/
|
|
331
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
363
332
|
ref: ref => this.container = ref,
|
|
364
|
-
className:
|
|
365
|
-
|
|
366
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
367
|
-
})
|
|
368
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
333
|
+
className: "sea-chart-container"
|
|
334
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
369
335
|
tooltipData: tooltipData,
|
|
370
336
|
toolTipPosition: toolTipPosition,
|
|
371
337
|
chart: this.chart
|
|
@@ -373,16 +339,16 @@ class BarStack extends _chartComponent.default {
|
|
|
373
339
|
}
|
|
374
340
|
}
|
|
375
341
|
BarStack.propTypes = {
|
|
376
|
-
canvasStyle:
|
|
377
|
-
chart:
|
|
378
|
-
groupbyColumn:
|
|
379
|
-
columnGroupbyColumn:
|
|
380
|
-
summaryColumn:
|
|
381
|
-
result:
|
|
382
|
-
tables:
|
|
383
|
-
globalTheme:
|
|
384
|
-
chartColorTheme:
|
|
385
|
-
toggleRecords:
|
|
386
|
-
customRender:
|
|
342
|
+
canvasStyle: PropTypes.object,
|
|
343
|
+
chart: PropTypes.object,
|
|
344
|
+
groupbyColumn: PropTypes.object,
|
|
345
|
+
columnGroupbyColumn: PropTypes.object,
|
|
346
|
+
summaryColumn: PropTypes.object,
|
|
347
|
+
result: PropTypes.array,
|
|
348
|
+
tables: PropTypes.array,
|
|
349
|
+
globalTheme: PropTypes.string,
|
|
350
|
+
chartColorTheme: PropTypes.string,
|
|
351
|
+
toggleRecords: PropTypes.func,
|
|
352
|
+
customRender: PropTypes.func
|
|
387
353
|
};
|
|
388
|
-
|
|
354
|
+
export default BarStack;
|