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