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
|
@@ -1,22 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
var _lodashEs = require("lodash-es");
|
|
12
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
13
|
-
var _constants = require("../../constants");
|
|
14
|
-
var _utils = require("../../utils");
|
|
15
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
16
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
17
|
-
class Dashboard 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_THEME_COLOR } from '../../constants';
|
|
6
|
+
import { BaseUtils, isFunction } from '../../utils';
|
|
7
|
+
import ToolTip from '../../components/tooltip';
|
|
8
|
+
import ChartComponent from './chart-component';
|
|
9
|
+
class Dashboard extends ChartComponent {
|
|
18
10
|
constructor(props) {
|
|
19
11
|
super(props);
|
|
12
|
+
this.handleClickNumber = () => {
|
|
13
|
+
const {
|
|
14
|
+
toggleRecords,
|
|
15
|
+
result
|
|
16
|
+
} = this.props;
|
|
17
|
+
if (!toggleRecords) return;
|
|
18
|
+
if (typeof result === 'object' && result !== null && result.rows) {
|
|
19
|
+
toggleRecords({
|
|
20
|
+
rows: result.rows
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
toggleRecords({
|
|
24
|
+
isQueryBySql: true
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
this.componentDidMount = () => {
|
|
29
|
+
this.createChart();
|
|
30
|
+
this.drawChart();
|
|
31
|
+
this.debouncedHandleResize = debounce(this.handleResize, 300);
|
|
32
|
+
window.addEventListener('resize', this.debouncedHandleResize);
|
|
33
|
+
};
|
|
20
34
|
this.handleResize = () => {
|
|
21
35
|
this.destroyChart();
|
|
22
36
|
this.createChart();
|
|
@@ -37,7 +51,7 @@ class Dashboard extends _chartComponent.default {
|
|
|
37
51
|
customRender
|
|
38
52
|
} = this.props;
|
|
39
53
|
this.draw(data);
|
|
40
|
-
|
|
54
|
+
isFunction(customRender) && customRender(this.chart);
|
|
41
55
|
};
|
|
42
56
|
this.draw = data => {
|
|
43
57
|
const {
|
|
@@ -67,7 +81,7 @@ class Dashboard extends _chartComponent.default {
|
|
|
67
81
|
const top = height / 2 + insertPadding;
|
|
68
82
|
const offsetX = (chartWidth - insertPadding - insertPadding - width) / 2;
|
|
69
83
|
const offsetY = (chartHeight - insertPadding - insertPadding - height) / 2;
|
|
70
|
-
d3.select(g.node().parentNode).attr('transform',
|
|
84
|
+
d3.select(g.node().parentNode).attr('transform', `translate(${left + offsetX}, ${top + offsetY})`);
|
|
71
85
|
|
|
72
86
|
// Draw uncompleted path
|
|
73
87
|
if (formatValue < 100) {
|
|
@@ -89,14 +103,17 @@ class Dashboard extends _chartComponent.default {
|
|
|
89
103
|
const {
|
|
90
104
|
globalTheme
|
|
91
105
|
} = this.props;
|
|
92
|
-
const theme =
|
|
106
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
93
107
|
const ticks = Array.from({
|
|
94
108
|
length: 51
|
|
95
109
|
}, (_, i) => i);
|
|
96
110
|
const lineInnerRadius = arc.innerRadius()();
|
|
97
111
|
const x = d3.scaleBand().domain(ticks).range([startAngle, endAngle]).paddingInner(1).paddingOuter(0);
|
|
98
|
-
this.chart.append('g').attr('class', 'ticks-line-wrapper').attr('transform',
|
|
99
|
-
return
|
|
112
|
+
this.chart.append('g').attr('class', 'ticks-line-wrapper').attr('transform', `translate(${left + offsetX}, ${top + offsetY})`).selectAll().data(x.domain()).join('g').attr('transform', (d, index) => {
|
|
113
|
+
return `
|
|
114
|
+
rotate(${x(d) * 180 / Math.PI - 90})
|
|
115
|
+
translate(${lineInnerRadius},0)
|
|
116
|
+
`;
|
|
100
117
|
}).attr('data-value', d => d).call(g => {
|
|
101
118
|
g.nodes().forEach(group => {
|
|
102
119
|
const value = Number(group.getAttribute('data-value'));
|
|
@@ -109,16 +126,16 @@ class Dashboard extends _chartComponent.default {
|
|
|
109
126
|
const rotateVal = ((x(value) + x.bandwidth() / 2) * 180 / Math.PI - 90) * -1; // -1 is Rotate the text
|
|
110
127
|
d3.select(group).append('text').attr('transform', () => {
|
|
111
128
|
if (x(value) <= -(Math.PI / 4)) {
|
|
112
|
-
return
|
|
129
|
+
return `translate(-25,-5) rotate(${rotateVal})`;
|
|
113
130
|
}
|
|
114
131
|
if (x(value) <= 0) {
|
|
115
|
-
return
|
|
132
|
+
return `translate(-30,-5) rotate(${rotateVal})`;
|
|
116
133
|
}
|
|
117
134
|
if (x(value) <= Math.PI / 4) {
|
|
118
|
-
return
|
|
135
|
+
return `translate(-30,-2) rotate(${rotateVal})`;
|
|
119
136
|
}
|
|
120
137
|
if (x(value) <= Math.PI) {
|
|
121
|
-
return
|
|
138
|
+
return `translate(-30,3) rotate(${rotateVal})`;
|
|
122
139
|
}
|
|
123
140
|
}).text(text).attr('fill', theme.textColor);
|
|
124
141
|
}
|
|
@@ -133,7 +150,7 @@ class Dashboard extends _chartComponent.default {
|
|
|
133
150
|
|
|
134
151
|
// Pointer
|
|
135
152
|
d3.select(wrapper).append('g').attr('class', 'pointer-wrapper').append('rect').attr('x', -2).attr('y', -78).attr('width', 6).attr('height', 70).attr('fill', '#1890FF').attr('rx', 3).attr('transform', () => {
|
|
136
|
-
return
|
|
153
|
+
return `rotate(${rotate})`;
|
|
137
154
|
});
|
|
138
155
|
};
|
|
139
156
|
this.drawUncompletedPath = (wrapper, innerRadius, outerRadius, startAngle, endAngle) => {
|
|
@@ -148,25 +165,59 @@ class Dashboard extends _chartComponent.default {
|
|
|
148
165
|
const {
|
|
149
166
|
name
|
|
150
167
|
} = chart.config;
|
|
151
|
-
const theme =
|
|
168
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
152
169
|
const {
|
|
153
170
|
height: chartHeight
|
|
154
171
|
} = this.chartBoundingClientRect;
|
|
172
|
+
const {
|
|
173
|
+
toggleRecords
|
|
174
|
+
} = this.props;
|
|
175
|
+
const {
|
|
176
|
+
font_size,
|
|
177
|
+
font_color,
|
|
178
|
+
font_weight,
|
|
179
|
+
text_align,
|
|
180
|
+
card_label_font_size,
|
|
181
|
+
label_font_color,
|
|
182
|
+
label_text_align,
|
|
183
|
+
label_font_weight
|
|
184
|
+
} = chart.config;
|
|
185
|
+
const {
|
|
186
|
+
width: chartWidth,
|
|
187
|
+
height: fullChartHeight
|
|
188
|
+
} = this.chartBoundingClientRect;
|
|
189
|
+
const radius = Math.min(chartWidth, fullChartHeight) / 2 * 0.75;
|
|
190
|
+
const alignOffset = radius * 0.25;
|
|
191
|
+
const getTextAnchorAndX = align => {
|
|
192
|
+
const v = (align || '').toLowerCase();
|
|
193
|
+
if (v === 'left') {
|
|
194
|
+
return {
|
|
195
|
+
textAnchor: 'end',
|
|
196
|
+
x: -alignOffset
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (v === 'right') {
|
|
200
|
+
return {
|
|
201
|
+
textAnchor: 'start',
|
|
202
|
+
x: alignOffset
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
textAnchor: 'middle',
|
|
207
|
+
x: 0
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
const titleAlign = getTextAnchorAndX(label_text_align);
|
|
211
|
+
const numberAlign = getTextAnchorAndX(text_align);
|
|
155
212
|
const totalWrapper = d3.select(wrapper).append('g').attr('class', 'total-wrapper');
|
|
156
213
|
// title
|
|
157
|
-
totalWrapper.append('text').attr('fill',
|
|
158
|
-
const {
|
|
159
|
-
width
|
|
160
|
-
} = g.node().getBoundingClientRect();
|
|
161
|
-
g.attr('dx', "".concat(-(width / 2)));
|
|
162
|
-
});
|
|
214
|
+
totalWrapper.append('text').attr('fill', label_font_color || theme.textColor).attr('font-size', card_label_font_size || (chartHeight > 240 ? 20 : 12)).attr('font-weight', label_font_weight).attr('text-anchor', titleAlign.textAnchor).attr('x', titleAlign.x).text(name).attr('dy', 50);
|
|
163
215
|
|
|
164
216
|
// total
|
|
165
|
-
totalWrapper.append('text').attr('fill', theme.textColor).attr('font-size', chartHeight > 240 ? 36 : 16).
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
g.attr('dx', "".concat(-(width / 2)));
|
|
217
|
+
totalWrapper.append('text').attr('fill', font_color || theme.textColor).attr('font-size', font_size || (chartHeight > 240 ? 36 : 16)).attr('font-weight', font_weight).attr('text-anchor', numberAlign.textAnchor).attr('x', numberAlign.x).text(`${formatValue}%`).attr('dy', 90).style('cursor', toggleRecords ? 'pointer' : 'default').on('click', () => {
|
|
218
|
+
if (toggleRecords) {
|
|
219
|
+
this.handleClickNumber();
|
|
220
|
+
}
|
|
170
221
|
});
|
|
171
222
|
};
|
|
172
223
|
this.chart = null;
|
|
@@ -175,15 +226,9 @@ class Dashboard extends _chartComponent.default {
|
|
|
175
226
|
toolTipPosition: null
|
|
176
227
|
};
|
|
177
228
|
}
|
|
178
|
-
componentDidMount() {
|
|
179
|
-
this.createChart();
|
|
180
|
-
this.drawChart();
|
|
181
|
-
this.debouncedHandleResize = (0, _lodashEs.debounce)(this.handleResize, 300);
|
|
182
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
183
|
-
}
|
|
184
229
|
componentDidUpdate(prevProps) {
|
|
185
230
|
super.componentDidUpdate(prevProps);
|
|
186
|
-
if (
|
|
231
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
187
232
|
this.destroyChart();
|
|
188
233
|
this.createChart();
|
|
189
234
|
this.drawChart();
|
|
@@ -198,10 +243,10 @@ class Dashboard extends _chartComponent.default {
|
|
|
198
243
|
tooltipData,
|
|
199
244
|
toolTipPosition
|
|
200
245
|
} = this.state;
|
|
201
|
-
return /*#__PURE__*/
|
|
246
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
202
247
|
ref: ref => this.container = ref,
|
|
203
248
|
className: "sea-chart-container"
|
|
204
|
-
}, /*#__PURE__*/
|
|
249
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
205
250
|
tooltipData: tooltipData,
|
|
206
251
|
toolTipPosition: toolTipPosition,
|
|
207
252
|
chart: this.chart
|
|
@@ -209,15 +254,15 @@ class Dashboard extends _chartComponent.default {
|
|
|
209
254
|
}
|
|
210
255
|
}
|
|
211
256
|
Dashboard.propTypes = {
|
|
212
|
-
canvasStyle:
|
|
213
|
-
chart:
|
|
214
|
-
groupbyColumn:
|
|
215
|
-
summaryColumn:
|
|
216
|
-
result:
|
|
217
|
-
tables:
|
|
218
|
-
globalTheme:
|
|
219
|
-
chartColorTheme:
|
|
220
|
-
toggleRecords:
|
|
221
|
-
customRender:
|
|
257
|
+
canvasStyle: PropTypes.object,
|
|
258
|
+
chart: PropTypes.object,
|
|
259
|
+
groupbyColumn: PropTypes.object,
|
|
260
|
+
summaryColumn: PropTypes.object,
|
|
261
|
+
result: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
|
|
262
|
+
tables: PropTypes.array,
|
|
263
|
+
globalTheme: PropTypes.string,
|
|
264
|
+
chartColorTheme: PropTypes.string,
|
|
265
|
+
toggleRecords: PropTypes.func,
|
|
266
|
+
customRender: PropTypes.func
|
|
222
267
|
};
|
|
223
|
-
|
|
268
|
+
export default Dashboard;
|
|
@@ -1,21 +1,13 @@
|
|
|
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 _constants = require("../../constants");
|
|
15
|
-
var _utils = require("../../utils");
|
|
16
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
17
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
18
|
-
class Funnel 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 classNames from 'classnames';
|
|
6
|
+
import { FUNNEL_LABEL_FORMAT, FUNNEL_LABEL_POSITIONS, CHART_THEME_COLOR } from '../../constants';
|
|
7
|
+
import { BaseUtils, getSortedDataByGivenOrder } from '../../utils';
|
|
8
|
+
import ToolTip from '../../components/tooltip';
|
|
9
|
+
import ChartComponent from './chart-component';
|
|
10
|
+
class Funnel extends ChartComponent {
|
|
19
11
|
constructor(props) {
|
|
20
12
|
super(props);
|
|
21
13
|
this.handleResize = () => {
|
|
@@ -42,7 +34,7 @@ class Funnel extends _chartComponent.default {
|
|
|
42
34
|
funnel_accumulate_values
|
|
43
35
|
} = chart.config;
|
|
44
36
|
if (!x_axis_option_list.length) return;
|
|
45
|
-
const sortedData =
|
|
37
|
+
const sortedData = getSortedDataByGivenOrder(data, x_axis_option_list);
|
|
46
38
|
const formatSortedData = this.formatSortedData(sortedData, funnel_accumulate_values);
|
|
47
39
|
this.draw(formatSortedData);
|
|
48
40
|
};
|
|
@@ -63,7 +55,7 @@ class Funnel extends _chartComponent.default {
|
|
|
63
55
|
items: [{
|
|
64
56
|
color: colorScale(data === null || data === void 0 ? void 0 : data.name),
|
|
65
57
|
name: data === null || data === void 0 ? void 0 : data.name,
|
|
66
|
-
value:
|
|
58
|
+
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, Number(data === null || data === void 0 ? void 0 : data.value), y_axis_summary_method)
|
|
67
59
|
}]
|
|
68
60
|
};
|
|
69
61
|
this.setState({
|
|
@@ -116,8 +108,8 @@ class Funnel extends _chartComponent.default {
|
|
|
116
108
|
height: chartHeight,
|
|
117
109
|
insertPadding
|
|
118
110
|
} = this.chartBoundingClientRect;
|
|
119
|
-
const theme =
|
|
120
|
-
const isInside = funnel_label_position ===
|
|
111
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
112
|
+
const isInside = funnel_label_position === FUNNEL_LABEL_POSITIONS.INSIDE;
|
|
121
113
|
const title = this.getTitle(tables, table_id, y_axis_summary_type, y_axis_column_key || y_axis_summary_column_key);
|
|
122
114
|
const nameDomain = new Set(data.map(item => item.name));
|
|
123
115
|
|
|
@@ -155,7 +147,12 @@ class Funnel extends _chartComponent.default {
|
|
|
155
147
|
points4X = x(0) + nextOffsetX;
|
|
156
148
|
points4Y = y(nextName);
|
|
157
149
|
}
|
|
158
|
-
contentWrapper.append('polygon').attr('opacity', 1).attr('fill', colorScale(curName)).attr('points',
|
|
150
|
+
contentWrapper.append('polygon').attr('opacity', 1).attr('fill', colorScale(curName)).attr('points', `
|
|
151
|
+
${x(0) + curOffsetX},${y(curName)}
|
|
152
|
+
${x(curValue) + curOffsetX},${y(curName)}
|
|
153
|
+
${points3X},${points3Y}
|
|
154
|
+
${points4X},${points4Y}
|
|
155
|
+
`).attr('data-left', `${Math.min(x(0) + curOffsetX, points4X)}`).attr('data-top', `${y(curName)}`).attr('data-name', curName).call(g => {
|
|
159
156
|
Array.from(g.node().parentNode.children).forEach((g, index) => {
|
|
160
157
|
// Add label
|
|
161
158
|
if (funnel_show_labels) {
|
|
@@ -245,20 +242,20 @@ class Funnel extends _chartComponent.default {
|
|
|
245
242
|
toolTipPosition: null
|
|
246
243
|
};
|
|
247
244
|
this.contentFormatterMap = {
|
|
248
|
-
[
|
|
249
|
-
[
|
|
250
|
-
[
|
|
245
|
+
[FUNNEL_LABEL_FORMAT.NUMBER]: obj => obj === null || obj === void 0 ? void 0 : obj.value,
|
|
246
|
+
[FUNNEL_LABEL_FORMAT.PERCENTAGE]: obj => ((obj === null || obj === void 0 ? void 0 : obj.percent) || 0) + '%',
|
|
247
|
+
[FUNNEL_LABEL_FORMAT.NUMBER_AND_PERCENTAGE]: obj => `${obj === null || obj === void 0 ? void 0 : obj.value} (${(obj === null || obj === void 0 ? void 0 : obj.percent) || 0}%)`
|
|
251
248
|
};
|
|
252
249
|
}
|
|
253
250
|
componentDidMount() {
|
|
254
251
|
this.createChart();
|
|
255
252
|
this.drawChart();
|
|
256
|
-
this.debouncedHandleResize =
|
|
253
|
+
this.debouncedHandleResize = debounce(this.handleResize, 300);
|
|
257
254
|
window.addEventListener('resize', this.debouncedHandleResize);
|
|
258
255
|
}
|
|
259
256
|
componentDidUpdate(prevProps) {
|
|
260
257
|
super.componentDidUpdate(prevProps);
|
|
261
|
-
if (
|
|
258
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
262
259
|
this.destroyChart();
|
|
263
260
|
this.createChart();
|
|
264
261
|
this.drawChart();
|
|
@@ -276,13 +273,13 @@ class Funnel extends _chartComponent.default {
|
|
|
276
273
|
tooltipData,
|
|
277
274
|
toolTipPosition
|
|
278
275
|
} = this.state;
|
|
279
|
-
return /*#__PURE__*/
|
|
276
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
280
277
|
ref: ref => this.container = ref,
|
|
281
|
-
className: (
|
|
278
|
+
className: classNames('sea-chart-container', {
|
|
282
279
|
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
283
280
|
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
284
281
|
})
|
|
285
|
-
}, /*#__PURE__*/
|
|
282
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
286
283
|
tooltipData: tooltipData,
|
|
287
284
|
toolTipPosition: toolTipPosition,
|
|
288
285
|
chart: this.chart
|
|
@@ -290,16 +287,16 @@ class Funnel extends _chartComponent.default {
|
|
|
290
287
|
}
|
|
291
288
|
}
|
|
292
289
|
Funnel.propTypes = {
|
|
293
|
-
canvasStyle:
|
|
294
|
-
chart:
|
|
295
|
-
groupbyColumn:
|
|
296
|
-
columnGroupbyColumn:
|
|
297
|
-
summaryColumn:
|
|
298
|
-
result:
|
|
299
|
-
tables:
|
|
300
|
-
globalTheme:
|
|
301
|
-
chartColorTheme:
|
|
302
|
-
toggleRecords:
|
|
303
|
-
customRender:
|
|
290
|
+
canvasStyle: PropTypes.object,
|
|
291
|
+
chart: PropTypes.object,
|
|
292
|
+
groupbyColumn: PropTypes.object,
|
|
293
|
+
columnGroupbyColumn: PropTypes.object,
|
|
294
|
+
summaryColumn: PropTypes.object,
|
|
295
|
+
result: PropTypes.array,
|
|
296
|
+
tables: PropTypes.array,
|
|
297
|
+
globalTheme: PropTypes.string,
|
|
298
|
+
chartColorTheme: PropTypes.string,
|
|
299
|
+
toggleRecords: PropTypes.func,
|
|
300
|
+
customRender: PropTypes.func
|
|
304
301
|
};
|
|
305
|
-
|
|
302
|
+
export default Funnel;
|