sea-chart 2.0.37 → 2.0.38
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 +20 -69
- package/dist/assets/css/sea-chart-d3-tooltip.css +0 -1
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +5 -12
- 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 +30 -38
- 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 +12 -19
- package/dist/components/color-popover/color-rules/color-rule.js +26 -34
- package/dist/components/color-popover/color-rules/index.js +7 -15
- 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 +9 -17
- package/dist/components/color-popover/color-rules-popover.js +31 -37
- package/dist/components/color-popover/color-selector-popover.js +12 -20
- package/dist/components/color-setting/color-group-selector.js +13 -21
- package/dist/components/common-add-tool/index.js +8 -15
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +13 -20
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +18 -26
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +41 -48
- 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 +12 -23
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +11 -24
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +13 -16
- package/dist/components/popover/hide-column-popover/hide-column-popover.css +5 -1
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +28 -38
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +58 -69
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +17 -24
- package/dist/components/row-card/row-card-header.js +15 -22
- package/dist/components/row-card/row-card-item.js +35 -43
- package/dist/components/row-card/row-card.js +17 -25
- package/dist/components/statistic-record-dialog/index.js +61 -68
- package/dist/components/tooltip/index.js +39 -28
- package/dist/components/types-dialog/index.js +62 -70
- 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 +142 -271
- 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 +13 -20
- package/dist/editor/index.js +13 -16
- 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 +2 -7
- package/dist/locale/lang/en.js +2 -7
- package/dist/locale/lang/es.js +2 -7
- package/dist/locale/lang/fr.js +2 -7
- package/dist/locale/lang/pt.js +2 -7
- package/dist/locale/lang/ru.js +2 -7
- package/dist/locale/lang/zh_CN.js +2 -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 +4 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +15 -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 +11 -18
- package/dist/model/horizontal-group-bar.js +10 -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 +14 -17
- 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 +11 -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 +14 -17
- 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 +66 -73
- 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 +51 -59
- package/dist/settings/basic-number-card/data-settings.js +50 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +19 -27
- package/dist/settings/combination-settings/data-settings.js +55 -64
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +67 -75
- 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 +44 -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 +22 -30
- 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 +57 -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 +27 -35
- 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 +65 -73
- package/dist/settings/table-element-settings/components/data-filter.js +49 -58
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.css +1 -31
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +113 -120
- 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 +44 -52
- 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 +19 -27
- package/dist/settings/widgets/basic-summary/index.js +59 -66
- 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 +27 -34
- package/dist/settings/widgets/data-filter/index.js +59 -59
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +26 -34
- 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 +52 -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 +25 -33
- 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 +75 -82
- package/dist/settings/widgets/switch/index.js +9 -16
- 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 +65 -72
- package/dist/utils/cell-format-utils.js +25 -33
- package/dist/utils/cell-value-utils.js +4 -11
- package/dist/utils/chart-utils/base-utils.js +467 -367
- package/dist/utils/chart-utils/index.js +29 -40
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +78 -85
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +20 -21
- 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 +21 -28
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +33 -40
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +28 -26
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +94 -97
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -25
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +50 -36
- package/dist/utils/chart-utils/sql-statistics-utils.js +385 -388
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +19 -31
- package/dist/utils/collaborator.js +6 -15
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +88 -102
- package/dist/utils/common-utils.js +28 -53
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +7 -11
- package/dist/utils/date-translate.js +12 -20
- 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 +73 -219
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +2 -8
- package/dist/utils/options-utils.js +10 -18
- package/dist/utils/row-record-utils.js +251 -183
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +106 -112
- package/dist/utils/sql/column-2-sql-column.js +162 -172
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +50 -45
- package/dist/view/index.css +2 -8
- package/dist/view/index.js +102 -103
- package/dist/view/title/index.js +16 -24
- package/dist/view/wrapper/area-group.js +57 -57
- package/dist/view/wrapper/area.js +43 -51
- package/dist/view/wrapper/bar-compare.js +56 -48
- package/dist/view/wrapper/bar-custom-stack.js +73 -55
- package/dist/view/wrapper/bar-group.js +94 -73
- package/dist/view/wrapper/bar-stack.js +49 -57
- package/dist/view/wrapper/bar.js +40 -48
- package/dist/view/wrapper/basic-number-card.js +50 -34
- package/dist/view/wrapper/chart-component.js +164 -569
- package/dist/view/wrapper/combination.js +55 -63
- package/dist/view/wrapper/completeness-group.js +140 -93
- package/dist/view/wrapper/completeness.js +36 -44
- package/dist/view/wrapper/dashboard.js +104 -59
- package/dist/view/wrapper/funnel.js +40 -43
- package/dist/view/wrapper/heat-map.js +62 -70
- package/dist/view/wrapper/horizontal-bar-group.js +70 -58
- package/dist/view/wrapper/horizontal-bar-stack.js +48 -56
- package/dist/view/wrapper/horizontal-bar.js +41 -49
- package/dist/view/wrapper/index.js +107 -115
- package/dist/view/wrapper/line-group.js +49 -52
- package/dist/view/wrapper/line.js +42 -50
- package/dist/view/wrapper/map-bubble.js +40 -48
- package/dist/view/wrapper/map-world-bubble.js +40 -47
- package/dist/view/wrapper/map-world.js +42 -49
- package/dist/view/wrapper/map.js +42 -50
- package/dist/view/wrapper/mirror.js +41 -49
- package/dist/view/wrapper/pie.js +45 -53
- package/dist/view/wrapper/ring.js +50 -58
- package/dist/view/wrapper/scatter.js +50 -56
- package/dist/view/wrapper/table/index.js +14 -22
- 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 +53 -61
- package/dist/view/wrapper/table/pivot-table-display-name.js +82 -90
- package/dist/view/wrapper/table/two-dimension-table.js +85 -92
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +90 -99
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +23 -32
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/record.js +13 -20
- package/dist/view/wrapper/table-element/components/records-body.js +9 -17
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -16
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +25 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +8 -13
- package/dist/view/wrapper/table-element/components/utils.js +6 -16
- 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 +30 -43
- package/dist/view/wrapper/treemap.js +38 -46
- package/dist/view/wrapper/trend.js +80 -65
- package/package.json +15 -12
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _constants = require("../../constants");
|
|
16
|
-
var _utils = require("../../utils");
|
|
17
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
18
|
-
var _colorRules = require("../../constants/color-rules");
|
|
19
|
-
var _columnUtils = require("../../utils/column-utils");
|
|
20
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
21
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
22
|
-
class HorizontalBarStack extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { debounce, cloneDeep } from 'lodash-es';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import * as d3 from 'd3';
|
|
6
|
+
import { CellType } from 'dtable-utils';
|
|
7
|
+
import { CHART_TYPE, EMPTY_NAME, CHART_THEME_COLOR, CHART_STYLE_COLORS } from '../../constants';
|
|
8
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
9
|
+
import intl from '../../intl';
|
|
10
|
+
import { SUPPORT_SINGLE_SELECT_THEMES_OPTIONS } from '../../constants/color-rules';
|
|
11
|
+
import { sortDataByGroupSum } from '../../utils/column-utils';
|
|
12
|
+
import ToolTip from '../../components/tooltip';
|
|
13
|
+
import ChartComponent from './chart-component';
|
|
14
|
+
class HorizontalBarStack extends ChartComponent {
|
|
23
15
|
constructor(props) {
|
|
24
16
|
super(props);
|
|
25
|
-
this.handleResize =
|
|
17
|
+
this.handleResize = debounce(() => {
|
|
26
18
|
this.destroyChart();
|
|
27
19
|
this.createChart();
|
|
28
20
|
this.drawChart();
|
|
@@ -49,17 +41,17 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
49
41
|
customRender,
|
|
50
42
|
chart
|
|
51
43
|
} = this.props;
|
|
52
|
-
data =
|
|
44
|
+
data = BaseUtils.formatEmptyName(data, chart.config.column_groupby_column_key, intl.get('Empty'));
|
|
53
45
|
if (!Array.isArray(data)) return;
|
|
54
46
|
const {
|
|
55
47
|
sort_type,
|
|
56
48
|
type
|
|
57
49
|
} = chart.config;
|
|
58
|
-
if (type ===
|
|
59
|
-
data =
|
|
50
|
+
if (type === CHART_TYPE.STACKED_HORIZONTAL_BAR && sort_type) {
|
|
51
|
+
data = sortDataByGroupSum(data, sort_type);
|
|
60
52
|
}
|
|
61
53
|
this.draw(data);
|
|
62
|
-
|
|
54
|
+
isFunction(customRender) && customRender(this.chart);
|
|
63
55
|
this.renderHorizontalLabel(this.props.chart, this.props.tables, this.container);
|
|
64
56
|
};
|
|
65
57
|
this.draw = data => {
|
|
@@ -72,7 +64,7 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
72
64
|
summaryColumn,
|
|
73
65
|
horizontal_axis_summary_method
|
|
74
66
|
} = this.props;
|
|
75
|
-
const theme =
|
|
67
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
76
68
|
const {
|
|
77
69
|
display_data,
|
|
78
70
|
label_font_size,
|
|
@@ -89,13 +81,13 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
89
81
|
insertPadding
|
|
90
82
|
} = this.chartBoundingClientRect;
|
|
91
83
|
const groupByColumn = this.getColumn(tables, table_id, column_groupby_column_key);
|
|
92
|
-
const useSingleSelectColumnColor = (groupByColumn === null || groupByColumn === void 0 ? void 0 : groupByColumn.type) ===
|
|
84
|
+
const useSingleSelectColumnColor = (groupByColumn === null || groupByColumn === void 0 ? void 0 : groupByColumn.type) === CellType.SINGLE_SELECT && color_theme === SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
93
85
|
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme, 'group_name', columnGroupbyColumn, chart);
|
|
94
|
-
const sortedData =
|
|
86
|
+
const sortedData = BaseUtils.sortDataByGroupName(cloneDeep(data), 'group_name', columnGroupbyColumn, chart);
|
|
95
87
|
const series = d3.stack().keys(d3.union(sortedData.map(d => d.group_name))).value((_ref, key) => {
|
|
96
88
|
var _group$get;
|
|
97
89
|
let [_, group] = _ref;
|
|
98
|
-
return ((_group$get = group.get(
|
|
90
|
+
return ((_group$get = group.get(key)) === null || _group$get === void 0 ? void 0 : _group$get.value) || 0;
|
|
99
91
|
})(d3.index(sortedData, d => d.name, d => d.group_name));
|
|
100
92
|
const newSeries = this.handleSeries(series, sortedData);
|
|
101
93
|
const y = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
@@ -110,14 +102,14 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
110
102
|
const {
|
|
111
103
|
width: axisWidth
|
|
112
104
|
} = g.node().getBoundingClientRect();
|
|
113
|
-
g.attr('transform',
|
|
105
|
+
g.attr('transform', `translate(${axisWidth}, 0)`).attr('data-axisWidth', axisWidth);
|
|
114
106
|
this.checkTickOverlap(g, 'yAxis');
|
|
115
107
|
});
|
|
116
108
|
|
|
117
109
|
// X axis
|
|
118
110
|
const niceEnd = d3.nice(0, d3.max(newSeries, d => d[1].sumValue), 5)[1];
|
|
119
111
|
const x = d3.scaleLinear().domain(horizontal_axis_auto_range ? [0, niceEnd] : [horizontal_axis_min || 0, horizontal_axis_max || niceEnd]).range([Number(yAxis.node().getAttribute('data-axisWidth')), chartWidth - insertPadding]);
|
|
120
|
-
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform',
|
|
112
|
+
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', `translate(0, ${chartHeight - insertPadding})`).call(d3.axisBottom(x).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(summaryColumn, d, horizontal_axis_summary_method))).call(g => {
|
|
121
113
|
g.selectAll('.domain').remove();
|
|
122
114
|
g.selectAll('.tick line').node() && g.selectAll('.tick line').node().remove(); // delete the first line
|
|
123
115
|
g.selectAll('.tick line').attr('y2', -(chartHeight - insertPadding * 2)).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
|
|
@@ -126,7 +118,7 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
126
118
|
});
|
|
127
119
|
|
|
128
120
|
// Rect group
|
|
129
|
-
const contentWrapper = this.chart.append('g').attr('class', 'content-wrapper').attr('transform',
|
|
121
|
+
const contentWrapper = this.chart.append('g').attr('class', 'content-wrapper').attr('transform', `translate(${Number(yAxis.node().getAttribute('data-axisWidth'))}, 0)`);
|
|
130
122
|
contentWrapper.selectAll().data(newSeries).join('g')
|
|
131
123
|
// rect item
|
|
132
124
|
.selectAll().data(_ref2 => {
|
|
@@ -136,7 +128,7 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
136
128
|
}).join('rect').attr('opacity', 1).attr('x', (d, index) => {
|
|
137
129
|
return x(d[0]) - Number(yAxis.node().getAttribute('data-axisWidth'));
|
|
138
130
|
}).attr('y', (d, index) => y(d.groupKey)).attr('width', d => x(d[1]) - x(d[0])).attr('height', y.bandwidth()).attr('fill', d => {
|
|
139
|
-
return this.colorMap[d.data.group_name] ||
|
|
131
|
+
return this.colorMap[d.data.group_name] || CHART_STYLE_COLORS[0];
|
|
140
132
|
}).attr('data-value', d => d.data.value).attr('data-slugid', d => d.data.slugId).attr('data-groupName', d => d.data.name).attr('data-stackKey', d => d.key).call(g => {
|
|
141
133
|
// add rect borderRadius
|
|
142
134
|
const allGroup = this.getAllGroup(contentWrapper);
|
|
@@ -158,7 +150,7 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
158
150
|
yheight: Number(rect.getAttribute('height')),
|
|
159
151
|
theme,
|
|
160
152
|
label_font_size,
|
|
161
|
-
text:
|
|
153
|
+
text: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(rect.getAttribute('data-value')), horizontal_axis_summary_method)
|
|
162
154
|
});
|
|
163
155
|
});
|
|
164
156
|
});
|
|
@@ -210,11 +202,11 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
210
202
|
const stackName = event.currentTarget.getAttribute('data-stackKey');
|
|
211
203
|
const stackValue = event.currentTarget.getAttribute('data-value');
|
|
212
204
|
const newTooltipData = {
|
|
213
|
-
title: !title && typeof title !== 'number' ?
|
|
205
|
+
title: !title && typeof title !== 'number' ? intl.get(EMPTY_NAME) : title,
|
|
214
206
|
items: [{
|
|
215
|
-
color: this.colorMap[stackName] ||
|
|
207
|
+
color: this.colorMap[stackName] || CHART_STYLE_COLORS[0],
|
|
216
208
|
name: stackName,
|
|
217
|
-
value:
|
|
209
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(stackValue), horizontal_axis_summary_method)
|
|
218
210
|
}]
|
|
219
211
|
};
|
|
220
212
|
this.setState({
|
|
@@ -308,7 +300,7 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
308
300
|
}).on('mouseleave', event => {
|
|
309
301
|
this.hiddenTooltip();
|
|
310
302
|
this.handleAcitveAndInActiveState('active', event);
|
|
311
|
-
}).append('xhtml:div').attr('style',
|
|
303
|
+
}).append('xhtml:div').attr('style', `width: 100%; height: 100%; background-color: ${rect.getAttribute('fill')}; border-radius: 0px ${xWidth * borderRadius}px ${xWidth * borderRadius}px 0px`);
|
|
312
304
|
|
|
313
305
|
// Remove old rect
|
|
314
306
|
d3.select(rect).remove();
|
|
@@ -326,7 +318,7 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
326
318
|
}
|
|
327
319
|
componentDidUpdate(prevProps) {
|
|
328
320
|
super.componentDidUpdate(prevProps);
|
|
329
|
-
if (
|
|
321
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
330
322
|
this.destroyChart();
|
|
331
323
|
this.createChart();
|
|
332
324
|
this.drawChart();
|
|
@@ -345,13 +337,13 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
345
337
|
tooltipData,
|
|
346
338
|
toolTipPosition
|
|
347
339
|
} = this.state;
|
|
348
|
-
return /*#__PURE__*/
|
|
340
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
349
341
|
ref: ref => this.container = ref,
|
|
350
|
-
className: (
|
|
342
|
+
className: classNames('sea-chart-container', {
|
|
351
343
|
'show-x-axis-label': this.isShowHorizontalAxisLabel(chart),
|
|
352
344
|
'show-y-axis-label': this.isShowVerticalAxisLabel(chart)
|
|
353
345
|
})
|
|
354
|
-
}, /*#__PURE__*/
|
|
346
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
355
347
|
tooltipData: tooltipData,
|
|
356
348
|
toolTipPosition: toolTipPosition,
|
|
357
349
|
chart: this.chart
|
|
@@ -359,16 +351,16 @@ class HorizontalBarStack extends _chartComponent.default {
|
|
|
359
351
|
}
|
|
360
352
|
}
|
|
361
353
|
HorizontalBarStack.propTypes = {
|
|
362
|
-
canvasStyle:
|
|
363
|
-
chart:
|
|
364
|
-
groupbyColumn:
|
|
365
|
-
columnGroupbyColumn:
|
|
366
|
-
summaryColumn:
|
|
367
|
-
result:
|
|
368
|
-
tables:
|
|
369
|
-
globalTheme:
|
|
370
|
-
chartColorTheme:
|
|
371
|
-
toggleRecords:
|
|
372
|
-
customRender:
|
|
354
|
+
canvasStyle: PropTypes.object,
|
|
355
|
+
chart: PropTypes.object,
|
|
356
|
+
groupbyColumn: PropTypes.object,
|
|
357
|
+
columnGroupbyColumn: PropTypes.object,
|
|
358
|
+
summaryColumn: PropTypes.object,
|
|
359
|
+
result: PropTypes.array,
|
|
360
|
+
tables: PropTypes.array,
|
|
361
|
+
globalTheme: PropTypes.string,
|
|
362
|
+
chartColorTheme: PropTypes.string,
|
|
363
|
+
toggleRecords: PropTypes.func,
|
|
364
|
+
customRender: PropTypes.func
|
|
373
365
|
};
|
|
374
|
-
|
|
366
|
+
export default HorizontalBarStack;
|
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
var _utils = require("../../utils");
|
|
16
|
-
var _colorUtils = require("../../utils/color-utils");
|
|
17
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
18
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
19
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
20
|
-
class HorizontalBar extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { debounce } from 'lodash-es';
|
|
4
|
+
import * as d3 from 'd3';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { TYPE_COLOR_USING, CHART_STYLE_COLORS, CHART_THEME_COLOR } from '../../constants';
|
|
7
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
8
|
+
import { getLabelColor, getConvertedColorRules } from '../../utils/color-utils';
|
|
9
|
+
import intl from '../../intl';
|
|
10
|
+
import ToolTip from '../../components/tooltip';
|
|
11
|
+
import ChartComponent from './chart-component';
|
|
12
|
+
class HorizontalBar extends ChartComponent {
|
|
21
13
|
constructor(props) {
|
|
22
14
|
super(props);
|
|
23
15
|
this.handleResize = () => {
|
|
@@ -48,10 +40,10 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
48
40
|
result: data,
|
|
49
41
|
customRender
|
|
50
42
|
} = this.props;
|
|
51
|
-
data =
|
|
43
|
+
data = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
52
44
|
if (!Array.isArray(data)) return;
|
|
53
45
|
this.draw(data);
|
|
54
|
-
|
|
46
|
+
isFunction(customRender) && customRender(this.chart);
|
|
55
47
|
this.renderHorizontalLabel(this.props.chart, this.props.tables, this.container);
|
|
56
48
|
};
|
|
57
49
|
this.draw = data => {
|
|
@@ -62,7 +54,7 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
62
54
|
tables,
|
|
63
55
|
summaryColumn
|
|
64
56
|
} = this.props;
|
|
65
|
-
const theme =
|
|
57
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
66
58
|
const {
|
|
67
59
|
table_id,
|
|
68
60
|
horizontal_axis_summary_type,
|
|
@@ -83,11 +75,11 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
83
75
|
insertPadding,
|
|
84
76
|
marginRight
|
|
85
77
|
} = this.chartBoundingClientRect;
|
|
86
|
-
let chartBarColor = horizontal_axis_label_color ||
|
|
78
|
+
let chartBarColor = horizontal_axis_label_color || CHART_STYLE_COLORS[0];
|
|
87
79
|
if (chartColorTheme) {
|
|
88
|
-
chartBarColor =
|
|
80
|
+
chartBarColor = BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
|
|
89
81
|
}
|
|
90
|
-
const colorRules = color_option ===
|
|
82
|
+
const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && horizontal_axis_label_color_rules && getConvertedColorRules(horizontal_axis_label_color_rules);
|
|
91
83
|
const tooltipTitle = this.getTitle(tables, table_id, horizontal_axis_summary_type, horizontal_axis_column_key);
|
|
92
84
|
data.reverse();
|
|
93
85
|
const y = d3.scaleBand().domain(data.map(item => item.name)).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
@@ -102,23 +94,23 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
102
94
|
const {
|
|
103
95
|
width: axisWidth
|
|
104
96
|
} = g.node().getBoundingClientRect();
|
|
105
|
-
g.attr('transform',
|
|
97
|
+
g.attr('transform', `translate(${axisWidth}, 0)`).attr('data-axisWidth', axisWidth);
|
|
106
98
|
this.checkTickOverlap(g, 'yAxis');
|
|
107
99
|
});
|
|
108
100
|
const niceEnd = d3.nice(0, d3.max(data, d => d.value), 5)[1];
|
|
109
101
|
const x = d3.scaleLinear().domain(horizontal_axis_auto_range ? [0, niceEnd] : [horizontal_axis_min || 0, horizontal_axis_max || niceEnd]).range([Number(yAxis.node().getAttribute('data-axisWidth')), chartWidth - insertPadding - marginRight]);
|
|
110
102
|
|
|
111
103
|
// X axis
|
|
112
|
-
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform',
|
|
104
|
+
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', `translate(0, ${chartHeight - insertPadding})`).call(d3.axisBottom(x).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(summaryColumn, d, horizontal_axis_summary_method))).call(g => {
|
|
113
105
|
g.selectAll('.domain').remove();
|
|
114
106
|
g.selectAll('.tick line').node() && g.selectAll('.tick line').node().remove(); // delete the first line
|
|
115
107
|
g.selectAll('.tick line').attr('y2', -(chartHeight - insertPadding * 2)).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
|
|
116
108
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
117
109
|
g.selectAll('text').attr('fill', theme.textColor);
|
|
118
110
|
});
|
|
119
|
-
const contentWrapper = this.chart.append('g').attr('class', 'content-wrapper').attr('transform',
|
|
111
|
+
const contentWrapper = this.chart.append('g').attr('class', 'content-wrapper').attr('transform', `translate(${Number(yAxis.node().getAttribute('data-axisWidth'))}, 0)`);
|
|
120
112
|
contentWrapper.selectAll().data(data).join('rect').attr('opacity', 1).attr('x', 0).attr('y', d => y(d.name)).attr('width', d => x(d.value) - x(0)).attr('height', y.bandwidth()).attr('fill', d => {
|
|
121
|
-
const color =
|
|
113
|
+
const color = getLabelColor({
|
|
122
114
|
chart: chart.config,
|
|
123
115
|
colorRules,
|
|
124
116
|
value: d.value
|
|
@@ -146,7 +138,7 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
146
138
|
y: Number(rect.getAttribute('y')),
|
|
147
139
|
theme,
|
|
148
140
|
label_font_size,
|
|
149
|
-
text:
|
|
141
|
+
text: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(rect.getAttribute('value')), horizontal_axis_summary_method)
|
|
150
142
|
});
|
|
151
143
|
}
|
|
152
144
|
});
|
|
@@ -182,13 +174,13 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
182
174
|
const newTooltipData = {
|
|
183
175
|
title: title,
|
|
184
176
|
items: [{
|
|
185
|
-
color:
|
|
177
|
+
color: getLabelColor({
|
|
186
178
|
chart: chart.config,
|
|
187
179
|
colorRules,
|
|
188
180
|
value: data.value
|
|
189
181
|
}) || chartBarColor,
|
|
190
182
|
name: data.name,
|
|
191
|
-
value:
|
|
183
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(data.value), horizontal_axis_summary_method)
|
|
192
184
|
}]
|
|
193
185
|
};
|
|
194
186
|
this.setState({
|
|
@@ -228,12 +220,12 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
228
220
|
super.componentDidMount();
|
|
229
221
|
this.createChart();
|
|
230
222
|
this.drawChart();
|
|
231
|
-
this.debouncedHandleResize =
|
|
223
|
+
this.debouncedHandleResize = debounce(this.handleResize, 300);
|
|
232
224
|
window.addEventListener('resize', this.debouncedHandleResize);
|
|
233
225
|
}
|
|
234
226
|
componentDidUpdate(prevProps) {
|
|
235
227
|
super.componentDidUpdate(prevProps);
|
|
236
|
-
if (
|
|
228
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
237
229
|
this.destroyChart();
|
|
238
230
|
this.createChart();
|
|
239
231
|
this.drawChart();
|
|
@@ -252,13 +244,13 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
252
244
|
tooltipData,
|
|
253
245
|
toolTipPosition
|
|
254
246
|
} = this.state;
|
|
255
|
-
return /*#__PURE__*/
|
|
247
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
256
248
|
ref: ref => this.container = ref,
|
|
257
|
-
className: (
|
|
249
|
+
className: classNames('sea-chart-container', {
|
|
258
250
|
'show-x-axis-label': this.isShowHorizontalAxisLabel(chart),
|
|
259
251
|
'show-y-axis-label': this.isShowVerticalAxisLabel(chart)
|
|
260
252
|
})
|
|
261
|
-
}, /*#__PURE__*/
|
|
253
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
262
254
|
tooltipData: tooltipData,
|
|
263
255
|
toolTipPosition: toolTipPosition,
|
|
264
256
|
chart: this.chart
|
|
@@ -266,15 +258,15 @@ class HorizontalBar extends _chartComponent.default {
|
|
|
266
258
|
}
|
|
267
259
|
}
|
|
268
260
|
HorizontalBar.propTypes = {
|
|
269
|
-
canvasStyle:
|
|
270
|
-
chart:
|
|
271
|
-
groupbyColumn:
|
|
272
|
-
columnGroupbyColumn:
|
|
273
|
-
summaryColumn:
|
|
274
|
-
result:
|
|
275
|
-
tables:
|
|
276
|
-
globalTheme:
|
|
277
|
-
chartColorTheme:
|
|
278
|
-
toggleRecords:
|
|
261
|
+
canvasStyle: PropTypes.object,
|
|
262
|
+
chart: PropTypes.object,
|
|
263
|
+
groupbyColumn: PropTypes.object,
|
|
264
|
+
columnGroupbyColumn: PropTypes.object,
|
|
265
|
+
summaryColumn: PropTypes.object,
|
|
266
|
+
result: PropTypes.array,
|
|
267
|
+
tables: PropTypes.array,
|
|
268
|
+
globalTheme: PropTypes.string,
|
|
269
|
+
chartColorTheme: PropTypes.string,
|
|
270
|
+
toggleRecords: PropTypes.func
|
|
279
271
|
};
|
|
280
|
-
|
|
272
|
+
export default HorizontalBar;
|