sea-chart 2.0.37 → 2.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +20 -69
- package/dist/assets/css/sea-chart-d3-tooltip.css +0 -1
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +5 -12
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +30 -38
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +12 -19
- package/dist/components/color-popover/color-rules/color-rule.js +26 -34
- package/dist/components/color-popover/color-rules/index.js +7 -15
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +9 -17
- package/dist/components/color-popover/color-rules-popover.js +31 -37
- package/dist/components/color-popover/color-selector-popover.js +12 -20
- package/dist/components/color-setting/color-group-selector.js +13 -21
- package/dist/components/common-add-tool/index.js +8 -15
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +13 -20
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +18 -26
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +41 -48
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +12 -23
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +11 -24
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +13 -16
- package/dist/components/popover/hide-column-popover/hide-column-popover.css +5 -1
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +28 -38
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +58 -69
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +17 -24
- package/dist/components/row-card/row-card-header.js +15 -22
- package/dist/components/row-card/row-card-item.js +35 -43
- package/dist/components/row-card/row-card.js +17 -25
- package/dist/components/statistic-record-dialog/index.js +61 -68
- package/dist/components/tooltip/index.js +39 -28
- package/dist/components/types-dialog/index.js +62 -70
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +142 -271
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +13 -20
- package/dist/editor/index.js +13 -16
- 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 +2 -7
- package/dist/locale/lang/en.js +2 -7
- package/dist/locale/lang/es.js +2 -7
- package/dist/locale/lang/fr.js +2 -7
- package/dist/locale/lang/pt.js +2 -7
- package/dist/locale/lang/ru.js +2 -7
- package/dist/locale/lang/zh_CN.js +2 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +4 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +15 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +11 -18
- package/dist/model/horizontal-group-bar.js +10 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +14 -17
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +11 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +14 -17
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +66 -73
- 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 +51 -59
- package/dist/settings/basic-number-card/data-settings.js +50 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +19 -27
- package/dist/settings/combination-settings/data-settings.js +55 -64
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +67 -75
- 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 +44 -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 +22 -30
- 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 +57 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +27 -35
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +65 -73
- package/dist/settings/table-element-settings/components/data-filter.js +49 -58
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.css +1 -31
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +113 -120
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +44 -52
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +19 -27
- package/dist/settings/widgets/basic-summary/index.js +59 -66
- 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 +27 -34
- package/dist/settings/widgets/data-filter/index.js +59 -59
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +26 -34
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +52 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +25 -33
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +75 -82
- package/dist/settings/widgets/switch/index.js +9 -16
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +65 -72
- package/dist/utils/cell-format-utils.js +25 -33
- package/dist/utils/cell-value-utils.js +4 -11
- package/dist/utils/chart-utils/base-utils.js +467 -367
- package/dist/utils/chart-utils/index.js +29 -40
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +78 -85
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +20 -21
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +33 -40
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +28 -26
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +94 -97
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -25
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +50 -36
- package/dist/utils/chart-utils/sql-statistics-utils.js +385 -388
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +19 -31
- package/dist/utils/collaborator.js +6 -15
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +88 -102
- package/dist/utils/common-utils.js +28 -53
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +7 -11
- package/dist/utils/date-translate.js +12 -20
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +73 -219
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +2 -8
- package/dist/utils/options-utils.js +10 -18
- package/dist/utils/row-record-utils.js +251 -183
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +106 -112
- package/dist/utils/sql/column-2-sql-column.js +162 -172
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +50 -45
- package/dist/view/index.css +2 -8
- package/dist/view/index.js +102 -103
- package/dist/view/title/index.js +16 -24
- package/dist/view/wrapper/area-group.js +57 -57
- package/dist/view/wrapper/area.js +43 -51
- package/dist/view/wrapper/bar-compare.js +56 -48
- package/dist/view/wrapper/bar-custom-stack.js +73 -55
- package/dist/view/wrapper/bar-group.js +94 -73
- package/dist/view/wrapper/bar-stack.js +49 -57
- package/dist/view/wrapper/bar.js +40 -48
- package/dist/view/wrapper/basic-number-card.js +50 -34
- package/dist/view/wrapper/chart-component.js +164 -569
- package/dist/view/wrapper/combination.js +55 -63
- package/dist/view/wrapper/completeness-group.js +140 -93
- package/dist/view/wrapper/completeness.js +36 -44
- package/dist/view/wrapper/dashboard.js +104 -59
- package/dist/view/wrapper/funnel.js +40 -43
- package/dist/view/wrapper/heat-map.js +62 -70
- package/dist/view/wrapper/horizontal-bar-group.js +70 -58
- package/dist/view/wrapper/horizontal-bar-stack.js +48 -56
- package/dist/view/wrapper/horizontal-bar.js +41 -49
- package/dist/view/wrapper/index.js +107 -115
- package/dist/view/wrapper/line-group.js +49 -52
- package/dist/view/wrapper/line.js +42 -50
- package/dist/view/wrapper/map-bubble.js +40 -48
- package/dist/view/wrapper/map-world-bubble.js +40 -47
- package/dist/view/wrapper/map-world.js +42 -49
- package/dist/view/wrapper/map.js +42 -50
- package/dist/view/wrapper/mirror.js +41 -49
- package/dist/view/wrapper/pie.js +45 -53
- package/dist/view/wrapper/ring.js +50 -58
- package/dist/view/wrapper/scatter.js +50 -56
- package/dist/view/wrapper/table/index.js +14 -22
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +53 -61
- package/dist/view/wrapper/table/pivot-table-display-name.js +82 -90
- package/dist/view/wrapper/table/two-dimension-table.js +85 -92
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +90 -99
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +23 -32
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/record.js +13 -20
- package/dist/view/wrapper/table-element/components/records-body.js +9 -17
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -16
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +25 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +8 -13
- package/dist/view/wrapper/table-element/components/utils.js +6 -16
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +30 -43
- package/dist/view/wrapper/treemap.js +38 -46
- package/dist/view/wrapper/trend.js +80 -65
- package/package.json +15 -12
package/dist/view/wrapper/pie.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 { debounce } from 'lodash-es';
|
|
4
|
+
import * as d3 from 'd3';
|
|
5
|
+
import { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS, CHART_THEME_COLOR, CHART_TYPE } from '../../constants';
|
|
6
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
import { SUPPORT_SINGLE_SELECT_THEMES_OPTIONS } from '../../constants/color-rules';
|
|
9
|
+
import ToolTip from '../../components/tooltip';
|
|
10
|
+
import ChartComponent from './chart-component';
|
|
11
|
+
class Pie extends ChartComponent {
|
|
20
12
|
constructor(props) {
|
|
21
13
|
super(props);
|
|
22
14
|
this.handleResize = () => {
|
|
@@ -33,7 +25,7 @@ class Pie extends _chartComponent.default {
|
|
|
33
25
|
} = chart.config;
|
|
34
26
|
const initConfig = {
|
|
35
27
|
insertPadding: 30,
|
|
36
|
-
rightLegendSpace: show_legend ?
|
|
28
|
+
rightLegendSpace: show_legend ? 50 : 0
|
|
37
29
|
};
|
|
38
30
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
39
31
|
};
|
|
@@ -43,7 +35,7 @@ class Pie extends _chartComponent.default {
|
|
|
43
35
|
customRender
|
|
44
36
|
} = this.props;
|
|
45
37
|
this.draw(data);
|
|
46
|
-
|
|
38
|
+
isFunction(customRender) && customRender(this.chart);
|
|
47
39
|
};
|
|
48
40
|
this.draw = data => {
|
|
49
41
|
const {
|
|
@@ -52,7 +44,7 @@ class Pie extends _chartComponent.default {
|
|
|
52
44
|
globalTheme,
|
|
53
45
|
chartColorTheme
|
|
54
46
|
} = this.props;
|
|
55
|
-
const theme =
|
|
47
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
56
48
|
const {
|
|
57
49
|
show_legend,
|
|
58
50
|
display_label,
|
|
@@ -66,13 +58,13 @@ class Pie extends _chartComponent.default {
|
|
|
66
58
|
insertPadding,
|
|
67
59
|
rightLegendSpace
|
|
68
60
|
} = this.chartBoundingClientRect;
|
|
69
|
-
this.isInnerLabel = !label_position || label_position ===
|
|
70
|
-
const currentTheme =
|
|
71
|
-
const useSingleSelectColumnColor = color_theme ===
|
|
61
|
+
this.isInnerLabel = !label_position || label_position === CHART_LABEL_POSITIONS[0];
|
|
62
|
+
const currentTheme = BaseUtils.getCurrentTheme(chartColorTheme);
|
|
63
|
+
const useSingleSelectColumnColor = color_theme === SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
72
64
|
const {
|
|
73
65
|
data: newData,
|
|
74
66
|
colorMap
|
|
75
|
-
} =
|
|
67
|
+
} = BaseUtils.formatPieChartData(data, chart, tables, currentTheme, useSingleSelectColumnColor);
|
|
76
68
|
if (!Array.isArray(newData) || newData.length === 0) return;
|
|
77
69
|
|
|
78
70
|
// Color
|
|
@@ -96,25 +88,25 @@ class Pie extends _chartComponent.default {
|
|
|
96
88
|
const top = height / 2 + insertPadding;
|
|
97
89
|
const offsetX = (chartWidth - (insertPadding + rightLegendSpace) - insertPadding - width) / 2;
|
|
98
90
|
const offsetY = (chartHeight - insertPadding - insertPadding - height) / 2;
|
|
99
|
-
d3.select(g.node().parentNode).attr('transform',
|
|
91
|
+
d3.select(g.node().parentNode).attr('transform', `translate(${left + offsetX}, ${top + offsetY})`);
|
|
100
92
|
|
|
101
93
|
// Draw label
|
|
102
94
|
if (display_label) {
|
|
103
95
|
const labelRadius = this.isInnerLabel ? arc.outerRadius()() * 0.7 : arc.outerRadius()() * 1.2;
|
|
104
96
|
const arcLabel = d3.arc().innerRadius(labelRadius).outerRadius(labelRadius);
|
|
105
|
-
this.chart.append('g').attr('transform',
|
|
97
|
+
this.chart.append('g').attr('transform', `translate(${left + offsetX}, ${top + offsetY})`).attr('text-anchor', 'middle').selectAll().data(arcs).join('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('transform', d => `translate(${arcLabel.centroid(d)})`).text(d => {
|
|
106
98
|
const {
|
|
107
99
|
value,
|
|
108
100
|
percent
|
|
109
101
|
} = d.data;
|
|
110
102
|
return this.getLabel(value, percent);
|
|
111
|
-
}).attr('fill', theme.labelColor).attr('font-size',
|
|
103
|
+
}).attr('fill', theme.labelColor).attr('font-size', BaseUtils.getLabelFontSize(label_font_size));
|
|
112
104
|
|
|
113
105
|
// Line
|
|
114
106
|
if (!this.isInnerLabel) {
|
|
115
107
|
const lineRadius = arc.outerRadius()() * 0.5;
|
|
116
108
|
const arcLine = d3.arc().innerRadius(lineRadius).outerRadius(lineRadius);
|
|
117
|
-
this.chart.append('g').attr('transform',
|
|
109
|
+
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
110
|
}
|
|
119
111
|
}
|
|
120
112
|
}).on('click', (event, rowData) => {
|
|
@@ -185,7 +177,7 @@ class Pie extends _chartComponent.default {
|
|
|
185
177
|
this.handleAcitveAndInActiveState = (state, event) => {
|
|
186
178
|
const allGroup = [event.currentTarget.parentNode];
|
|
187
179
|
const curGroupName = event.currentTarget.getAttribute('data-groupName');
|
|
188
|
-
this.setActiveAndInActiveState(state, allGroup, curGroupName,
|
|
180
|
+
this.setActiveAndInActiveState(state, allGroup, curGroupName, CHART_TYPE.PIE);
|
|
189
181
|
};
|
|
190
182
|
this.getLabel = (val, percent) => {
|
|
191
183
|
const {
|
|
@@ -197,17 +189,17 @@ class Pie extends _chartComponent.default {
|
|
|
197
189
|
display_label,
|
|
198
190
|
label_format
|
|
199
191
|
} = chart.config;
|
|
200
|
-
const value =
|
|
192
|
+
const value = BaseUtils.getSummaryValueDisplayString(summaryColumn, val, summary_method);
|
|
201
193
|
if (!display_label || !value || !percent) {
|
|
202
194
|
return '';
|
|
203
195
|
}
|
|
204
196
|
switch (label_format) {
|
|
205
|
-
case
|
|
197
|
+
case CHART_LABEL_FORMATS[0]:
|
|
206
198
|
return percent;
|
|
207
|
-
case
|
|
199
|
+
case CHART_LABEL_FORMATS[1]:
|
|
208
200
|
return value;
|
|
209
|
-
case
|
|
210
|
-
return
|
|
201
|
+
case CHART_LABEL_FORMATS[2]:
|
|
202
|
+
return `${value} (${percent})`;
|
|
211
203
|
default:
|
|
212
204
|
return percent;
|
|
213
205
|
}
|
|
@@ -215,9 +207,9 @@ class Pie extends _chartComponent.default {
|
|
|
215
207
|
this.getTooltipName = name => {
|
|
216
208
|
let title = name;
|
|
217
209
|
if (!name || name.trim() === 'undefined' || name.trim() === 'null') {
|
|
218
|
-
title =
|
|
210
|
+
title = intl.get('Empty');
|
|
219
211
|
} else if (name === '_Others') {
|
|
220
|
-
title =
|
|
212
|
+
title = intl.get('Others');
|
|
221
213
|
}
|
|
222
214
|
return title;
|
|
223
215
|
};
|
|
@@ -230,12 +222,12 @@ class Pie extends _chartComponent.default {
|
|
|
230
222
|
componentDidMount() {
|
|
231
223
|
this.createChart();
|
|
232
224
|
this.drawChart();
|
|
233
|
-
this.debouncedHandleResize =
|
|
225
|
+
this.debouncedHandleResize = debounce(this.handleResize, 300);
|
|
234
226
|
window.addEventListener('resize', this.debouncedHandleResize);
|
|
235
227
|
}
|
|
236
228
|
componentDidUpdate(prevProps) {
|
|
237
229
|
super.componentDidUpdate(prevProps);
|
|
238
|
-
if (
|
|
230
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
239
231
|
this.destroyChart();
|
|
240
232
|
this.createChart();
|
|
241
233
|
this.drawChart();
|
|
@@ -250,10 +242,10 @@ class Pie extends _chartComponent.default {
|
|
|
250
242
|
tooltipData,
|
|
251
243
|
toolTipPosition
|
|
252
244
|
} = this.state;
|
|
253
|
-
return /*#__PURE__*/
|
|
245
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
254
246
|
ref: ref => this.container = ref,
|
|
255
247
|
className: "sea-chart-container"
|
|
256
|
-
}, /*#__PURE__*/
|
|
248
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
257
249
|
tooltipData: tooltipData,
|
|
258
250
|
toolTipPosition: toolTipPosition,
|
|
259
251
|
chart: this.chart
|
|
@@ -261,15 +253,15 @@ class Pie extends _chartComponent.default {
|
|
|
261
253
|
}
|
|
262
254
|
}
|
|
263
255
|
Pie.propTypes = {
|
|
264
|
-
canvasStyle:
|
|
265
|
-
chart:
|
|
266
|
-
groupbyColumn:
|
|
267
|
-
summaryColumn:
|
|
268
|
-
result:
|
|
269
|
-
tables:
|
|
270
|
-
globalTheme:
|
|
271
|
-
chartColorTheme:
|
|
272
|
-
toggleRecords:
|
|
273
|
-
customRender:
|
|
256
|
+
canvasStyle: PropTypes.object,
|
|
257
|
+
chart: PropTypes.object,
|
|
258
|
+
groupbyColumn: PropTypes.object,
|
|
259
|
+
summaryColumn: PropTypes.object,
|
|
260
|
+
result: PropTypes.array,
|
|
261
|
+
tables: PropTypes.array,
|
|
262
|
+
globalTheme: PropTypes.string,
|
|
263
|
+
chartColorTheme: PropTypes.string,
|
|
264
|
+
toggleRecords: PropTypes.func,
|
|
265
|
+
customRender: PropTypes.func
|
|
274
266
|
};
|
|
275
|
-
|
|
267
|
+
export default Pie;
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 Ring extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { debounce } from 'lodash-es';
|
|
4
|
+
import * as d3 from 'd3';
|
|
5
|
+
import { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS, CHART_THEME_COLOR, CHART_TYPE } from '../../constants';
|
|
6
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
import { SUPPORT_SINGLE_SELECT_THEMES_OPTIONS } from '../../constants/color-rules';
|
|
9
|
+
import ToolTip from '../../components/tooltip';
|
|
10
|
+
import ChartComponent from './chart-component';
|
|
11
|
+
class Ring extends ChartComponent {
|
|
20
12
|
constructor(props) {
|
|
21
13
|
super(props);
|
|
22
14
|
this.handleResize = () => {
|
|
@@ -33,7 +25,7 @@ class Ring extends _chartComponent.default {
|
|
|
33
25
|
} = chart.config;
|
|
34
26
|
const initConfig = {
|
|
35
27
|
insertPadding: 30,
|
|
36
|
-
rightLegendSpace: show_legend ?
|
|
28
|
+
rightLegendSpace: show_legend ? 50 : 0
|
|
37
29
|
};
|
|
38
30
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
39
31
|
};
|
|
@@ -43,7 +35,7 @@ class Ring extends _chartComponent.default {
|
|
|
43
35
|
customRender
|
|
44
36
|
} = this.props;
|
|
45
37
|
this.draw(data);
|
|
46
|
-
|
|
38
|
+
isFunction(customRender) && customRender(this.chart);
|
|
47
39
|
};
|
|
48
40
|
this.draw = data => {
|
|
49
41
|
const {
|
|
@@ -52,7 +44,7 @@ class Ring extends _chartComponent.default {
|
|
|
52
44
|
globalTheme,
|
|
53
45
|
chartColorTheme
|
|
54
46
|
} = this.props;
|
|
55
|
-
const theme =
|
|
47
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
56
48
|
const {
|
|
57
49
|
show_legend,
|
|
58
50
|
display_label,
|
|
@@ -66,14 +58,14 @@ class Ring extends _chartComponent.default {
|
|
|
66
58
|
insertPadding,
|
|
67
59
|
rightLegendSpace
|
|
68
60
|
} = this.chartBoundingClientRect;
|
|
69
|
-
this.isInnerLabel = !label_position || label_position ===
|
|
70
|
-
const currentTheme =
|
|
71
|
-
const useSingleSelectColumnColor = color_theme ===
|
|
61
|
+
this.isInnerLabel = !label_position || label_position === CHART_LABEL_POSITIONS[0];
|
|
62
|
+
const currentTheme = BaseUtils.getCurrentTheme(chartColorTheme);
|
|
63
|
+
const useSingleSelectColumnColor = color_theme === SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
72
64
|
const {
|
|
73
65
|
data: newData,
|
|
74
66
|
colorMap,
|
|
75
67
|
total
|
|
76
|
-
} =
|
|
68
|
+
} = BaseUtils.formatPieChartData(data, chart, tables, currentTheme, useSingleSelectColumnColor);
|
|
77
69
|
if (!Array.isArray(newData) || newData.length === 0) return;
|
|
78
70
|
|
|
79
71
|
// Color
|
|
@@ -97,7 +89,7 @@ class Ring extends _chartComponent.default {
|
|
|
97
89
|
const top = height / 2 + insertPadding;
|
|
98
90
|
const offsetX = (chartWidth - (insertPadding + rightLegendSpace) - insertPadding - width) / 2;
|
|
99
91
|
const offsetY = (chartHeight - insertPadding - insertPadding - height) / 2;
|
|
100
|
-
d3.select(g.node().parentNode).attr('transform',
|
|
92
|
+
d3.select(g.node().parentNode).attr('transform', `translate(${left + offsetX}, ${top + offsetY})`);
|
|
101
93
|
|
|
102
94
|
// Draw total
|
|
103
95
|
this.setAnnotationTotal(g.node().parentNode, {
|
|
@@ -108,19 +100,19 @@ class Ring extends _chartComponent.default {
|
|
|
108
100
|
if (display_label) {
|
|
109
101
|
const labelRadius = this.isInnerLabel ? arc.outerRadius()() * 1.2 : arc.outerRadius()() * 1.65;
|
|
110
102
|
const arcLabel = d3.arc().innerRadius(labelRadius).outerRadius(labelRadius);
|
|
111
|
-
this.chart.append('g').attr('class', 'label-wrapper').attr('transform',
|
|
103
|
+
this.chart.append('g').attr('class', 'label-wrapper').attr('transform', `translate(${left + offsetX}, ${top + offsetY})`).attr('text-anchor', 'middle').selectAll().data(arcs).join('text').attr('class', 'label').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('transform', d => `translate(${arcLabel.centroid(d)})`).text(d => {
|
|
112
104
|
const {
|
|
113
105
|
value,
|
|
114
106
|
percent
|
|
115
107
|
} = d.data;
|
|
116
108
|
return this.getLabel(value, percent);
|
|
117
|
-
}).attr('fill', theme.labelColor).attr('font-size',
|
|
109
|
+
}).attr('fill', theme.labelColor).attr('font-size', BaseUtils.getLabelFontSize(label_font_size));
|
|
118
110
|
|
|
119
111
|
// Line
|
|
120
112
|
if (!this.isInnerLabel) {
|
|
121
113
|
const lineRadius = arc.outerRadius()() * 0.7;
|
|
122
114
|
const arcLine = d3.arc().innerRadius(lineRadius).outerRadius(lineRadius);
|
|
123
|
-
this.chart.append('g').attr('transform',
|
|
115
|
+
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));
|
|
124
116
|
}
|
|
125
117
|
}
|
|
126
118
|
}).on('click', (event, rowData) => {
|
|
@@ -199,7 +191,7 @@ class Ring extends _chartComponent.default {
|
|
|
199
191
|
this.handleAcitveAndInActiveState = (state, event) => {
|
|
200
192
|
const allGroup = [event.currentTarget.parentNode];
|
|
201
193
|
const curGroupName = event.currentTarget.getAttribute('data-groupName');
|
|
202
|
-
this.setActiveAndInActiveState(state, allGroup, curGroupName,
|
|
194
|
+
this.setActiveAndInActiveState(state, allGroup, curGroupName, CHART_TYPE.RING);
|
|
203
195
|
};
|
|
204
196
|
this.getLabel = (val, percent) => {
|
|
205
197
|
const {
|
|
@@ -211,17 +203,17 @@ class Ring extends _chartComponent.default {
|
|
|
211
203
|
display_label,
|
|
212
204
|
label_format
|
|
213
205
|
} = chart.config;
|
|
214
|
-
const value =
|
|
206
|
+
const value = BaseUtils.getSummaryValueDisplayString(summaryColumn, val, summary_method);
|
|
215
207
|
if (!display_label || !value || !percent) {
|
|
216
208
|
return '';
|
|
217
209
|
}
|
|
218
210
|
switch (label_format) {
|
|
219
|
-
case
|
|
211
|
+
case CHART_LABEL_FORMATS[0]:
|
|
220
212
|
return percent;
|
|
221
|
-
case
|
|
213
|
+
case CHART_LABEL_FORMATS[1]:
|
|
222
214
|
return value;
|
|
223
|
-
case
|
|
224
|
-
return
|
|
215
|
+
case CHART_LABEL_FORMATS[2]:
|
|
216
|
+
return `${value} (${percent})`;
|
|
225
217
|
default:
|
|
226
218
|
return percent;
|
|
227
219
|
}
|
|
@@ -229,9 +221,9 @@ class Ring extends _chartComponent.default {
|
|
|
229
221
|
this.getTooltipName = name => {
|
|
230
222
|
let title = name;
|
|
231
223
|
if (!name || name.trim() === 'undefined' || name.trim() === 'null') {
|
|
232
|
-
title =
|
|
224
|
+
title = intl.get('Empty');
|
|
233
225
|
} else if (name === '_Others') {
|
|
234
|
-
title =
|
|
226
|
+
title = intl.get('Others');
|
|
235
227
|
}
|
|
236
228
|
return title;
|
|
237
229
|
};
|
|
@@ -249,7 +241,7 @@ class Ring extends _chartComponent.default {
|
|
|
249
241
|
const {
|
|
250
242
|
summary_method
|
|
251
243
|
} = chart.config;
|
|
252
|
-
const theme =
|
|
244
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
253
245
|
// Clear old annotation
|
|
254
246
|
const oldTitle = (_d3$select$select = d3.select(wrapper).select('.title')) === null || _d3$select$select === void 0 ? void 0 : _d3$select$select.node();
|
|
255
247
|
const oldText = (_d3$select$select2 = d3.select(wrapper).select('.text')) === null || _d3$select$select2 === void 0 ? void 0 : _d3$select$select2.node();
|
|
@@ -257,21 +249,21 @@ class Ring extends _chartComponent.default {
|
|
|
257
249
|
oldText && oldText.remove();
|
|
258
250
|
|
|
259
251
|
// Title
|
|
260
|
-
d3.select(wrapper).append('text').attr('class', 'title').text(name ? name :
|
|
252
|
+
d3.select(wrapper).append('text').attr('class', 'title').text(name ? name : intl.get('Total')).attr('fill', theme.annotationTitleFontColor).attr('font-size', theme.annotationFontSize).attr('font-weight', 300).attr('pointer-events', 'none').call(g => {
|
|
261
253
|
var _g$node;
|
|
262
254
|
const {
|
|
263
255
|
width
|
|
264
256
|
} = (_g$node = g.node()) === null || _g$node === void 0 ? void 0 : _g$node.getBoundingClientRect();
|
|
265
|
-
g.attr('transform',
|
|
257
|
+
g.attr('transform', `translate(${-(width / 2)}, ${-20})`);
|
|
266
258
|
});
|
|
267
259
|
|
|
268
260
|
// Text this.getLabel(value, percent)
|
|
269
|
-
d3.select(wrapper).append('text').attr('class', 'text').text(summaryColumn ?
|
|
261
|
+
d3.select(wrapper).append('text').attr('class', 'text').text(summaryColumn ? BaseUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method) : value).attr('fill', theme.annotationValueFontColor).attr('font-size', theme.annotationFontSize).call(g => {
|
|
270
262
|
var _g$node2;
|
|
271
263
|
const {
|
|
272
264
|
width
|
|
273
265
|
} = (_g$node2 = g.node()) === null || _g$node2 === void 0 ? void 0 : _g$node2.getBoundingClientRect();
|
|
274
|
-
g.attr('transform',
|
|
266
|
+
g.attr('transform', `translate(${-(width / 2)}, ${10})`);
|
|
275
267
|
});
|
|
276
268
|
};
|
|
277
269
|
this.chart = null;
|
|
@@ -283,12 +275,12 @@ class Ring extends _chartComponent.default {
|
|
|
283
275
|
componentDidMount() {
|
|
284
276
|
this.createChart();
|
|
285
277
|
this.drawChart();
|
|
286
|
-
this.debouncedHandleResize =
|
|
278
|
+
this.debouncedHandleResize = debounce(this.handleResize, 300);
|
|
287
279
|
window.addEventListener('resize', this.debouncedHandleResize);
|
|
288
280
|
}
|
|
289
281
|
componentDidUpdate(prevProps) {
|
|
290
282
|
super.componentDidUpdate(prevProps);
|
|
291
|
-
if (
|
|
283
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
292
284
|
this.destroyChart();
|
|
293
285
|
this.createChart();
|
|
294
286
|
this.drawChart();
|
|
@@ -303,10 +295,10 @@ class Ring extends _chartComponent.default {
|
|
|
303
295
|
tooltipData,
|
|
304
296
|
toolTipPosition
|
|
305
297
|
} = this.state;
|
|
306
|
-
return /*#__PURE__*/
|
|
298
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
307
299
|
ref: ref => this.container = ref,
|
|
308
300
|
className: "sea-chart-container"
|
|
309
|
-
}, /*#__PURE__*/
|
|
301
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
310
302
|
tooltipData: tooltipData,
|
|
311
303
|
toolTipPosition: toolTipPosition,
|
|
312
304
|
chart: this.chart
|
|
@@ -314,15 +306,15 @@ class Ring extends _chartComponent.default {
|
|
|
314
306
|
}
|
|
315
307
|
}
|
|
316
308
|
Ring.propTypes = {
|
|
317
|
-
canvasStyle:
|
|
318
|
-
chart:
|
|
319
|
-
groupbyColumn:
|
|
320
|
-
summaryColumn:
|
|
321
|
-
result:
|
|
322
|
-
tables:
|
|
323
|
-
globalTheme:
|
|
324
|
-
chartColorTheme:
|
|
325
|
-
toggleRecords:
|
|
326
|
-
customRender:
|
|
309
|
+
canvasStyle: PropTypes.object,
|
|
310
|
+
chart: PropTypes.object,
|
|
311
|
+
groupbyColumn: PropTypes.object,
|
|
312
|
+
summaryColumn: PropTypes.object,
|
|
313
|
+
result: PropTypes.array,
|
|
314
|
+
tables: PropTypes.array,
|
|
315
|
+
globalTheme: PropTypes.string,
|
|
316
|
+
chartColorTheme: PropTypes.string,
|
|
317
|
+
toggleRecords: PropTypes.func,
|
|
318
|
+
customRender: PropTypes.func
|
|
327
319
|
};
|
|
328
|
-
|
|
320
|
+
export default Ring;
|