sea-chart 2.0.40 → 2.0.42
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 +63 -72
- 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 +325 -333
- 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 +45 -52
- 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 +49 -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 +126 -133
- 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 +54 -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 +51 -53
- 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 +102 -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/css/index.css +79 -0
- 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 +1 -1
|
@@ -1,33 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _dtableUtils = require("dtable-utils");
|
|
13
|
-
var _utils = require("../../utils");
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
var _style = require("../../constants/style");
|
|
16
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
17
|
-
require("../../assets/css/sea-chart-d3-tooltip.css");
|
|
18
|
-
class ChartComponent extends _react.Component {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import { cloneDeep, debounce } from 'lodash-es';
|
|
5
|
+
import { getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
6
|
+
import { BaseUtils, formatXAxisLabel } from '../../utils';
|
|
7
|
+
import { CHART_TYPE, CHART_SUMMARY_TYPE, LABEL_POSITION_TYPE, CHART_THEME_COLOR, EMPTY_NAME, THEME_NAME_MAP, CHART_STYLE_COLORS } from '../../constants';
|
|
8
|
+
import { FILL_BORDER_COLOR_MAP } from '../../constants/style';
|
|
9
|
+
import intl from '../../intl';
|
|
10
|
+
import '../../assets/css/sea-chart-d3-tooltip.css';
|
|
11
|
+
export default class ChartComponent extends Component {
|
|
19
12
|
constructor(props) {
|
|
20
13
|
var _this;
|
|
21
14
|
super(props);
|
|
22
15
|
_this = this;
|
|
23
16
|
this.initLabelStroke = theme => {
|
|
24
|
-
this.globalTheme = theme ||
|
|
25
|
-
this.labelStroke = theme ===
|
|
17
|
+
this.globalTheme = theme || THEME_NAME_MAP.LIGHT;
|
|
18
|
+
this.labelStroke = theme === THEME_NAME_MAP.DARK ? {} : {
|
|
26
19
|
stroke: '#fff',
|
|
27
20
|
lineWidth: 1
|
|
28
21
|
};
|
|
29
22
|
};
|
|
30
|
-
this.handleResize =
|
|
23
|
+
this.handleResize = debounce(() => {
|
|
31
24
|
if (!this.createChart || !this.drawChart) return;
|
|
32
25
|
this.destroyChart();
|
|
33
26
|
this.createChart();
|
|
@@ -40,11 +33,11 @@ class ChartComponent extends _react.Component {
|
|
|
40
33
|
this.chart && this.chart.node() && this.chart.node().remove();
|
|
41
34
|
};
|
|
42
35
|
this.getTitle = (tables, table_id, yAxisType, yAxisKey) => {
|
|
43
|
-
return yAxisType ===
|
|
36
|
+
return yAxisType === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : this.getAxisLabel(tables, table_id, yAxisKey);
|
|
44
37
|
};
|
|
45
38
|
this.getColumn = (tables, table_id, columnKey) => {
|
|
46
|
-
const table =
|
|
47
|
-
const column =
|
|
39
|
+
const table = getTableById(tables, table_id);
|
|
40
|
+
const column = getTableColumnByKey(table, columnKey) || {};
|
|
48
41
|
return column;
|
|
49
42
|
};
|
|
50
43
|
this.getAxisLabel = (tables, tableId, columnKey) => {
|
|
@@ -85,7 +78,7 @@ class ChartComponent extends _react.Component {
|
|
|
85
78
|
width,
|
|
86
79
|
height
|
|
87
80
|
} = this.chartBoundingClientRect;
|
|
88
|
-
this.chart.append('defs').append('mask').attr('id',
|
|
81
|
+
this.chart.append('defs').append('mask').attr('id', `mask-wrapper-${previewType}-${this.chart.node().id}`).append('rect').attr('x', 0).attr('y', 0).attr('width', width).attr('height', height - 30).attr('fill', 'white');
|
|
89
82
|
}
|
|
90
83
|
};
|
|
91
84
|
this.getChartDisplayLabels = (containerWidth, minItemWidth, charts) => {
|
|
@@ -107,7 +100,7 @@ class ChartComponent extends _react.Component {
|
|
|
107
100
|
if (item.group_name === 'rest' && isCompleteness) return;
|
|
108
101
|
const groupData = chartGroupData.find(g => g.name === item.name);
|
|
109
102
|
if (!groupData) {
|
|
110
|
-
const newItem =
|
|
103
|
+
const newItem = cloneDeep(item);
|
|
111
104
|
newItem.currentGroupCount = 1;
|
|
112
105
|
chartGroupData.push(newItem);
|
|
113
106
|
} else {
|
|
@@ -161,13 +154,13 @@ class ChartComponent extends _react.Component {
|
|
|
161
154
|
// mark the first item in each group,but if item value is 0, mark the next item
|
|
162
155
|
let targetMarkItem = item[0],
|
|
163
156
|
i = 1;
|
|
164
|
-
while (!((_targetMarkItem = targetMarkItem)
|
|
157
|
+
while (!((_targetMarkItem = targetMarkItem) === null || _targetMarkItem === void 0 ? void 0 : _targetMarkItem.value) && !Number.isNaN((_targetMarkItem2 = targetMarkItem) === null || _targetMarkItem2 === void 0 ? void 0 : _targetMarkItem2.value)) {
|
|
165
158
|
var _targetMarkItem, _targetMarkItem2;
|
|
166
159
|
targetMarkItem = item[i];
|
|
167
160
|
i++;
|
|
168
161
|
if (i >= item.length) break;
|
|
169
162
|
}
|
|
170
|
-
if (!((_targetMarkItem3 = targetMarkItem)
|
|
163
|
+
if (!((_targetMarkItem3 = targetMarkItem) === null || _targetMarkItem3 === void 0 ? void 0 : _targetMarkItem3.value)) return;
|
|
171
164
|
targetMarkItem.isFirst = 1;
|
|
172
165
|
} else if (position === 'last') {
|
|
173
166
|
var _targetMarkItem6;
|
|
@@ -175,13 +168,13 @@ class ChartComponent extends _react.Component {
|
|
|
175
168
|
const l = item.length;
|
|
176
169
|
let targetMarkItem = item[l - 1],
|
|
177
170
|
i = l - 2;
|
|
178
|
-
while (!((_targetMarkItem4 = targetMarkItem)
|
|
171
|
+
while (!((_targetMarkItem4 = targetMarkItem) === null || _targetMarkItem4 === void 0 ? void 0 : _targetMarkItem4.value) && !Number.isNaN((_targetMarkItem5 = targetMarkItem) === null || _targetMarkItem5 === void 0 ? void 0 : _targetMarkItem5.value)) {
|
|
179
172
|
var _targetMarkItem4, _targetMarkItem5;
|
|
180
173
|
targetMarkItem = item[i];
|
|
181
174
|
i--;
|
|
182
175
|
if (i < 0) break;
|
|
183
176
|
}
|
|
184
|
-
if (!((_targetMarkItem6 = targetMarkItem)
|
|
177
|
+
if (!((_targetMarkItem6 = targetMarkItem) === null || _targetMarkItem6 === void 0 ? void 0 : _targetMarkItem6.value)) return;
|
|
185
178
|
targetMarkItem.isLast = 1;
|
|
186
179
|
} else {
|
|
187
180
|
console.error('on markFirstOrLast: unknown position');
|
|
@@ -243,13 +236,13 @@ class ChartComponent extends _react.Component {
|
|
|
243
236
|
if (y_axis_summary_column_key) {
|
|
244
237
|
y_axis_column_key = y_axis_summary_column_key;
|
|
245
238
|
}
|
|
246
|
-
const table =
|
|
239
|
+
const table = getTableById(tables, table_id);
|
|
247
240
|
let textColor;
|
|
248
|
-
this.globalTheme ===
|
|
241
|
+
this.globalTheme === THEME_NAME_MAP.DARK ? textColor = '#fff' : textColor = '#999';
|
|
249
242
|
|
|
250
243
|
// xAxis
|
|
251
|
-
const xAxisID =
|
|
252
|
-
const xLabel = chartContainer === null || chartContainer === void 0 ? void 0 : chartContainer.querySelector(
|
|
244
|
+
const xAxisID = `chart-x-axis-label_${chart.id}`;
|
|
245
|
+
const xLabel = chartContainer === null || chartContainer === void 0 ? void 0 : chartContainer.querySelector(`#${xAxisID}`);
|
|
253
246
|
const {
|
|
254
247
|
width: containerWidth
|
|
255
248
|
} = this.chartBoundingClientRect;
|
|
@@ -257,33 +250,33 @@ class ChartComponent extends _react.Component {
|
|
|
257
250
|
const div = document.createElement('div');
|
|
258
251
|
div.id = xAxisID;
|
|
259
252
|
div.className = 'chart-axis-label';
|
|
260
|
-
const column =
|
|
261
|
-
div.innerHTML =
|
|
262
|
-
div.setAttribute('style',
|
|
253
|
+
const column = getTableColumnByKey(table, x_axis_column_key);
|
|
254
|
+
div.innerHTML = `${column ? column.name : ''}`;
|
|
255
|
+
div.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
|
|
263
256
|
chartContainer.appendChild(div);
|
|
264
257
|
}
|
|
265
258
|
if (xLabel && x_axis_show_label) {
|
|
266
|
-
xLabel.setAttribute('style',
|
|
259
|
+
xLabel.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
|
|
267
260
|
}
|
|
268
261
|
if (xLabel && !x_axis_show_label) {
|
|
269
262
|
xLabel.parentNode.removeChild(xLabel);
|
|
270
263
|
}
|
|
271
264
|
|
|
272
265
|
// yAxis
|
|
273
|
-
const yAxisID =
|
|
274
|
-
const yLabel = chartContainer.querySelector(
|
|
266
|
+
const yAxisID = `chart-y-axis-label_${chart.id}`;
|
|
267
|
+
const yLabel = chartContainer.querySelector(`#${yAxisID}`);
|
|
275
268
|
const divHeight = 20;
|
|
276
269
|
if (!yLabel && y_axis_show_label) {
|
|
277
270
|
const div = document.createElement('div');
|
|
278
271
|
div.id = yAxisID;
|
|
279
272
|
div.className = 'chart-axis-label';
|
|
280
273
|
// SCATTER always has y_axis_column_key
|
|
281
|
-
if (y_axis_summary_type ===
|
|
282
|
-
div.innerHTML =
|
|
274
|
+
if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT && type !== CHART_TYPE.SCATTER) {
|
|
275
|
+
div.innerHTML = intl.get('Amount');
|
|
283
276
|
} else {
|
|
284
|
-
const column =
|
|
277
|
+
const column = getTableColumnByKey(table, y_axis_column_key) || {};
|
|
285
278
|
div.innerHTML = column.name || '';
|
|
286
|
-
if (type ===
|
|
279
|
+
if (type === CHART_TYPE.BAR_STACK) {
|
|
287
280
|
div.innerHTML = title_name || '';
|
|
288
281
|
}
|
|
289
282
|
}
|
|
@@ -291,9 +284,9 @@ class ChartComponent extends _react.Component {
|
|
|
291
284
|
height: containerHeight
|
|
292
285
|
} = this.chartBoundingClientRect;
|
|
293
286
|
let textAlign = 'center';
|
|
294
|
-
if (y_axis_label_position ===
|
|
295
|
-
if (y_axis_label_position ===
|
|
296
|
-
div.setAttribute('style',
|
|
287
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
288
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
289
|
+
div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
|
|
297
290
|
chartContainer.appendChild(div);
|
|
298
291
|
}
|
|
299
292
|
if (yLabel && y_axis_show_label) {
|
|
@@ -301,32 +294,32 @@ class ChartComponent extends _react.Component {
|
|
|
301
294
|
height: containerHeight
|
|
302
295
|
} = this.chartBoundingClientRect;
|
|
303
296
|
let textAlign = 'center';
|
|
304
|
-
if (y_axis_label_position ===
|
|
305
|
-
if (y_axis_label_position ===
|
|
306
|
-
yLabel.setAttribute('style',
|
|
297
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
298
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
299
|
+
yLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
|
|
307
300
|
}
|
|
308
301
|
if (yLabel && !y_axis_show_label) {
|
|
309
302
|
yLabel.parentNode.removeChild(yLabel);
|
|
310
303
|
}
|
|
311
304
|
|
|
312
305
|
// yAxis(left) - combination chart
|
|
313
|
-
const yAxisLeftID =
|
|
314
|
-
const yAxisLeftLabel = chartContainer.querySelector(
|
|
306
|
+
const yAxisLeftID = `chart-y-axis-left-label_${chart.id}`;
|
|
307
|
+
const yAxisLeftLabel = chartContainer.querySelector(`#${yAxisLeftID}`);
|
|
315
308
|
if (!yAxisLeftLabel && show_y_axis_left_label) {
|
|
316
309
|
const div = document.createElement('div');
|
|
317
310
|
div.id = yAxisLeftID;
|
|
318
311
|
div.className = 'chart-axis-label text-truncate';
|
|
319
|
-
if (y_axis_left_summary_type ===
|
|
320
|
-
div.innerHTML =
|
|
312
|
+
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
313
|
+
div.innerHTML = intl.get('Amount');
|
|
321
314
|
} else {
|
|
322
|
-
const column =
|
|
315
|
+
const column = getTableColumnByKey(table, y_axis_left_summary_column) || {};
|
|
323
316
|
div.innerHTML = column.name || '';
|
|
324
317
|
}
|
|
325
318
|
const containerHeight = chartContainer.offsetHeight;
|
|
326
319
|
let textAlign = 'center';
|
|
327
|
-
if (y_axis_left_label_position ===
|
|
328
|
-
if (y_axis_left_label_position ===
|
|
329
|
-
div.setAttribute('style',
|
|
320
|
+
if (y_axis_left_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
321
|
+
if (y_axis_left_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
322
|
+
div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
|
|
330
323
|
chartContainer.appendChild(div);
|
|
331
324
|
}
|
|
332
325
|
if (yAxisLeftLabel && show_y_axis_left_label) {
|
|
@@ -334,30 +327,30 @@ class ChartComponent extends _react.Component {
|
|
|
334
327
|
let textAlign = 'center';
|
|
335
328
|
if (y_axis_left_label_position === 'bottom') textAlign = 'left';
|
|
336
329
|
if (y_axis_left_label_position === 'top') textAlign = 'right';
|
|
337
|
-
yAxisLeftLabel.setAttribute('style',
|
|
330
|
+
yAxisLeftLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
|
|
338
331
|
}
|
|
339
332
|
if (yAxisLeftLabel && !show_y_axis_left_label) {
|
|
340
333
|
yAxisLeftLabel.parentNode.removeChild(yAxisLeftLabel);
|
|
341
334
|
}
|
|
342
335
|
|
|
343
336
|
// yAxis(right) - combination chart
|
|
344
|
-
const yAxisRightID =
|
|
345
|
-
const yAxisRightLabel = chartContainer.querySelector(
|
|
337
|
+
const yAxisRightID = `chart-y-axis-right-label_${chart.id}`;
|
|
338
|
+
const yAxisRightLabel = chartContainer.querySelector(`#${yAxisRightID}`);
|
|
346
339
|
if (!yAxisRightLabel && show_y_axis_right_label) {
|
|
347
340
|
const div = document.createElement('div');
|
|
348
341
|
div.id = yAxisRightID;
|
|
349
342
|
div.className = 'chart-axis-label text-truncate';
|
|
350
|
-
if (y_axis_right_summary_type ===
|
|
351
|
-
div.innerHTML =
|
|
343
|
+
if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
344
|
+
div.innerHTML = intl.get('Amount');
|
|
352
345
|
} else {
|
|
353
|
-
const column =
|
|
346
|
+
const column = getTableColumnByKey(table, y_axis_right_summary_column) || {};
|
|
354
347
|
div.innerHTML = column.name || '';
|
|
355
348
|
}
|
|
356
349
|
const containerHeight = chartContainer.offsetHeight;
|
|
357
350
|
let textAlign = 'center';
|
|
358
|
-
if (y_axis_right_label_position ===
|
|
359
|
-
if (y_axis_right_label_position ===
|
|
360
|
-
div.setAttribute('style',
|
|
351
|
+
if (y_axis_right_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
352
|
+
if (y_axis_right_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
353
|
+
div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: translate(${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
|
|
361
354
|
chartContainer.appendChild(div);
|
|
362
355
|
}
|
|
363
356
|
if (yAxisRightLabel && show_y_axis_right_label) {
|
|
@@ -365,7 +358,7 @@ class ChartComponent extends _react.Component {
|
|
|
365
358
|
let textAlign = 'center';
|
|
366
359
|
if (y_axis_right_label_position === 'bottom') textAlign = 'left';
|
|
367
360
|
if (y_axis_right_label_position === 'top') textAlign = 'right';
|
|
368
|
-
yAxisRightLabel.setAttribute('style',
|
|
361
|
+
yAxisRightLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: translate(${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
|
|
369
362
|
}
|
|
370
363
|
if (yAxisRightLabel && !show_y_axis_right_label) {
|
|
371
364
|
yAxisRightLabel.parentNode.removeChild(yAxisRightLabel);
|
|
@@ -383,10 +376,10 @@ class ChartComponent extends _react.Component {
|
|
|
383
376
|
show_vertical_axis_label,
|
|
384
377
|
show_horizontal_axis_label
|
|
385
378
|
} = chart.config;
|
|
386
|
-
const table =
|
|
379
|
+
const table = getTableById(tables, table_id);
|
|
387
380
|
const textColor = '#999999';
|
|
388
|
-
const xAxisID =
|
|
389
|
-
const xLabel = chartContainer.querySelector(
|
|
381
|
+
const xAxisID = `chart-x-axis-label_${chart.id}`;
|
|
382
|
+
const xLabel = chartContainer.querySelector(`#${xAxisID}`);
|
|
390
383
|
const {
|
|
391
384
|
width: containerWidth
|
|
392
385
|
} = this.chartBoundingClientRect;
|
|
@@ -394,37 +387,37 @@ class ChartComponent extends _react.Component {
|
|
|
394
387
|
const div = document.createElement('div');
|
|
395
388
|
div.id = xAxisID;
|
|
396
389
|
div.className = 'chart-axis-label';
|
|
397
|
-
if (horizontal_axis_summary_type ===
|
|
398
|
-
div.innerHTML =
|
|
390
|
+
if (horizontal_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
391
|
+
div.innerHTML = intl.get('Amount');
|
|
399
392
|
} else {
|
|
400
|
-
const column =
|
|
401
|
-
div.innerHTML =
|
|
393
|
+
const column = getTableColumnByKey(table, horizontal_axis_column_key);
|
|
394
|
+
div.innerHTML = `${column ? column.name : ''}`;
|
|
402
395
|
}
|
|
403
|
-
div.setAttribute('style',
|
|
396
|
+
div.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
|
|
404
397
|
chartContainer.appendChild(div);
|
|
405
398
|
}
|
|
406
399
|
if (xLabel && show_horizontal_axis_label) {
|
|
407
|
-
xLabel.setAttribute('style',
|
|
400
|
+
xLabel.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
|
|
408
401
|
}
|
|
409
402
|
if (xLabel && !show_horizontal_axis_label) {
|
|
410
403
|
xLabel.parentNode.removeChild(xLabel);
|
|
411
404
|
}
|
|
412
|
-
const yAxisID =
|
|
413
|
-
const yLabel = chartContainer.querySelector(
|
|
405
|
+
const yAxisID = `chart-y-axis-label_${chart.id}`;
|
|
406
|
+
const yLabel = chartContainer.querySelector(`#${yAxisID}`);
|
|
414
407
|
const divHeight = 20;
|
|
415
408
|
if (!yLabel && show_vertical_axis_label) {
|
|
416
409
|
const div = document.createElement('div');
|
|
417
410
|
div.id = yAxisID;
|
|
418
411
|
div.className = 'chart-axis-label';
|
|
419
|
-
const column =
|
|
412
|
+
const column = getTableColumnByKey(table, vertical_axis_column_key) || {};
|
|
420
413
|
div.innerHTML = column.name || '';
|
|
421
414
|
const {
|
|
422
415
|
height: containerHeight
|
|
423
416
|
} = this.chartBoundingClientRect;
|
|
424
417
|
let textAlign = 'center';
|
|
425
|
-
if (vertical_axis_label_position ===
|
|
426
|
-
if (vertical_axis_label_position ===
|
|
427
|
-
div.setAttribute('style',
|
|
418
|
+
if (vertical_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
419
|
+
if (vertical_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
420
|
+
div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
|
|
428
421
|
chartContainer.appendChild(div);
|
|
429
422
|
}
|
|
430
423
|
if (yLabel && show_horizontal_axis_label) {
|
|
@@ -432,9 +425,9 @@ class ChartComponent extends _react.Component {
|
|
|
432
425
|
height: containerHeight
|
|
433
426
|
} = this.chartBoundingClientRect;
|
|
434
427
|
let textAlign = 'center';
|
|
435
|
-
if (vertical_axis_label_position ===
|
|
436
|
-
if (vertical_axis_label_position ===
|
|
437
|
-
yLabel.setAttribute('style',
|
|
428
|
+
if (vertical_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
429
|
+
if (vertical_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
430
|
+
yLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
|
|
438
431
|
}
|
|
439
432
|
if (yLabel && !show_horizontal_axis_label) {
|
|
440
433
|
yLabel.parentNode.removeChild(yLabel);
|
|
@@ -448,18 +441,18 @@ class ChartComponent extends _react.Component {
|
|
|
448
441
|
};
|
|
449
442
|
this.formatterLegendName = name => {
|
|
450
443
|
if (!name && typeof name !== 'number' || name.trim() === 'undefined' || name.trim() === 'null') {
|
|
451
|
-
return
|
|
444
|
+
return intl.get(EMPTY_NAME);
|
|
452
445
|
} else if (name === '_Others') {
|
|
453
|
-
return
|
|
446
|
+
return intl.get('Others');
|
|
454
447
|
} else {
|
|
455
|
-
return
|
|
448
|
+
return intl.get(name) || name;
|
|
456
449
|
}
|
|
457
450
|
};
|
|
458
451
|
this.setLegend = _ref => {
|
|
459
452
|
var _chart$config, _chart$config2;
|
|
460
453
|
let {
|
|
461
454
|
legendName,
|
|
462
|
-
theme =
|
|
455
|
+
theme = CHART_THEME_COLOR['light'],
|
|
463
456
|
legendPosition = 'top-left',
|
|
464
457
|
data,
|
|
465
458
|
colorScale,
|
|
@@ -468,8 +461,8 @@ class ChartComponent extends _react.Component {
|
|
|
468
461
|
} = _ref;
|
|
469
462
|
if (!this.chart) return;
|
|
470
463
|
this.legendConfig = {
|
|
471
|
-
legendRectWidth: [
|
|
472
|
-
legendRectHeight: [
|
|
464
|
+
legendRectWidth: [CHART_TYPE.SCATTER, CHART_TYPE.MIRROR].includes(chart === null || chart === void 0 ? void 0 : (_chart$config = chart.config) === null || _chart$config === void 0 ? void 0 : _chart$config.type) ? 8 : 20,
|
|
465
|
+
legendRectHeight: [CHART_TYPE.SCATTER, CHART_TYPE.MIRROR].includes(chart === null || chart === void 0 ? void 0 : (_chart$config2 = chart.config) === null || _chart$config2 === void 0 ? void 0 : _chart$config2.type) ? 8 : 6,
|
|
473
466
|
r: this.getLegendR(chart),
|
|
474
467
|
legendItemPaddingTop: 5,
|
|
475
468
|
legendItemTextPaddingTop: 13,
|
|
@@ -484,7 +477,7 @@ class ChartComponent extends _react.Component {
|
|
|
484
477
|
|
|
485
478
|
// sort legend data and format data
|
|
486
479
|
data.forEach(item => item[legendName] = String(item[legendName]));
|
|
487
|
-
const legendData =
|
|
480
|
+
const legendData = BaseUtils.sortDataByGroupName(cloneDeep(data), legendName, groupColumn, chart);
|
|
488
481
|
const {
|
|
489
482
|
width: chartWidth,
|
|
490
483
|
height: chartHeight,
|
|
@@ -509,7 +502,7 @@ class ChartComponent extends _react.Component {
|
|
|
509
502
|
if (groupsData.length === 1) {
|
|
510
503
|
curTranslateX = (chartWidth - width - insertPadding * 2) / 2;
|
|
511
504
|
}
|
|
512
|
-
legendWrapper.attr('transform',
|
|
505
|
+
legendWrapper.attr('transform', `translate(${curTranslateX},${curTranslateY})`);
|
|
513
506
|
});
|
|
514
507
|
}
|
|
515
508
|
|
|
@@ -532,7 +525,7 @@ class ChartComponent extends _react.Component {
|
|
|
532
525
|
const pageNavigator = legendWrapper.append('g').attr('class', 'legend-flip-page');
|
|
533
526
|
|
|
534
527
|
// count
|
|
535
|
-
pageNavigator.append('text').attr('class', 'legend-count').attr('x', 15).attr('y', legendItemTextPaddingTop).attr('fill', theme.legendTextColor).attr('font-size', theme.legendFontSize).text(
|
|
528
|
+
pageNavigator.append('text').attr('class', 'legend-count').attr('x', 15).attr('y', legendItemTextPaddingTop).attr('fill', theme.legendTextColor).attr('font-size', theme.legendFontSize).text(`${curCount + 1}/${groupsData.length}`);
|
|
536
529
|
|
|
537
530
|
// prev page
|
|
538
531
|
pageNavigator.append('polygon').attr('class', 'legend-prev-page').attr('points', this.calcEquilateralTriangle(5, 8, 12)).attr('fill', theme.legendPageNavigatorMarkerColor).attr('opacity', curCount === 0 ? 0.45 : 1).attr('style', 'cursor: pointer;').on('click', event => {
|
|
@@ -543,7 +536,7 @@ class ChartComponent extends _react.Component {
|
|
|
543
536
|
groupData: groupsData[curCount],
|
|
544
537
|
colorScale,
|
|
545
538
|
theme,
|
|
546
|
-
text:
|
|
539
|
+
text: `${curCount + 1}/${groupsData.length}`
|
|
547
540
|
});
|
|
548
541
|
}
|
|
549
542
|
});
|
|
@@ -557,7 +550,7 @@ class ChartComponent extends _react.Component {
|
|
|
557
550
|
groupData: groupsData[curCount],
|
|
558
551
|
colorScale,
|
|
559
552
|
theme,
|
|
560
|
-
text:
|
|
553
|
+
text: `${curCount + 1}/${groupsData.length}`
|
|
561
554
|
});
|
|
562
555
|
}
|
|
563
556
|
});
|
|
@@ -582,7 +575,7 @@ class ChartComponent extends _react.Component {
|
|
|
582
575
|
} = g.node().parentNode.getBoundingClientRect();
|
|
583
576
|
groupTranslateY = groupTranslateY + height + legendItemMargin;
|
|
584
577
|
}
|
|
585
|
-
g.attr('transform',
|
|
578
|
+
g.attr('transform', `translate(${groupTranslateX},${groupTranslateY})`);
|
|
586
579
|
});
|
|
587
580
|
}
|
|
588
581
|
};
|
|
@@ -625,7 +618,7 @@ class ChartComponent extends _react.Component {
|
|
|
625
618
|
}).append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('y', legendItemPaddingTop).attr('rx', r).attr('fill', _ref4 => {
|
|
626
619
|
let [groupName] = _ref4;
|
|
627
620
|
if (colorScale) return colorScale(groupName);
|
|
628
|
-
return this.colorMap[groupName] ||
|
|
621
|
+
return this.colorMap[groupName] || CHART_STYLE_COLORS[0];
|
|
629
622
|
}).attr('data-text', _ref5 => {
|
|
630
623
|
let [groupName] = _ref5;
|
|
631
624
|
return groupName;
|
|
@@ -654,7 +647,7 @@ class ChartComponent extends _react.Component {
|
|
|
654
647
|
const prevTranslateY = Number(prevItem.getAttribute('data-translateY'));
|
|
655
648
|
translateY = prevTranslateY + height + legendItemMargin;
|
|
656
649
|
}
|
|
657
|
-
d3.select(item).attr('transform',
|
|
650
|
+
d3.select(item).attr('transform', `translate(${start},${translateY})`).attr('data-translateY', translateY);
|
|
658
651
|
});
|
|
659
652
|
} else {
|
|
660
653
|
// update g translateX
|
|
@@ -668,7 +661,7 @@ class ChartComponent extends _react.Component {
|
|
|
668
661
|
const prevTranslateX = Number(prevItem.getAttribute('data-translateX'));
|
|
669
662
|
translateX = prevTranslateX + width + legendItemMargin;
|
|
670
663
|
}
|
|
671
|
-
d3.select(item).attr('transform',
|
|
664
|
+
d3.select(item).attr('transform', `translate(${translateX},0)`).attr('data-translateX', translateX);
|
|
672
665
|
|
|
673
666
|
// legend items add offset
|
|
674
667
|
if (legendPosition === 'top-right') {
|
|
@@ -707,7 +700,7 @@ class ChartComponent extends _react.Component {
|
|
|
707
700
|
if (top && bottom) {
|
|
708
701
|
let allHeight = top;
|
|
709
702
|
const groupsData = [];
|
|
710
|
-
const newLegendData =
|
|
703
|
+
const newLegendData = cloneDeep(legendData);
|
|
711
704
|
let lastIndex = 0;
|
|
712
705
|
legendData.forEach((item, index) => {
|
|
713
706
|
const virtualLegend = this.chart.append('g').attr('opacity', 0);
|
|
@@ -732,7 +725,7 @@ class ChartComponent extends _react.Component {
|
|
|
732
725
|
} else {
|
|
733
726
|
let allWidth = start;
|
|
734
727
|
const groupsData = [];
|
|
735
|
-
const newLegendData =
|
|
728
|
+
const newLegendData = cloneDeep(legendData);
|
|
736
729
|
let lastIndex = 0;
|
|
737
730
|
legendData.forEach((item, index) => {
|
|
738
731
|
const virtualLegend = this.chart.append('g').attr('opacity', 0);
|
|
@@ -815,20 +808,20 @@ class ChartComponent extends _react.Component {
|
|
|
815
808
|
const offset = end - (endTranslateX + endWidth);
|
|
816
809
|
legendItems.forEach(legendItem => {
|
|
817
810
|
const curTranslateX = Number(legendItem.getAttribute('data-translateX')) + offset;
|
|
818
|
-
d3.select(legendItem).attr('transform',
|
|
811
|
+
d3.select(legendItem).attr('transform', `translate(${curTranslateX}, 0)`).attr('data-translateX', curTranslateX);
|
|
819
812
|
d3.select(legendItem).attr('opacity', 1);
|
|
820
813
|
});
|
|
821
814
|
};
|
|
822
815
|
this.sortLegend = (result, groupColumn, legendName) => {
|
|
823
816
|
result.forEach(item => {
|
|
824
817
|
const option = groupColumn.data.options.find(option => option.name === item[legendName]);
|
|
825
|
-
if (option
|
|
818
|
+
if (option === null || option === void 0 ? void 0 : option.id) {
|
|
826
819
|
item['group_name_id'] = option.id;
|
|
827
820
|
item['oldName'] = item.name;
|
|
828
821
|
item.name = item['group_name_id'];
|
|
829
822
|
}
|
|
830
823
|
});
|
|
831
|
-
|
|
824
|
+
BaseUtils.sortCharts(result, groupColumn, 'name');
|
|
832
825
|
result.forEach(item => {
|
|
833
826
|
item.name = item['oldName'];
|
|
834
827
|
});
|
|
@@ -841,8 +834,8 @@ class ChartComponent extends _react.Component {
|
|
|
841
834
|
const {
|
|
842
835
|
type
|
|
843
836
|
} = config;
|
|
844
|
-
if (type ===
|
|
845
|
-
if (type ===
|
|
837
|
+
if (type === CHART_TYPE.SCATTER) return 4;
|
|
838
|
+
if (type === CHART_TYPE.MIRROR) return 0;
|
|
846
839
|
return 3;
|
|
847
840
|
};
|
|
848
841
|
this.calcEquilateralTriangle = (cx, cy, size, direction) => {
|
|
@@ -856,16 +849,17 @@ class ChartComponent extends _react.Component {
|
|
|
856
849
|
let groupName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'group_name';
|
|
857
850
|
let groupColumn = arguments.length > 3 ? arguments[3] : undefined;
|
|
858
851
|
let chart = arguments.length > 4 ? arguments[4] : undefined;
|
|
859
|
-
const newData =
|
|
852
|
+
const newData = BaseUtils.sortDataByGroupName(cloneDeep(data), groupName, groupColumn, chart);
|
|
860
853
|
let currentIdx = 0;
|
|
861
|
-
const defaultColors =
|
|
854
|
+
const defaultColors = CHART_STYLE_COLORS;
|
|
862
855
|
let colors = defaultColors;
|
|
863
856
|
if (chartColorTheme) {
|
|
864
|
-
colors =
|
|
857
|
+
colors = BaseUtils.getCurrentTheme(chartColorTheme).colors;
|
|
865
858
|
}
|
|
866
859
|
const colorMap = newData.reduce((acc, cur) => {
|
|
867
|
-
|
|
868
|
-
|
|
860
|
+
const key = cur[groupName] || cur[groupName] === 0 ? cur[groupName] : '';
|
|
861
|
+
if (!acc.hasOwnProperty(key)) {
|
|
862
|
+
acc[key] = colors[currentIdx++ % colors.length];
|
|
869
863
|
}
|
|
870
864
|
return acc;
|
|
871
865
|
}, {});
|
|
@@ -960,13 +954,13 @@ class ChartComponent extends _react.Component {
|
|
|
960
954
|
formatted_value: item.formatted_value + ''
|
|
961
955
|
});
|
|
962
956
|
}
|
|
963
|
-
if (type ===
|
|
957
|
+
if (type === CHART_TYPE.WORLD_MAP_BUBBLE) {
|
|
964
958
|
sum += item.value;
|
|
965
959
|
}
|
|
966
960
|
}
|
|
967
961
|
}
|
|
968
962
|
});
|
|
969
|
-
if (type ===
|
|
963
|
+
if (type === CHART_TYPE.WORLD_MAP_BUBBLE) {
|
|
970
964
|
statisticNewData.sum = sum;
|
|
971
965
|
}
|
|
972
966
|
return statisticNewData;
|
|
@@ -987,16 +981,16 @@ class ChartComponent extends _react.Component {
|
|
|
987
981
|
let themeColors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
988
982
|
let theme = arguments.length > 1 ? arguments[1] : undefined;
|
|
989
983
|
// dark->custom->light
|
|
990
|
-
if (theme ===
|
|
991
|
-
themeColors =
|
|
984
|
+
if (theme === THEME_NAME_MAP.DARK) {
|
|
985
|
+
themeColors = CHART_THEME_COLOR.dark;
|
|
992
986
|
}
|
|
993
|
-
return themeColors ||
|
|
987
|
+
return themeColors || CHART_THEME_COLOR[THEME_NAME_MAP.LIGHT];
|
|
994
988
|
};
|
|
995
989
|
this.setDispalyGoalLine = (goal_label, goal_value, insertPadding, yScale) => {
|
|
996
990
|
const {
|
|
997
991
|
width: chartWidth
|
|
998
992
|
} = this.chartBoundingClientRect;
|
|
999
|
-
const annotationWrapper = this.chart.append('g').attr('class',
|
|
993
|
+
const annotationWrapper = this.chart.append('g').attr('class', `annotation-wrapper`);
|
|
1000
994
|
annotationWrapper.append('line').attr('stroke', '#aaa').attr('x1', insertPadding).attr('y1', yScale(goal_value)).attr('x2', chartWidth - insertPadding).attr('y2', yScale(goal_value)).attr('stroke-dasharray', '8,3').call(g => {
|
|
1001
995
|
annotationWrapper.append('text').attr('x', chartWidth - insertPadding - 30).attr('y', yScale(goal_value) - 10).attr('fill', '#666').text(goal_label);
|
|
1002
996
|
});
|
|
@@ -1011,7 +1005,7 @@ class ChartComponent extends _react.Component {
|
|
|
1011
1005
|
label_font_size,
|
|
1012
1006
|
text
|
|
1013
1007
|
} = _ref6;
|
|
1014
|
-
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('y', Number(y) - 10).attr('fill', theme.labelColor).attr('font-size',
|
|
1008
|
+
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('y', Number(y) - 10).attr('fill', theme.labelColor).attr('font-size', BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1015
1009
|
if (!g.node()) return;
|
|
1016
1010
|
const {
|
|
1017
1011
|
width
|
|
@@ -1030,7 +1024,7 @@ class ChartComponent extends _react.Component {
|
|
|
1030
1024
|
label_font_size,
|
|
1031
1025
|
text
|
|
1032
1026
|
} = _ref7;
|
|
1033
|
-
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('x', Number(x) + Number(xWidth) + 10).attr('y', Number(y)).attr('fill', theme.labelColor).attr('dominant-baseline', 'hanging').attr('font-size',
|
|
1027
|
+
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('x', Number(x) + Number(xWidth) + 10).attr('y', Number(y)).attr('fill', theme.labelColor).attr('dominant-baseline', 'hanging').attr('font-size', BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1034
1028
|
if (g.node()) {
|
|
1035
1029
|
var _g$node;
|
|
1036
1030
|
const {
|
|
@@ -1052,7 +1046,7 @@ class ChartComponent extends _react.Component {
|
|
|
1052
1046
|
label_font_size,
|
|
1053
1047
|
text
|
|
1054
1048
|
} = _ref8;
|
|
1055
|
-
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size',
|
|
1049
|
+
d3.select(container).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(text).call(g => {
|
|
1056
1050
|
if (!g.node()) return;
|
|
1057
1051
|
const {
|
|
1058
1052
|
width,
|
|
@@ -1060,10 +1054,10 @@ class ChartComponent extends _react.Component {
|
|
|
1060
1054
|
} = g.node().getBoundingClientRect();
|
|
1061
1055
|
const translateX = Number(x) + xWidth / 2 - width / 2;
|
|
1062
1056
|
let translateY = Number(y) + Number(yheight / 2) + height / 2;
|
|
1063
|
-
if (chartType ===
|
|
1057
|
+
if (chartType === CHART_TYPE.BAR_STACK) {
|
|
1064
1058
|
translateY = translateY;
|
|
1065
1059
|
}
|
|
1066
|
-
g.attr('transform',
|
|
1060
|
+
g.attr('transform', `translate(${translateX}, ${translateY})`);
|
|
1067
1061
|
});
|
|
1068
1062
|
};
|
|
1069
1063
|
this.setActiveAndInActiveState = (state, allGroup, curGroupName, chartType) => {
|
|
@@ -1072,7 +1066,7 @@ class ChartComponent extends _react.Component {
|
|
|
1072
1066
|
const rects = Array.from(g.children).filter(item => item.tagName !== 'text');
|
|
1073
1067
|
rects.forEach(item => {
|
|
1074
1068
|
d3.select(item).transition().duration(this.transitionDuration).attr('opacity', 1);
|
|
1075
|
-
if ([
|
|
1069
|
+
if ([CHART_TYPE.PIE, CHART_TYPE.RING].includes(chartType)) {
|
|
1076
1070
|
d3.select(item).attr('stroke-width', 2);
|
|
1077
1071
|
}
|
|
1078
1072
|
});
|
|
@@ -1085,7 +1079,7 @@ class ChartComponent extends _react.Component {
|
|
|
1085
1079
|
if (item.getAttribute('data-groupName') !== curGroupName) {
|
|
1086
1080
|
d3.selectAll([item]).transition().duration(this.transitionDuration).attr('opacity', 0.3);
|
|
1087
1081
|
} else {
|
|
1088
|
-
if ([
|
|
1082
|
+
if ([CHART_TYPE.PIE, CHART_TYPE.RING].includes(chartType)) {
|
|
1089
1083
|
d3.select(item).attr('stroke-width', 0.5);
|
|
1090
1084
|
}
|
|
1091
1085
|
}
|
|
@@ -1123,7 +1117,7 @@ class ChartComponent extends _react.Component {
|
|
|
1123
1117
|
}
|
|
1124
1118
|
const clipPath = d3.select(parentNode).append('clipPath').attr('opacity', 1).attr('id', rectId);
|
|
1125
1119
|
clipPath.node().appendChild(clipRect.node());
|
|
1126
|
-
d3.select(rect).attr('clip-path',
|
|
1120
|
+
d3.select(rect).attr('clip-path', `url(#${rectId})`);
|
|
1127
1121
|
};
|
|
1128
1122
|
this.drawYaxis = function (g, theme) {
|
|
1129
1123
|
let rightAxisOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -1144,7 +1138,7 @@ class ChartComponent extends _react.Component {
|
|
|
1144
1138
|
g.selectAll('.tick line').clone().attr('x2', chartWidth - insertPadding * 2 - _this.horizontalOverflowOffset - rightAxisOffset).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
|
|
1145
1139
|
|
|
1146
1140
|
// update g translateX
|
|
1147
|
-
g.attr('transform',
|
|
1141
|
+
g.attr('transform', `translate(${insertPadding + _this.horizontalOverflowOffset}, 0)`);
|
|
1148
1142
|
};
|
|
1149
1143
|
this.checkTextOverflow = allTextEl => {
|
|
1150
1144
|
const {
|
|
@@ -1235,8 +1229,8 @@ class ChartComponent extends _react.Component {
|
|
|
1235
1229
|
} = g.node().getBoundingClientRect();
|
|
1236
1230
|
if (isRoateText && width > insertPadding) {
|
|
1237
1231
|
const viewWidth = viewBox[viewBox.length - 2];
|
|
1238
|
-
viewBox[0] =
|
|
1239
|
-
viewBox[viewBox.length - 2] =
|
|
1232
|
+
viewBox[0] = `-${width - insertPadding}`;
|
|
1233
|
+
viewBox[viewBox.length - 2] = `${Number(viewWidth) + (width - insertPadding)}`;
|
|
1240
1234
|
queueMicrotask(() => {
|
|
1241
1235
|
if (!this.chart) return;
|
|
1242
1236
|
this.chart.attr('viewBox', viewBox.join(','));
|
|
@@ -1269,7 +1263,7 @@ class ChartComponent extends _react.Component {
|
|
|
1269
1263
|
} = g.node().getBoundingClientRect();
|
|
1270
1264
|
if (height > insertPadding) {
|
|
1271
1265
|
const viewHeight = viewBox[viewBox.length - 1];
|
|
1272
|
-
viewBox[viewBox.length - 1] =
|
|
1266
|
+
viewBox[viewBox.length - 1] = `${Number(viewHeight) + (height - insertPadding)}`;
|
|
1273
1267
|
queueMicrotask(() => {
|
|
1274
1268
|
if (!this.chart) return;
|
|
1275
1269
|
this.chart.attr('viewBox', viewBox.join(','));
|
|
@@ -1331,5 +1325,4 @@ class ChartComponent extends _react.Component {
|
|
|
1331
1325
|
componentWillUnmount() {
|
|
1332
1326
|
window.removeEventListener('resize', this.handleResize);
|
|
1333
1327
|
}
|
|
1334
|
-
}
|
|
1335
|
-
exports.default = ChartComponent;
|
|
1328
|
+
}
|