sea-chart 2.0.43 → 2.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +4 -11
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +4 -11
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +27 -35
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +11 -18
- package/dist/components/color-popover/color-rules/color-rule.js +25 -33
- package/dist/components/color-popover/color-rules/index.js +6 -14
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +10 -18
- package/dist/components/color-popover/color-rules-popover.js +26 -34
- package/dist/components/color-popover/color-selector-popover.js +10 -18
- package/dist/components/color-setting/color-group-selector.js +12 -20
- package/dist/components/common-add-tool/index.js +6 -13
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +12 -19
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +16 -24
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +42 -50
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +4 -11
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +4 -11
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +25 -33
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +54 -64
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +15 -22
- package/dist/components/row-card/row-card-header.js +14 -21
- package/dist/components/row-card/row-card-item.js +33 -41
- package/dist/components/row-card/row-card.js +15 -23
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +21 -21
- package/dist/components/types-dialog/index.js +56 -64
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +149 -273
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +20 -24
- package/dist/editor/index.js +8 -15
- package/dist/index.js +13 -104
- package/dist/intl.js +10 -17
- package/dist/locale/index.js +16 -23
- package/dist/locale/lang/de.js +1 -7
- package/dist/locale/lang/en.js +1 -7
- package/dist/locale/lang/es.js +1 -7
- package/dist/locale/lang/fr.js +1 -7
- package/dist/locale/lang/pt.js +1 -7
- package/dist/locale/lang/ru.js +1 -7
- package/dist/locale/lang/zh_CN.js +1 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +8 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +19 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +15 -18
- package/dist/model/horizontal-group-bar.js +14 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +12 -19
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +15 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +7 -13
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +83 -74
- package/dist/settings/bar-settings/data-settings.js +39 -47
- package/dist/settings/bar-settings/index.js +3 -20
- package/dist/settings/bar-settings/style-settings.js +69 -60
- package/dist/settings/basic-number-card/data-settings.js +49 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +18 -26
- package/dist/settings/combination-settings/data-settings.js +55 -63
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +94 -77
- package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
- package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
- package/dist/settings/completeness-settings/index.js +3 -20
- package/dist/settings/completeness-settings/style-settings.js +19 -26
- package/dist/settings/dashboard-settings/data-settings.js +43 -51
- package/dist/settings/dashboard-settings/index.js +2 -13
- package/dist/settings/data-settings.js +72 -79
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
- package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
- package/dist/settings/funnel-settings/data-settings.js +23 -31
- package/dist/settings/funnel-settings/index.js +3 -20
- package/dist/settings/funnel-settings/style-settings.js +11 -19
- package/dist/settings/heat-map-settings/data-settings.js +18 -26
- package/dist/settings/heat-map-settings/index.js +3 -20
- package/dist/settings/heat-map-settings/style-settings.js +18 -26
- package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
- package/dist/settings/horizontal-bar-settings/index.js +3 -20
- package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
- package/dist/settings/index.js +52 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +26 -34
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +64 -72
- package/dist/settings/table-element-settings/components/data-filter.js +30 -38
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +111 -119
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +62 -53
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +17 -25
- package/dist/settings/widgets/axis-title-font-settings/index.js +39 -0
- package/dist/settings/widgets/basic-summary/index.js +55 -63
- package/dist/settings/widgets/chart-type/index.js +18 -26
- package/dist/settings/widgets/color-settings/index.js +72 -80
- package/dist/settings/widgets/common-data-settings.js +21 -29
- package/dist/settings/widgets/data-filter/index.js +35 -43
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +24 -32
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +51 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +23 -31
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +72 -80
- package/dist/settings/widgets/switch/index.js +8 -15
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +63 -71
- package/dist/utils/cell-format-utils.js +18 -28
- package/dist/utils/cell-value-utils.js +5 -12
- package/dist/utils/chart-utils/base-utils.js +362 -334
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +80 -86
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +32 -39
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +91 -97
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
- package/dist/utils/chart-utils/sql-statistics-utils.js +284 -246
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +18 -30
- package/dist/utils/collaborator.js +4 -13
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +65 -92
- package/dist/utils/common-utils.js +27 -52
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +11 -19
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +1 -7
- package/dist/utils/options-utils.js +8 -16
- package/dist/utils/row-record-utils.js +182 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +49 -55
- package/dist/utils/sql/column-2-sql-column.js +146 -154
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.css +0 -17
- package/dist/view/index.js +89 -95
- package/dist/view/title/index.js +15 -23
- package/dist/view/wrapper/area-group.js +53 -72
- package/dist/view/wrapper/area.js +51 -72
- package/dist/view/wrapper/bar-compare.js +43 -56
- package/dist/view/wrapper/bar-custom-stack.js +50 -120
- package/dist/view/wrapper/bar-group.js +51 -94
- package/dist/view/wrapper/bar-stack.js +54 -90
- package/dist/view/wrapper/bar.js +45 -66
- package/dist/view/wrapper/basic-number-card.js +25 -26
- package/dist/view/wrapper/chart-component.js +539 -162
- package/dist/view/wrapper/combination.js +63 -83
- package/dist/view/wrapper/completeness-group.js +42 -96
- package/dist/view/wrapper/completeness.js +42 -96
- package/dist/view/wrapper/dashboard.js +33 -47
- package/dist/view/wrapper/funnel.js +36 -56
- package/dist/view/wrapper/heat-map.js +126 -104
- package/dist/view/wrapper/horizontal-bar-group.js +57 -76
- package/dist/view/wrapper/horizontal-bar-stack.js +56 -109
- package/dist/view/wrapper/horizontal-bar.js +45 -68
- package/dist/view/wrapper/index.js +110 -115
- package/dist/view/wrapper/line-group.js +48 -66
- package/dist/view/wrapper/line.js +47 -67
- package/dist/view/wrapper/map-bubble.js +46 -59
- package/dist/view/wrapper/map-world-bubble.js +45 -58
- package/dist/view/wrapper/map-world.js +47 -60
- package/dist/view/wrapper/map.js +48 -60
- package/dist/view/wrapper/mirror.js +40 -61
- package/dist/view/wrapper/pie.js +48 -59
- package/dist/view/wrapper/ring.js +52 -63
- package/dist/view/wrapper/scatter.js +49 -67
- package/dist/view/wrapper/table/index.js +13 -21
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +50 -58
- package/dist/view/wrapper/table/pivot-table-display-name.js +83 -91
- package/dist/view/wrapper/table/two-dimension-table.js +76 -84
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +96 -105
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +22 -31
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/record.js +10 -17
- package/dist/view/wrapper/table-element/components/records-body.js +17 -19
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +23 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
- package/dist/view/wrapper/table-element/components/utils.js +5 -15
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +39 -57
- package/dist/view/wrapper/trend.js +41 -48
- package/package.json +1 -1
|
@@ -1,56 +1,84 @@
|
|
|
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, DEFAULT_AXIS_LABEL_FONT_COLOR, DEFAULT_AXIS_LABEL_FONT_COLOR_DARK, DEFAULT_AXIS_LABEL_FONT_SIZE } 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();
|
|
34
27
|
this.drawChart();
|
|
35
|
-
if (this.needRenderAxisLabel) {
|
|
36
|
-
this.renderAxisLabel(this.props.chart, this.props.tables);
|
|
37
|
-
}
|
|
38
28
|
}, 300);
|
|
39
29
|
this.destroyChart = () => {
|
|
40
30
|
this.chart && this.chart.node() && this.chart.node().remove();
|
|
31
|
+
this.container && this.setAxisTitlePadding(this.container, {
|
|
32
|
+
left: null,
|
|
33
|
+
bottom: null,
|
|
34
|
+
right: null
|
|
35
|
+
});
|
|
36
|
+
this._clipMaskByRect.clear();
|
|
37
|
+
this._defs = null;
|
|
38
|
+
};
|
|
39
|
+
this.toggleRecords = function (statisticRecord) {
|
|
40
|
+
if (!statisticRecord) return;
|
|
41
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
42
|
+
args[_key - 1] = arguments[_key];
|
|
43
|
+
}
|
|
44
|
+
_this.props.toggleRecords && _this.props.toggleRecords(statisticRecord, ...args);
|
|
41
45
|
};
|
|
42
46
|
this.getTitle = (tables, table_id, yAxisType, yAxisKey) => {
|
|
43
|
-
return yAxisType ===
|
|
47
|
+
return yAxisType === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : this.getAxisLabel(tables, table_id, yAxisKey);
|
|
44
48
|
};
|
|
45
49
|
this.getColumn = (tables, table_id, columnKey) => {
|
|
46
|
-
const table =
|
|
47
|
-
const column =
|
|
50
|
+
const table = getTableById(tables, table_id);
|
|
51
|
+
const column = getTableColumnByKey(table, columnKey) || {};
|
|
48
52
|
return column;
|
|
49
53
|
};
|
|
50
54
|
this.getAxisLabel = (tables, tableId, columnKey) => {
|
|
51
55
|
const column = this.getColumn(tables, tableId, columnKey);
|
|
52
56
|
return column.name || '';
|
|
53
57
|
};
|
|
58
|
+
this.getAxisTitleHeight = fontSize => {
|
|
59
|
+
const safeFontSize = Number(fontSize) || DEFAULT_AXIS_LABEL_FONT_SIZE;
|
|
60
|
+
return Math.max(this.axisTitleMinHeight, safeFontSize + 4);
|
|
61
|
+
};
|
|
62
|
+
this.setAxisTitlePadding = function (chartContainer) {
|
|
63
|
+
let {
|
|
64
|
+
left = null,
|
|
65
|
+
bottom = null,
|
|
66
|
+
right = null
|
|
67
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
68
|
+
if (!chartContainer) return;
|
|
69
|
+
chartContainer.style.paddingLeft = left != null ? `${left}px` : '';
|
|
70
|
+
chartContainer.style.paddingBottom = bottom != null ? `${bottom}px` : '';
|
|
71
|
+
chartContainer.style.paddingRight = right != null ? `${right}px` : '';
|
|
72
|
+
};
|
|
73
|
+
this.getRotatedAxisTitleTransform = function (containerHeight, titleHeight) {
|
|
74
|
+
let placement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'left';
|
|
75
|
+
const translateX = containerHeight / 2 - titleHeight / 2;
|
|
76
|
+
const translateY = containerHeight / 2 - titleHeight / 2;
|
|
77
|
+
if (placement === 'right') {
|
|
78
|
+
return `translate(${translateX}px, ${translateY}px) rotate(-90deg)`;
|
|
79
|
+
}
|
|
80
|
+
return `translate(-${translateX}px, ${translateY}px) rotate(-90deg)`;
|
|
81
|
+
};
|
|
54
82
|
this.initChart = function (container, id) {
|
|
55
83
|
let initConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
56
84
|
const {
|
|
@@ -68,6 +96,8 @@ class ChartComponent extends _react.Component {
|
|
|
68
96
|
const height = customHeight ? customHeight : containerHeight - marginBottom;
|
|
69
97
|
_this.chart = d3.create('svg').attr('id', id).attr('width', width).attr('height', height).attr('viewBox', [0, 0, width, height]);
|
|
70
98
|
_this.container.appendChild(_this.chart.node());
|
|
99
|
+
_this._defs = null;
|
|
100
|
+
_this._clipMaskByRect = new Map();
|
|
71
101
|
_this.chartBoundingClientRect = {
|
|
72
102
|
...JSON.parse(JSON.stringify(_this.chart.node().getBoundingClientRect())),
|
|
73
103
|
...initConfig,
|
|
@@ -75,6 +105,12 @@ class ChartComponent extends _react.Component {
|
|
|
75
105
|
height
|
|
76
106
|
};
|
|
77
107
|
};
|
|
108
|
+
this.getDefs = () => {
|
|
109
|
+
if (!this._defs || !this._defs.node() || !this._defs.node().isConnected) {
|
|
110
|
+
this._defs = this.chart.append('defs').attr('class', 'sea-chart-defs');
|
|
111
|
+
}
|
|
112
|
+
return this._defs;
|
|
113
|
+
};
|
|
78
114
|
this.initDefs = () => {
|
|
79
115
|
if (this.container) {
|
|
80
116
|
// add Mask
|
|
@@ -107,7 +143,7 @@ class ChartComponent extends _react.Component {
|
|
|
107
143
|
if (item.group_name === 'rest' && isCompleteness) return;
|
|
108
144
|
const groupData = chartGroupData.find(g => g.name === item.name);
|
|
109
145
|
if (!groupData) {
|
|
110
|
-
const newItem =
|
|
146
|
+
const newItem = cloneDeep(item);
|
|
111
147
|
newItem.currentGroupCount = 1;
|
|
112
148
|
chartGroupData.push(newItem);
|
|
113
149
|
} else {
|
|
@@ -161,13 +197,13 @@ class ChartComponent extends _react.Component {
|
|
|
161
197
|
// mark the first item in each group,but if item value is 0, mark the next item
|
|
162
198
|
let targetMarkItem = item[0],
|
|
163
199
|
i = 1;
|
|
164
|
-
while (!((_targetMarkItem = targetMarkItem)
|
|
200
|
+
while (!((_targetMarkItem = targetMarkItem) === null || _targetMarkItem === void 0 ? void 0 : _targetMarkItem.value) && !Number.isNaN((_targetMarkItem2 = targetMarkItem) === null || _targetMarkItem2 === void 0 ? void 0 : _targetMarkItem2.value)) {
|
|
165
201
|
var _targetMarkItem, _targetMarkItem2;
|
|
166
202
|
targetMarkItem = item[i];
|
|
167
203
|
i++;
|
|
168
204
|
if (i >= item.length) break;
|
|
169
205
|
}
|
|
170
|
-
if (!((_targetMarkItem3 = targetMarkItem)
|
|
206
|
+
if (!((_targetMarkItem3 = targetMarkItem) === null || _targetMarkItem3 === void 0 ? void 0 : _targetMarkItem3.value)) return;
|
|
171
207
|
targetMarkItem.isFirst = 1;
|
|
172
208
|
} else if (position === 'last') {
|
|
173
209
|
var _targetMarkItem6;
|
|
@@ -175,13 +211,13 @@ class ChartComponent extends _react.Component {
|
|
|
175
211
|
const l = item.length;
|
|
176
212
|
let targetMarkItem = item[l - 1],
|
|
177
213
|
i = l - 2;
|
|
178
|
-
while (!((_targetMarkItem4 = targetMarkItem)
|
|
214
|
+
while (!((_targetMarkItem4 = targetMarkItem) === null || _targetMarkItem4 === void 0 ? void 0 : _targetMarkItem4.value) && !Number.isNaN((_targetMarkItem5 = targetMarkItem) === null || _targetMarkItem5 === void 0 ? void 0 : _targetMarkItem5.value)) {
|
|
179
215
|
var _targetMarkItem4, _targetMarkItem5;
|
|
180
216
|
targetMarkItem = item[i];
|
|
181
217
|
i--;
|
|
182
218
|
if (i < 0) break;
|
|
183
219
|
}
|
|
184
|
-
if (!((_targetMarkItem6 = targetMarkItem)
|
|
220
|
+
if (!((_targetMarkItem6 = targetMarkItem) === null || _targetMarkItem6 === void 0 ? void 0 : _targetMarkItem6.value)) return;
|
|
185
221
|
targetMarkItem.isLast = 1;
|
|
186
222
|
} else {
|
|
187
223
|
console.error('on markFirstOrLast: unknown position');
|
|
@@ -229,23 +265,38 @@ class ChartComponent extends _react.Component {
|
|
|
229
265
|
y_axis_summary_type,
|
|
230
266
|
type,
|
|
231
267
|
title_name,
|
|
268
|
+
x_axis_label_font_size,
|
|
269
|
+
x_axis_label_font_color,
|
|
270
|
+
y_axis_label_font_size,
|
|
271
|
+
y_axis_label_font_color,
|
|
232
272
|
// left axis - combination chart
|
|
233
273
|
show_y_axis_left_label,
|
|
234
274
|
y_axis_left_label_position,
|
|
235
275
|
y_axis_left_summary_type,
|
|
236
276
|
y_axis_left_summary_column,
|
|
277
|
+
y_axis_left_label_font_size,
|
|
278
|
+
y_axis_left_label_font_color,
|
|
237
279
|
// right axis - combination chart
|
|
238
280
|
show_y_axis_right_label,
|
|
239
281
|
y_axis_right_label_position,
|
|
240
282
|
y_axis_right_summary_type,
|
|
241
|
-
y_axis_right_summary_column
|
|
283
|
+
y_axis_right_summary_column,
|
|
284
|
+
y_axis_right_label_font_size,
|
|
285
|
+
y_axis_right_label_font_color
|
|
242
286
|
} = chart.config;
|
|
243
287
|
if (y_axis_summary_column_key) {
|
|
244
288
|
y_axis_column_key = y_axis_summary_column_key;
|
|
245
289
|
}
|
|
246
|
-
const table =
|
|
247
|
-
|
|
248
|
-
|
|
290
|
+
const table = getTableById(tables, table_id);
|
|
291
|
+
const defaultTextColor = this.globalTheme === THEME_NAME_MAP.DARK ? DEFAULT_AXIS_LABEL_FONT_COLOR_DARK : DEFAULT_AXIS_LABEL_FONT_COLOR;
|
|
292
|
+
const xColor = x_axis_label_font_color || defaultTextColor;
|
|
293
|
+
const xFontSize = x_axis_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
|
|
294
|
+
const yColor = y_axis_label_font_color || defaultTextColor;
|
|
295
|
+
const yFontSize = y_axis_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
|
|
296
|
+
const yLeftColor = y_axis_left_label_font_color || defaultTextColor;
|
|
297
|
+
const yLeftFontSize = y_axis_left_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
|
|
298
|
+
const yRightColor = y_axis_right_label_font_color || defaultTextColor;
|
|
299
|
+
const yRightFontSize = y_axis_right_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
|
|
249
300
|
|
|
250
301
|
// xAxis
|
|
251
302
|
const xAxisID = `chart-x-axis-label_${chart.id}`;
|
|
@@ -253,17 +304,18 @@ class ChartComponent extends _react.Component {
|
|
|
253
304
|
const {
|
|
254
305
|
width: containerWidth
|
|
255
306
|
} = this.chartBoundingClientRect;
|
|
307
|
+
const xTitleHeight = this.getAxisTitleHeight(xFontSize);
|
|
256
308
|
if (!xLabel && x_axis_show_label) {
|
|
257
309
|
const div = document.createElement('div');
|
|
258
310
|
div.id = xAxisID;
|
|
259
311
|
div.className = 'chart-axis-label';
|
|
260
|
-
const column =
|
|
312
|
+
const column = getTableColumnByKey(table, x_axis_column_key);
|
|
261
313
|
div.innerHTML = `${column ? column.name : ''}`;
|
|
262
|
-
div.setAttribute('style', `color:${
|
|
314
|
+
div.setAttribute('style', `color:${xColor}; font-size:${xFontSize}px; width: ${containerWidth}px; height: ${xTitleHeight}px; line-height: ${xTitleHeight}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
|
|
263
315
|
chartContainer.appendChild(div);
|
|
264
316
|
}
|
|
265
317
|
if (xLabel && x_axis_show_label) {
|
|
266
|
-
xLabel.setAttribute('style', `color:${
|
|
318
|
+
xLabel.setAttribute('style', `color:${xColor}; font-size:${xFontSize}px; width: ${containerWidth}px; height: ${xTitleHeight}px; line-height: ${xTitleHeight}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
|
|
267
319
|
}
|
|
268
320
|
if (xLabel && !x_axis_show_label) {
|
|
269
321
|
xLabel.parentNode.removeChild(xLabel);
|
|
@@ -272,18 +324,18 @@ class ChartComponent extends _react.Component {
|
|
|
272
324
|
// yAxis
|
|
273
325
|
const yAxisID = `chart-y-axis-label_${chart.id}`;
|
|
274
326
|
const yLabel = chartContainer.querySelector(`#${yAxisID}`);
|
|
275
|
-
const
|
|
327
|
+
const yTitleHeight = this.getAxisTitleHeight(yFontSize);
|
|
276
328
|
if (!yLabel && y_axis_show_label) {
|
|
277
329
|
const div = document.createElement('div');
|
|
278
330
|
div.id = yAxisID;
|
|
279
331
|
div.className = 'chart-axis-label';
|
|
280
332
|
// SCATTER always has y_axis_column_key
|
|
281
|
-
if (y_axis_summary_type ===
|
|
282
|
-
div.innerHTML =
|
|
333
|
+
if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT && type !== CHART_TYPE.SCATTER) {
|
|
334
|
+
div.innerHTML = intl.get('Amount');
|
|
283
335
|
} else {
|
|
284
|
-
const column =
|
|
336
|
+
const column = getTableColumnByKey(table, y_axis_column_key) || {};
|
|
285
337
|
div.innerHTML = column.name || '';
|
|
286
|
-
if (type ===
|
|
338
|
+
if (type === CHART_TYPE.BAR_STACK) {
|
|
287
339
|
div.innerHTML = title_name || '';
|
|
288
340
|
}
|
|
289
341
|
}
|
|
@@ -291,9 +343,9 @@ class ChartComponent extends _react.Component {
|
|
|
291
343
|
height: containerHeight
|
|
292
344
|
} = this.chartBoundingClientRect;
|
|
293
345
|
let textAlign = 'center';
|
|
294
|
-
if (y_axis_label_position ===
|
|
295
|
-
if (y_axis_label_position ===
|
|
296
|
-
div.setAttribute('style', `color:${
|
|
346
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
347
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
348
|
+
div.setAttribute('style', `color:${yColor}; font-size:${yFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yTitleHeight}px; line-height: ${yTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yTitleHeight)}`);
|
|
297
349
|
chartContainer.appendChild(div);
|
|
298
350
|
}
|
|
299
351
|
if (yLabel && y_axis_show_label) {
|
|
@@ -301,9 +353,9 @@ class ChartComponent extends _react.Component {
|
|
|
301
353
|
height: containerHeight
|
|
302
354
|
} = this.chartBoundingClientRect;
|
|
303
355
|
let textAlign = 'center';
|
|
304
|
-
if (y_axis_label_position ===
|
|
305
|
-
if (y_axis_label_position ===
|
|
306
|
-
yLabel.setAttribute('style', `color:${
|
|
356
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
357
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
358
|
+
yLabel.setAttribute('style', `color:${yColor}; font-size:${yFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yTitleHeight}px; line-height: ${yTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yTitleHeight)}`);
|
|
307
359
|
}
|
|
308
360
|
if (yLabel && !y_axis_show_label) {
|
|
309
361
|
yLabel.parentNode.removeChild(yLabel);
|
|
@@ -312,21 +364,22 @@ class ChartComponent extends _react.Component {
|
|
|
312
364
|
// yAxis(left) - combination chart
|
|
313
365
|
const yAxisLeftID = `chart-y-axis-left-label_${chart.id}`;
|
|
314
366
|
const yAxisLeftLabel = chartContainer.querySelector(`#${yAxisLeftID}`);
|
|
367
|
+
const yLeftTitleHeight = this.getAxisTitleHeight(yLeftFontSize);
|
|
315
368
|
if (!yAxisLeftLabel && show_y_axis_left_label) {
|
|
316
369
|
const div = document.createElement('div');
|
|
317
370
|
div.id = yAxisLeftID;
|
|
318
371
|
div.className = 'chart-axis-label text-truncate';
|
|
319
|
-
if (y_axis_left_summary_type ===
|
|
320
|
-
div.innerHTML =
|
|
372
|
+
if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
373
|
+
div.innerHTML = intl.get('Amount');
|
|
321
374
|
} else {
|
|
322
|
-
const column =
|
|
375
|
+
const column = getTableColumnByKey(table, y_axis_left_summary_column) || {};
|
|
323
376
|
div.innerHTML = column.name || '';
|
|
324
377
|
}
|
|
325
378
|
const containerHeight = chartContainer.offsetHeight;
|
|
326
379
|
let textAlign = 'center';
|
|
327
|
-
if (y_axis_left_label_position ===
|
|
328
|
-
if (y_axis_left_label_position ===
|
|
329
|
-
div.setAttribute('style', `color:${
|
|
380
|
+
if (y_axis_left_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
381
|
+
if (y_axis_left_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
382
|
+
div.setAttribute('style', `color:${yLeftColor}; font-size:${yLeftFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yLeftTitleHeight}px; line-height: ${yLeftTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yLeftTitleHeight)}`);
|
|
330
383
|
chartContainer.appendChild(div);
|
|
331
384
|
}
|
|
332
385
|
if (yAxisLeftLabel && show_y_axis_left_label) {
|
|
@@ -334,7 +387,7 @@ class ChartComponent extends _react.Component {
|
|
|
334
387
|
let textAlign = 'center';
|
|
335
388
|
if (y_axis_left_label_position === 'bottom') textAlign = 'left';
|
|
336
389
|
if (y_axis_left_label_position === 'top') textAlign = 'right';
|
|
337
|
-
yAxisLeftLabel.setAttribute('style', `color:${
|
|
390
|
+
yAxisLeftLabel.setAttribute('style', `color:${yLeftColor}; font-size:${yLeftFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yLeftTitleHeight}px; line-height: ${yLeftTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yLeftTitleHeight)}`);
|
|
338
391
|
}
|
|
339
392
|
if (yAxisLeftLabel && !show_y_axis_left_label) {
|
|
340
393
|
yAxisLeftLabel.parentNode.removeChild(yAxisLeftLabel);
|
|
@@ -343,21 +396,22 @@ class ChartComponent extends _react.Component {
|
|
|
343
396
|
// yAxis(right) - combination chart
|
|
344
397
|
const yAxisRightID = `chart-y-axis-right-label_${chart.id}`;
|
|
345
398
|
const yAxisRightLabel = chartContainer.querySelector(`#${yAxisRightID}`);
|
|
399
|
+
const yRightTitleHeight = this.getAxisTitleHeight(yRightFontSize);
|
|
346
400
|
if (!yAxisRightLabel && show_y_axis_right_label) {
|
|
347
401
|
const div = document.createElement('div');
|
|
348
402
|
div.id = yAxisRightID;
|
|
349
403
|
div.className = 'chart-axis-label text-truncate';
|
|
350
|
-
if (y_axis_right_summary_type ===
|
|
351
|
-
div.innerHTML =
|
|
404
|
+
if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
405
|
+
div.innerHTML = intl.get('Amount');
|
|
352
406
|
} else {
|
|
353
|
-
const column =
|
|
407
|
+
const column = getTableColumnByKey(table, y_axis_right_summary_column) || {};
|
|
354
408
|
div.innerHTML = column.name || '';
|
|
355
409
|
}
|
|
356
410
|
const containerHeight = chartContainer.offsetHeight;
|
|
357
411
|
let textAlign = 'center';
|
|
358
|
-
if (y_axis_right_label_position ===
|
|
359
|
-
if (y_axis_right_label_position ===
|
|
360
|
-
div.setAttribute('style', `color:${
|
|
412
|
+
if (y_axis_right_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
413
|
+
if (y_axis_right_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
414
|
+
div.setAttribute('style', `color:${yRightColor}; font-size:${yRightFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yRightTitleHeight}px; line-height: ${yRightTitleHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yRightTitleHeight, 'right')}`);
|
|
361
415
|
chartContainer.appendChild(div);
|
|
362
416
|
}
|
|
363
417
|
if (yAxisRightLabel && show_y_axis_right_label) {
|
|
@@ -365,11 +419,16 @@ class ChartComponent extends _react.Component {
|
|
|
365
419
|
let textAlign = 'center';
|
|
366
420
|
if (y_axis_right_label_position === 'bottom') textAlign = 'left';
|
|
367
421
|
if (y_axis_right_label_position === 'top') textAlign = 'right';
|
|
368
|
-
yAxisRightLabel.setAttribute('style', `color:${
|
|
422
|
+
yAxisRightLabel.setAttribute('style', `color:${yRightColor}; font-size:${yRightFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yRightTitleHeight}px; line-height: ${yRightTitleHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yRightTitleHeight, 'right')}`);
|
|
369
423
|
}
|
|
370
424
|
if (yAxisRightLabel && !show_y_axis_right_label) {
|
|
371
425
|
yAxisRightLabel.parentNode.removeChild(yAxisRightLabel);
|
|
372
426
|
}
|
|
427
|
+
this.setAxisTitlePadding(chartContainer, {
|
|
428
|
+
left: y_axis_show_label ? yTitleHeight : show_y_axis_left_label ? yLeftTitleHeight : null,
|
|
429
|
+
right: show_y_axis_right_label ? yRightTitleHeight : null,
|
|
430
|
+
bottom: x_axis_show_label ? xTitleHeight : null
|
|
431
|
+
});
|
|
373
432
|
};
|
|
374
433
|
this.renderHorizontalLabel = (chart, tables, chartContainer) => {
|
|
375
434
|
if (!this.chart || !chart) return;
|
|
@@ -381,85 +440,97 @@ class ChartComponent extends _react.Component {
|
|
|
381
440
|
horizontal_axis_label_position,
|
|
382
441
|
vertical_axis_label_position,
|
|
383
442
|
show_vertical_axis_label,
|
|
384
|
-
show_horizontal_axis_label
|
|
443
|
+
show_horizontal_axis_label,
|
|
444
|
+
horizontal_axis_label_font_size,
|
|
445
|
+
horizontal_axis_label_font_color,
|
|
446
|
+
vertical_axis_label_font_size,
|
|
447
|
+
vertical_axis_label_font_color
|
|
385
448
|
} = chart.config;
|
|
386
|
-
const table =
|
|
387
|
-
const
|
|
449
|
+
const table = getTableById(tables, table_id);
|
|
450
|
+
const defaultTextColor = this.globalTheme === THEME_NAME_MAP.DARK ? DEFAULT_AXIS_LABEL_FONT_COLOR_DARK : DEFAULT_AXIS_LABEL_FONT_COLOR;
|
|
451
|
+
const xColor = horizontal_axis_label_font_color || defaultTextColor;
|
|
452
|
+
const xFontSize = horizontal_axis_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
|
|
453
|
+
const yColor = vertical_axis_label_font_color || defaultTextColor;
|
|
454
|
+
const yFontSize = vertical_axis_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
|
|
388
455
|
const xAxisID = `chart-x-axis-label_${chart.id}`;
|
|
389
456
|
const xLabel = chartContainer.querySelector(`#${xAxisID}`);
|
|
390
457
|
const {
|
|
391
458
|
width: containerWidth
|
|
392
459
|
} = this.chartBoundingClientRect;
|
|
460
|
+
const xTitleHeight = this.getAxisTitleHeight(xFontSize);
|
|
393
461
|
if (!xLabel && show_horizontal_axis_label) {
|
|
394
462
|
const div = document.createElement('div');
|
|
395
463
|
div.id = xAxisID;
|
|
396
464
|
div.className = 'chart-axis-label';
|
|
397
|
-
if (horizontal_axis_summary_type ===
|
|
398
|
-
div.innerHTML =
|
|
465
|
+
if (horizontal_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
466
|
+
div.innerHTML = intl.get('Amount');
|
|
399
467
|
} else {
|
|
400
|
-
const column =
|
|
468
|
+
const column = getTableColumnByKey(table, horizontal_axis_column_key);
|
|
401
469
|
div.innerHTML = `${column ? column.name : ''}`;
|
|
402
470
|
}
|
|
403
|
-
div.setAttribute('style', `color:${
|
|
471
|
+
div.setAttribute('style', `color:${xColor}; font-size:${xFontSize}px; width: ${containerWidth}px; height: ${xTitleHeight}px; line-height: ${xTitleHeight}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
|
|
404
472
|
chartContainer.appendChild(div);
|
|
405
473
|
}
|
|
406
474
|
if (xLabel && show_horizontal_axis_label) {
|
|
407
|
-
xLabel.setAttribute('style', `color:${
|
|
475
|
+
xLabel.setAttribute('style', `color:${xColor}; font-size:${xFontSize}px; width: ${containerWidth}px; height: ${xTitleHeight}px; line-height: ${xTitleHeight}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
|
|
408
476
|
}
|
|
409
477
|
if (xLabel && !show_horizontal_axis_label) {
|
|
410
478
|
xLabel.parentNode.removeChild(xLabel);
|
|
411
479
|
}
|
|
412
480
|
const yAxisID = `chart-y-axis-label_${chart.id}`;
|
|
413
481
|
const yLabel = chartContainer.querySelector(`#${yAxisID}`);
|
|
414
|
-
const
|
|
482
|
+
const yTitleHeight = this.getAxisTitleHeight(yFontSize);
|
|
415
483
|
if (!yLabel && show_vertical_axis_label) {
|
|
416
484
|
const div = document.createElement('div');
|
|
417
485
|
div.id = yAxisID;
|
|
418
486
|
div.className = 'chart-axis-label';
|
|
419
|
-
const column =
|
|
487
|
+
const column = getTableColumnByKey(table, vertical_axis_column_key) || {};
|
|
420
488
|
div.innerHTML = column.name || '';
|
|
421
489
|
const {
|
|
422
490
|
height: containerHeight
|
|
423
491
|
} = this.chartBoundingClientRect;
|
|
424
492
|
let textAlign = 'center';
|
|
425
|
-
if (vertical_axis_label_position ===
|
|
426
|
-
if (vertical_axis_label_position ===
|
|
427
|
-
div.setAttribute('style', `color:${
|
|
493
|
+
if (vertical_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
494
|
+
if (vertical_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
495
|
+
div.setAttribute('style', `color:${yColor}; font-size:${yFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yTitleHeight}px; line-height: ${yTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yTitleHeight)}`);
|
|
428
496
|
chartContainer.appendChild(div);
|
|
429
497
|
}
|
|
430
|
-
if (yLabel &&
|
|
498
|
+
if (yLabel && show_vertical_axis_label) {
|
|
431
499
|
const {
|
|
432
500
|
height: containerHeight
|
|
433
501
|
} = this.chartBoundingClientRect;
|
|
434
502
|
let textAlign = 'center';
|
|
435
|
-
if (vertical_axis_label_position ===
|
|
436
|
-
if (vertical_axis_label_position ===
|
|
437
|
-
yLabel.setAttribute('style', `color:${
|
|
503
|
+
if (vertical_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
504
|
+
if (vertical_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
505
|
+
yLabel.setAttribute('style', `color:${yColor}; font-size:${yFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yTitleHeight}px; line-height: ${yTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yTitleHeight)}`);
|
|
438
506
|
}
|
|
439
|
-
if (yLabel && !
|
|
507
|
+
if (yLabel && !show_vertical_axis_label) {
|
|
440
508
|
yLabel.parentNode.removeChild(yLabel);
|
|
441
509
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
return !!(chart && chart.config && chart.config.show_horizontal_axis_label);
|
|
510
|
+
this.setAxisTitlePadding(chartContainer, {
|
|
511
|
+
left: show_vertical_axis_label ? yTitleHeight : null,
|
|
512
|
+
bottom: show_horizontal_axis_label ? xTitleHeight : null,
|
|
513
|
+
right: null
|
|
514
|
+
});
|
|
448
515
|
};
|
|
449
516
|
this.formatterLegendName = name => {
|
|
450
|
-
if (
|
|
451
|
-
return
|
|
517
|
+
if (typeof name !== 'string') {
|
|
518
|
+
if (!name && typeof name !== 'number') return intl.get(EMPTY_NAME);
|
|
519
|
+
return intl.get(String(name)) || String(name);
|
|
520
|
+
}
|
|
521
|
+
if (name.trim() === 'undefined' || name.trim() === 'null' || name.trim() === '') {
|
|
522
|
+
return intl.get(EMPTY_NAME);
|
|
452
523
|
} else if (name === '_Others') {
|
|
453
|
-
return
|
|
524
|
+
return intl.get('Others');
|
|
454
525
|
} else {
|
|
455
|
-
return
|
|
526
|
+
return intl.get(name) || name;
|
|
456
527
|
}
|
|
457
528
|
};
|
|
458
529
|
this.setLegend = _ref => {
|
|
459
530
|
var _chart$config, _chart$config2;
|
|
460
531
|
let {
|
|
461
532
|
legendName,
|
|
462
|
-
theme =
|
|
533
|
+
theme = CHART_THEME_COLOR['light'],
|
|
463
534
|
legendPosition = 'top-left',
|
|
464
535
|
data,
|
|
465
536
|
colorScale,
|
|
@@ -468,8 +539,8 @@ class ChartComponent extends _react.Component {
|
|
|
468
539
|
} = _ref;
|
|
469
540
|
if (!this.chart) return;
|
|
470
541
|
this.legendConfig = {
|
|
471
|
-
legendRectWidth: [
|
|
472
|
-
legendRectHeight: [
|
|
542
|
+
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,
|
|
543
|
+
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
544
|
r: this.getLegendR(chart),
|
|
474
545
|
legendItemPaddingTop: 5,
|
|
475
546
|
legendItemTextPaddingTop: 13,
|
|
@@ -483,8 +554,9 @@ class ChartComponent extends _react.Component {
|
|
|
483
554
|
};
|
|
484
555
|
|
|
485
556
|
// sort legend data and format data
|
|
486
|
-
|
|
487
|
-
|
|
557
|
+
const clonedData = cloneDeep(data);
|
|
558
|
+
clonedData.forEach(item => item[legendName] = String(item[legendName]));
|
|
559
|
+
const legendData = BaseUtils.sortDataByGroupName(clonedData, legendName, groupColumn, chart);
|
|
488
560
|
const {
|
|
489
561
|
width: chartWidth,
|
|
490
562
|
height: chartHeight,
|
|
@@ -625,7 +697,7 @@ class ChartComponent extends _react.Component {
|
|
|
625
697
|
}).append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('y', legendItemPaddingTop).attr('rx', r).attr('fill', _ref4 => {
|
|
626
698
|
let [groupName] = _ref4;
|
|
627
699
|
if (colorScale) return colorScale(groupName);
|
|
628
|
-
return this.colorMap[groupName] ||
|
|
700
|
+
return this.colorMap[groupName] || CHART_STYLE_COLORS[0];
|
|
629
701
|
}).attr('data-text', _ref5 => {
|
|
630
702
|
let [groupName] = _ref5;
|
|
631
703
|
return groupName;
|
|
@@ -707,7 +779,7 @@ class ChartComponent extends _react.Component {
|
|
|
707
779
|
if (top && bottom) {
|
|
708
780
|
let allHeight = top;
|
|
709
781
|
const groupsData = [];
|
|
710
|
-
const newLegendData =
|
|
782
|
+
const newLegendData = cloneDeep(legendData);
|
|
711
783
|
let lastIndex = 0;
|
|
712
784
|
legendData.forEach((item, index) => {
|
|
713
785
|
const virtualLegend = this.chart.append('g').attr('opacity', 0);
|
|
@@ -732,7 +804,7 @@ class ChartComponent extends _react.Component {
|
|
|
732
804
|
} else {
|
|
733
805
|
let allWidth = start;
|
|
734
806
|
const groupsData = [];
|
|
735
|
-
const newLegendData =
|
|
807
|
+
const newLegendData = cloneDeep(legendData);
|
|
736
808
|
let lastIndex = 0;
|
|
737
809
|
legendData.forEach((item, index) => {
|
|
738
810
|
const virtualLegend = this.chart.append('g').attr('opacity', 0);
|
|
@@ -822,13 +894,13 @@ class ChartComponent extends _react.Component {
|
|
|
822
894
|
this.sortLegend = (result, groupColumn, legendName) => {
|
|
823
895
|
result.forEach(item => {
|
|
824
896
|
const option = groupColumn.data.options.find(option => option.name === item[legendName]);
|
|
825
|
-
if (option
|
|
897
|
+
if (option === null || option === void 0 ? void 0 : option.id) {
|
|
826
898
|
item['group_name_id'] = option.id;
|
|
827
899
|
item['oldName'] = item.name;
|
|
828
900
|
item.name = item['group_name_id'];
|
|
829
901
|
}
|
|
830
902
|
});
|
|
831
|
-
|
|
903
|
+
BaseUtils.sortCharts(result, groupColumn, 'name');
|
|
832
904
|
result.forEach(item => {
|
|
833
905
|
item.name = item['oldName'];
|
|
834
906
|
});
|
|
@@ -841,8 +913,8 @@ class ChartComponent extends _react.Component {
|
|
|
841
913
|
const {
|
|
842
914
|
type
|
|
843
915
|
} = config;
|
|
844
|
-
if (type ===
|
|
845
|
-
if (type ===
|
|
916
|
+
if (type === CHART_TYPE.SCATTER) return 4;
|
|
917
|
+
if (type === CHART_TYPE.MIRROR) return 0;
|
|
846
918
|
return 3;
|
|
847
919
|
};
|
|
848
920
|
this.calcEquilateralTriangle = (cx, cy, size, direction) => {
|
|
@@ -856,12 +928,12 @@ class ChartComponent extends _react.Component {
|
|
|
856
928
|
let groupName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'group_name';
|
|
857
929
|
let groupColumn = arguments.length > 3 ? arguments[3] : undefined;
|
|
858
930
|
let chart = arguments.length > 4 ? arguments[4] : undefined;
|
|
859
|
-
const newData =
|
|
931
|
+
const newData = BaseUtils.sortDataByGroupName(cloneDeep(data), groupName, groupColumn, chart);
|
|
860
932
|
let currentIdx = 0;
|
|
861
|
-
const defaultColors =
|
|
933
|
+
const defaultColors = CHART_STYLE_COLORS;
|
|
862
934
|
let colors = defaultColors;
|
|
863
935
|
if (chartColorTheme) {
|
|
864
|
-
colors =
|
|
936
|
+
colors = BaseUtils.getCurrentTheme(chartColorTheme).colors;
|
|
865
937
|
}
|
|
866
938
|
const colorMap = newData.reduce((acc, cur) => {
|
|
867
939
|
const key = cur[groupName] || cur[groupName] === 0 ? cur[groupName] : '';
|
|
@@ -961,37 +1033,25 @@ class ChartComponent extends _react.Component {
|
|
|
961
1033
|
formatted_value: item.formatted_value + ''
|
|
962
1034
|
});
|
|
963
1035
|
}
|
|
964
|
-
if (type ===
|
|
1036
|
+
if (type === CHART_TYPE.WORLD_MAP_BUBBLE) {
|
|
965
1037
|
sum += item.value;
|
|
966
1038
|
}
|
|
967
1039
|
}
|
|
968
1040
|
}
|
|
969
1041
|
});
|
|
970
|
-
if (type ===
|
|
1042
|
+
if (type === CHART_TYPE.WORLD_MAP_BUBBLE) {
|
|
971
1043
|
statisticNewData.sum = sum;
|
|
972
1044
|
}
|
|
973
1045
|
return statisticNewData;
|
|
974
1046
|
};
|
|
975
|
-
this.isShowXAxisLabel = chart => {
|
|
976
|
-
return !!(chart && chart.config && chart.config.x_axis_show_label);
|
|
977
|
-
};
|
|
978
|
-
this.isShowYAxisLabel = chart => {
|
|
979
|
-
return !!(chart && chart.config && chart.config.y_axis_show_label);
|
|
980
|
-
};
|
|
981
|
-
this.isShowYAxisLeftLabel = chart => {
|
|
982
|
-
return !!(chart && chart.config && chart.config.show_y_axis_left_label);
|
|
983
|
-
};
|
|
984
|
-
this.isShowYAxisRightLabel = chart => {
|
|
985
|
-
return !!(chart && chart.config && chart.config.show_y_axis_right_label);
|
|
986
|
-
};
|
|
987
1047
|
this.getThemeColors = function () {
|
|
988
1048
|
let themeColors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
989
1049
|
let theme = arguments.length > 1 ? arguments[1] : undefined;
|
|
990
1050
|
// dark->custom->light
|
|
991
|
-
if (theme ===
|
|
992
|
-
themeColors =
|
|
1051
|
+
if (theme === THEME_NAME_MAP.DARK) {
|
|
1052
|
+
themeColors = CHART_THEME_COLOR.dark;
|
|
993
1053
|
}
|
|
994
|
-
return themeColors ||
|
|
1054
|
+
return themeColors || CHART_THEME_COLOR[THEME_NAME_MAP.LIGHT];
|
|
995
1055
|
};
|
|
996
1056
|
this.setDispalyGoalLine = (goal_label, goal_value, insertPadding, yScale) => {
|
|
997
1057
|
const {
|
|
@@ -1012,7 +1072,7 @@ class ChartComponent extends _react.Component {
|
|
|
1012
1072
|
label_font_size,
|
|
1013
1073
|
text
|
|
1014
1074
|
} = _ref6;
|
|
1015
|
-
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',
|
|
1075
|
+
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 => {
|
|
1016
1076
|
if (!g.node()) return;
|
|
1017
1077
|
const {
|
|
1018
1078
|
width
|
|
@@ -1031,7 +1091,7 @@ class ChartComponent extends _react.Component {
|
|
|
1031
1091
|
label_font_size,
|
|
1032
1092
|
text
|
|
1033
1093
|
} = _ref7;
|
|
1034
|
-
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',
|
|
1094
|
+
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 => {
|
|
1035
1095
|
if (g.node()) {
|
|
1036
1096
|
var _g$node;
|
|
1037
1097
|
const {
|
|
@@ -1053,7 +1113,7 @@ class ChartComponent extends _react.Component {
|
|
|
1053
1113
|
label_font_size,
|
|
1054
1114
|
text
|
|
1055
1115
|
} = _ref8;
|
|
1056
|
-
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size',
|
|
1116
|
+
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 => {
|
|
1057
1117
|
if (!g.node()) return;
|
|
1058
1118
|
const {
|
|
1059
1119
|
width,
|
|
@@ -1061,7 +1121,7 @@ class ChartComponent extends _react.Component {
|
|
|
1061
1121
|
} = g.node().getBoundingClientRect();
|
|
1062
1122
|
const translateX = Number(x) + xWidth / 2 - width / 2;
|
|
1063
1123
|
let translateY = Number(y) + Number(yheight / 2) + height / 2;
|
|
1064
|
-
if (chartType ===
|
|
1124
|
+
if (chartType === CHART_TYPE.BAR_STACK) {
|
|
1065
1125
|
translateY = translateY;
|
|
1066
1126
|
}
|
|
1067
1127
|
g.attr('transform', `translate(${translateX}, ${translateY})`);
|
|
@@ -1072,8 +1132,8 @@ class ChartComponent extends _react.Component {
|
|
|
1072
1132
|
allGroup.forEach(g => {
|
|
1073
1133
|
const rects = Array.from(g.children).filter(item => item.tagName !== 'text');
|
|
1074
1134
|
rects.forEach(item => {
|
|
1075
|
-
d3.select(item).transition().duration(this.
|
|
1076
|
-
if ([
|
|
1135
|
+
d3.select(item).transition().duration(this.interactionDuration).attr('opacity', 1);
|
|
1136
|
+
if ([CHART_TYPE.PIE, CHART_TYPE.RING].includes(chartType)) {
|
|
1077
1137
|
d3.select(item).attr('stroke-width', 2);
|
|
1078
1138
|
}
|
|
1079
1139
|
});
|
|
@@ -1084,9 +1144,9 @@ class ChartComponent extends _react.Component {
|
|
|
1084
1144
|
const rects = Array.from(g.children).filter(item => item.tagName !== 'text');
|
|
1085
1145
|
rects.forEach(item => {
|
|
1086
1146
|
if (item.getAttribute('data-groupName') !== curGroupName) {
|
|
1087
|
-
d3.selectAll([item]).transition().duration(this.
|
|
1147
|
+
d3.selectAll([item]).transition().duration(this.interactionDuration).attr('opacity', 0.3);
|
|
1088
1148
|
} else {
|
|
1089
|
-
if ([
|
|
1149
|
+
if ([CHART_TYPE.PIE, CHART_TYPE.RING].includes(chartType)) {
|
|
1090
1150
|
d3.select(item).attr('stroke-width', 0.5);
|
|
1091
1151
|
}
|
|
1092
1152
|
}
|
|
@@ -1094,37 +1154,222 @@ class ChartComponent extends _react.Component {
|
|
|
1094
1154
|
});
|
|
1095
1155
|
}
|
|
1096
1156
|
};
|
|
1097
|
-
// Use clipPath to make rectangle rounded corners
|
|
1098
1157
|
this.addClipPath = _ref9 => {
|
|
1099
1158
|
let {
|
|
1100
1159
|
rect,
|
|
1101
|
-
parentNode,
|
|
1102
1160
|
attr,
|
|
1103
|
-
rectId,
|
|
1104
1161
|
borderRadiusVal
|
|
1105
1162
|
} = _ref9;
|
|
1163
|
+
return this.addRoundedClip(rect, attr === 'x' ? 'x' : 'y', null, borderRadiusVal);
|
|
1164
|
+
};
|
|
1165
|
+
this.addRoundedClip = function (rect, orient) {
|
|
1166
|
+
let width = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1167
|
+
let radiusOverride = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
1106
1168
|
const {
|
|
1107
1169
|
borderRadius
|
|
1108
|
-
} =
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1170
|
+
} = _this.chartBoundingClientRect;
|
|
1171
|
+
const x = Number(rect.getAttribute('x'));
|
|
1172
|
+
const y = Number(rect.getAttribute('y'));
|
|
1173
|
+
const w = width != null ? width : Number(rect.getAttribute('width'));
|
|
1174
|
+
const h = Number(rect.getAttribute('height'));
|
|
1175
|
+
const computedRadius = orient === 'x' ? Math.min(h * borderRadius, h / 2, w / 2) : Math.min(w * borderRadius, w / 2, h / 2);
|
|
1176
|
+
const radius = radiusOverride != null ? Math.min(radiusOverride, w / 2, h / 2) : computedRadius;
|
|
1177
|
+
const d = orient === 'x' ? _this.getRightRoundedRectPath(x, y, w, h, radius) : _this.getTopRoundedRectPath(x, y, w, h, radius);
|
|
1178
|
+
const clipId = `rounded-clip-${Math.random().toString(36).slice(2)}`;
|
|
1179
|
+
const path = _this.getDefs().append('clipPath').attr('id', clipId).append('path').attr('class', 'rounded-clip-path').attr('data-x', x).attr('data-y', y).attr('data-width', w).attr('data-height', h).attr('data-radius', radius).attr('data-orient', orient).attr('d', d);
|
|
1180
|
+
d3.select(rect).attr('clip-path', `url(#${clipId})`);
|
|
1181
|
+
_this._clipMaskByRect.set(rect, path.node());
|
|
1182
|
+
return path.node();
|
|
1183
|
+
};
|
|
1184
|
+
this.animateMaskForRect = (rect, orient, baseline, t) => {
|
|
1185
|
+
const path = this._clipMaskByRect && this._clipMaskByRect.get(rect);
|
|
1186
|
+
if (!path) return;
|
|
1187
|
+
const x = Number(path.getAttribute('data-x'));
|
|
1188
|
+
const y = Number(path.getAttribute('data-y'));
|
|
1189
|
+
const width = Number(path.getAttribute('data-width'));
|
|
1190
|
+
const height = Number(path.getAttribute('data-height'));
|
|
1191
|
+
const radius = Number(path.getAttribute('data-radius'));
|
|
1192
|
+
const el = d3.select(path);
|
|
1193
|
+
if (orient === 'x') {
|
|
1194
|
+
const interpX = d3.interpolateNumber(baseline, x);
|
|
1195
|
+
const interpW = d3.interpolateNumber(0, width);
|
|
1196
|
+
el.attr('d', this.getRightRoundedRectPath(baseline, y, 0, height, radius)).transition(t).attrTween('d', () => tt => this.getRightRoundedRectPath(interpX(tt), y, interpW(tt), height, radius));
|
|
1117
1197
|
} else {
|
|
1118
|
-
const
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
const safeBorderRadius = Math.min(borderRadiusVal !== null && borderRadiusVal !== void 0 ? borderRadiusVal : computedBorderRadius, rectWidth / 2, rectHeight / 2);
|
|
1122
|
-
clipRect.attr('rx', safeBorderRadius);
|
|
1123
|
-
clipRect.attr('height', rectHeight + safeBorderRadius);
|
|
1198
|
+
const interpY = d3.interpolateNumber(baseline, y);
|
|
1199
|
+
const interpH = d3.interpolateNumber(0, height);
|
|
1200
|
+
el.attr('d', this.getTopRoundedRectPath(x, baseline, width, 0, radius)).transition(t).attrTween('d', () => tt => this.getTopRoundedRectPath(x, interpY(tt), width, interpH(tt), radius));
|
|
1124
1201
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1202
|
+
};
|
|
1203
|
+
this.getTopRoundedRectPath = (x, y, width, height, radius) => {
|
|
1204
|
+
const r = Math.min(radius, width / 2, height / 2);
|
|
1205
|
+
if (height <= 0) return `M${x},${y} L${x + width},${y} L${x + width},${y} L${x},${y} Z`;
|
|
1206
|
+
return `M${x},${y + r} Q${x},${y} ${x + r},${y} L${x + width - r},${y} Q${x + width},${y} ${x + width},${y + r} L${x + width},${y + height} L${x},${y + height} Z`;
|
|
1207
|
+
};
|
|
1208
|
+
this.getRightRoundedRectPath = (x, y, width, height, radius) => {
|
|
1209
|
+
const r = Math.min(radius, width / 2, height / 2);
|
|
1210
|
+
if (width <= 0) return `M${x},${y} L${x},${y + height} L${x},${y + height} L${x},${y} Z`;
|
|
1211
|
+
return `M${x},${y} L${x + width - r},${y} Q${x + width},${y} ${x + width},${y + r} L${x + width},${y + height - r} Q${x + width},${y + height} ${x + width - r},${y + height} L${x},${y + height} Z`;
|
|
1212
|
+
};
|
|
1213
|
+
this.animateRectGrowInY = function (selection) {
|
|
1214
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
|
|
1215
|
+
if (!selection || selection.empty()) return;
|
|
1216
|
+
const self = _this;
|
|
1217
|
+
selection.each(function () {
|
|
1218
|
+
const finalY = Number(this.getAttribute('y'));
|
|
1219
|
+
const finalHeight = Number(this.getAttribute('height'));
|
|
1220
|
+
if (!(finalHeight > 0)) return;
|
|
1221
|
+
const baseline = finalY + finalHeight;
|
|
1222
|
+
const t = d3.transition(self.enterTransitionName).duration(duration).ease(d3.easeCubicOut);
|
|
1223
|
+
d3.select(this).attr('y', baseline).attr('height', 0).transition(t).attr('y', finalY).attr('height', finalHeight);
|
|
1224
|
+
self.animateMaskForRect(this, 'y', baseline, t);
|
|
1225
|
+
});
|
|
1226
|
+
};
|
|
1227
|
+
this.animateStackGrowInY = function (selection) {
|
|
1228
|
+
let groupKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node => node.getAttribute('x');
|
|
1229
|
+
let duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _this.transitionDuration;
|
|
1230
|
+
if (!selection || selection.empty()) return null;
|
|
1231
|
+
const columns = new Map();
|
|
1232
|
+
selection.each(function () {
|
|
1233
|
+
if (!(Number(this.getAttribute('height')) > 0)) return;
|
|
1234
|
+
const key = groupKey(this);
|
|
1235
|
+
if (!columns.has(key)) columns.set(key, []);
|
|
1236
|
+
columns.get(key).push(this);
|
|
1237
|
+
});
|
|
1238
|
+
if (columns.size === 0) return null;
|
|
1239
|
+
const t = d3.transition(_this.enterTransitionName).duration(duration).ease(d3.easeCubicOut);
|
|
1240
|
+
columns.forEach(rects => {
|
|
1241
|
+
let baselineY = -Infinity;
|
|
1242
|
+
rects.forEach(rect => {
|
|
1243
|
+
baselineY = Math.max(baselineY, Number(rect.getAttribute('y')) + Number(rect.getAttribute('height')));
|
|
1244
|
+
});
|
|
1245
|
+
rects.forEach(rect => {
|
|
1246
|
+
const finalY = Number(rect.getAttribute('y'));
|
|
1247
|
+
const finalHeight = Number(rect.getAttribute('height'));
|
|
1248
|
+
d3.select(rect).attr('y', baselineY).attr('height', 0).transition(t).attr('y', finalY).attr('height', finalHeight);
|
|
1249
|
+
_this.animateMaskForRect(rect, 'y', baselineY, t);
|
|
1250
|
+
});
|
|
1251
|
+
});
|
|
1252
|
+
return t;
|
|
1253
|
+
};
|
|
1254
|
+
this.animateRectGrowInX = function (selection) {
|
|
1255
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
|
|
1256
|
+
if (!selection || selection.empty()) return;
|
|
1257
|
+
const self = _this;
|
|
1258
|
+
selection.each(function () {
|
|
1259
|
+
const finalX = Number(this.getAttribute('x'));
|
|
1260
|
+
const finalWidth = Number(this.getAttribute('width'));
|
|
1261
|
+
if (!(finalWidth > 0)) return;
|
|
1262
|
+
const t = d3.transition(self.enterTransitionName).duration(duration).ease(d3.easeCubicOut);
|
|
1263
|
+
d3.select(this).attr('width', 0).transition(t).attr('width', finalWidth);
|
|
1264
|
+
self.animateMaskForRect(this, 'x', finalX, t);
|
|
1265
|
+
});
|
|
1266
|
+
};
|
|
1267
|
+
this.animateStackGrowInX = function (selection) {
|
|
1268
|
+
let groupKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node => node.getAttribute('y');
|
|
1269
|
+
let duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _this.transitionDuration;
|
|
1270
|
+
if (!selection || selection.empty()) return null;
|
|
1271
|
+
const rows = new Map();
|
|
1272
|
+
selection.each(function () {
|
|
1273
|
+
if (!(Number(this.getAttribute('width')) > 0)) return;
|
|
1274
|
+
const key = groupKey(this);
|
|
1275
|
+
if (!rows.has(key)) rows.set(key, []);
|
|
1276
|
+
rows.get(key).push(this);
|
|
1277
|
+
});
|
|
1278
|
+
if (rows.size === 0) return null;
|
|
1279
|
+
const t = d3.transition(_this.enterTransitionName).duration(duration).ease(d3.easeCubicOut);
|
|
1280
|
+
rows.forEach(rects => {
|
|
1281
|
+
let baselineX = Infinity;
|
|
1282
|
+
rects.forEach(rect => {
|
|
1283
|
+
baselineX = Math.min(baselineX, Number(rect.getAttribute('x')));
|
|
1284
|
+
});
|
|
1285
|
+
rects.forEach(rect => {
|
|
1286
|
+
const finalX = Number(rect.getAttribute('x'));
|
|
1287
|
+
const finalWidth = Number(rect.getAttribute('width'));
|
|
1288
|
+
d3.select(rect).attr('x', baselineX).attr('width', 0).transition(t).attr('x', finalX).attr('width', finalWidth);
|
|
1289
|
+
_this.animateMaskForRect(rect, 'x', baselineX, t);
|
|
1290
|
+
});
|
|
1291
|
+
});
|
|
1292
|
+
return t;
|
|
1293
|
+
};
|
|
1294
|
+
this.animateArcGrowIn = function (selection, arc) {
|
|
1295
|
+
let duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _this.transitionDuration;
|
|
1296
|
+
if (!selection || selection.empty()) return;
|
|
1297
|
+
const transitionName = _this.enterTransitionName;
|
|
1298
|
+
selection.each(function (d) {
|
|
1299
|
+
const path = d3.select(this);
|
|
1300
|
+
const interpolate = d3.interpolate({
|
|
1301
|
+
startAngle: d.startAngle,
|
|
1302
|
+
endAngle: d.startAngle,
|
|
1303
|
+
padAngle: d.padAngle
|
|
1304
|
+
}, {
|
|
1305
|
+
startAngle: d.startAngle,
|
|
1306
|
+
endAngle: d.endAngle,
|
|
1307
|
+
padAngle: d.padAngle
|
|
1308
|
+
});
|
|
1309
|
+
path.attr('d', arc(interpolate(0))).transition(transitionName).duration(duration).ease(d3.easeCubicOut).attrTween('d', () => t => arc(interpolate(t)));
|
|
1310
|
+
});
|
|
1311
|
+
};
|
|
1312
|
+
this.animatePathDrawIn = function (selection) {
|
|
1313
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
|
|
1314
|
+
if (!selection || selection.empty()) return;
|
|
1315
|
+
const transitionName = _this.enterTransitionName;
|
|
1316
|
+
selection.each(function () {
|
|
1317
|
+
const path = d3.select(this);
|
|
1318
|
+
let totalLength = 0;
|
|
1319
|
+
try {
|
|
1320
|
+
totalLength = this.getTotalLength();
|
|
1321
|
+
} catch (e) {
|
|
1322
|
+
totalLength = 0;
|
|
1323
|
+
}
|
|
1324
|
+
if (!(totalLength > 0)) return;
|
|
1325
|
+
path.attr('stroke-dasharray', `${totalLength} ${totalLength}`).attr('stroke-dashoffset', totalLength).transition(transitionName).duration(duration).ease(d3.easeLinear).attr('stroke-dashoffset', 0).on('end', function () {
|
|
1326
|
+
d3.select(this).attr('stroke-dasharray', null).attr('stroke-dashoffset', null);
|
|
1327
|
+
});
|
|
1328
|
+
});
|
|
1329
|
+
};
|
|
1330
|
+
this.animateRevealInX = function (selection, width) {
|
|
1331
|
+
let duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _this.transitionDuration;
|
|
1332
|
+
if (!selection || selection.empty()) return;
|
|
1333
|
+
const {
|
|
1334
|
+
height: chartHeight
|
|
1335
|
+
} = _this.chartBoundingClientRect;
|
|
1336
|
+
const clipId = `reveal-clip-${Math.random().toString(36).slice(2)}`;
|
|
1337
|
+
const clipPath = _this.getDefs().append('clipPath').attr('id', clipId);
|
|
1338
|
+
const clipRect = clipPath.append('rect').attr('x', 0).attr('y', 0).attr('width', 0).attr('height', chartHeight);
|
|
1339
|
+
selection.attr('clip-path', `url(#${clipId})`);
|
|
1340
|
+
clipRect.transition(_this.enterTransitionName).duration(duration).ease(d3.easeLinear).attr('width', width).on('end', () => {
|
|
1341
|
+
selection.attr('clip-path', null);
|
|
1342
|
+
clipPath.remove();
|
|
1343
|
+
});
|
|
1344
|
+
};
|
|
1345
|
+
this.animateFadeIn = function (selection) {
|
|
1346
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
|
|
1347
|
+
let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
1348
|
+
let finalOpacity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
1349
|
+
if (!selection || selection.empty()) return;
|
|
1350
|
+
const transitionName = _this.enterTransitionName;
|
|
1351
|
+
selection.each(function () {
|
|
1352
|
+
const el = d3.select(this);
|
|
1353
|
+
let target = finalOpacity;
|
|
1354
|
+
if (target == null) {
|
|
1355
|
+
const orig = this.getAttribute('opacity');
|
|
1356
|
+
const parsed = orig === null || orig === '' ? 1 : Number(orig);
|
|
1357
|
+
target = Number.isNaN(parsed) ? 1 : parsed;
|
|
1358
|
+
}
|
|
1359
|
+
if (!(target > 0)) return;
|
|
1360
|
+
el.attr('opacity', 0).transition(transitionName).duration(duration).delay(delay).ease(d3.easeLinear).attr('opacity', target);
|
|
1361
|
+
});
|
|
1362
|
+
};
|
|
1363
|
+
this.animateCircleZoomIn = function (selection) {
|
|
1364
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
|
|
1365
|
+
if (!selection || selection.empty()) return;
|
|
1366
|
+
const transitionName = _this.enterTransitionName;
|
|
1367
|
+
selection.each(function () {
|
|
1368
|
+
const circle = d3.select(this);
|
|
1369
|
+
const finalR = Number(this.getAttribute('r')) || 0;
|
|
1370
|
+
if (!(finalR > 0)) return;
|
|
1371
|
+
circle.attr('r', 0).transition(transitionName).duration(duration).ease(d3.easeCubicOut).attr('r', finalR);
|
|
1372
|
+
});
|
|
1128
1373
|
};
|
|
1129
1374
|
this.drawYaxis = function (g, theme) {
|
|
1130
1375
|
let rightAxisOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -1138,33 +1383,92 @@ class ChartComponent extends _react.Component {
|
|
|
1138
1383
|
// add text
|
|
1139
1384
|
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
1140
1385
|
g.selectAll('text').attr('fill', theme.textColor);
|
|
1386
|
+
_this.thinYAxisTicks(g);
|
|
1141
1387
|
_this.checkTextOverflow(g.selectAll('text').nodes());
|
|
1142
1388
|
|
|
1143
1389
|
// line
|
|
1144
1390
|
g.selectAll('line').node() && g.selectAll('line').node().remove(); // delete the first line
|
|
1145
|
-
g.selectAll('.tick line').clone().attr('x2', chartWidth -
|
|
1391
|
+
g.selectAll('.tick line').clone().attr('x2', chartWidth - _this.getYAxisTranslateX() - insertPadding - rightAxisOffset).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
|
|
1146
1392
|
|
|
1147
1393
|
// update g translateX
|
|
1148
|
-
g.attr('transform', `translate(${
|
|
1394
|
+
g.attr('transform', `translate(${_this.getYAxisTranslateX()}, 0)`);
|
|
1395
|
+
};
|
|
1396
|
+
this.thinYAxisTicks = g => {
|
|
1397
|
+
const ticks = g.selectAll('.tick').nodes();
|
|
1398
|
+
if (ticks.length <= 2) return;
|
|
1399
|
+
const visibleTicks = ticks.map((tick, index) => {
|
|
1400
|
+
const text = d3.select(tick).select('text').node();
|
|
1401
|
+
if (!text) return null;
|
|
1402
|
+
const {
|
|
1403
|
+
top,
|
|
1404
|
+
bottom
|
|
1405
|
+
} = text.getBoundingClientRect();
|
|
1406
|
+
return {
|
|
1407
|
+
tick,
|
|
1408
|
+
index,
|
|
1409
|
+
top,
|
|
1410
|
+
bottom
|
|
1411
|
+
};
|
|
1412
|
+
}).filter(Boolean).sort((a, b) => a.top - b.top);
|
|
1413
|
+
const keptTicks = [];
|
|
1414
|
+
let prevBottom = -Infinity;
|
|
1415
|
+
visibleTicks.forEach(_ref10 => {
|
|
1416
|
+
let {
|
|
1417
|
+
tick,
|
|
1418
|
+
index,
|
|
1419
|
+
top,
|
|
1420
|
+
bottom
|
|
1421
|
+
} = _ref10;
|
|
1422
|
+
const shouldKeepFirstTick = index === 0;
|
|
1423
|
+
const shouldKeepLastTick = index === ticks.length - 1;
|
|
1424
|
+
const hasEnoughSpace = top > prevBottom + this.yAxisTickLabelGap;
|
|
1425
|
+
if (shouldKeepLastTick) {
|
|
1426
|
+
keptTicks.forEach(keptTick => {
|
|
1427
|
+
if (keptTick.bottom + this.yAxisTickLabelGap >= top) {
|
|
1428
|
+
d3.select(keptTick.tick).attr('opacity', 0);
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
d3.select(tick).attr('opacity', 1);
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
if (shouldKeepFirstTick || hasEnoughSpace) {
|
|
1435
|
+
d3.select(tick).attr('opacity', 1);
|
|
1436
|
+
keptTicks.push({
|
|
1437
|
+
tick,
|
|
1438
|
+
bottom
|
|
1439
|
+
});
|
|
1440
|
+
prevBottom = bottom;
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
d3.select(tick).attr('opacity', 0);
|
|
1444
|
+
});
|
|
1149
1445
|
};
|
|
1150
1446
|
this.checkTextOverflow = allTextEl => {
|
|
1151
1447
|
const {
|
|
1152
1448
|
insertPadding
|
|
1153
1449
|
} = this.chartBoundingClientRect;
|
|
1154
1450
|
const allTextWidth = allTextEl.map(item => {
|
|
1451
|
+
const tick = item.parentNode;
|
|
1452
|
+
if (tick && Number(tick.getAttribute('opacity')) === 0) return 0;
|
|
1155
1453
|
const {
|
|
1156
1454
|
width
|
|
1157
1455
|
} = item.getBoundingClientRect();
|
|
1158
1456
|
return width;
|
|
1159
1457
|
});
|
|
1160
|
-
const maxTextWidth = Math.max(...allTextWidth);
|
|
1458
|
+
const maxTextWidth = Math.max(...allTextWidth, 0);
|
|
1161
1459
|
this.horizontalOverflowOffset = 0;
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
const offset =
|
|
1460
|
+
const requiredLeftSpace = maxTextWidth + 3;
|
|
1461
|
+
if (requiredLeftSpace > insertPadding) {
|
|
1462
|
+
const offset = requiredLeftSpace - insertPadding;
|
|
1165
1463
|
this.horizontalOverflowOffset = offset;
|
|
1166
1464
|
}
|
|
1167
1465
|
};
|
|
1466
|
+
this.getYAxisTranslateX = () => {
|
|
1467
|
+
const {
|
|
1468
|
+
insertPadding
|
|
1469
|
+
} = this.chartBoundingClientRect;
|
|
1470
|
+
return insertPadding + this.horizontalOverflowOffset;
|
|
1471
|
+
};
|
|
1168
1472
|
this.checkTickOverlap = (g, axis) => {
|
|
1169
1473
|
const allTicks = g.selectAll('.tick').nodes();
|
|
1170
1474
|
if (axis === 'yAxis') {
|
|
@@ -1316,10 +1620,84 @@ class ChartComponent extends _react.Component {
|
|
|
1316
1620
|
const annotationWrapper = contentWrapper.insert('g', ':first-child').attr('class', 'vertical-annotation-wrapper');
|
|
1317
1621
|
annotationWrapper.append('line').attr('x1', x).attr('y1', insertPadding + marginTop).attr('x2', x).attr('y2', chartHeight - insertPadding).attr('stroke', theme.XAxisColor);
|
|
1318
1622
|
};
|
|
1623
|
+
this.setLegendForHeatMap = _ref11 => {
|
|
1624
|
+
let {
|
|
1625
|
+
exampleColors,
|
|
1626
|
+
themeColors
|
|
1627
|
+
} = _ref11;
|
|
1628
|
+
const legendOffsetY = 3;
|
|
1629
|
+
const legendItemTextWidth = 32;
|
|
1630
|
+
const legendItemWidth = 12;
|
|
1631
|
+
const legendItemHeight = 12;
|
|
1632
|
+
const legendItemGap = 3;
|
|
1633
|
+
const legendItemRadius = 2;
|
|
1634
|
+
const legendWrapper = this.chart.append('g').attr('class', 'legend-heat-map-wrapper').attr('transform', `translate(0, ${legendOffsetY})`);
|
|
1635
|
+
legendWrapper.append('text').attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(intl.get('Less'));
|
|
1636
|
+
exampleColors.forEach((color, index) => {
|
|
1637
|
+
legendWrapper.append('rect').attr('x', legendItemTextWidth + index * legendItemWidth + index * legendItemGap).attr('width', legendItemWidth).attr('height', legendItemHeight).attr('rx', legendItemRadius).attr('fill', color).attr('stroke', FILL_BORDER_COLOR_MAP[color]).attr('stroke-width', 1);
|
|
1638
|
+
});
|
|
1639
|
+
legendWrapper.append('text').attr('x', 182).attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(intl.get('More'));
|
|
1640
|
+
};
|
|
1641
|
+
this.setContinuousLegend = _ref12 => {
|
|
1642
|
+
var _this$chart$node2;
|
|
1643
|
+
let {
|
|
1644
|
+
previewType,
|
|
1645
|
+
theme,
|
|
1646
|
+
colorRange = [],
|
|
1647
|
+
legendDirection,
|
|
1648
|
+
legendSize,
|
|
1649
|
+
legendTextRange,
|
|
1650
|
+
bubbleColor,
|
|
1651
|
+
type
|
|
1652
|
+
} = _ref12;
|
|
1653
|
+
const {
|
|
1654
|
+
width: chartWidth,
|
|
1655
|
+
height: chartHeight,
|
|
1656
|
+
insertPadding
|
|
1657
|
+
} = this.chartBoundingClientRect;
|
|
1658
|
+
const legendRectWidth = legendDirection === 'vertical' ? 12 : Math.min(legendSize * 100, chartWidth - insertPadding * 2);
|
|
1659
|
+
const legendRectHeight = legendDirection === 'vertical' ? Math.min(legendSize * 100, chartHeight - insertPadding * 2) : 12;
|
|
1660
|
+
const legendTextOffset = 2;
|
|
1661
|
+
const legendTextHeightSpace = legendDirection === 'vertical' ? 0 : 14 + legendTextOffset;
|
|
1662
|
+
if (![CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
|
|
1663
|
+
var _this$chart$node;
|
|
1664
|
+
const gradient = this.chart.append('defs').attr('class', 'linear-gradient-wrapper').append('linearGradient').attr("id", `gradient-${(_this$chart$node = this.chart.node()) === null || _this$chart$node === void 0 ? void 0 : _this$chart$node.id}-${previewType}`).attr("x1", '0%').attr("y1", '0%').attr("x2", legendDirection === 'vertical' ? '0%' : '100%').attr("y2", legendDirection === 'vertical' ? '100%' : '0%');
|
|
1665
|
+
gradient.append('stop').attr('offset', '0%').attr('stop-color', `${colorRange[0]}`);
|
|
1666
|
+
gradient.append('stop').attr('offset', '50%').attr('stop-color', `${colorRange[4]}`);
|
|
1667
|
+
gradient.append('stop').attr('offset', '100%').attr('stop-color', `${colorRange[8]}`);
|
|
1668
|
+
}
|
|
1669
|
+
const continuousLegendWrapper = this.chart.append('g').attr('class', 'legend-continuous-wrapper').attr('transform', `translate(0, ${chartHeight - legendRectHeight - legendTextHeightSpace})`);
|
|
1670
|
+
continuousLegendWrapper.append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('fill', [CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type) ? bubbleColor : `url(#gradient-${(_this$chart$node2 = this.chart.node()) === null || _this$chart$node2 === void 0 ? void 0 : _this$chart$node2.id}-${previewType})`).call(g => {
|
|
1671
|
+
if ([CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
|
|
1672
|
+
continuousLegendWrapper.append('polygon').attr('points', `0,0 ${legendRectWidth - 0.5},0 0,${legendRectHeight - 0.5}`).attr('fill', '#fff').attr('stroke', '#fff');
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
continuousLegendWrapper.append('text').attr('class', 'range-start').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).text(legendTextRange[0]).call(g => {
|
|
1676
|
+
const {
|
|
1677
|
+
height
|
|
1678
|
+
} = g.node().getBoundingClientRect();
|
|
1679
|
+
g.attr('x', legendDirection === 'vertical' ? legendRectWidth + legendTextOffset : legendTextOffset);
|
|
1680
|
+
g.attr('y', legendDirection === 'vertical' ? height : height + legendRectHeight);
|
|
1681
|
+
});
|
|
1682
|
+
continuousLegendWrapper.append('text').attr('class', 'range-end').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).text(legendTextRange[1]).call(g => {
|
|
1683
|
+
const {
|
|
1684
|
+
width,
|
|
1685
|
+
height
|
|
1686
|
+
} = g.node().getBoundingClientRect();
|
|
1687
|
+
g.attr('x', legendDirection === 'vertical' ? legendRectWidth + legendTextOffset : legendRectWidth - width);
|
|
1688
|
+
g.attr('y', legendDirection === 'vertical' ? legendRectHeight - legendTextOffset : height + legendRectHeight);
|
|
1689
|
+
});
|
|
1690
|
+
};
|
|
1319
1691
|
this.initLabelStroke(props === null || props === void 0 ? void 0 : props.globalTheme);
|
|
1320
1692
|
this.chartBoundingClientRect = {};
|
|
1321
|
-
this.transitionDuration =
|
|
1693
|
+
this.transitionDuration = 450;
|
|
1694
|
+
this.interactionDuration = 150;
|
|
1322
1695
|
this.areaTransitionDuration = 200;
|
|
1696
|
+
this.yAxisTickLabelGap = 4;
|
|
1697
|
+
this.axisTitleMinHeight = 20;
|
|
1698
|
+
this.enterTransitionName = 'enter';
|
|
1699
|
+
this._defs = null;
|
|
1700
|
+
this._clipMaskByRect = new Map();
|
|
1323
1701
|
}
|
|
1324
1702
|
componentDidMount() {
|
|
1325
1703
|
window.addEventListener('resize', this.handleResize);
|
|
@@ -1332,5 +1710,4 @@ class ChartComponent extends _react.Component {
|
|
|
1332
1710
|
componentWillUnmount() {
|
|
1333
1711
|
window.removeEventListener('resize', this.handleResize);
|
|
1334
1712
|
}
|
|
1335
|
-
}
|
|
1336
|
-
exports.default = ChartComponent;
|
|
1713
|
+
}
|