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
package/dist/view/wrapper/map.js
CHANGED
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _dtableUtils = require("dtable-utils");
|
|
15
|
-
var _constants = require("../../constants");
|
|
16
|
-
var _utils = require("../../utils");
|
|
17
|
-
var _colorRules = require("../../constants/color-rules");
|
|
18
|
-
var _context = _interopRequireDefault(require("../../context"));
|
|
19
|
-
var _mapJson = _interopRequireDefault(require("../../services/map-json"));
|
|
20
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
21
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
22
|
-
class Map extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import { feature } from 'topojson';
|
|
5
|
+
import { getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
6
|
+
import { CHART_SUMMARY_TYPE, MAP_LEVEL, DEFAULT_NUMBER_FORMAT_OBJECT, CHART_THEME_COLOR } from '../../constants';
|
|
7
|
+
import { BaseUtils } from '../../utils';
|
|
8
|
+
import { COLOR_OPTIONS } from '../../constants/color-rules';
|
|
9
|
+
import context from '../../context';
|
|
10
|
+
import fetchMapJson from '../../services/map-json';
|
|
11
|
+
import ToolTip from '../../components/tooltip';
|
|
12
|
+
import ChartComponent from './chart-component';
|
|
13
|
+
class Map extends ChartComponent {
|
|
23
14
|
constructor(props) {
|
|
24
15
|
super(props);
|
|
25
|
-
this.handleResize = () => {
|
|
26
|
-
this.destroyChart();
|
|
27
|
-
this.createChart();
|
|
28
|
-
this.drawChart();
|
|
29
|
-
};
|
|
30
16
|
this.createChart = () => {
|
|
31
17
|
const {
|
|
32
18
|
chart
|
|
@@ -44,13 +30,13 @@ class Map extends _chartComponent.default {
|
|
|
44
30
|
if (!Array.isArray(data)) return;
|
|
45
31
|
const {
|
|
46
32
|
map_location,
|
|
47
|
-
map_level =
|
|
33
|
+
map_level = MAP_LEVEL.COUNTRY,
|
|
48
34
|
type
|
|
49
35
|
} = chart.config;
|
|
50
|
-
const mediaUrl =
|
|
51
|
-
const mapJson = await (
|
|
36
|
+
const mediaUrl = context.getSetting('mediaUrl');
|
|
37
|
+
const mapJson = await fetchMapJson(map_level, map_location, mediaUrl);
|
|
52
38
|
if (!mapJson) return;
|
|
53
|
-
const newMapJson = map_level ===
|
|
39
|
+
const newMapJson = map_level === MAP_LEVEL.COUNTRY ? feature(mapJson, mapJson.objects) : mapJson;
|
|
54
40
|
const statisticNewData = this.formatMapStatisticData(data, newMapJson, type);
|
|
55
41
|
this.draw(statisticNewData, newMapJson);
|
|
56
42
|
};
|
|
@@ -102,7 +88,7 @@ class Map extends _chartComponent.default {
|
|
|
102
88
|
globalTheme,
|
|
103
89
|
canvasStyle
|
|
104
90
|
} = this.props;
|
|
105
|
-
const theme =
|
|
91
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
106
92
|
const {
|
|
107
93
|
data_color,
|
|
108
94
|
legend_size,
|
|
@@ -114,7 +100,7 @@ class Map extends _chartComponent.default {
|
|
|
114
100
|
height: chartHeight,
|
|
115
101
|
insertPadding
|
|
116
102
|
} = this.chartBoundingClientRect;
|
|
117
|
-
const currentColorOption =
|
|
103
|
+
const currentColorOption = COLOR_OPTIONS.filter(item => item.name === data_color)[0] || COLOR_OPTIONS[0];
|
|
118
104
|
const {
|
|
119
105
|
exampleColors,
|
|
120
106
|
highlightedBorderColor
|
|
@@ -171,7 +157,7 @@ class Map extends _chartComponent.default {
|
|
|
171
157
|
d3.select(item).attr('fill', color());
|
|
172
158
|
}
|
|
173
159
|
});
|
|
174
|
-
});
|
|
160
|
+
}).call(g => this.animateFadeIn(g));
|
|
175
161
|
const columnData = this.getColumnData();
|
|
176
162
|
this.setContinuousLegend({
|
|
177
163
|
previewType: canvasStyle.previewType,
|
|
@@ -179,7 +165,7 @@ class Map extends _chartComponent.default {
|
|
|
179
165
|
colorRange: exampleColors,
|
|
180
166
|
legendDirection: legend_direction,
|
|
181
167
|
legendSize: legend_size,
|
|
182
|
-
legendTextRange: [
|
|
168
|
+
legendTextRange: [BaseUtils.getSummaryValueDisplayString(columnData, minVal, summary_method), BaseUtils.getSummaryValueDisplayString(columnData, maxVal, summary_method)]
|
|
183
169
|
});
|
|
184
170
|
};
|
|
185
171
|
this.handleAcitveAndInActiveState = (state, event, highlightedBorderColor) => {
|
|
@@ -187,12 +173,12 @@ class Map extends _chartComponent.default {
|
|
|
187
173
|
const lastElement = Array.from(event.target.parentNode.parentNode.children).at(-1);
|
|
188
174
|
|
|
189
175
|
// Add element to the end
|
|
190
|
-
d3.select(this.curElement).select('path').transition().duration(this.
|
|
176
|
+
d3.select(this.curElement).select('path').transition().duration(this.interactionDuration).attr('stroke-opacity', 0.7).attr('stroke-width', 0.5).attr('stroke', highlightedBorderColor);
|
|
191
177
|
lastElement.after(this.curElement);
|
|
192
178
|
return;
|
|
193
179
|
}
|
|
194
180
|
if (this.curElement) {
|
|
195
|
-
d3.select(this.curElement).select('path').transition().duration(this.
|
|
181
|
+
d3.select(this.curElement).select('path').transition().duration(this.interactionDuration).attr('stroke-opacity', 1).attr('stroke-width', 1).attr('stroke', '#bdbdbd');
|
|
196
182
|
}
|
|
197
183
|
};
|
|
198
184
|
this.getColumnData = () => {
|
|
@@ -204,11 +190,14 @@ class Map extends _chartComponent.default {
|
|
|
204
190
|
summary_column_key,
|
|
205
191
|
table_id
|
|
206
192
|
} = chart.config;
|
|
207
|
-
let columnData =
|
|
208
|
-
if (summary_type ===
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
193
|
+
let columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
194
|
+
if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
195
|
+
const {
|
|
196
|
+
tables
|
|
197
|
+
} = this.props;
|
|
198
|
+
const table = getTableById(tables, table_id);
|
|
199
|
+
const summaryColumn = getTableColumnByKey(table, summary_column_key) || {};
|
|
200
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
212
201
|
}
|
|
213
202
|
return columnData;
|
|
214
203
|
};
|
|
@@ -222,12 +211,11 @@ class Map extends _chartComponent.default {
|
|
|
222
211
|
componentDidMount() {
|
|
223
212
|
this.createChart();
|
|
224
213
|
this.drawChart();
|
|
225
|
-
|
|
226
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
214
|
+
super.componentDidMount();
|
|
227
215
|
}
|
|
228
216
|
componentDidUpdate(prevProps) {
|
|
229
217
|
super.componentDidUpdate(prevProps);
|
|
230
|
-
if (
|
|
218
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
231
219
|
this.destroyChart();
|
|
232
220
|
this.createChart();
|
|
233
221
|
this.drawChart();
|
|
@@ -235,17 +223,17 @@ class Map extends _chartComponent.default {
|
|
|
235
223
|
}
|
|
236
224
|
componentWillUnmount() {
|
|
237
225
|
this.destroyChart();
|
|
238
|
-
|
|
226
|
+
super.componentWillUnmount();
|
|
239
227
|
}
|
|
240
228
|
render() {
|
|
241
229
|
const {
|
|
242
230
|
tooltipData,
|
|
243
231
|
toolTipPosition
|
|
244
232
|
} = this.state;
|
|
245
|
-
return /*#__PURE__*/
|
|
233
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
246
234
|
ref: ref => this.container = ref,
|
|
247
235
|
className: "sea-chart-container"
|
|
248
|
-
}, /*#__PURE__*/
|
|
236
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
249
237
|
tooltipData: tooltipData,
|
|
250
238
|
toolTipPosition: toolTipPosition,
|
|
251
239
|
chart: this.chart
|
|
@@ -253,16 +241,16 @@ class Map extends _chartComponent.default {
|
|
|
253
241
|
}
|
|
254
242
|
}
|
|
255
243
|
Map.propTypes = {
|
|
256
|
-
canvasStyle:
|
|
257
|
-
chart:
|
|
258
|
-
groupbyColumn:
|
|
259
|
-
columnGroupbyColumn:
|
|
260
|
-
summaryColumn:
|
|
261
|
-
result:
|
|
262
|
-
tables:
|
|
263
|
-
globalTheme:
|
|
264
|
-
chartColorTheme:
|
|
265
|
-
toggleRecords:
|
|
266
|
-
customRender:
|
|
244
|
+
canvasStyle: PropTypes.object,
|
|
245
|
+
chart: PropTypes.object,
|
|
246
|
+
groupbyColumn: PropTypes.object,
|
|
247
|
+
columnGroupbyColumn: PropTypes.object,
|
|
248
|
+
summaryColumn: PropTypes.object,
|
|
249
|
+
result: PropTypes.array,
|
|
250
|
+
tables: PropTypes.array,
|
|
251
|
+
globalTheme: PropTypes.string,
|
|
252
|
+
chartColorTheme: PropTypes.string,
|
|
253
|
+
toggleRecords: PropTypes.func,
|
|
254
|
+
customRender: PropTypes.func
|
|
267
255
|
};
|
|
268
|
-
|
|
256
|
+
export default Map;
|
|
@@ -1,30 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _lodashEs = require("lodash-es");
|
|
12
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
13
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
-
var _dtableUtils = require("dtable-utils");
|
|
15
|
-
var _constants = require("../../constants");
|
|
16
|
-
var _utils = require("../../utils");
|
|
17
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
18
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
19
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
20
|
-
class Mirror extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import { getTableById, getTableColumnByKey, getNumberDisplayString } from 'dtable-utils';
|
|
5
|
+
import { CHART_SUMMARY_SHOW, DEFAULT_NUMBER_FORMAT_OBJECT, CHART_SUMMARY_TYPE, TITLE_AMOUNT } from '../../constants';
|
|
6
|
+
import { BaseUtils } from '../../utils';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
import ToolTip from '../../components/tooltip';
|
|
9
|
+
import ChartComponent from './chart-component';
|
|
10
|
+
class Mirror extends ChartComponent {
|
|
21
11
|
constructor(props) {
|
|
22
12
|
super(props);
|
|
23
|
-
this.handleResize = () => {
|
|
24
|
-
this.destroyChart();
|
|
25
|
-
this.createChart();
|
|
26
|
-
this.drawChart();
|
|
27
|
-
};
|
|
28
13
|
this.createChart = () => {
|
|
29
14
|
const {
|
|
30
15
|
chart
|
|
@@ -39,7 +24,7 @@ class Mirror extends _chartComponent.default {
|
|
|
39
24
|
let {
|
|
40
25
|
result
|
|
41
26
|
} = this.props;
|
|
42
|
-
const data =
|
|
27
|
+
const data = BaseUtils.formatEmptyName(result.data, '', intl.get('Empty'));
|
|
43
28
|
if (!Array.isArray(data)) return;
|
|
44
29
|
this.draw({
|
|
45
30
|
data,
|
|
@@ -60,7 +45,7 @@ class Mirror extends _chartComponent.default {
|
|
|
60
45
|
offsetY
|
|
61
46
|
} = event;
|
|
62
47
|
const newTooltipData = {
|
|
63
|
-
title: summary_type === 'count' ?
|
|
48
|
+
title: summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(CHART_SUMMARY_SHOW[summary_method]),
|
|
64
49
|
items: [{
|
|
65
50
|
color: '',
|
|
66
51
|
name: data.name,
|
|
@@ -116,19 +101,20 @@ class Mirror extends _chartComponent.default {
|
|
|
116
101
|
bottomLegendSpace
|
|
117
102
|
} = this.chartBoundingClientRect;
|
|
118
103
|
const themeColors = this.getThemeColors();
|
|
119
|
-
let columnData =
|
|
120
|
-
if (summary_type ===
|
|
121
|
-
const table =
|
|
122
|
-
const summaryColumn =
|
|
123
|
-
columnData = summaryColumn.data ||
|
|
104
|
+
let columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
105
|
+
if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
106
|
+
const table = getTableById(tables, table_id);
|
|
107
|
+
const summaryColumn = getTableColumnByKey(table, summary_column) || {};
|
|
108
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
124
109
|
}
|
|
125
110
|
const scaleBandDomain = Array.from(new Set(data.map(d => d.group_name)));
|
|
126
111
|
const scaleBand = d3.scaleBand().domain(scaleBandDomain).range(is_transpose ? [insertPadding, chartWidth - insertPadding] : [insertPadding, chartHeight - insertPadding - bottomLegendSpace]).paddingInner(0.1).paddingOuter(0);
|
|
127
112
|
|
|
128
113
|
// ScaleLinear axis
|
|
129
|
-
const maxDomain = d3.max(data, d => d.value);
|
|
114
|
+
const maxDomain = d3.max(data, d => d.value) || 0;
|
|
130
115
|
const scaleLinear1 = d3.scaleLinear().domain([maxDomain, 0]).range([scaleBand(scaleBandDomain[0]), scaleBand.bandwidth()]);
|
|
131
|
-
const
|
|
116
|
+
const secondDomainKey = scaleBandDomain[1] !== undefined ? scaleBandDomain[1] : scaleBandDomain[0];
|
|
117
|
+
const scaleLinear2 = d3.scaleLinear().domain([0, maxDomain]).range([scaleBand(secondDomainKey), scaleBand(secondDomainKey) + scaleBand.bandwidth()]);
|
|
132
118
|
const scaleLinearWrapper = this.chart.append('g').attr('class', 'scale-linear-axis-wrapper');
|
|
133
119
|
scaleLinearWrapper.append('g').attr('class', 'scale-linear-1').attr('transform', is_transpose ? `translate(0, ${chartHeight - insertPadding - bottomLegendSpace})` : `translate(${insertPadding}, 0)`).call(is_transpose ? d3.axisBottom(scaleLinear1).tickSizeInner(0).tickSizeOuter(0).ticks(5) : d3.axisLeft(scaleLinear1).tickSizeInner(0).tickSizeOuter(0).ticks(5)).call(g => {
|
|
134
120
|
g.select('.domain').remove();
|
|
@@ -136,7 +122,7 @@ class Mirror extends _chartComponent.default {
|
|
|
136
122
|
g.selectAll('.tick line').attr('stroke', themeColors.gridColor);
|
|
137
123
|
is_transpose ? g.selectAll('.tick line').attr('y2', -(chartHeight - insertPadding - insertPadding - bottomLegendSpace)) : g.selectAll('.tick line').attr('x2', chartWidth - insertPadding - insertPadding);
|
|
138
124
|
});
|
|
139
|
-
scaleLinearWrapper.append('g').attr('class', 'scale-linear-2').attr('transform', is_transpose ? `translate(0, ${chartHeight - insertPadding - bottomLegendSpace})` : `translate(${insertPadding}, 0)`).call(is_transpose ? d3.axisBottom(scaleLinear2).tickSizeInner(0).tickSizeOuter(0).ticks(5).tickFormat(t =>
|
|
125
|
+
scaleLinearWrapper.append('g').attr('class', 'scale-linear-2').attr('transform', is_transpose ? `translate(0, ${chartHeight - insertPadding - bottomLegendSpace})` : `translate(${insertPadding}, 0)`).call(is_transpose ? d3.axisBottom(scaleLinear2).tickSizeInner(0).tickSizeOuter(0).ticks(5).tickFormat(t => getNumberDisplayString(t, columnData)) : d3.axisLeft(scaleLinear2).tickSizeInner(0).tickSizeOuter(0).ticks(5).tickFormat(t => getNumberDisplayString(t, columnData))).call(g => {
|
|
140
126
|
g.select('.domain').remove();
|
|
141
127
|
g.selectAll('text').attr('font-size', themeColors.fontSize).attr('fill', themeColors.textColor);
|
|
142
128
|
g.selectAll('.tick line').attr('stroke', themeColors.gridColor);
|
|
@@ -245,7 +231,7 @@ class Mirror extends _chartComponent.default {
|
|
|
245
231
|
this.moveTooltip(event);
|
|
246
232
|
}).on('mouseleave', event => {
|
|
247
233
|
this.hiddenTooltip(event);
|
|
248
|
-
});
|
|
234
|
+
}).call(g => this.animateFadeIn(g));
|
|
249
235
|
this.setLegend({
|
|
250
236
|
legendName: 'group_name',
|
|
251
237
|
theme: themeColors,
|
|
@@ -268,12 +254,11 @@ class Mirror extends _chartComponent.default {
|
|
|
268
254
|
componentDidMount() {
|
|
269
255
|
this.createChart();
|
|
270
256
|
this.drawChart();
|
|
271
|
-
|
|
272
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
257
|
+
super.componentDidMount();
|
|
273
258
|
}
|
|
274
259
|
componentDidUpdate(prevProps) {
|
|
275
260
|
super.componentDidUpdate(prevProps);
|
|
276
|
-
if (
|
|
261
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
277
262
|
this.destroyChart();
|
|
278
263
|
this.createChart();
|
|
279
264
|
this.drawChart();
|
|
@@ -281,23 +266,17 @@ class Mirror extends _chartComponent.default {
|
|
|
281
266
|
}
|
|
282
267
|
componentWillUnmount() {
|
|
283
268
|
this.destroyChart();
|
|
284
|
-
|
|
269
|
+
super.componentWillUnmount();
|
|
285
270
|
}
|
|
286
271
|
render() {
|
|
287
|
-
const {
|
|
288
|
-
chart
|
|
289
|
-
} = this.props;
|
|
290
272
|
const {
|
|
291
273
|
tooltipData,
|
|
292
274
|
toolTipPosition
|
|
293
275
|
} = this.state;
|
|
294
|
-
return /*#__PURE__*/
|
|
276
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
295
277
|
ref: ref => this.container = ref,
|
|
296
|
-
className:
|
|
297
|
-
|
|
298
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
299
|
-
})
|
|
300
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
278
|
+
className: "sea-chart-container"
|
|
279
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
301
280
|
tooltipData: tooltipData,
|
|
302
281
|
toolTipPosition: toolTipPosition,
|
|
303
282
|
chart: this.chart
|
|
@@ -305,16 +284,16 @@ class Mirror extends _chartComponent.default {
|
|
|
305
284
|
}
|
|
306
285
|
}
|
|
307
286
|
Mirror.propTypes = {
|
|
308
|
-
canvasStyle:
|
|
309
|
-
chart:
|
|
310
|
-
groupbyColumn:
|
|
311
|
-
columnGroupbyColumn:
|
|
312
|
-
summaryColumn:
|
|
313
|
-
result:
|
|
314
|
-
tables:
|
|
315
|
-
globalTheme:
|
|
316
|
-
chartColorTheme:
|
|
317
|
-
toggleRecords:
|
|
318
|
-
customRender:
|
|
287
|
+
canvasStyle: PropTypes.object,
|
|
288
|
+
chart: PropTypes.object,
|
|
289
|
+
groupbyColumn: PropTypes.object,
|
|
290
|
+
columnGroupbyColumn: PropTypes.object,
|
|
291
|
+
summaryColumn: PropTypes.object,
|
|
292
|
+
result: PropTypes.object,
|
|
293
|
+
tables: PropTypes.array,
|
|
294
|
+
globalTheme: PropTypes.string,
|
|
295
|
+
chartColorTheme: PropTypes.string,
|
|
296
|
+
toggleRecords: PropTypes.func,
|
|
297
|
+
customRender: PropTypes.func
|
|
319
298
|
};
|
|
320
|
-
|
|
299
|
+
export default Mirror;
|
package/dist/view/wrapper/pie.js
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _lodashEs = require("lodash-es");
|
|
12
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
13
|
-
var _constants = require("../../constants");
|
|
14
|
-
var _utils = require("../../utils");
|
|
15
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
16
|
-
var _colorRules = require("../../constants/color-rules");
|
|
17
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
18
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
19
|
-
class Pie extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS, CHART_THEME_COLOR, CHART_TYPE } from '../../constants';
|
|
5
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
6
|
+
import intl from '../../intl';
|
|
7
|
+
import { SUPPORT_SINGLE_SELECT_THEMES_OPTIONS } from '../../constants/color-rules';
|
|
8
|
+
import ToolTip from '../../components/tooltip';
|
|
9
|
+
import ChartComponent from './chart-component';
|
|
10
|
+
class Pie extends ChartComponent {
|
|
20
11
|
constructor(props) {
|
|
21
12
|
super(props);
|
|
22
|
-
this.handleResize = () => {
|
|
23
|
-
this.destroyChart();
|
|
24
|
-
this.createChart();
|
|
25
|
-
this.drawChart();
|
|
26
|
-
};
|
|
27
13
|
this.createChart = () => {
|
|
28
14
|
const {
|
|
29
15
|
chart
|
|
@@ -43,7 +29,7 @@ class Pie extends _chartComponent.default {
|
|
|
43
29
|
customRender
|
|
44
30
|
} = this.props;
|
|
45
31
|
this.draw(data);
|
|
46
|
-
|
|
32
|
+
isFunction(customRender) && customRender(this.chart);
|
|
47
33
|
};
|
|
48
34
|
this.draw = data => {
|
|
49
35
|
const {
|
|
@@ -52,7 +38,7 @@ class Pie extends _chartComponent.default {
|
|
|
52
38
|
globalTheme,
|
|
53
39
|
chartColorTheme
|
|
54
40
|
} = this.props;
|
|
55
|
-
const theme =
|
|
41
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
56
42
|
const {
|
|
57
43
|
show_legend,
|
|
58
44
|
display_label,
|
|
@@ -66,23 +52,23 @@ class Pie extends _chartComponent.default {
|
|
|
66
52
|
insertPadding,
|
|
67
53
|
rightLegendSpace
|
|
68
54
|
} = this.chartBoundingClientRect;
|
|
69
|
-
this.isInnerLabel = !label_position || label_position ===
|
|
70
|
-
const currentTheme =
|
|
71
|
-
const useSingleSelectColumnColor = color_theme ===
|
|
55
|
+
this.isInnerLabel = !label_position || label_position === CHART_LABEL_POSITIONS[0];
|
|
56
|
+
const currentTheme = BaseUtils.getCurrentTheme(chartColorTheme);
|
|
57
|
+
const useSingleSelectColumnColor = color_theme === SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
72
58
|
const {
|
|
73
59
|
data: newData,
|
|
74
60
|
colorMap
|
|
75
|
-
} =
|
|
61
|
+
} = BaseUtils.formatPieChartData(data, chart, tables, currentTheme, useSingleSelectColumnColor);
|
|
76
62
|
if (!Array.isArray(newData) || newData.length === 0) return;
|
|
77
63
|
|
|
78
64
|
// Color
|
|
79
|
-
const colorDomain = new Set(
|
|
65
|
+
const colorDomain = new Set(newData.map(d => d.name));
|
|
80
66
|
const colorRange = Array.from(colorDomain).map(name => colorMap[name === null || name === void 0 ? void 0 : name.trim()]);
|
|
81
67
|
const color = d3.scaleOrdinal().domain(colorDomain).range(colorRange);
|
|
82
68
|
|
|
83
69
|
// Pie and Arc
|
|
84
70
|
const pie = d3.pie().sort(null).value(d => d.value);
|
|
85
|
-
const arcs = pie(
|
|
71
|
+
const arcs = pie(newData);
|
|
86
72
|
const arc = d3.arc().innerRadius(0).outerRadius(Math.min(chartWidth, chartHeight) / 2 * 0.7);
|
|
87
73
|
|
|
88
74
|
// Draw Pie
|
|
@@ -108,13 +94,13 @@ class Pie extends _chartComponent.default {
|
|
|
108
94
|
percent
|
|
109
95
|
} = d.data;
|
|
110
96
|
return this.getLabel(value, percent);
|
|
111
|
-
}).attr('fill', theme.labelColor).attr('font-size',
|
|
97
|
+
}).attr('fill', theme.labelColor).attr('font-size', BaseUtils.getLabelFontSize(label_font_size));
|
|
112
98
|
|
|
113
99
|
// Line
|
|
114
100
|
if (!this.isInnerLabel) {
|
|
115
101
|
const lineRadius = arc.outerRadius()() * 0.5;
|
|
116
102
|
const arcLine = d3.arc().innerRadius(lineRadius).outerRadius(lineRadius);
|
|
117
|
-
this.chart.append('g').attr('transform', `translate(${left + offsetX}, ${top + offsetY})`).selectAll().data(arcs).join('line').attr('transform', d => `translate(${arcLine.centroid(d)})`).attr('x1', d => arcLine.centroid(d)[0]).attr('y1', d => arcLine.centroid(d)[1]).attr('x2', d => arcLine.centroid(d)[0] * 1.2).attr('y2', d => arcLine.centroid(d)[1] * 1.2).attr('stroke', d => color(d.data.name)).attr('font-size',
|
|
103
|
+
this.chart.append('g').attr('transform', `translate(${left + offsetX}, ${top + offsetY})`).selectAll().data(arcs).join('line').attr('transform', d => `translate(${arcLine.centroid(d)})`).attr('x1', d => arcLine.centroid(d)[0]).attr('y1', d => arcLine.centroid(d)[1]).attr('x2', d => arcLine.centroid(d)[0] * 1.2).attr('y2', d => arcLine.centroid(d)[1] * 1.2).attr('stroke', d => color(d.data.name)).attr('font-size', BaseUtils.getLabelFontSize(label_font_size));
|
|
118
104
|
}
|
|
119
105
|
}
|
|
120
106
|
}).on('click', (event, rowData) => {
|
|
@@ -127,13 +113,17 @@ class Pie extends _chartComponent.default {
|
|
|
127
113
|
}).on('mouseleave', (event, data) => {
|
|
128
114
|
this.hiddenTooltip();
|
|
129
115
|
this.handleAcitveAndInActiveState('active', event);
|
|
116
|
+
}).call(g => {
|
|
117
|
+
this.animateArcGrowIn(g, arc);
|
|
118
|
+
this.animateFadeIn(this.chart.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
119
|
+
this.animateFadeIn(this.chart.selectAll('line'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
130
120
|
});
|
|
131
121
|
if (show_legend) {
|
|
132
122
|
this.setLegend({
|
|
133
123
|
legendName: 'name',
|
|
134
124
|
theme,
|
|
135
125
|
legendPosition: 'center-right',
|
|
136
|
-
data,
|
|
126
|
+
data: newData,
|
|
137
127
|
colorScale: color
|
|
138
128
|
});
|
|
139
129
|
}
|
|
@@ -185,7 +175,7 @@ class Pie extends _chartComponent.default {
|
|
|
185
175
|
this.handleAcitveAndInActiveState = (state, event) => {
|
|
186
176
|
const allGroup = [event.currentTarget.parentNode];
|
|
187
177
|
const curGroupName = event.currentTarget.getAttribute('data-groupName');
|
|
188
|
-
this.setActiveAndInActiveState(state, allGroup, curGroupName,
|
|
178
|
+
this.setActiveAndInActiveState(state, allGroup, curGroupName, CHART_TYPE.PIE);
|
|
189
179
|
};
|
|
190
180
|
this.getLabel = (val, percent) => {
|
|
191
181
|
const {
|
|
@@ -197,16 +187,16 @@ class Pie extends _chartComponent.default {
|
|
|
197
187
|
display_label,
|
|
198
188
|
label_format
|
|
199
189
|
} = chart.config;
|
|
200
|
-
const value =
|
|
190
|
+
const value = BaseUtils.getSummaryValueDisplayString(summaryColumn, val, summary_method);
|
|
201
191
|
if (!display_label || !value || !percent) {
|
|
202
192
|
return '';
|
|
203
193
|
}
|
|
204
194
|
switch (label_format) {
|
|
205
|
-
case
|
|
195
|
+
case CHART_LABEL_FORMATS[0]:
|
|
206
196
|
return percent;
|
|
207
|
-
case
|
|
197
|
+
case CHART_LABEL_FORMATS[1]:
|
|
208
198
|
return value;
|
|
209
|
-
case
|
|
199
|
+
case CHART_LABEL_FORMATS[2]:
|
|
210
200
|
return `${value} (${percent})`;
|
|
211
201
|
default:
|
|
212
202
|
return percent;
|
|
@@ -215,9 +205,9 @@ class Pie extends _chartComponent.default {
|
|
|
215
205
|
this.getTooltipName = name => {
|
|
216
206
|
let title = name;
|
|
217
207
|
if (!name || name.trim() === 'undefined' || name.trim() === 'null') {
|
|
218
|
-
title =
|
|
208
|
+
title = intl.get('Empty');
|
|
219
209
|
} else if (name === '_Others') {
|
|
220
|
-
title =
|
|
210
|
+
title = intl.get('Others');
|
|
221
211
|
}
|
|
222
212
|
return title;
|
|
223
213
|
};
|
|
@@ -230,12 +220,11 @@ class Pie extends _chartComponent.default {
|
|
|
230
220
|
componentDidMount() {
|
|
231
221
|
this.createChart();
|
|
232
222
|
this.drawChart();
|
|
233
|
-
|
|
234
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
223
|
+
super.componentDidMount();
|
|
235
224
|
}
|
|
236
225
|
componentDidUpdate(prevProps) {
|
|
237
226
|
super.componentDidUpdate(prevProps);
|
|
238
|
-
if (
|
|
227
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
239
228
|
this.destroyChart();
|
|
240
229
|
this.createChart();
|
|
241
230
|
this.drawChart();
|
|
@@ -243,17 +232,17 @@ class Pie extends _chartComponent.default {
|
|
|
243
232
|
}
|
|
244
233
|
componentWillUnmount() {
|
|
245
234
|
this.destroyChart();
|
|
246
|
-
|
|
235
|
+
super.componentWillUnmount();
|
|
247
236
|
}
|
|
248
237
|
render() {
|
|
249
238
|
const {
|
|
250
239
|
tooltipData,
|
|
251
240
|
toolTipPosition
|
|
252
241
|
} = this.state;
|
|
253
|
-
return /*#__PURE__*/
|
|
242
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
254
243
|
ref: ref => this.container = ref,
|
|
255
244
|
className: "sea-chart-container"
|
|
256
|
-
}, /*#__PURE__*/
|
|
245
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
257
246
|
tooltipData: tooltipData,
|
|
258
247
|
toolTipPosition: toolTipPosition,
|
|
259
248
|
chart: this.chart
|
|
@@ -261,15 +250,15 @@ class Pie extends _chartComponent.default {
|
|
|
261
250
|
}
|
|
262
251
|
}
|
|
263
252
|
Pie.propTypes = {
|
|
264
|
-
canvasStyle:
|
|
265
|
-
chart:
|
|
266
|
-
groupbyColumn:
|
|
267
|
-
summaryColumn:
|
|
268
|
-
result:
|
|
269
|
-
tables:
|
|
270
|
-
globalTheme:
|
|
271
|
-
chartColorTheme:
|
|
272
|
-
toggleRecords:
|
|
273
|
-
customRender:
|
|
253
|
+
canvasStyle: PropTypes.object,
|
|
254
|
+
chart: PropTypes.object,
|
|
255
|
+
groupbyColumn: PropTypes.object,
|
|
256
|
+
summaryColumn: PropTypes.object,
|
|
257
|
+
result: PropTypes.array,
|
|
258
|
+
tables: PropTypes.array,
|
|
259
|
+
globalTheme: PropTypes.string,
|
|
260
|
+
chartColorTheme: PropTypes.string,
|
|
261
|
+
toggleRecords: PropTypes.func,
|
|
262
|
+
customRender: PropTypes.func
|
|
274
263
|
};
|
|
275
|
-
|
|
264
|
+
export default Pie;
|