sea-chart 2.0.43 → 2.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +4 -11
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +4 -11
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +27 -35
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +11 -18
- package/dist/components/color-popover/color-rules/color-rule.js +25 -33
- package/dist/components/color-popover/color-rules/index.js +6 -14
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +10 -18
- package/dist/components/color-popover/color-rules-popover.js +26 -34
- package/dist/components/color-popover/color-selector-popover.js +10 -18
- package/dist/components/color-setting/color-group-selector.js +12 -20
- package/dist/components/common-add-tool/index.js +6 -13
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +12 -19
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +16 -24
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +42 -50
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +4 -11
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +4 -11
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +25 -33
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +54 -64
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +15 -22
- package/dist/components/row-card/row-card-header.js +14 -21
- package/dist/components/row-card/row-card-item.js +33 -41
- package/dist/components/row-card/row-card.js +15 -23
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +21 -21
- package/dist/components/types-dialog/index.js +56 -64
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +149 -273
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +20 -24
- package/dist/editor/index.js +8 -15
- package/dist/index.js +13 -104
- package/dist/intl.js +10 -17
- package/dist/locale/index.js +16 -23
- package/dist/locale/lang/de.js +1 -7
- package/dist/locale/lang/en.js +1 -7
- package/dist/locale/lang/es.js +1 -7
- package/dist/locale/lang/fr.js +1 -7
- package/dist/locale/lang/pt.js +1 -7
- package/dist/locale/lang/ru.js +1 -7
- package/dist/locale/lang/zh_CN.js +1 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +8 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +19 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +15 -18
- package/dist/model/horizontal-group-bar.js +14 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +12 -19
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +15 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +7 -13
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +83 -74
- package/dist/settings/bar-settings/data-settings.js +39 -47
- package/dist/settings/bar-settings/index.js +3 -20
- package/dist/settings/bar-settings/style-settings.js +69 -60
- package/dist/settings/basic-number-card/data-settings.js +49 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +18 -26
- package/dist/settings/combination-settings/data-settings.js +55 -63
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +94 -77
- package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
- package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
- package/dist/settings/completeness-settings/index.js +3 -20
- package/dist/settings/completeness-settings/style-settings.js +19 -26
- package/dist/settings/dashboard-settings/data-settings.js +43 -51
- package/dist/settings/dashboard-settings/index.js +2 -13
- package/dist/settings/data-settings.js +72 -79
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
- package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
- package/dist/settings/funnel-settings/data-settings.js +23 -31
- package/dist/settings/funnel-settings/index.js +3 -20
- package/dist/settings/funnel-settings/style-settings.js +11 -19
- package/dist/settings/heat-map-settings/data-settings.js +18 -26
- package/dist/settings/heat-map-settings/index.js +3 -20
- package/dist/settings/heat-map-settings/style-settings.js +18 -26
- package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
- package/dist/settings/horizontal-bar-settings/index.js +3 -20
- package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
- package/dist/settings/index.js +52 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +26 -34
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +64 -72
- package/dist/settings/table-element-settings/components/data-filter.js +30 -38
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +111 -119
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +62 -53
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +17 -25
- package/dist/settings/widgets/axis-title-font-settings/index.js +39 -0
- package/dist/settings/widgets/basic-summary/index.js +55 -63
- package/dist/settings/widgets/chart-type/index.js +18 -26
- package/dist/settings/widgets/color-settings/index.js +72 -80
- package/dist/settings/widgets/common-data-settings.js +21 -29
- package/dist/settings/widgets/data-filter/index.js +35 -43
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +24 -32
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +51 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +23 -31
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +72 -80
- package/dist/settings/widgets/switch/index.js +8 -15
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +63 -71
- package/dist/utils/cell-format-utils.js +18 -28
- package/dist/utils/cell-value-utils.js +5 -12
- package/dist/utils/chart-utils/base-utils.js +362 -334
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +80 -86
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +32 -39
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +91 -97
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
- package/dist/utils/chart-utils/sql-statistics-utils.js +284 -246
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +18 -30
- package/dist/utils/collaborator.js +4 -13
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +65 -92
- package/dist/utils/common-utils.js +27 -52
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +11 -19
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +1 -7
- package/dist/utils/options-utils.js +8 -16
- package/dist/utils/row-record-utils.js +182 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +49 -55
- package/dist/utils/sql/column-2-sql-column.js +146 -154
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.css +0 -17
- package/dist/view/index.js +89 -95
- package/dist/view/title/index.js +15 -23
- package/dist/view/wrapper/area-group.js +53 -72
- package/dist/view/wrapper/area.js +51 -72
- package/dist/view/wrapper/bar-compare.js +43 -56
- package/dist/view/wrapper/bar-custom-stack.js +50 -120
- package/dist/view/wrapper/bar-group.js +51 -94
- package/dist/view/wrapper/bar-stack.js +54 -90
- package/dist/view/wrapper/bar.js +45 -66
- package/dist/view/wrapper/basic-number-card.js +25 -26
- package/dist/view/wrapper/chart-component.js +539 -162
- package/dist/view/wrapper/combination.js +63 -83
- package/dist/view/wrapper/completeness-group.js +42 -96
- package/dist/view/wrapper/completeness.js +42 -96
- package/dist/view/wrapper/dashboard.js +33 -47
- package/dist/view/wrapper/funnel.js +36 -56
- package/dist/view/wrapper/heat-map.js +126 -104
- package/dist/view/wrapper/horizontal-bar-group.js +57 -76
- package/dist/view/wrapper/horizontal-bar-stack.js +56 -109
- package/dist/view/wrapper/horizontal-bar.js +45 -68
- package/dist/view/wrapper/index.js +110 -115
- package/dist/view/wrapper/line-group.js +48 -66
- package/dist/view/wrapper/line.js +47 -67
- package/dist/view/wrapper/map-bubble.js +46 -59
- package/dist/view/wrapper/map-world-bubble.js +45 -58
- package/dist/view/wrapper/map-world.js +47 -60
- package/dist/view/wrapper/map.js +48 -60
- package/dist/view/wrapper/mirror.js +40 -61
- package/dist/view/wrapper/pie.js +48 -59
- package/dist/view/wrapper/ring.js +52 -63
- package/dist/view/wrapper/scatter.js +49 -67
- package/dist/view/wrapper/table/index.js +13 -21
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +50 -58
- package/dist/view/wrapper/table/pivot-table-display-name.js +83 -91
- package/dist/view/wrapper/table/two-dimension-table.js +76 -84
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +96 -105
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +22 -31
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/record.js +10 -17
- package/dist/view/wrapper/table-element/components/records-body.js +17 -19
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +23 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
- package/dist/view/wrapper/table-element/components/utils.js +5 -15
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +39 -57
- package/dist/view/wrapper/trend.js +41 -48
- package/package.json +1 -1
|
@@ -1,34 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
15
|
-
var _dtableUtils = require("dtable-utils");
|
|
16
|
-
var _dayOfYear = _interopRequireDefault(require("dayjs/plugin/dayOfYear"));
|
|
17
|
-
var _style = require("../../constants/style");
|
|
18
|
-
var _constants = require("../../constants");
|
|
19
|
-
var _utils = require("../../utils");
|
|
20
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
21
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
22
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
23
|
-
_dayjs.default.extend(_dayOfYear.default);
|
|
24
|
-
class HeatMap extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import { getTableById, getTableColumnByKey, getNumberDisplayString } from 'dtable-utils';
|
|
6
|
+
import { FILL_BORDER_COLOR_MAP, COLOR_OPTIONS } from '../../constants/style';
|
|
7
|
+
import { DEFAULT_GRID_SIZE, DEFAULT_GRID_DISTANCE, DEFAULT_NUMBER_FORMAT_OBJECT, CHART_SUMMARY_TYPE, TITLE_AMOUNT } from '../../constants';
|
|
8
|
+
import { BaseUtils } from '../../utils';
|
|
9
|
+
import intl from '../../intl';
|
|
10
|
+
import ToolTip from '../../components/tooltip';
|
|
11
|
+
import ChartComponent from './chart-component';
|
|
12
|
+
class HeatMap extends ChartComponent {
|
|
25
13
|
constructor(props) {
|
|
26
14
|
super(props);
|
|
27
|
-
this.handleResize = () => {
|
|
28
|
-
this.destroyChart();
|
|
29
|
-
this.createChart();
|
|
30
|
-
this.drawChart();
|
|
31
|
-
};
|
|
32
15
|
this.createChart = () => {
|
|
33
16
|
const {
|
|
34
17
|
chart,
|
|
@@ -37,7 +20,8 @@ class HeatMap extends _chartComponent.default {
|
|
|
37
20
|
const initConfig = {
|
|
38
21
|
insertPadding: 30,
|
|
39
22
|
borderRadius: 0.06,
|
|
40
|
-
monthAxisHeight: 30
|
|
23
|
+
monthAxisHeight: 30,
|
|
24
|
+
titleHeight: 20
|
|
41
25
|
};
|
|
42
26
|
const {
|
|
43
27
|
width,
|
|
@@ -58,23 +42,61 @@ class HeatMap extends _chartComponent.default {
|
|
|
58
42
|
this.getCustomWidthAndHeight = (result, chartConfig, initConfig) => {
|
|
59
43
|
const {
|
|
60
44
|
insertPadding,
|
|
61
|
-
monthAxisHeight
|
|
45
|
+
monthAxisHeight,
|
|
46
|
+
titleHeight
|
|
62
47
|
} = initConfig;
|
|
63
|
-
const
|
|
48
|
+
const years = (result === null || result === void 0 ? void 0 : result.years) || [];
|
|
49
|
+
const count = years.length;
|
|
64
50
|
let {
|
|
65
51
|
grid_size,
|
|
66
52
|
grid_distance
|
|
67
53
|
} = chartConfig;
|
|
68
|
-
grid_size = grid_size ||
|
|
69
|
-
grid_distance = grid_distance ||
|
|
54
|
+
grid_size = grid_size || DEFAULT_GRID_SIZE;
|
|
55
|
+
grid_distance = grid_distance || DEFAULT_GRID_DISTANCE;
|
|
70
56
|
const yearHeight = grid_size * 7 + grid_distance * 6; // height for 1 year
|
|
71
|
-
const height = (yearHeight + monthAxisHeight) * count + (insertPadding + insertPadding);
|
|
72
|
-
const
|
|
57
|
+
const height = (titleHeight + yearHeight + monthAxisHeight) * count + (insertPadding + insertPadding);
|
|
58
|
+
const weekCount = Math.max(...years.map(year => this.getYearWeekCount(year)), 53);
|
|
59
|
+
const width = grid_size * weekCount + grid_distance * (weekCount - 1) + (insertPadding + insertPadding);
|
|
73
60
|
return {
|
|
74
61
|
width,
|
|
75
62
|
height
|
|
76
63
|
};
|
|
77
64
|
};
|
|
65
|
+
this.shouldHeatMapUpdate = prevProps => {
|
|
66
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) return true;
|
|
67
|
+
const prevResult = prevProps.result || {};
|
|
68
|
+
const currentResult = this.props.result || {};
|
|
69
|
+
const prevYears = prevResult.years || [];
|
|
70
|
+
const currentYears = currentResult.years || [];
|
|
71
|
+
if (prevYears.length !== currentYears.length) return true;
|
|
72
|
+
for (let i = 0; i < currentYears.length; i++) {
|
|
73
|
+
if (prevYears[i] !== currentYears[i]) return true;
|
|
74
|
+
}
|
|
75
|
+
const prevData = prevResult.data || [];
|
|
76
|
+
const currentData = currentResult.data || [];
|
|
77
|
+
if (prevData.length !== currentData.length) return true;
|
|
78
|
+
for (let i = 0; i < currentData.length; i++) {
|
|
79
|
+
const prevItem = prevData[i] || {};
|
|
80
|
+
const currentItem = currentData[i] || {};
|
|
81
|
+
if (prevItem.name !== currentItem.name || prevItem.value !== currentItem.value) return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
};
|
|
85
|
+
this.getDayOfYear = date => {
|
|
86
|
+
const dateObj = dayjs(date);
|
|
87
|
+
const yearStart = dayjs(`${dateObj.year()}-01-01`);
|
|
88
|
+
return dateObj.diff(yearStart, 'day') + 1;
|
|
89
|
+
};
|
|
90
|
+
this.getWeekIndex = date => {
|
|
91
|
+
const dateObj = dayjs(date);
|
|
92
|
+
const yearStart = dayjs(`${dateObj.year()}-01-01`);
|
|
93
|
+
const dayOfYear = this.getDayOfYear(date);
|
|
94
|
+
const firstDayOfYear = yearStart.day();
|
|
95
|
+
return Math.floor((dayOfYear - 1 + firstDayOfYear) / 7) + 1;
|
|
96
|
+
};
|
|
97
|
+
this.getYearWeekCount = year => {
|
|
98
|
+
return this.getWeekIndex(dayjs(`${year}-12-31`));
|
|
99
|
+
};
|
|
78
100
|
this.showTooltip = (event, data, columnData) => {
|
|
79
101
|
const {
|
|
80
102
|
offsetX,
|
|
@@ -84,8 +106,8 @@ class HeatMap extends _chartComponent.default {
|
|
|
84
106
|
title: data.name,
|
|
85
107
|
items: [{
|
|
86
108
|
color: '',
|
|
87
|
-
name:
|
|
88
|
-
value:
|
|
109
|
+
name: intl.get(TITLE_AMOUNT),
|
|
110
|
+
value: getNumberDisplayString(data.value, columnData)
|
|
89
111
|
}]
|
|
90
112
|
};
|
|
91
113
|
this.setState({
|
|
@@ -129,26 +151,30 @@ class HeatMap extends _chartComponent.default {
|
|
|
129
151
|
height: chartHeight,
|
|
130
152
|
insertPadding,
|
|
131
153
|
borderRadius,
|
|
132
|
-
|
|
154
|
+
titleHeight
|
|
133
155
|
} = this.chartBoundingClientRect;
|
|
134
|
-
|
|
156
|
+
const {
|
|
135
157
|
data_color,
|
|
136
|
-
grid_size,
|
|
137
158
|
table_id,
|
|
138
159
|
summary_type,
|
|
139
160
|
summary_column
|
|
140
161
|
} = chart.config;
|
|
141
|
-
|
|
142
|
-
|
|
162
|
+
let {
|
|
163
|
+
grid_size,
|
|
164
|
+
grid_distance
|
|
165
|
+
} = chart.config;
|
|
166
|
+
grid_size = grid_size ? grid_size : DEFAULT_GRID_SIZE;
|
|
167
|
+
grid_distance = grid_distance ? grid_distance : DEFAULT_GRID_DISTANCE;
|
|
168
|
+
const currentColorOption = COLOR_OPTIONS.filter(item => item.name === data_color)[0] || COLOR_OPTIONS[0];
|
|
143
169
|
const {
|
|
144
170
|
exampleColors
|
|
145
171
|
} = currentColorOption;
|
|
146
172
|
const themeColors = this.getThemeColors();
|
|
147
|
-
let columnData =
|
|
148
|
-
if (summary_type ===
|
|
149
|
-
const table =
|
|
150
|
-
const summaryColumn =
|
|
151
|
-
columnData = summaryColumn.data ||
|
|
173
|
+
let columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
174
|
+
if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
175
|
+
const table = getTableById(tables, table_id);
|
|
176
|
+
const summaryColumn = getTableColumnByKey(table, summary_column) || {};
|
|
177
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
152
178
|
}
|
|
153
179
|
const yAxisWrapper = this.chart.append('g').attr('class', 'y-axis-wrapper');
|
|
154
180
|
const xAxisWrapper = this.chart.append('g').attr('class', 'x-axis-wrapper');
|
|
@@ -158,10 +184,13 @@ class HeatMap extends _chartComponent.default {
|
|
|
158
184
|
// Fy scale
|
|
159
185
|
const fyDomain = new Set(years.map(d => d));
|
|
160
186
|
const fy = d3.scaleBand().domain(fyDomain).range([insertPadding, chartHeight - insertPadding]).paddingInner(0).paddingOuter(0);
|
|
161
|
-
Array.from(fyDomain).forEach(
|
|
187
|
+
Array.from(fyDomain).forEach(year => {
|
|
188
|
+
const bandTop = fy(year) + titleHeight;
|
|
189
|
+
|
|
162
190
|
// Y axis
|
|
163
|
-
const
|
|
164
|
-
|
|
191
|
+
const weekYScale = d3.scaleOrdinal().domain(this.weeks).range(this.weeks.map((_, i) => bandTop + i * (grid_size + grid_distance)));
|
|
192
|
+
const yAxisScale = d3.scaleOrdinal().domain(this.weeks).range(this.weeks.map((_, i) => bandTop + i * (grid_size + grid_distance) + grid_size / 2));
|
|
193
|
+
yAxisWrapper.append('g').attr('class', `y-axis-${year}`).attr('transform', `translate(${insertPadding}, 0)`).call(d3.axisLeft(yAxisScale).tickSizeInner(0).tickSizeOuter(0).tickFormat(d => intl.get(d))).call(g => {
|
|
165
194
|
g.select('.domain').remove();
|
|
166
195
|
g.selectAll('text').attr('font-size', 12);
|
|
167
196
|
g.selectAll('text').attr('fill', themeColors.textColor);
|
|
@@ -173,7 +202,7 @@ class HeatMap extends _chartComponent.default {
|
|
|
173
202
|
const weekDomain = Array.from({
|
|
174
203
|
length: weekCount
|
|
175
204
|
}, (_, i) => i + 1);
|
|
176
|
-
const weekScale = d3.
|
|
205
|
+
const weekScale = d3.scaleOrdinal().domain(weekDomain).range(weekDomain.map((_, i) => insertPadding + i * (grid_size + grid_distance)));
|
|
177
206
|
|
|
178
207
|
// year
|
|
179
208
|
const yearWrapper = contentWrapper.append('g').attr('class', `year-wrapper-${year}`);
|
|
@@ -183,31 +212,27 @@ class HeatMap extends _chartComponent.default {
|
|
|
183
212
|
const monthWrapper = yearWrapper.append('g').attr('class', `month-${this.months[monthIndex]}`);
|
|
184
213
|
// day
|
|
185
214
|
days.forEach((d, index) => {
|
|
186
|
-
monthWrapper.append('rect').attr('class', () => `day-${
|
|
187
|
-
|
|
188
|
-
// The last few days are the first week of the next year
|
|
189
|
-
if (monthIndex === 11 && curWeek === 1) {
|
|
190
|
-
curWeek = weekCount;
|
|
191
|
-
}
|
|
215
|
+
monthWrapper.append('rect').attr('class', () => `day-${this.getDayOfYear(d)}`).attr('x', () => {
|
|
216
|
+
const curWeek = this.getWeekIndex(d);
|
|
192
217
|
if (index === 0) {
|
|
193
218
|
monthTranslateX.push(weekScale(curWeek));
|
|
194
|
-
}
|
|
219
|
+
}
|
|
195
220
|
return weekScale(curWeek);
|
|
196
221
|
}).attr('y', () => {
|
|
197
|
-
const curWeek = this.weeks[(
|
|
198
|
-
return
|
|
222
|
+
const curWeek = this.weeks[dayjs(d).day()];
|
|
223
|
+
return weekYScale(curWeek);
|
|
199
224
|
}).attr('width', grid_size).attr('height', grid_size).attr('rx', grid_size * borderRadius).attr('fill', () => this.getRectColor(d, data, 'fill', exampleColors)).attr('stroke', () => this.getRectColor(d, data, 'stroke', exampleColors)).attr('stroke-width', 1).on('click', () => {
|
|
200
|
-
const curDate = data.find(item => item.name === (
|
|
225
|
+
const curDate = data.find(item => item.name === dayjs(d).format('YYYY-MM-DD'));
|
|
201
226
|
if (curDate) {
|
|
202
227
|
this.props.toggleRecords(curDate);
|
|
203
228
|
}
|
|
204
229
|
}).on('mouseover', event => {
|
|
205
|
-
const curDate = data.find(item => item.name === (
|
|
230
|
+
const curDate = data.find(item => item.name === dayjs(d).format('YYYY-MM-DD'));
|
|
206
231
|
if (curDate) {
|
|
207
232
|
this.showTooltip(event, curDate, columnData);
|
|
208
233
|
}
|
|
209
234
|
}).on('mousemove', event => {
|
|
210
|
-
const curDate = data.find(item => item.name === (
|
|
235
|
+
const curDate = data.find(item => item.name === dayjs(d).format('YYYY-MM-DD'));
|
|
211
236
|
if (curDate) {
|
|
212
237
|
this.moveTooltip(event);
|
|
213
238
|
}
|
|
@@ -219,19 +244,23 @@ class HeatMap extends _chartComponent.default {
|
|
|
219
244
|
|
|
220
245
|
// X axis
|
|
221
246
|
const x = d3.scalePoint().domain(this.months).range([insertPadding, chartWidth - insertPadding]);
|
|
222
|
-
xAxisWrapper.append('g').attr('class', `x-axis-${year}`).attr('transform', `translate(0, ${
|
|
247
|
+
xAxisWrapper.append('g').attr('class', `x-axis-${year}`).attr('transform', `translate(0, ${bandTop + (grid_size * 7 + grid_distance * 6)})`).call(d3.axisBottom(x).tickSizeInner(0).tickSizeOuter(0).tickFormat(d => intl.get(d))).call(g => {
|
|
223
248
|
g.select('.domain').remove();
|
|
224
249
|
g.selectAll('.tick').nodes().forEach((item, index) => {
|
|
225
|
-
const
|
|
250
|
+
const monthX = monthTranslateX[index];
|
|
251
|
+
if (!Number.isFinite(monthX)) {
|
|
252
|
+
d3.select(item).attr('opacity', 0);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const curTranslateX = monthX + grid_size / 2;
|
|
226
256
|
d3.select(item).attr('transform', `translate(${curTranslateX}, 0)`);
|
|
227
257
|
});
|
|
228
258
|
g.selectAll('text').attr('font-size', 12);
|
|
229
259
|
g.selectAll('text').attr('fill', themeColors.textColor);
|
|
230
260
|
});
|
|
231
|
-
|
|
232
|
-
// Title
|
|
233
|
-
titleWrapper.append('text').attr('class', `text-${year}`).attr('x', 0).attr('y', fy(year) + fy.bandwidth()).attr('fill', '#000').attr('font-size', 12).attr('font-weight', 500).text(year);
|
|
261
|
+
titleWrapper.append('text').attr('class', `text-${year}`).attr('x', 0).attr('y', fy(year) + titleHeight - 6).attr('fill', '#000').attr('font-size', 12).attr('font-weight', 500).text(year);
|
|
234
262
|
});
|
|
263
|
+
this.animateFadeIn(contentWrapper.selectAll('rect'));
|
|
235
264
|
this.setLegendForHeatMap({
|
|
236
265
|
exampleColors: ['#EBEDF0', ...exampleColors],
|
|
237
266
|
themeColors
|
|
@@ -239,27 +268,27 @@ class HeatMap extends _chartComponent.default {
|
|
|
239
268
|
};
|
|
240
269
|
this.generateYearDates = year => {
|
|
241
270
|
const dates = [];
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
271
|
+
const isLeapYear = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
272
|
+
const dayCount = isLeapYear ? 366 : 365;
|
|
273
|
+
for (let i = 0; i < dayCount; i++) {
|
|
274
|
+
dates.push(dayjs(`${year}-01-01`).add(i, 'day'));
|
|
246
275
|
}
|
|
247
|
-
const weekCount =
|
|
248
|
-
return [d3.groups(dates, d => (
|
|
276
|
+
const weekCount = this.getYearWeekCount(year);
|
|
277
|
+
return [d3.groups(dates, d => dayjs(d).month()), weekCount];
|
|
249
278
|
};
|
|
250
279
|
this.getRectColor = (d, data, type, exampleColors) => {
|
|
251
280
|
const maxVal = d3.max(data, d => d.value);
|
|
252
281
|
const defaultColor = type === 'stroke' ? '#E1E3E6' : '#EBEDF0';
|
|
253
|
-
const curDate = data.find(item => item.name === (
|
|
282
|
+
const curDate = data.find(item => item.name === dayjs(d).format('YYYY-MM-DD'));
|
|
254
283
|
if (curDate) {
|
|
255
284
|
if (curDate.value <= 0) return defaultColor;
|
|
256
|
-
if (curDate.value === maxVal) return type === 'stroke' ?
|
|
285
|
+
if (curDate.value === maxVal) return type === 'stroke' ? FILL_BORDER_COLOR_MAP[exampleColors[8]] : exampleColors[8];
|
|
257
286
|
const curColor = Math.floor(curDate.value / (maxVal / 9));
|
|
258
|
-
return type === 'stroke' ?
|
|
287
|
+
return type === 'stroke' ? FILL_BORDER_COLOR_MAP[exampleColors[curColor]] : exampleColors[curColor];
|
|
259
288
|
}
|
|
260
289
|
return defaultColor;
|
|
261
290
|
};
|
|
262
|
-
|
|
291
|
+
dayjs.locale('en');
|
|
263
292
|
this.weeks = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
264
293
|
this.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
265
294
|
this.chart = null;
|
|
@@ -271,12 +300,11 @@ class HeatMap extends _chartComponent.default {
|
|
|
271
300
|
componentDidMount() {
|
|
272
301
|
this.createChart();
|
|
273
302
|
this.drawChart();
|
|
274
|
-
|
|
275
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
303
|
+
super.componentDidMount();
|
|
276
304
|
}
|
|
277
305
|
componentDidUpdate(prevProps) {
|
|
278
306
|
super.componentDidUpdate(prevProps);
|
|
279
|
-
if (
|
|
307
|
+
if (this.shouldHeatMapUpdate(prevProps)) {
|
|
280
308
|
this.destroyChart();
|
|
281
309
|
this.createChart();
|
|
282
310
|
this.drawChart();
|
|
@@ -284,23 +312,17 @@ class HeatMap extends _chartComponent.default {
|
|
|
284
312
|
}
|
|
285
313
|
componentWillUnmount() {
|
|
286
314
|
this.destroyChart();
|
|
287
|
-
|
|
315
|
+
super.componentWillUnmount();
|
|
288
316
|
}
|
|
289
317
|
render() {
|
|
290
|
-
const {
|
|
291
|
-
chart
|
|
292
|
-
} = this.props;
|
|
293
318
|
const {
|
|
294
319
|
tooltipData,
|
|
295
320
|
toolTipPosition
|
|
296
321
|
} = this.state;
|
|
297
|
-
return /*#__PURE__*/
|
|
322
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
298
323
|
ref: ref => this.container = ref,
|
|
299
|
-
className:
|
|
300
|
-
|
|
301
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
302
|
-
})
|
|
303
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
324
|
+
className: "sea-chart-container"
|
|
325
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
304
326
|
tooltipData: tooltipData,
|
|
305
327
|
toolTipPosition: toolTipPosition,
|
|
306
328
|
chart: this.chart
|
|
@@ -308,16 +330,16 @@ class HeatMap extends _chartComponent.default {
|
|
|
308
330
|
}
|
|
309
331
|
}
|
|
310
332
|
HeatMap.propTypes = {
|
|
311
|
-
canvasStyle:
|
|
312
|
-
chart:
|
|
313
|
-
groupbyColumn:
|
|
314
|
-
columnGroupbyColumn:
|
|
315
|
-
summaryColumn:
|
|
316
|
-
result:
|
|
317
|
-
tables:
|
|
318
|
-
globalTheme:
|
|
319
|
-
chartColorTheme:
|
|
320
|
-
toggleRecords:
|
|
321
|
-
customRender:
|
|
333
|
+
canvasStyle: PropTypes.object,
|
|
334
|
+
chart: PropTypes.object,
|
|
335
|
+
groupbyColumn: PropTypes.object,
|
|
336
|
+
columnGroupbyColumn: PropTypes.object,
|
|
337
|
+
summaryColumn: PropTypes.object,
|
|
338
|
+
result: PropTypes.object,
|
|
339
|
+
tables: PropTypes.array,
|
|
340
|
+
globalTheme: PropTypes.string,
|
|
341
|
+
chartColorTheme: PropTypes.string,
|
|
342
|
+
toggleRecords: PropTypes.func,
|
|
343
|
+
customRender: PropTypes.func
|
|
322
344
|
};
|
|
323
|
-
|
|
345
|
+
export default HeatMap;
|
|
@@ -1,33 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
16
|
-
var _constants = require("../../constants");
|
|
17
|
-
var _utils = require("../../utils");
|
|
18
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
19
|
-
var _colorRules = require("../../constants/color-rules");
|
|
20
|
-
var _columnUtils = require("../../utils/column-utils");
|
|
21
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
22
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
23
|
-
class HorizontalBarGroup 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 { CellType, isEmpty } from 'dtable-utils';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
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 HorizontalBarGroup extends ChartComponent {
|
|
24
15
|
constructor(props) {
|
|
25
16
|
super(props);
|
|
26
|
-
this.handleResize = (0, _lodashEs.debounce)(() => {
|
|
27
|
-
this.destroyChart();
|
|
28
|
-
this.createChart();
|
|
29
|
-
this.drawChart();
|
|
30
|
-
}, 300);
|
|
31
17
|
this.createChart = () => {
|
|
32
18
|
const {
|
|
33
19
|
chart
|
|
@@ -40,8 +26,8 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
40
26
|
const initConfig = {
|
|
41
27
|
insertPadding: 30,
|
|
42
28
|
borderRadius: 0.2,
|
|
43
|
-
marginLeft: show_vertical_axis_label ?
|
|
44
|
-
marginBottom: show_horizontal_axis_label ?
|
|
29
|
+
marginLeft: show_vertical_axis_label ? this.getAxisTitleHeight(chart.config.vertical_axis_label_font_size) : 0,
|
|
30
|
+
marginBottom: show_horizontal_axis_label ? this.getAxisTitleHeight(chart.config.horizontal_axis_label_font_size) : 0,
|
|
45
31
|
marginRight: display_data ? 15 : 0
|
|
46
32
|
};
|
|
47
33
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
@@ -55,17 +41,17 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
55
41
|
const {
|
|
56
42
|
column_groupby_column_key
|
|
57
43
|
} = chart.config || {};
|
|
58
|
-
data =
|
|
44
|
+
data = BaseUtils.formatEmptyName(data, column_groupby_column_key, intl.get(EMPTY_NAME));
|
|
59
45
|
if (!Array.isArray(data)) return;
|
|
60
46
|
const {
|
|
61
47
|
sort_type,
|
|
62
48
|
type
|
|
63
49
|
} = chart.config;
|
|
64
|
-
if (type ===
|
|
65
|
-
data =
|
|
50
|
+
if (type === CHART_TYPE.STACKED_HORIZONTAL_BAR && sort_type) {
|
|
51
|
+
data = sortDataByGroupSum(data, sort_type);
|
|
66
52
|
}
|
|
67
53
|
this.draw(data);
|
|
68
|
-
|
|
54
|
+
isFunction(customRender) && customRender(this.chart);
|
|
69
55
|
this.renderHorizontalLabel(this.props.chart, this.props.tables, this.container);
|
|
70
56
|
};
|
|
71
57
|
this.draw = data => {
|
|
@@ -77,7 +63,7 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
77
63
|
columnGroupbyColumn,
|
|
78
64
|
summaryColumn
|
|
79
65
|
} = this.props;
|
|
80
|
-
const theme =
|
|
66
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
81
67
|
const {
|
|
82
68
|
display_data,
|
|
83
69
|
label_font_size,
|
|
@@ -96,14 +82,14 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
96
82
|
marginRight
|
|
97
83
|
} = this.chartBoundingClientRect;
|
|
98
84
|
const groupByColumn = this.getColumn(tables, table_id, column_groupby_column_key);
|
|
99
|
-
const isGroupByDate = [
|
|
85
|
+
const isGroupByDate = [CellType.DATE, CellType.CTIME, CellType.MTIME].includes(groupByColumn === null || groupByColumn === void 0 ? void 0 : groupByColumn.type);
|
|
100
86
|
if (isGroupByDate) {
|
|
101
|
-
const emptyName =
|
|
87
|
+
const emptyName = intl.get(EMPTY_NAME);
|
|
102
88
|
data = data.map(item => {
|
|
103
89
|
const rawGroupName = item.group_name;
|
|
104
|
-
if (rawGroupName
|
|
90
|
+
if (isEmpty(rawGroupName)) return item;
|
|
105
91
|
if (rawGroupName === emptyName) return item;
|
|
106
|
-
const dateValue = (
|
|
92
|
+
const dateValue = dayjs(rawGroupName);
|
|
107
93
|
if (!dateValue.isValid()) return item;
|
|
108
94
|
return {
|
|
109
95
|
...item,
|
|
@@ -111,10 +97,10 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
111
97
|
};
|
|
112
98
|
});
|
|
113
99
|
}
|
|
114
|
-
const useSingleSelectColumnColor = (groupByColumn === null || groupByColumn === void 0 ? void 0 : groupByColumn.type) ===
|
|
100
|
+
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;
|
|
115
101
|
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme);
|
|
116
102
|
const fy = d3.scaleBand().domain(new Set(data.map(d => d.name))).range([chartHeight - insertPadding, insertPadding]).paddingInner(0.3).paddingOuter(0.1);
|
|
117
|
-
const sortedData =
|
|
103
|
+
const sortedData = BaseUtils.sortDataByGroupName(cloneDeep(data), 'group_name', columnGroupbyColumn, chart);
|
|
118
104
|
const y = d3.scaleBand().domain(new Set(sortedData.map(d => d.group_name))).range([0, fy.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
119
105
|
|
|
120
106
|
// Y axis
|
|
@@ -134,7 +120,7 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
134
120
|
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]);
|
|
135
121
|
|
|
136
122
|
// X axis
|
|
137
|
-
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 =>
|
|
123
|
+
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 => {
|
|
138
124
|
g.selectAll('.domain').remove();
|
|
139
125
|
g.selectAll('.tick line').node() && g.selectAll('.tick line').node().remove(); // delete the first line
|
|
140
126
|
g.selectAll('.tick line').attr('y2', -(chartHeight - insertPadding * 2)).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
|
|
@@ -156,15 +142,13 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
156
142
|
}).join('rect').attr('opacity', 1).attr('x', 0).attr('y', (d, index) => index * y.bandwidth()).attr('width', d => x(d.value) - x(0)).attr('height', y.bandwidth()).attr('fill', d => {
|
|
157
143
|
var _this$colorMap$colorK;
|
|
158
144
|
const colorKey = d.group_name || d.group_name === 0 ? d.group_name : '';
|
|
159
|
-
return (_this$colorMap$colorK = this.colorMap[colorKey]) !== null && _this$colorMap$colorK !== void 0 ? _this$colorMap$colorK :
|
|
160
|
-
}).attr('value', d => d.value).attr('data-
|
|
145
|
+
return (_this$colorMap$colorK = this.colorMap[colorKey]) !== null && _this$colorMap$colorK !== void 0 ? _this$colorMap$colorK : CHART_STYLE_COLORS[0];
|
|
146
|
+
}).attr('value', d => d.value).attr('data-groupName', d => d.name).call(g => {
|
|
161
147
|
// add rect borderRadius
|
|
162
148
|
g.nodes().forEach(rect => {
|
|
163
149
|
this.addClipPath({
|
|
164
150
|
rect,
|
|
165
|
-
|
|
166
|
-
attr: 'x',
|
|
167
|
-
rectId: rect.getAttribute('data-slugid')
|
|
151
|
+
attr: 'x'
|
|
168
152
|
});
|
|
169
153
|
});
|
|
170
154
|
|
|
@@ -179,7 +163,7 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
179
163
|
y: Number(rect.getAttribute('y')),
|
|
180
164
|
theme,
|
|
181
165
|
label_font_size,
|
|
182
|
-
text:
|
|
166
|
+
text: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(rect.getAttribute('value')), horizontal_axis_summary_method)
|
|
183
167
|
});
|
|
184
168
|
}
|
|
185
169
|
});
|
|
@@ -193,6 +177,9 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
193
177
|
}).on('mouseleave', event => {
|
|
194
178
|
this.hiddenTooltip();
|
|
195
179
|
this.handleAcitveAndInActiveState('active', event);
|
|
180
|
+
}).call(g => {
|
|
181
|
+
this.animateRectGrowInX(g);
|
|
182
|
+
this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
196
183
|
});
|
|
197
184
|
this.setLegend({
|
|
198
185
|
legendName: 'group_name',
|
|
@@ -223,14 +210,14 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
223
210
|
const title = event.currentTarget.getAttribute('data-groupName');
|
|
224
211
|
const children = Array.from(event.currentTarget.parentNode.children).filter(item => item.tagName === 'rect');
|
|
225
212
|
const newTooltipData = {
|
|
226
|
-
title: !title && typeof title !== 'number' ?
|
|
213
|
+
title: !title && typeof title !== 'number' ? intl.get(EMPTY_NAME) : title,
|
|
227
214
|
items: children.map(child => {
|
|
228
215
|
const data = child.__data__;
|
|
229
|
-
const groupName = data.group_name
|
|
216
|
+
const groupName = isEmpty(data.group_name) ? intl.get(EMPTY_NAME) : data.group_name;
|
|
230
217
|
return {
|
|
231
|
-
color: this.colorMap[groupName] ||
|
|
218
|
+
color: this.colorMap[groupName] || CHART_STYLE_COLORS[0],
|
|
232
219
|
name: groupName,
|
|
233
|
-
value:
|
|
220
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(child.getAttribute('value')), horizontal_axis_summary_method)
|
|
234
221
|
};
|
|
235
222
|
})
|
|
236
223
|
};
|
|
@@ -270,11 +257,11 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
270
257
|
componentDidMount() {
|
|
271
258
|
this.createChart();
|
|
272
259
|
this.drawChart();
|
|
273
|
-
|
|
260
|
+
super.componentDidMount();
|
|
274
261
|
}
|
|
275
262
|
componentDidUpdate(prevProps) {
|
|
276
263
|
super.componentDidUpdate(prevProps);
|
|
277
|
-
if (
|
|
264
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
278
265
|
this.destroyChart();
|
|
279
266
|
this.createChart();
|
|
280
267
|
this.drawChart();
|
|
@@ -282,23 +269,17 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
282
269
|
}
|
|
283
270
|
componentWillUnmount() {
|
|
284
271
|
this.destroyChart();
|
|
285
|
-
|
|
272
|
+
super.componentWillUnmount();
|
|
286
273
|
}
|
|
287
274
|
render() {
|
|
288
|
-
const {
|
|
289
|
-
chart
|
|
290
|
-
} = this.props;
|
|
291
275
|
const {
|
|
292
276
|
tooltipData,
|
|
293
277
|
toolTipPosition
|
|
294
278
|
} = this.state;
|
|
295
|
-
return /*#__PURE__*/
|
|
279
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
296
280
|
ref: ref => this.container = ref,
|
|
297
|
-
className:
|
|
298
|
-
|
|
299
|
-
'show-y-axis-label': this.isShowVerticalAxisLabel(chart)
|
|
300
|
-
})
|
|
301
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
281
|
+
className: "sea-chart-container"
|
|
282
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
302
283
|
tooltipData: tooltipData,
|
|
303
284
|
toolTipPosition: toolTipPosition,
|
|
304
285
|
chart: this.chart
|
|
@@ -306,16 +287,16 @@ class HorizontalBarGroup extends _chartComponent.default {
|
|
|
306
287
|
}
|
|
307
288
|
}
|
|
308
289
|
HorizontalBarGroup.propTypes = {
|
|
309
|
-
canvasStyle:
|
|
310
|
-
chart:
|
|
311
|
-
groupbyColumn:
|
|
312
|
-
columnGroupbyColumn:
|
|
313
|
-
summaryColumn:
|
|
314
|
-
result:
|
|
315
|
-
tables:
|
|
316
|
-
globalTheme:
|
|
317
|
-
chartColorTheme:
|
|
318
|
-
toggleRecords:
|
|
319
|
-
customRender:
|
|
290
|
+
canvasStyle: PropTypes.object,
|
|
291
|
+
chart: PropTypes.object,
|
|
292
|
+
groupbyColumn: PropTypes.object,
|
|
293
|
+
columnGroupbyColumn: PropTypes.object,
|
|
294
|
+
summaryColumn: PropTypes.object,
|
|
295
|
+
result: PropTypes.array,
|
|
296
|
+
tables: PropTypes.array,
|
|
297
|
+
globalTheme: PropTypes.string,
|
|
298
|
+
chartColorTheme: PropTypes.string,
|
|
299
|
+
toggleRecords: PropTypes.func,
|
|
300
|
+
customRender: PropTypes.func
|
|
320
301
|
};
|
|
321
|
-
|
|
302
|
+
export default HorizontalBarGroup;
|