sea-chart 2.0.36 → 2.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +8 -15
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +5 -12
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +30 -38
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +12 -19
- package/dist/components/color-popover/color-rules/color-rule.js +26 -34
- package/dist/components/color-popover/color-rules/index.js +7 -15
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +9 -17
- package/dist/components/color-popover/color-rules-popover.js +30 -38
- package/dist/components/color-popover/color-selector-popover.js +12 -20
- package/dist/components/color-setting/color-group-selector.js +13 -21
- package/dist/components/common-add-tool/index.js +8 -15
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +13 -20
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +18 -26
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +40 -48
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +5 -12
- 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 +26 -34
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +55 -65
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +17 -24
- package/dist/components/row-card/row-card-header.js +15 -22
- package/dist/components/row-card/row-card-item.js +35 -43
- package/dist/components/row-card/row-card.js +17 -25
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +14 -21
- package/dist/components/types-dialog/index.js +62 -70
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +142 -271
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +13 -20
- package/dist/editor/index.js +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 +4 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +15 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +11 -18
- package/dist/model/horizontal-group-bar.js +10 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +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 +11 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +11 -17
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +63 -71
- 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 +49 -57
- 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 +19 -27
- 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 +65 -73
- 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 +27 -35
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +65 -73
- package/dist/settings/table-element-settings/components/data-filter.js +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 +112 -120
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +42 -50
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +19 -27
- package/dist/settings/widgets/basic-summary/index.js +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 +26 -34
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +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 +25 -33
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +74 -82
- package/dist/settings/widgets/switch/index.js +9 -16
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +64 -72
- package/dist/utils/cell-format-utils.js +17 -27
- package/dist/utils/cell-value-utils.js +4 -11
- package/dist/utils/chart-utils/base-utils.js +324 -332
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +77 -84
- 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 +21 -28
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +33 -40
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +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 +19 -26
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +90 -96
- 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 +229 -237
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +19 -31
- package/dist/utils/collaborator.js +6 -15
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +77 -104
- package/dist/utils/common-utils.js +28 -53
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +12 -20
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +2 -8
- package/dist/utils/options-utils.js +10 -18
- package/dist/utils/row-record-utils.js +166 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +106 -112
- package/dist/utils/sql/column-2-sql-column.js +158 -168
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.js +90 -96
- package/dist/view/title/index.js +16 -24
- package/dist/view/wrapper/area-group.js +45 -53
- package/dist/view/wrapper/area.js +43 -51
- package/dist/view/wrapper/bar-compare.js +38 -46
- package/dist/view/wrapper/bar-custom-stack.js +39 -47
- package/dist/view/wrapper/bar-group.js +45 -53
- package/dist/view/wrapper/bar-stack.js +48 -56
- package/dist/view/wrapper/bar.js +40 -48
- package/dist/view/wrapper/basic-number-card.js +26 -34
- package/dist/view/wrapper/chart-component.js +123 -131
- package/dist/view/wrapper/combination.js +55 -63
- package/dist/view/wrapper/completeness-group.js +40 -48
- package/dist/view/wrapper/completeness.js +36 -44
- package/dist/view/wrapper/dashboard.js +39 -44
- package/dist/view/wrapper/funnel.js +40 -43
- package/dist/view/wrapper/heat-map.js +62 -70
- package/dist/view/wrapper/horizontal-bar-group.js +52 -60
- package/dist/view/wrapper/horizontal-bar-stack.js +47 -55
- package/dist/view/wrapper/horizontal-bar.js +41 -49
- package/dist/view/wrapper/index.js +107 -115
- package/dist/view/wrapper/line-group.js +43 -51
- package/dist/view/wrapper/line.js +42 -50
- package/dist/view/wrapper/map-bubble.js +40 -48
- package/dist/view/wrapper/map-world-bubble.js +39 -47
- package/dist/view/wrapper/map-world.js +41 -49
- package/dist/view/wrapper/map.js +42 -50
- package/dist/view/wrapper/mirror.js +41 -49
- package/dist/view/wrapper/pie.js +44 -52
- package/dist/view/wrapper/ring.js +49 -57
- package/dist/view/wrapper/scatter.js +42 -50
- package/dist/view/wrapper/table/index.js +14 -22
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +53 -61
- package/dist/view/wrapper/table/pivot-table-display-name.js +82 -90
- package/dist/view/wrapper/table/two-dimension-table.js +85 -93
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +90 -99
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +23 -32
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/record.js +13 -20
- package/dist/view/wrapper/table-element/components/records-body.js +9 -17
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -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 +25 -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 +6 -16
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +38 -46
- package/dist/view/wrapper/trend.js +58 -66
- package/package.json +5 -5
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
15
|
-
var _constants = require("../../constants");
|
|
16
|
-
var _colorRules = require("../../constants/color-rules");
|
|
17
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
18
|
-
var _utils = require("../../utils");
|
|
19
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
20
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
21
|
-
class AreaGroup extends _chartComponent.default {
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { debounce } from 'lodash-es';
|
|
5
|
+
import { CellType } from 'dtable-utils';
|
|
6
|
+
import * as d3 from 'd3';
|
|
7
|
+
import { CHART_LINE_TYPES, CHART_THEME_COLOR } from '../../constants';
|
|
8
|
+
import { SUPPORT_SINGLE_SELECT_THEMES_OPTIONS } from '../../constants/color-rules';
|
|
9
|
+
import intl from '../../intl';
|
|
10
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
11
|
+
import ToolTip from '../../components/tooltip';
|
|
12
|
+
import ChartComponent from './chart-component';
|
|
13
|
+
class AreaGroup extends ChartComponent {
|
|
22
14
|
constructor(props) {
|
|
23
15
|
super(props);
|
|
24
16
|
this.handleResize = () => {
|
|
@@ -48,10 +40,10 @@ class AreaGroup extends _chartComponent.default {
|
|
|
48
40
|
result: data,
|
|
49
41
|
customRender
|
|
50
42
|
} = this.props;
|
|
51
|
-
data =
|
|
43
|
+
data = BaseUtils.formatEmptyName(data, 'group_name', intl.get('Empty'));
|
|
52
44
|
if (!Array.isArray(data)) return;
|
|
53
45
|
this.draw(data);
|
|
54
|
-
|
|
46
|
+
isFunction(customRender) && customRender(this.chart);
|
|
55
47
|
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
56
48
|
};
|
|
57
49
|
this.draw = data => {
|
|
@@ -63,7 +55,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
63
55
|
chartColorTheme,
|
|
64
56
|
summaryColumn
|
|
65
57
|
} = this.props;
|
|
66
|
-
const theme =
|
|
58
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
67
59
|
const {
|
|
68
60
|
display_goal_line,
|
|
69
61
|
goal_label,
|
|
@@ -89,19 +81,19 @@ class AreaGroup extends _chartComponent.default {
|
|
|
89
81
|
insertPadding,
|
|
90
82
|
marginTop
|
|
91
83
|
} = this.chartBoundingClientRect;
|
|
92
|
-
const useSingleSelectColumnColor = (columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) ===
|
|
84
|
+
const useSingleSelectColumnColor = (columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.SINGLE_SELECT && color_theme === SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
93
85
|
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme, 'group_name', columnGroupbyColumn, chart);
|
|
94
86
|
const tooltipTitle = this.getTitle(tables, table_id, y_axis_summary_type, y_axis_column_key || y_axis_summary_column_key);
|
|
95
87
|
|
|
96
88
|
// Y axis
|
|
97
89
|
const niceEnd = d3.nice(0, d3.max(data, d => d.value), 5)[1];
|
|
98
90
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min || 0, y_axis_max || niceEnd]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
99
|
-
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform',
|
|
91
|
+
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', `translate(${insertPadding}, 0)`).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(summaryColumn, d, y_axis_summary_method))).call(g => this.drawYaxis(g, theme));
|
|
100
92
|
|
|
101
93
|
// X axis
|
|
102
94
|
const xDomain = data.map(item => item.name);
|
|
103
95
|
const x = d3.scaleBand().domain(xDomain).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
104
|
-
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform',
|
|
96
|
+
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', `translate(0, ${chartHeight - insertPadding})`).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
105
97
|
this.ticksAddName(g);
|
|
106
98
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
107
99
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
@@ -128,7 +120,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
128
120
|
circleData[index]['y'] = yVal;
|
|
129
121
|
circleData[index]['value'] = d.value;
|
|
130
122
|
return yVal;
|
|
131
|
-
}).curve(line_type ===
|
|
123
|
+
}).curve(line_type === CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
|
|
132
124
|
contentWrapper.append('path').attr('opacity', 1).attr('fill', 'none').attr('class', 'line').attr('stroke', this.colorMap[group_name]).attr('stroke-width', 2).attr('d', () => line(data));
|
|
133
125
|
circleDatas.push({
|
|
134
126
|
group_name,
|
|
@@ -142,7 +134,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
142
134
|
const area = d3.area().x(d => {
|
|
143
135
|
const xVal = x(d.name) + x.bandwidth() / 2;
|
|
144
136
|
return xVal;
|
|
145
|
-
}).y0(y(0)).y1(d => y(d.value)).curve(line_type ===
|
|
137
|
+
}).y0(y(0)).y1(d => y(d.value)).curve(line_type === CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
|
|
146
138
|
contentWrapper.append('path').attr('class', 'area').attr('fill', this.colorMap[group_name]).attr('d', () => area(data)).attr('opacity', '0.3');
|
|
147
139
|
});
|
|
148
140
|
|
|
@@ -158,13 +150,13 @@ class AreaGroup extends _chartComponent.default {
|
|
|
158
150
|
// circle label
|
|
159
151
|
if (y_axis_show_value) {
|
|
160
152
|
const curCircleEl = g.node();
|
|
161
|
-
contentWrapper.append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size',
|
|
153
|
+
contentWrapper.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(summaryColumn, Number(curCircleEl.getAttribute('data-text')), y_axis_summary_method)).call(g => {
|
|
162
154
|
const {
|
|
163
155
|
width
|
|
164
156
|
} = g.node().getBoundingClientRect();
|
|
165
157
|
const translateX = Number(curCircleEl.getAttribute('cx')) - width / 2;
|
|
166
158
|
const translateY = Number(curCircleEl.getAttribute('cy')) - 10;
|
|
167
|
-
g.attr('transform',
|
|
159
|
+
g.attr('transform', `translate(${translateX}, ${translateY})`);
|
|
168
160
|
});
|
|
169
161
|
}
|
|
170
162
|
}).on('click', (event, data) => {
|
|
@@ -255,7 +247,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
255
247
|
contentWrapper.selectAll('.area').transition().duration(this.areaTransitionDuration).attr('opacity', 0.1);
|
|
256
248
|
contentWrapper.selectAll('.line').transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
|
|
257
249
|
// line
|
|
258
|
-
const theme =
|
|
250
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
259
251
|
this.clearOldVerticalAnnotation(contentWrapper);
|
|
260
252
|
this.addVerticalAnnotation(contentWrapper, minDistanceItem, theme);
|
|
261
253
|
} else {
|
|
@@ -300,11 +292,11 @@ class AreaGroup extends _chartComponent.default {
|
|
|
300
292
|
const newTooltipData = {
|
|
301
293
|
title: title,
|
|
302
294
|
items: data.map(item => {
|
|
303
|
-
const groupName = item.group_name ||
|
|
295
|
+
const groupName = item.group_name || intl.get('Empty');
|
|
304
296
|
return {
|
|
305
297
|
color: this.colorMap[groupName],
|
|
306
298
|
name: groupName,
|
|
307
|
-
value:
|
|
299
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, item.value, y_axis_summary_method)
|
|
308
300
|
};
|
|
309
301
|
}).sort((a, b) => String(a.name).localeCompare(String(b.name), undefined, {
|
|
310
302
|
numeric: true,
|
|
@@ -336,11 +328,11 @@ class AreaGroup extends _chartComponent.default {
|
|
|
336
328
|
const newTooltipData = {
|
|
337
329
|
title: title,
|
|
338
330
|
items: data.map(item => {
|
|
339
|
-
const groupName = item.group_name ||
|
|
331
|
+
const groupName = item.group_name || intl.get('Empty');
|
|
340
332
|
return {
|
|
341
333
|
color: this.colorMap[groupName],
|
|
342
334
|
name: groupName,
|
|
343
|
-
value:
|
|
335
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, item.value, y_axis_summary_method)
|
|
344
336
|
};
|
|
345
337
|
}).sort((a, b) => String(a.name).localeCompare(String(b.name), undefined, {
|
|
346
338
|
numeric: true,
|
|
@@ -371,13 +363,13 @@ class AreaGroup extends _chartComponent.default {
|
|
|
371
363
|
componentDidMount() {
|
|
372
364
|
this.createChart();
|
|
373
365
|
this.drawChart();
|
|
374
|
-
this.debouncedHandleResize =
|
|
366
|
+
this.debouncedHandleResize = debounce(this.handleResize, 300);
|
|
375
367
|
window.addEventListener('resize', this.debouncedHandleResize);
|
|
376
368
|
super.componentDidMount();
|
|
377
369
|
}
|
|
378
370
|
componentDidUpdate(prevProps) {
|
|
379
371
|
super.componentDidUpdate(prevProps);
|
|
380
|
-
if (
|
|
372
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
381
373
|
this.destroyChart();
|
|
382
374
|
this.createChart();
|
|
383
375
|
this.drawChart();
|
|
@@ -396,13 +388,13 @@ class AreaGroup extends _chartComponent.default {
|
|
|
396
388
|
tooltipData,
|
|
397
389
|
toolTipPosition
|
|
398
390
|
} = this.state;
|
|
399
|
-
return /*#__PURE__*/
|
|
391
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
400
392
|
ref: ref => this.container = ref,
|
|
401
|
-
className: (
|
|
393
|
+
className: classNames('sea-chart-container', {
|
|
402
394
|
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
403
395
|
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
404
396
|
})
|
|
405
|
-
}, /*#__PURE__*/
|
|
397
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
406
398
|
tooltipData: tooltipData,
|
|
407
399
|
toolTipPosition: toolTipPosition,
|
|
408
400
|
chart: this.chart
|
|
@@ -410,16 +402,16 @@ class AreaGroup extends _chartComponent.default {
|
|
|
410
402
|
}
|
|
411
403
|
}
|
|
412
404
|
AreaGroup.propTypes = {
|
|
413
|
-
canvasStyle:
|
|
414
|
-
chart:
|
|
415
|
-
groupbyColumn:
|
|
416
|
-
columnGroupbyColumn:
|
|
417
|
-
summaryColumn:
|
|
418
|
-
result:
|
|
419
|
-
tables:
|
|
420
|
-
globalTheme:
|
|
421
|
-
chartColorTheme:
|
|
422
|
-
toggleRecords:
|
|
423
|
-
customRender:
|
|
405
|
+
canvasStyle: PropTypes.object,
|
|
406
|
+
chart: PropTypes.object,
|
|
407
|
+
groupbyColumn: PropTypes.object,
|
|
408
|
+
columnGroupbyColumn: PropTypes.object,
|
|
409
|
+
summaryColumn: PropTypes.object,
|
|
410
|
+
result: PropTypes.array,
|
|
411
|
+
tables: PropTypes.array,
|
|
412
|
+
globalTheme: PropTypes.string,
|
|
413
|
+
chartColorTheme: PropTypes.string,
|
|
414
|
+
toggleRecords: PropTypes.func,
|
|
415
|
+
customRender: PropTypes.func
|
|
424
416
|
};
|
|
425
|
-
|
|
417
|
+
export default AreaGroup;
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _lodashEs = require("lodash-es");
|
|
13
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
16
|
-
var _utils = require("../../utils");
|
|
17
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
18
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
19
|
-
class Area extends _chartComponent.default {
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { debounce } from 'lodash-es';
|
|
5
|
+
import * as d3 from 'd3';
|
|
6
|
+
import { CHART_LINE_TYPES, CHART_STYLE_COLORS, CHART_THEME_COLOR, TYPE_COLOR_USING } from '../../constants';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
9
|
+
import ToolTip from '../../components/tooltip';
|
|
10
|
+
import ChartComponent from './chart-component';
|
|
11
|
+
class Area extends ChartComponent {
|
|
20
12
|
constructor(props) {
|
|
21
13
|
super(props);
|
|
22
14
|
this.handleResize = () => {
|
|
@@ -46,10 +38,10 @@ class Area extends _chartComponent.default {
|
|
|
46
38
|
result: data,
|
|
47
39
|
customRender
|
|
48
40
|
} = this.props;
|
|
49
|
-
data =
|
|
41
|
+
data = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
50
42
|
if (!Array.isArray(data)) return;
|
|
51
43
|
this.draw(data);
|
|
52
|
-
|
|
44
|
+
isFunction(customRender) && customRender(this.chart);
|
|
53
45
|
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
54
46
|
};
|
|
55
47
|
this.draw = data => {
|
|
@@ -59,7 +51,7 @@ class Area extends _chartComponent.default {
|
|
|
59
51
|
tables,
|
|
60
52
|
summaryColumn
|
|
61
53
|
} = this.props;
|
|
62
|
-
const theme =
|
|
54
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
63
55
|
const {
|
|
64
56
|
display_goal_line,
|
|
65
57
|
goal_label,
|
|
@@ -89,12 +81,12 @@ class Area extends _chartComponent.default {
|
|
|
89
81
|
// Y axis
|
|
90
82
|
const niceEnd = d3.nice(0, d3.max(data, d => d.value), 5)[1];
|
|
91
83
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min || 0, y_axis_max || niceEnd]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
92
|
-
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform',
|
|
84
|
+
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', `translate(${insertPadding}, 0)`).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(summaryColumn, d, y_axis_summary_method))).call(g => this.drawYaxis(g, theme));
|
|
93
85
|
|
|
94
86
|
// X axis
|
|
95
87
|
const xDomain = data.map(item => item.name);
|
|
96
88
|
const x = d3.scaleBand().domain(xDomain).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
97
|
-
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform',
|
|
89
|
+
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', `translate(0, ${chartHeight - insertPadding})`).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
98
90
|
this.ticksAddName(g);
|
|
99
91
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
100
92
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
@@ -116,14 +108,14 @@ class Area extends _chartComponent.default {
|
|
|
116
108
|
circleData[index]['y'] = yVal;
|
|
117
109
|
circleData[index]['value'] = d.value;
|
|
118
110
|
return yVal;
|
|
119
|
-
}).curve(line_type ===
|
|
111
|
+
}).curve(line_type === CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
|
|
120
112
|
this.Line = contentWrapper.append('path').attr('opacity', 1).attr('fill', 'none').attr('stroke', this.getAreaColor()).attr('stroke-width', 2).attr('d', () => line(data));
|
|
121
113
|
|
|
122
114
|
// Area
|
|
123
115
|
const area = d3.area().x(d => {
|
|
124
116
|
const xVal = x(d.name) + x.bandwidth() / 2;
|
|
125
117
|
return xVal;
|
|
126
|
-
}).y0(y(0)).y1(d => y(d.value)).curve(line_type ===
|
|
118
|
+
}).y0(y(0)).y1(d => y(d.value)).curve(line_type === CHART_LINE_TYPES[1] ? d3.curveBumpX : d3.curveLinear);
|
|
127
119
|
this.Area = contentWrapper.append('path').attr('fill', this.getAreaColor()).attr('d', () => area(data)).attr('opacity', '0.3');
|
|
128
120
|
|
|
129
121
|
// circle
|
|
@@ -132,13 +124,13 @@ class Area extends _chartComponent.default {
|
|
|
132
124
|
// circle label
|
|
133
125
|
if (y_axis_show_value) {
|
|
134
126
|
const curCircleEl = g.node();
|
|
135
|
-
contentWrapper.append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size',
|
|
127
|
+
contentWrapper.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(summaryColumn, Number(curCircleEl.getAttribute('data-text')), y_axis_summary_method)).call(g => {
|
|
136
128
|
const {
|
|
137
129
|
width
|
|
138
130
|
} = g.node().getBoundingClientRect();
|
|
139
131
|
const translateX = Number(curCircleEl.getAttribute('cx')) - width / 2;
|
|
140
132
|
const translateY = Number(curCircleEl.getAttribute('cy')) - 10;
|
|
141
|
-
g.attr('transform',
|
|
133
|
+
g.attr('transform', `translate(${translateX}, ${translateY})`);
|
|
142
134
|
});
|
|
143
135
|
}
|
|
144
136
|
}).on('click', (event, data) => {
|
|
@@ -214,7 +206,7 @@ class Area extends _chartComponent.default {
|
|
|
214
206
|
this.Area.transition().duration(this.areaTransitionDuration).attr('opacity', 0.1);
|
|
215
207
|
this.Line.transition().duration(this.areaTransitionDuration).attr('opacity', 0.3);
|
|
216
208
|
// line
|
|
217
|
-
const theme =
|
|
209
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
218
210
|
this.clearOldVerticalAnnotation(contentWrapper);
|
|
219
211
|
this.addVerticalAnnotation(contentWrapper, minDistanceItem, theme);
|
|
220
212
|
} else {
|
|
@@ -261,7 +253,7 @@ class Area extends _chartComponent.default {
|
|
|
261
253
|
items: [{
|
|
262
254
|
color: this.getAreaColor(),
|
|
263
255
|
name: data.name,
|
|
264
|
-
value:
|
|
256
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, data.value, y_axis_summary_method)
|
|
265
257
|
}]
|
|
266
258
|
};
|
|
267
259
|
this.setState({
|
|
@@ -291,7 +283,7 @@ class Area extends _chartComponent.default {
|
|
|
291
283
|
items: [{
|
|
292
284
|
color: this.getAreaColor(),
|
|
293
285
|
name: data.name,
|
|
294
|
-
value:
|
|
286
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, data.value, y_axis_summary_method)
|
|
295
287
|
}]
|
|
296
288
|
};
|
|
297
289
|
this.setState({
|
|
@@ -318,11 +310,11 @@ class Area extends _chartComponent.default {
|
|
|
318
310
|
y_axis_label_color,
|
|
319
311
|
color_option
|
|
320
312
|
} = chart.config;
|
|
321
|
-
let chartBarColor =
|
|
313
|
+
let chartBarColor = CHART_STYLE_COLORS[0];
|
|
322
314
|
if (chartColorTheme) {
|
|
323
|
-
chartBarColor =
|
|
315
|
+
chartBarColor = BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
|
|
324
316
|
}
|
|
325
|
-
if (color_option ===
|
|
317
|
+
if (color_option === TYPE_COLOR_USING.USE_SPECIFIC_COLORS && y_axis_label_color) {
|
|
326
318
|
chartBarColor = y_axis_label_color;
|
|
327
319
|
}
|
|
328
320
|
return chartBarColor;
|
|
@@ -336,13 +328,13 @@ class Area extends _chartComponent.default {
|
|
|
336
328
|
componentDidMount() {
|
|
337
329
|
this.createChart();
|
|
338
330
|
this.drawChart();
|
|
339
|
-
this.debouncedHandleResize =
|
|
331
|
+
this.debouncedHandleResize = debounce(this.handleResize, 300);
|
|
340
332
|
window.addEventListener('resize', this.debouncedHandleResize);
|
|
341
333
|
super.componentDidMount();
|
|
342
334
|
}
|
|
343
335
|
componentDidUpdate(prevProps) {
|
|
344
336
|
super.componentDidUpdate(prevProps);
|
|
345
|
-
if (
|
|
337
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
346
338
|
this.destroyChart();
|
|
347
339
|
this.createChart();
|
|
348
340
|
this.drawChart();
|
|
@@ -361,13 +353,13 @@ class Area extends _chartComponent.default {
|
|
|
361
353
|
tooltipData,
|
|
362
354
|
toolTipPosition
|
|
363
355
|
} = this.state;
|
|
364
|
-
return /*#__PURE__*/
|
|
356
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
365
357
|
ref: ref => this.container = ref,
|
|
366
|
-
className: (
|
|
358
|
+
className: classNames('sea-chart-container', {
|
|
367
359
|
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
368
360
|
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
369
361
|
})
|
|
370
|
-
}, /*#__PURE__*/
|
|
362
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
371
363
|
tooltipData: tooltipData,
|
|
372
364
|
toolTipPosition: toolTipPosition,
|
|
373
365
|
chart: this.chart
|
|
@@ -375,16 +367,16 @@ class Area extends _chartComponent.default {
|
|
|
375
367
|
}
|
|
376
368
|
}
|
|
377
369
|
Area.propTypes = {
|
|
378
|
-
canvasStyle:
|
|
379
|
-
chart:
|
|
380
|
-
groupbyColumn:
|
|
381
|
-
columnGroupbyColumn:
|
|
382
|
-
summaryColumn:
|
|
383
|
-
result:
|
|
384
|
-
tables:
|
|
385
|
-
globalTheme:
|
|
386
|
-
chartColorTheme:
|
|
387
|
-
toggleRecords:
|
|
388
|
-
customRender:
|
|
370
|
+
canvasStyle: PropTypes.object,
|
|
371
|
+
chart: PropTypes.object,
|
|
372
|
+
groupbyColumn: PropTypes.object,
|
|
373
|
+
columnGroupbyColumn: PropTypes.object,
|
|
374
|
+
summaryColumn: PropTypes.object,
|
|
375
|
+
result: PropTypes.array,
|
|
376
|
+
tables: PropTypes.array,
|
|
377
|
+
globalTheme: PropTypes.string,
|
|
378
|
+
chartColorTheme: PropTypes.string,
|
|
379
|
+
toggleRecords: PropTypes.func,
|
|
380
|
+
customRender: PropTypes.func
|
|
389
381
|
};
|
|
390
|
-
|
|
382
|
+
export default Area;
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
var _dtableUtils = require("dtable-utils");
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
var _chartUtils = require("../../utils/chart-utils");
|
|
16
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
17
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
18
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
19
|
-
class BarCompare extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { getNumberDisplayString } from 'dtable-utils';
|
|
6
|
+
import { CHART_SUMMARY_SHOW, TITLE_AMOUNT, TITLE_INCREASE, CHART_THEME_COLOR } from '../../constants';
|
|
7
|
+
import { BaseUtils } from '../../utils/chart-utils';
|
|
8
|
+
import intl from '../../intl';
|
|
9
|
+
import ToolTip from '../../components/tooltip';
|
|
10
|
+
import ChartComponent from './chart-component';
|
|
11
|
+
class BarCompare extends ChartComponent {
|
|
20
12
|
constructor(props) {
|
|
21
13
|
super(props);
|
|
22
14
|
this.createChart = () => {
|
|
@@ -39,7 +31,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
39
31
|
let {
|
|
40
32
|
result: data
|
|
41
33
|
} = this.props;
|
|
42
|
-
data =
|
|
34
|
+
data = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
43
35
|
if (!Array.isArray(data)) return;
|
|
44
36
|
this.draw(data);
|
|
45
37
|
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
@@ -51,7 +43,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
51
43
|
chartColorTheme,
|
|
52
44
|
columnGroupbyColumn
|
|
53
45
|
} = this.props;
|
|
54
|
-
const theme =
|
|
46
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
55
47
|
const {
|
|
56
48
|
display_increase,
|
|
57
49
|
y_axis_auto_range = true,
|
|
@@ -68,13 +60,13 @@ class BarCompare extends _chartComponent.default {
|
|
|
68
60
|
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, d3.max(data, d => d.value)] : [y_axis_min, y_axis_max]).range([chartHeight - insertPadding, insertPadding]);
|
|
69
61
|
|
|
70
62
|
// Y axis
|
|
71
|
-
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform',
|
|
63
|
+
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', `translate(${insertPadding},0)`).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(columnGroupbyColumn, d, y_axis_summary_method))).call(g => this.drawYaxis(g, theme));
|
|
72
64
|
const fx = d3.scaleBand().domain(d3.group(data, d => d.name).keys()).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
73
|
-
const color = d3.scaleOrdinal().domain(d3.group(data, d => d.group_name).keys()).range(
|
|
65
|
+
const color = d3.scaleOrdinal().domain(d3.group(data, d => d.group_name).keys()).range(BaseUtils.getCurrentTheme(chartColorTheme).colors).unknown('#ccc');
|
|
74
66
|
const x = d3.scaleBand().domain(d3.group(data, d => d.group_name).keys()).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
75
67
|
|
|
76
68
|
// X axis
|
|
77
|
-
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform',
|
|
69
|
+
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 => {
|
|
78
70
|
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
79
71
|
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
80
72
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
@@ -87,7 +79,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
87
79
|
let [name, dum] = _ref;
|
|
88
80
|
// Each group is horizontally centered
|
|
89
81
|
const offset = (fx.bandwidth() - dum.length * x.bandwidth()) / 2;
|
|
90
|
-
return
|
|
82
|
+
return `translate(${fx(name) + offset},0)`;
|
|
91
83
|
})
|
|
92
84
|
// rect item
|
|
93
85
|
.selectAll().data(_ref2 => {
|
|
@@ -140,7 +132,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
140
132
|
if (isCircle) {
|
|
141
133
|
const circleEl = event.target;
|
|
142
134
|
newTooltipData = {
|
|
143
|
-
title:
|
|
135
|
+
title: intl.get(TITLE_INCREASE),
|
|
144
136
|
items: [{
|
|
145
137
|
color: increase_line_color || '#fbd44a',
|
|
146
138
|
name: circleEl.getAttribute('data-name'),
|
|
@@ -151,7 +143,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
151
143
|
const curGroup = event.target.parentNode;
|
|
152
144
|
const [, data] = curGroup.__data__;
|
|
153
145
|
newTooltipData = {
|
|
154
|
-
title: y_axis_summary_type === 'count' ?
|
|
146
|
+
title: y_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]),
|
|
155
147
|
items: data.map(item => {
|
|
156
148
|
return {
|
|
157
149
|
color: colorScale(item.group_name),
|
|
@@ -193,7 +185,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
193
185
|
chart,
|
|
194
186
|
globalTheme
|
|
195
187
|
} = this.props;
|
|
196
|
-
const theme =
|
|
188
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
197
189
|
const {
|
|
198
190
|
label_font_size,
|
|
199
191
|
y_axis_min,
|
|
@@ -248,13 +240,13 @@ class BarCompare extends _chartComponent.default {
|
|
|
248
240
|
// circle label
|
|
249
241
|
if (display_increase_percentage) {
|
|
250
242
|
const curCircleEl = g.node();
|
|
251
|
-
wrapper.append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size',
|
|
243
|
+
wrapper.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(curCircleEl.getAttribute('data-text')).call(g => {
|
|
252
244
|
const {
|
|
253
245
|
width
|
|
254
246
|
} = g.node().getBoundingClientRect();
|
|
255
247
|
const translateX = Number(curCircleEl.getAttribute('cx')) - width / 2;
|
|
256
248
|
const translateY = Number(curCircleEl.getAttribute('cy')) - 10;
|
|
257
|
-
g.attr('transform',
|
|
249
|
+
g.attr('transform', `translate(${translateX}, ${translateY})`);
|
|
258
250
|
});
|
|
259
251
|
}
|
|
260
252
|
}).on('mouseover', event => {
|
|
@@ -275,7 +267,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
275
267
|
const increaseValue = value.filter(d => (d === null || d === void 0 ? void 0 : d.increase_value) !== undefined) || [{
|
|
276
268
|
increaseValue: 0
|
|
277
269
|
}];
|
|
278
|
-
const formatValue =
|
|
270
|
+
const formatValue = getNumberDisplayString((_increaseValue$ = increaseValue[0]) === null || _increaseValue$ === void 0 ? void 0 : _increaseValue$.increase_value, {
|
|
279
271
|
format: 'percent'
|
|
280
272
|
});
|
|
281
273
|
const data = {
|
|
@@ -314,7 +306,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
314
306
|
}
|
|
315
307
|
componentDidUpdate(prevProps) {
|
|
316
308
|
super.componentDidUpdate(prevProps);
|
|
317
|
-
if (
|
|
309
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
318
310
|
this.destroyChart();
|
|
319
311
|
this.createChart();
|
|
320
312
|
this.drawChart();
|
|
@@ -331,13 +323,13 @@ class BarCompare extends _chartComponent.default {
|
|
|
331
323
|
tooltipData,
|
|
332
324
|
toolTipPosition
|
|
333
325
|
} = this.state;
|
|
334
|
-
return /*#__PURE__*/
|
|
326
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
335
327
|
ref: ref => this.container = ref,
|
|
336
|
-
className: (
|
|
328
|
+
className: classNames('sea-chart-container', {
|
|
337
329
|
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
338
330
|
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
339
331
|
})
|
|
340
|
-
}, /*#__PURE__*/
|
|
332
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
341
333
|
tooltipData: tooltipData,
|
|
342
334
|
toolTipPosition: toolTipPosition,
|
|
343
335
|
chart: this.chart
|
|
@@ -345,15 +337,15 @@ class BarCompare extends _chartComponent.default {
|
|
|
345
337
|
}
|
|
346
338
|
}
|
|
347
339
|
BarCompare.propTypes = {
|
|
348
|
-
canvasStyle:
|
|
349
|
-
chart:
|
|
350
|
-
groupbyColumn:
|
|
351
|
-
columnGroupbyColumn:
|
|
352
|
-
summaryColumn:
|
|
353
|
-
result:
|
|
354
|
-
tables:
|
|
355
|
-
globalTheme:
|
|
356
|
-
chartColorTheme:
|
|
357
|
-
toggleRecords:
|
|
340
|
+
canvasStyle: PropTypes.object,
|
|
341
|
+
chart: PropTypes.object,
|
|
342
|
+
groupbyColumn: PropTypes.object,
|
|
343
|
+
columnGroupbyColumn: PropTypes.object,
|
|
344
|
+
summaryColumn: PropTypes.object,
|
|
345
|
+
result: PropTypes.array,
|
|
346
|
+
tables: PropTypes.array,
|
|
347
|
+
globalTheme: PropTypes.string,
|
|
348
|
+
chartColorTheme: PropTypes.string,
|
|
349
|
+
toggleRecords: PropTypes.func
|
|
358
350
|
};
|
|
359
|
-
|
|
351
|
+
export default BarCompare;
|