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,30 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _dtableUtils = require("dtable-utils");
|
|
12
|
-
var _lodashEs = require("lodash-es");
|
|
13
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
14
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
16
|
-
var _constants = require("../../constants");
|
|
17
|
-
var _utils = require("../../utils");
|
|
18
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
19
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
20
|
-
class Combination extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { getTableColumnByKey, getTableById } from 'dtable-utils';
|
|
4
|
+
import * as d3 from 'd3';
|
|
5
|
+
import intl from '../../intl';
|
|
6
|
+
import { EMPTY_NAME, CHART_THEME_COLOR, CHART_LINE_TYPES } from '../../constants';
|
|
7
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
8
|
+
import ToolTip from '../../components/tooltip';
|
|
9
|
+
import ChartComponent from './chart-component';
|
|
10
|
+
class Combination extends ChartComponent {
|
|
21
11
|
constructor(props) {
|
|
22
12
|
super(props);
|
|
23
|
-
this.handleResize = () => {
|
|
24
|
-
this.destroyChart();
|
|
25
|
-
this.createChart();
|
|
26
|
-
this.drawChart();
|
|
27
|
-
};
|
|
28
13
|
this.createChart = () => {
|
|
29
14
|
const {
|
|
30
15
|
chart
|
|
@@ -38,9 +23,9 @@ class Combination extends _chartComponent.default {
|
|
|
38
23
|
const initConfig = {
|
|
39
24
|
insertPadding: 30,
|
|
40
25
|
borderRadius: 0.2,
|
|
41
|
-
marginLeft: show_y_axis_left_label ?
|
|
42
|
-
marginRight: show_y_axis_right_label ?
|
|
43
|
-
marginBottom: x_axis_show_label ?
|
|
26
|
+
marginLeft: show_y_axis_left_label ? this.getAxisTitleHeight(chart.config.y_axis_left_label_font_size) : 0,
|
|
27
|
+
marginRight: show_y_axis_right_label ? this.getAxisTitleHeight(chart.config.y_axis_right_label_font_size) : 0,
|
|
28
|
+
marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0,
|
|
44
29
|
marginTop: display_data ? 15 : 0
|
|
45
30
|
};
|
|
46
31
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
@@ -52,11 +37,11 @@ class Combination extends _chartComponent.default {
|
|
|
52
37
|
let {
|
|
53
38
|
result: data
|
|
54
39
|
} = this.props;
|
|
55
|
-
data =
|
|
40
|
+
data = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
56
41
|
if (!Array.isArray(data)) return;
|
|
57
42
|
this.draw(data);
|
|
58
43
|
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
59
|
-
|
|
44
|
+
isFunction(customRender) && customRender(this.chart);
|
|
60
45
|
};
|
|
61
46
|
this.draw = data => {
|
|
62
47
|
const {
|
|
@@ -65,8 +50,8 @@ class Combination extends _chartComponent.default {
|
|
|
65
50
|
tables,
|
|
66
51
|
chartColorTheme
|
|
67
52
|
} = this.props;
|
|
68
|
-
const theme =
|
|
69
|
-
const currentTheme =
|
|
53
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
54
|
+
const currentTheme = BaseUtils.getCurrentTheme(chartColorTheme);
|
|
70
55
|
const {
|
|
71
56
|
display_goal_line,
|
|
72
57
|
goal_value,
|
|
@@ -96,9 +81,9 @@ class Combination extends _chartComponent.default {
|
|
|
96
81
|
display_data_field,
|
|
97
82
|
label_font_size
|
|
98
83
|
} = chart.config;
|
|
99
|
-
const table =
|
|
100
|
-
const leftSummaryColumn =
|
|
101
|
-
const rightSummaryColumn =
|
|
84
|
+
const table = getTableById(tables, table_id);
|
|
85
|
+
const leftSummaryColumn = getTableColumnByKey(table, y_axis_left_summary_column) || {};
|
|
86
|
+
const rightSummaryColumn = getTableColumnByKey(table, y_axis_right_summary_column) || {};
|
|
102
87
|
const leftTitle = this.getTitle(tables, table_id, y_axis_left_summary_type, y_axis_left_summary_column);
|
|
103
88
|
const rightTitle = this.getTitle(tables, table_id, y_axis_right_summary_type, y_axis_right_summary_column);
|
|
104
89
|
const showLeftValue = display_data && this.valueFieldMap['value_left'].includes(display_data_field);
|
|
@@ -108,23 +93,33 @@ class Combination extends _chartComponent.default {
|
|
|
108
93
|
showRightValue = true;
|
|
109
94
|
}
|
|
110
95
|
this.setCombinationColorMap(data, leftSummaryColumn, rightSummaryColumn);
|
|
111
|
-
|
|
96
|
+
|
|
97
|
+
// Legend toggle: keep the shared x scale on the full data, but re-lay out the
|
|
98
|
+
// left bars (and hide the right line) for the categories toggled off in the legend.
|
|
99
|
+
const rightHidden = this.hiddenLegendGroups && this.hiddenLegendGroups.has(String(rightSummaryColumn === null || rightSummaryColumn === void 0 ? void 0 : rightSummaryColumn.name) + ' ');
|
|
100
|
+
let dataLeft = data;
|
|
101
|
+
if (y_axis_left_group_by_multiple_numeric_column) {
|
|
102
|
+
dataLeft = this.getVisibleLegendData(data, 'group_name');
|
|
103
|
+
} else if (this.hiddenLegendGroups && this.hiddenLegendGroups.has(String(leftSummaryColumn === null || leftSummaryColumn === void 0 ? void 0 : leftSummaryColumn.name))) {
|
|
104
|
+
dataLeft = [];
|
|
105
|
+
}
|
|
106
|
+
const rightNiceEnd = d3.nice(0, d3.max(data, d => d.value_right) || 0, 5)[1];
|
|
112
107
|
const rightY = d3.scaleLinear().domain(y_axis_auto_range_right ? [d3.min(data, d => d.value_right), rightNiceEnd] : [y_axis_min_right, y_axis_max_right]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
113
108
|
|
|
114
109
|
// Y axis (right)
|
|
115
|
-
const rightAxisWrapper = this.chart.append('g').attr('class', 'y-axis-wrapper-right').attr('transform', `translate(${chartWidth - insertPadding},0)`).call(d3.axisRight(rightY).tickSizeInner(0).ticks(5).tickFormat(d =>
|
|
110
|
+
const rightAxisWrapper = this.chart.append('g').attr('class', 'y-axis-wrapper-right').attr('transform', `translate(${chartWidth - insertPadding},0)`).call(d3.axisRight(rightY).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(rightSummaryColumn, d, y_axis_right_summary_column))).call(g => {
|
|
116
111
|
g.select('.domain').remove();
|
|
117
112
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
118
113
|
g.selectAll('text').attr('fill', theme.textColor);
|
|
119
114
|
});
|
|
120
115
|
const rightAxisOffset = this.getRightAxisOffset(rightAxisWrapper);
|
|
121
|
-
const leftNiceEnd = d3.nice(0, d3.max(
|
|
116
|
+
const leftNiceEnd = d3.nice(0, d3.max(dataLeft, d => d.value_left) || 0, 5)[1];
|
|
122
117
|
const leftY = d3.scaleLinear().domain(y_axis_auto_range_left ? [0, leftNiceEnd] : [y_axis_min_left, y_axis_max_left]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
123
118
|
|
|
124
119
|
// Y axis (left)
|
|
125
|
-
this.chart.append('g').attr('class', 'y-axis-wrapper-left').attr('transform', `translate(${insertPadding},0)`).call(d3.axisLeft(leftY).tickSizeInner(0).ticks(5).tickFormat(d =>
|
|
120
|
+
this.chart.append('g').attr('class', 'y-axis-wrapper-left').attr('transform', `translate(${insertPadding},0)`).call(d3.axisLeft(leftY).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(leftSummaryColumn, d, y_axis_left_summary_method))).call(g => this.drawYaxis(g, theme, rightAxisOffset));
|
|
126
121
|
const fx = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding - rightAxisOffset]).paddingInner(0.5).paddingOuter(0.1);
|
|
127
|
-
const x = d3.scaleBand().domain(y_axis_left_group_by_multiple_numeric_column ? new Set(
|
|
122
|
+
const x = d3.scaleBand().domain(y_axis_left_group_by_multiple_numeric_column ? new Set(dataLeft.map(d => d.group_name)) : new Set([data[0]])).range([0, fx.bandwidth()]).paddingInner(y_axis_left_group_by_multiple_numeric_column ? 0.2 : 0).paddingOuter(0);
|
|
128
123
|
|
|
129
124
|
// X axis
|
|
130
125
|
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 => {
|
|
@@ -136,7 +131,7 @@ class Combination extends _chartComponent.default {
|
|
|
136
131
|
});
|
|
137
132
|
|
|
138
133
|
// Rect group
|
|
139
|
-
this.chart.append('g').attr('class', 'content-wrapper').selectAll().data(d3.group(
|
|
134
|
+
this.chart.append('g').attr('class', 'content-wrapper').selectAll().data(d3.group(dataLeft, d => d.name)).join('g').attr('transform', _ref => {
|
|
140
135
|
let [name, dum] = _ref;
|
|
141
136
|
return `translate(${fx(name)},0)`;
|
|
142
137
|
})
|
|
@@ -154,14 +149,12 @@ class Combination extends _chartComponent.default {
|
|
|
154
149
|
return currentTheme.colors[0];
|
|
155
150
|
}
|
|
156
151
|
return d.color;
|
|
157
|
-
}).attr('data-value', d =>
|
|
152
|
+
}).attr('data-value', d => BaseUtils.getSummaryValueDisplayString(leftSummaryColumn, d.value_left, y_axis_left_summary_method)).attr('data-groupName', d => d.name).call(g => {
|
|
158
153
|
g.nodes().forEach(rect => {
|
|
159
154
|
const parentNode = rect.parentNode;
|
|
160
155
|
// add rect borderRadius
|
|
161
156
|
this.addClipPath({
|
|
162
|
-
rect
|
|
163
|
-
parentNode,
|
|
164
|
-
rectId: rect.getAttribute('data-slugid')
|
|
157
|
+
rect
|
|
165
158
|
});
|
|
166
159
|
|
|
167
160
|
// Add label
|
|
@@ -193,10 +186,15 @@ class Combination extends _chartComponent.default {
|
|
|
193
186
|
}).on('mouseleave', (event, data) => {
|
|
194
187
|
this.hiddenTooltip();
|
|
195
188
|
this.handleAcitveAndInActiveState('active', event);
|
|
189
|
+
}).call(g => {
|
|
190
|
+
this.animateRectGrowInY(g);
|
|
191
|
+
this.animateFadeIn(this.chart.select('.content-wrapper').selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
196
192
|
});
|
|
197
193
|
|
|
198
194
|
// Line group
|
|
199
|
-
|
|
195
|
+
if (!rightHidden) {
|
|
196
|
+
this.drawRightContent(data, fx, rightY, showRightValue, rightSummaryColumn, rightTitle);
|
|
197
|
+
}
|
|
200
198
|
if (display_goal_line && goal_label && goal_value) {
|
|
201
199
|
this.setDispalyGoalLine(goal_label, goal_value, insertPadding, rightY);
|
|
202
200
|
}
|
|
@@ -244,14 +242,14 @@ class Combination extends _chartComponent.default {
|
|
|
244
242
|
});
|
|
245
243
|
});
|
|
246
244
|
} else {
|
|
247
|
-
if (leftSummaryColumn
|
|
245
|
+
if (leftSummaryColumn === null || leftSummaryColumn === void 0 ? void 0 : leftSummaryColumn.name) {
|
|
248
246
|
newData.push({
|
|
249
247
|
group_name: leftSummaryColumn.name
|
|
250
248
|
});
|
|
251
249
|
}
|
|
252
250
|
}
|
|
253
251
|
// right legend item
|
|
254
|
-
if (rightSummaryColumn
|
|
252
|
+
if (rightSummaryColumn === null || rightSummaryColumn === void 0 ? void 0 : rightSummaryColumn.name) {
|
|
255
253
|
newData.push({
|
|
256
254
|
group_name: String(rightSummaryColumn.name) + ' '
|
|
257
255
|
}); // Add a space character to avoid merging with the previous left legend
|
|
@@ -266,7 +264,7 @@ class Combination extends _chartComponent.default {
|
|
|
266
264
|
const {
|
|
267
265
|
y_axis_left_group_by_multiple_numeric_column
|
|
268
266
|
} = chart.config;
|
|
269
|
-
const currentTheme =
|
|
267
|
+
const currentTheme = BaseUtils.getCurrentTheme(chartColorTheme);
|
|
270
268
|
|
|
271
269
|
// left color map
|
|
272
270
|
if (y_axis_left_group_by_multiple_numeric_column) {
|
|
@@ -292,8 +290,8 @@ class Combination extends _chartComponent.default {
|
|
|
292
290
|
chartColorTheme,
|
|
293
291
|
globalTheme
|
|
294
292
|
} = this.props;
|
|
295
|
-
const theme =
|
|
296
|
-
const currentTheme =
|
|
293
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
294
|
+
const currentTheme = BaseUtils.getCurrentTheme(chartColorTheme);
|
|
297
295
|
const {
|
|
298
296
|
line_type,
|
|
299
297
|
label_font_size,
|
|
@@ -310,11 +308,11 @@ class Combination extends _chartComponent.default {
|
|
|
310
308
|
circleData[index]['y'] = y;
|
|
311
309
|
circleData[index]['value'] = d.value_right;
|
|
312
310
|
return y;
|
|
313
|
-
}).curve(line_type ===
|
|
311
|
+
}).curve(line_type === CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
|
|
314
312
|
const rightContentWrapper = this.chart.append('g').attr('class', 'lines-wrapper');
|
|
315
313
|
|
|
316
314
|
// line
|
|
317
|
-
rightContentWrapper.append('path').attr('fill', 'none').attr('stroke', currentTheme.colors[1]).attr('stroke-width', 2).attr('d', () => line(data));
|
|
315
|
+
rightContentWrapper.append('path').attr('fill', 'none').attr('stroke', currentTheme.colors[1]).attr('stroke-width', 2).attr('d', () => line(data)).call(g => this.animateFadeIn(g));
|
|
318
316
|
|
|
319
317
|
// circle
|
|
320
318
|
circleData.forEach(item => {
|
|
@@ -322,7 +320,7 @@ class Combination extends _chartComponent.default {
|
|
|
322
320
|
// circle label
|
|
323
321
|
if (showRightValue) {
|
|
324
322
|
const curCircleEl = g.node();
|
|
325
|
-
rightContentWrapper.append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size',
|
|
323
|
+
rightContentWrapper.append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size', BaseUtils.getLabelFontSize(label_font_size)).text(BaseUtils.getSummaryValueDisplayString(rightSummaryColumn, Number(curCircleEl.getAttribute('data-text')), y_axis_right_summary_column)).call(g => {
|
|
326
324
|
const {
|
|
327
325
|
width
|
|
328
326
|
} = g.node().getBoundingClientRect();
|
|
@@ -345,6 +343,8 @@ class Combination extends _chartComponent.default {
|
|
|
345
343
|
this.updateCombinationCircleStyle(event, 'zoomOut');
|
|
346
344
|
});
|
|
347
345
|
});
|
|
346
|
+
this.animateFadeIn(rightContentWrapper.selectAll('circle'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
347
|
+
this.animateFadeIn(rightContentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
348
348
|
};
|
|
349
349
|
this.showTooltip = (event, _ref4) => {
|
|
350
350
|
let {
|
|
@@ -363,28 +363,28 @@ class Combination extends _chartComponent.default {
|
|
|
363
363
|
y_axis_left_group_by_multiple_numeric_column,
|
|
364
364
|
y_axis_right_summary_method
|
|
365
365
|
} = chart.config;
|
|
366
|
-
const currentTheme =
|
|
366
|
+
const currentTheme = BaseUtils.getCurrentTheme(chartColorTheme);
|
|
367
367
|
const {
|
|
368
368
|
offsetX,
|
|
369
369
|
offsetY
|
|
370
370
|
} = event;
|
|
371
371
|
const newTooltipData = {};
|
|
372
372
|
if (isCircle) {
|
|
373
|
-
newTooltipData['title'] = !rightTitle && typeof rightTitle !== 'number' ?
|
|
373
|
+
newTooltipData['title'] = !rightTitle && typeof rightTitle !== 'number' ? intl.get(EMPTY_NAME) : rightTitle;
|
|
374
374
|
newTooltipData['items'] = [{
|
|
375
375
|
color: currentTheme.colors[1],
|
|
376
376
|
name: event.target.getAttribute('data-name'),
|
|
377
|
-
value:
|
|
377
|
+
value: BaseUtils.getSummaryValueDisplayString(rightSummaryColumn, Number(event.target.getAttribute('data-text')), y_axis_right_summary_method)
|
|
378
378
|
}];
|
|
379
379
|
} else {
|
|
380
380
|
const curGroup = event.target.parentNode;
|
|
381
381
|
const [curGroupName, data] = curGroup.__data__;
|
|
382
|
-
newTooltipData['title'] = !curGroupName && typeof curGroupName !== 'number' ?
|
|
382
|
+
newTooltipData['title'] = !curGroupName && typeof curGroupName !== 'number' ? intl.get(EMPTY_NAME) : curGroupName;
|
|
383
383
|
newTooltipData['items'] = data.map(item => {
|
|
384
384
|
return {
|
|
385
385
|
color: y_axis_left_group_by_multiple_numeric_column ? this.colorMap[item.group_name] : currentTheme.colors[0],
|
|
386
386
|
name: y_axis_left_group_by_multiple_numeric_column ? item.group_name : leftTitle,
|
|
387
|
-
value:
|
|
387
|
+
value: BaseUtils.getSummaryValueDisplayString(leftSummaryColumn, Number(item.value_left), y_axis_left_summary_method)
|
|
388
388
|
};
|
|
389
389
|
});
|
|
390
390
|
}
|
|
@@ -423,11 +423,11 @@ class Combination extends _chartComponent.default {
|
|
|
423
423
|
};
|
|
424
424
|
this.updateCombinationCircleStyle = (event, state) => {
|
|
425
425
|
if (state === 'zoomIn') {
|
|
426
|
-
d3.select(event.currentTarget).transition().duration(this.
|
|
426
|
+
d3.select(event.currentTarget).transition().duration(this.interactionDuration).attr('r', 5);
|
|
427
427
|
return;
|
|
428
428
|
}
|
|
429
429
|
const circles = d3.select(event.currentTarget.parentNode).selectAll('circle').nodes();
|
|
430
|
-
circles.forEach(circle => d3.select(circle).transition().duration(this.
|
|
430
|
+
circles.forEach(circle => d3.select(circle).transition().duration(this.interactionDuration).attr('r', 3));
|
|
431
431
|
};
|
|
432
432
|
this.updateLastLegendToCircle = () => {
|
|
433
433
|
const legendWrapper = this.chart.select('.legend-wrapper').node();
|
|
@@ -452,12 +452,11 @@ class Combination extends _chartComponent.default {
|
|
|
452
452
|
componentDidMount() {
|
|
453
453
|
this.createChart();
|
|
454
454
|
this.drawChart();
|
|
455
|
-
|
|
456
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
455
|
+
super.componentDidMount();
|
|
457
456
|
}
|
|
458
457
|
componentDidUpdate(prevProps) {
|
|
459
458
|
super.componentDidUpdate(prevProps);
|
|
460
|
-
if (
|
|
459
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
461
460
|
this.destroyChart();
|
|
462
461
|
this.createChart();
|
|
463
462
|
this.drawChart();
|
|
@@ -465,24 +464,17 @@ class Combination extends _chartComponent.default {
|
|
|
465
464
|
}
|
|
466
465
|
componentWillUnmount() {
|
|
467
466
|
this.destroyChart();
|
|
468
|
-
|
|
467
|
+
super.componentWillUnmount();
|
|
469
468
|
}
|
|
470
469
|
render() {
|
|
471
|
-
const {
|
|
472
|
-
chart
|
|
473
|
-
} = this.props;
|
|
474
470
|
const {
|
|
475
471
|
tooltipData,
|
|
476
472
|
toolTipPosition
|
|
477
473
|
} = this.state;
|
|
478
|
-
return /*#__PURE__*/
|
|
474
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
479
475
|
ref: ref => this.container = ref,
|
|
480
|
-
className:
|
|
481
|
-
|
|
482
|
-
'show-y-axis-left-label': this.isShowYAxisLeftLabel(chart),
|
|
483
|
-
'show-y-axis-right-label': this.isShowYAxisRightLabel(chart)
|
|
484
|
-
})
|
|
485
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
476
|
+
className: "sea-chart-container"
|
|
477
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
486
478
|
tooltipData: tooltipData,
|
|
487
479
|
toolTipPosition: toolTipPosition,
|
|
488
480
|
chart: this.chart
|
|
@@ -490,16 +482,16 @@ class Combination extends _chartComponent.default {
|
|
|
490
482
|
}
|
|
491
483
|
}
|
|
492
484
|
Combination.propTypes = {
|
|
493
|
-
canvasStyle:
|
|
494
|
-
chart:
|
|
495
|
-
groupbyColumn:
|
|
496
|
-
columnGroupbyColumn:
|
|
497
|
-
summaryColumn:
|
|
498
|
-
result:
|
|
499
|
-
tables:
|
|
500
|
-
globalTheme:
|
|
501
|
-
chartColorTheme:
|
|
502
|
-
toggleRecords:
|
|
503
|
-
customRender:
|
|
485
|
+
canvasStyle: PropTypes.object,
|
|
486
|
+
chart: PropTypes.object,
|
|
487
|
+
groupbyColumn: PropTypes.object,
|
|
488
|
+
columnGroupbyColumn: PropTypes.object,
|
|
489
|
+
summaryColumn: PropTypes.object,
|
|
490
|
+
result: PropTypes.array,
|
|
491
|
+
tables: PropTypes.array,
|
|
492
|
+
globalTheme: PropTypes.string,
|
|
493
|
+
chartColorTheme: PropTypes.string,
|
|
494
|
+
toggleRecords: PropTypes.func,
|
|
495
|
+
customRender: PropTypes.func
|
|
504
496
|
};
|
|
505
|
-
|
|
497
|
+
export default Combination;
|
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _lodashEs = require("lodash-es");
|
|
12
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
13
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
var _utils = require("../../utils");
|
|
16
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
17
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
18
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
19
|
-
class Completeness extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { cloneDeep } from 'lodash-es';
|
|
4
|
+
import * as d3 from 'd3';
|
|
5
|
+
import { CHART_THEME_COLOR } from '../../constants';
|
|
6
|
+
import { BaseUtils } from '../../utils';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
import ToolTip from '../../components/tooltip';
|
|
9
|
+
import ChartComponent from './chart-component';
|
|
10
|
+
class Completeness extends ChartComponent {
|
|
20
11
|
constructor(props) {
|
|
21
12
|
super(props);
|
|
22
|
-
this.handleResize = () => {
|
|
23
|
-
this.destroyChart();
|
|
24
|
-
this.createChart();
|
|
25
|
-
this.drawChart();
|
|
26
|
-
};
|
|
27
13
|
this.createChart = () => {
|
|
28
14
|
const {
|
|
29
15
|
chart
|
|
@@ -43,7 +29,7 @@ class Completeness extends _chartComponent.default {
|
|
|
43
29
|
let {
|
|
44
30
|
result: data
|
|
45
31
|
} = this.props;
|
|
46
|
-
data =
|
|
32
|
+
data = BaseUtils.formatEmptyName(data, (_this$props$chart = this.props.chart) === null || _this$props$chart === void 0 ? void 0 : (_this$props$chart$con = _this$props$chart.config) === null || _this$props$chart$con === void 0 ? void 0 : _this$props$chart$con.column_groupby_column_key, intl.get('Empty'));
|
|
47
33
|
if (!Array.isArray(data)) return;
|
|
48
34
|
this.draw(data);
|
|
49
35
|
};
|
|
@@ -54,7 +40,7 @@ class Completeness extends _chartComponent.default {
|
|
|
54
40
|
chartColorTheme,
|
|
55
41
|
columnGroupbyColumn
|
|
56
42
|
} = this.props;
|
|
57
|
-
const theme =
|
|
43
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
58
44
|
const {
|
|
59
45
|
y_axis_auto_range,
|
|
60
46
|
y_axis_min,
|
|
@@ -70,14 +56,16 @@ class Completeness extends _chartComponent.default {
|
|
|
70
56
|
marginRight
|
|
71
57
|
} = this.chartBoundingClientRect;
|
|
72
58
|
this.markLastForCompleteness(data);
|
|
73
|
-
const colors =
|
|
59
|
+
const colors = BaseUtils.getCurrentTheme(chartColorTheme).colors;
|
|
74
60
|
// Normalize groupby to string before setColorMap to ensure consistent keys
|
|
75
61
|
data.forEach(item => {
|
|
76
62
|
if (Array.isArray(item.groupby)) {
|
|
77
63
|
item.groupby = item.groupby.join(', ');
|
|
78
64
|
}
|
|
79
65
|
});
|
|
80
|
-
|
|
66
|
+
const fullData = data;
|
|
67
|
+
data = this.getVisibleLegendData(data, 'groupby');
|
|
68
|
+
this.setColorMap(fullData, chartColorTheme, 'groupby', columnGroupbyColumn, chart);
|
|
81
69
|
const newSeries = this.getGroupSeries(data, columnGroupbyColumn, chart);
|
|
82
70
|
|
|
83
71
|
// Y axis
|
|
@@ -147,7 +135,7 @@ class Completeness extends _chartComponent.default {
|
|
|
147
135
|
}).selectAll().data(_ref6 => {
|
|
148
136
|
let [_, d] = _ref6;
|
|
149
137
|
return d;
|
|
150
|
-
}).join('rect').attr('class', 'rect').attr('opacity', 1).attr('x', d => x(d[0]) - Number(yAxis.node().getAttribute('data-axisWidth'))).attr('y', d => localY(d.groupby)).attr('
|
|
138
|
+
}).join('rect').attr('class', 'rect').attr('opacity', 1).attr('x', d => x(d[0]) - Number(yAxis.node().getAttribute('data-axisWidth'))).attr('y', d => localY(d.groupby)).attr('width', d => x(d[1]) - x(d[0])).attr('height', localY.bandwidth()).attr('fill', d => {
|
|
151
139
|
const key = d.key;
|
|
152
140
|
const groupby = d.groupby;
|
|
153
141
|
if (key === 'rest') {
|
|
@@ -158,7 +146,7 @@ class Completeness extends _chartComponent.default {
|
|
|
158
146
|
}
|
|
159
147
|
return colors[0];
|
|
160
148
|
}).attr('data-value', d => d.rawData.value).attr('data-groupName', d => d.rawData.slugId).attr('data-tooltipTitle', d => d.rawData.name).attr('data-tooltipName', d => d.key).attr('data-groupBy', d => d.groupby).on('click', (event, data) => {
|
|
161
|
-
self.
|
|
149
|
+
self.toggleRecords(data.rawData);
|
|
162
150
|
}).on('mouseover', event => {
|
|
163
151
|
self.showTooltip(event);
|
|
164
152
|
self.handleAcitveAndInActiveState('inActive', event);
|
|
@@ -199,11 +187,13 @@ class Completeness extends _chartComponent.default {
|
|
|
199
187
|
});
|
|
200
188
|
}
|
|
201
189
|
});
|
|
190
|
+
this.animateStackGrowInX(contentWrapper.selectAll('rect'));
|
|
191
|
+
this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
202
192
|
this.setLegend({
|
|
203
193
|
legendName: 'groupby',
|
|
204
194
|
theme,
|
|
205
195
|
legendPosition: 'top-right',
|
|
206
|
-
data,
|
|
196
|
+
data: fullData,
|
|
207
197
|
groupColumn: columnGroupbyColumn,
|
|
208
198
|
chart
|
|
209
199
|
});
|
|
@@ -225,23 +215,17 @@ class Completeness extends _chartComponent.default {
|
|
|
225
215
|
const curGroupName = event.currentTarget.getAttribute('data-groupName');
|
|
226
216
|
this.setActiveAndInActiveState(state, allGroup, curGroupName);
|
|
227
217
|
};
|
|
228
|
-
this.showTooltip =
|
|
229
|
-
|
|
218
|
+
this.showTooltip = event => {
|
|
219
|
+
const {
|
|
230
220
|
offsetX,
|
|
231
221
|
offsetY
|
|
232
222
|
} = event;
|
|
233
|
-
if (isDiv) {
|
|
234
|
-
const initX = Number(event.currentTarget.getAttribute('data-x'));
|
|
235
|
-
const initY = Number(event.currentTarget.getAttribute('data-y'));
|
|
236
|
-
offsetX = offsetX + initX;
|
|
237
|
-
offsetY = offsetY + initY;
|
|
238
|
-
}
|
|
239
223
|
const groupby = event.currentTarget.getAttribute('data-groupBy');
|
|
240
224
|
const newTooltipData = {
|
|
241
225
|
title: event.currentTarget.getAttribute('data-tooltipTitle'),
|
|
242
226
|
items: [{
|
|
243
227
|
color: event.currentTarget.getAttribute('data-tooltipName') === 'rest' ? '#bdbdbd' : this.colorMap[groupby],
|
|
244
|
-
name:
|
|
228
|
+
name: intl.get(event.currentTarget.getAttribute('data-tooltipName')),
|
|
245
229
|
value: event.currentTarget.getAttribute('data-value')
|
|
246
230
|
}]
|
|
247
231
|
};
|
|
@@ -255,17 +239,11 @@ class Completeness extends _chartComponent.default {
|
|
|
255
239
|
}
|
|
256
240
|
});
|
|
257
241
|
};
|
|
258
|
-
this.moveTooltip =
|
|
259
|
-
|
|
242
|
+
this.moveTooltip = event => {
|
|
243
|
+
const {
|
|
260
244
|
offsetX,
|
|
261
245
|
offsetY
|
|
262
246
|
} = event;
|
|
263
|
-
if (isDiv) {
|
|
264
|
-
const initX = Number(event.currentTarget.getAttribute('data-x'));
|
|
265
|
-
const initY = Number(event.currentTarget.getAttribute('data-y'));
|
|
266
|
-
offsetX = offsetX + initX;
|
|
267
|
-
offsetY = offsetY + initY;
|
|
268
|
-
}
|
|
269
247
|
this.setState({
|
|
270
248
|
toolTipPosition: {
|
|
271
249
|
offsetX,
|
|
@@ -279,7 +257,7 @@ class Completeness extends _chartComponent.default {
|
|
|
279
257
|
});
|
|
280
258
|
};
|
|
281
259
|
this.getGroupSeries = (data, columnGroupbyColumn, chart) => {
|
|
282
|
-
const sortedData =
|
|
260
|
+
const sortedData = BaseUtils.sortDataByGroupName(cloneDeep(data), 'groupby', columnGroupbyColumn, chart);
|
|
283
261
|
sortedData.forEach(item => {
|
|
284
262
|
if (Array.isArray(item.groupby)) {
|
|
285
263
|
item.groupby = item.groupby.join(', ');
|
|
@@ -289,7 +267,7 @@ class Completeness extends _chartComponent.default {
|
|
|
289
267
|
// Sort main groups by name for stable order
|
|
290
268
|
groups.sort((a, b) => String(a[0]).localeCompare(String(b[0])));
|
|
291
269
|
groups.forEach((item, index) => {
|
|
292
|
-
const itemData =
|
|
270
|
+
const itemData = cloneDeep(item[1]);
|
|
293
271
|
const valueMap = d3.rollup(itemData, v => d3.sum(v, d => d.value), d => d.groupby, d => d.group_name);
|
|
294
272
|
const rawDataMap = d3.rollup(itemData, v => v[0], d => d.groupby, d => d.group_name);
|
|
295
273
|
|
|
@@ -373,28 +351,7 @@ class Completeness extends _chartComponent.default {
|
|
|
373
351
|
return allGroup;
|
|
374
352
|
};
|
|
375
353
|
this.addMaskRect = (topG, rect, yAxis) => {
|
|
376
|
-
|
|
377
|
-
const {
|
|
378
|
-
borderRadius
|
|
379
|
-
} = this.chartBoundingClientRect;
|
|
380
|
-
// Add mask rect
|
|
381
|
-
d3.select(topG).append('foreignObject').attr('class', rect.getAttribute('class')).attr('opacity', rect.getAttribute('opacity')).attr('x', rect.getAttribute('x')).attr('y', rect.getAttribute('y')).attr('data-y', rect.parentNode.parentNode.getAttribute('data-transform')).attr('width', rect.getAttribute('width')).attr('height', rect.getAttribute('height')).attr('data-groupName', rect.getAttribute('data-groupName')).attr('data-value', rect.getAttribute('data-value')).attr('data-tooltipTitle', rect.getAttribute('data-tooltipTitle')).attr('data-tooltipName', rect.getAttribute('data-tooltipName')).attr('data-groupBy', rect.getAttribute('data-groupBy')).attr('data-x', () => {
|
|
382
|
-
const x = Number(rect.getAttribute('x'));
|
|
383
|
-
return x + Number(yAxis.node().getAttribute('data-axisWidth'));
|
|
384
|
-
}).on('click', (event, data) => {
|
|
385
|
-
this.props.toggleRecords(data);
|
|
386
|
-
}).on('mouseover', event => {
|
|
387
|
-
this.showTooltip(event, true);
|
|
388
|
-
this.handleAcitveAndInActiveState('inActive', event);
|
|
389
|
-
}).on('mousemove', event => {
|
|
390
|
-
this.moveTooltip(event, true);
|
|
391
|
-
}).on('mouseleave', event => {
|
|
392
|
-
this.hiddenTooltip();
|
|
393
|
-
this.handleAcitveAndInActiveState('active', event);
|
|
394
|
-
}).append('xhtml:div').attr('style', `width: 100%; height: 100%; background-color: ${rect.getAttribute('fill')}; border-radius: 0px ${xWidth * borderRadius}px ${xWidth * borderRadius}px 0px`);
|
|
395
|
-
|
|
396
|
-
// Remove old rect
|
|
397
|
-
d3.select(rect).remove();
|
|
354
|
+
return this.addRoundedClip(rect, 'x');
|
|
398
355
|
};
|
|
399
356
|
this.chart = null;
|
|
400
357
|
this.state = {
|
|
@@ -403,40 +360,31 @@ class Completeness extends _chartComponent.default {
|
|
|
403
360
|
};
|
|
404
361
|
}
|
|
405
362
|
componentDidMount() {
|
|
406
|
-
super.componentDidMount();
|
|
407
363
|
this.createChart();
|
|
408
364
|
this.drawChart();
|
|
409
|
-
|
|
410
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
365
|
+
super.componentDidMount();
|
|
411
366
|
}
|
|
412
367
|
componentDidUpdate(prevProps) {
|
|
413
368
|
super.componentDidUpdate(prevProps);
|
|
414
|
-
if (
|
|
369
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
415
370
|
this.destroyChart();
|
|
416
371
|
this.createChart();
|
|
417
372
|
this.drawChart();
|
|
418
373
|
}
|
|
419
374
|
}
|
|
420
375
|
componentWillUnmount() {
|
|
421
|
-
super.componentWillUnmount();
|
|
422
376
|
this.destroyChart();
|
|
423
|
-
|
|
377
|
+
super.componentWillUnmount();
|
|
424
378
|
}
|
|
425
379
|
render() {
|
|
426
|
-
const {
|
|
427
|
-
chart
|
|
428
|
-
} = this.props;
|
|
429
380
|
const {
|
|
430
381
|
tooltipData,
|
|
431
382
|
toolTipPosition
|
|
432
383
|
} = this.state;
|
|
433
|
-
return /*#__PURE__*/
|
|
384
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
434
385
|
ref: ref => this.container = ref,
|
|
435
|
-
className:
|
|
436
|
-
|
|
437
|
-
'show-y-axis-label': this.isShowVerticalAxisLabel(chart)
|
|
438
|
-
})
|
|
439
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
386
|
+
className: "sea-chart-container"
|
|
387
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
440
388
|
tooltipData: tooltipData,
|
|
441
389
|
toolTipPosition: toolTipPosition,
|
|
442
390
|
chart: this.chart
|
|
@@ -444,15 +392,15 @@ class Completeness extends _chartComponent.default {
|
|
|
444
392
|
}
|
|
445
393
|
}
|
|
446
394
|
Completeness.propTypes = {
|
|
447
|
-
canvasStyle:
|
|
448
|
-
chart:
|
|
449
|
-
groupbyColumn:
|
|
450
|
-
columnGroupbyColumn:
|
|
451
|
-
summaryColumn:
|
|
452
|
-
result:
|
|
453
|
-
tables:
|
|
454
|
-
globalTheme:
|
|
455
|
-
chartColorTheme:
|
|
456
|
-
toggleRecords:
|
|
395
|
+
canvasStyle: PropTypes.object,
|
|
396
|
+
chart: PropTypes.object,
|
|
397
|
+
groupbyColumn: PropTypes.object,
|
|
398
|
+
columnGroupbyColumn: PropTypes.object,
|
|
399
|
+
summaryColumn: PropTypes.object,
|
|
400
|
+
result: PropTypes.array,
|
|
401
|
+
tables: PropTypes.array,
|
|
402
|
+
globalTheme: PropTypes.string,
|
|
403
|
+
chartColorTheme: PropTypes.string,
|
|
404
|
+
toggleRecords: PropTypes.func
|
|
457
405
|
};
|
|
458
|
-
|
|
406
|
+
export default Completeness;
|