sea-chart 1.1.64 → 2.0.0
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 +13 -6
- package/dist/assets/css/sea-chart-d3-tooltip.css +64 -0
- package/dist/components/cell-factory/FormatterConfig.js +62 -55
- package/dist/components/cell-factory/SimpleCellFormatter.js +11 -4
- package/dist/components/cell-factory/SingleSelectOption.js +18 -11
- package/dist/components/cell-factory/cell-editor-factory.js +12 -5
- package/dist/components/cell-factory/cell-formatter-factory.js +11 -4
- package/dist/components/cell-factory/link-content.js +35 -27
- package/dist/components/chart-color-selector/color-selector.js +18 -11
- package/dist/components/collaborator/index.js +14 -7
- package/dist/components/color-picker/index.js +18 -11
- package/dist/components/color-popover/color-rules/color-rule.js +33 -25
- package/dist/components/color-popover/color-rules/index.js +14 -6
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +34 -27
- package/dist/components/color-popover/color-rules/rule-filters/index.js +25 -17
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +17 -9
- package/dist/components/color-popover/color-rules-popover.js +33 -25
- package/dist/components/color-popover/color-selector-popover.js +18 -10
- package/dist/components/color-setting/color-group-selector.js +20 -12
- package/dist/components/common-add-tool/index.js +13 -6
- package/dist/components/data-process-setter/data-setting-header.js +14 -7
- package/dist/components/data-process-setter/hide-column-setter.js +19 -12
- package/dist/components/data-process-setter/index.js +27 -4
- package/dist/components/data-process-setter/sort-setter.js +24 -16
- package/dist/components/draggable/Draggable.js +13 -7
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +48 -40
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +18 -10
- package/dist/components/drill-down-settings/index.js +18 -11
- package/dist/components/dtable-popover/index.js +20 -13
- package/dist/components/dtable-search-input/index.js +21 -13
- package/dist/components/font-settings/index.js +22 -14
- package/dist/components/goal-line-setting/goal-setting-item.js +14 -6
- package/dist/components/goal-line-setting/index.js +19 -12
- package/dist/components/highlighter/highlighter.js +14 -7
- package/dist/components/icon/index.js +12 -5
- package/dist/components/index.js +48 -7
- package/dist/components/loading/index.js +13 -6
- package/dist/components/number-input/index.js +11 -4
- package/dist/components/pixel-editor/index.js +23 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +14 -7
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +35 -27
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +18 -9
- package/dist/components/popover/sort-popover/sort-popover.js +65 -55
- package/dist/components/resize-handle/ResizeHandle.js +13 -6
- package/dist/components/row-card/row-card-header-cell.js +22 -15
- package/dist/components/row-card/row-card-header.js +21 -14
- package/dist/components/row-card/row-card-item.js +41 -33
- package/dist/components/row-card/row-card.js +23 -15
- package/dist/components/statistic-record-dialog/index.js +63 -55
- package/dist/components/types-dialog/index.js +63 -55
- package/dist/components/types-dialog/use-force-update.js +10 -4
- package/dist/constants/color-rules.js +14 -8
- package/dist/constants/common-constants.js +14 -8
- package/dist/constants/error.js +8 -2
- package/dist/constants/geolocation.js +15 -9
- package/dist/constants/index.js +271 -142
- package/dist/constants/key-codes.js +2 -0
- package/dist/constants/model.js +9 -3
- package/dist/constants/regions.js +8 -3
- package/dist/constants/style.js +12 -6
- package/dist/constants/table.js +7 -1
- package/dist/constants/type-image.js +39 -33
- package/dist/constants/type.js +9 -3
- package/dist/context.js +19 -12
- package/dist/editor/index.js +15 -12
- package/dist/index.js +104 -13
- package/dist/intl.js +17 -10
- package/dist/locale/index.js +23 -16
- package/dist/locale/lang/de.js +7 -1
- package/dist/locale/lang/en.js +7 -1
- package/dist/locale/lang/es.js +7 -1
- package/dist/locale/lang/fr.js +7 -1
- package/dist/locale/lang/pt.js +7 -1
- package/dist/locale/lang/ru.js +7 -1
- package/dist/locale/lang/zh_CN.js +7 -1
- package/dist/model/area-group.js +19 -12
- package/dist/model/area.js +19 -12
- package/dist/model/bar-custom.js +18 -11
- package/dist/model/bar-group.js +19 -12
- package/dist/model/bar-stack.js +17 -10
- package/dist/model/bar.js +18 -11
- package/dist/model/base-model.js +11 -4
- package/dist/model/basic-number-card.js +20 -13
- package/dist/model/chart.js +13 -7
- package/dist/model/combination.js +22 -15
- package/dist/model/compare-bar.js +21 -14
- package/dist/model/completeness-group.js +18 -11
- package/dist/model/completeness.js +17 -10
- package/dist/model/dashboard.js +14 -7
- package/dist/model/funnel.js +21 -14
- package/dist/model/generic-model.js +143 -135
- package/dist/model/heat-map.js +16 -9
- package/dist/model/horizontal-bar.js +18 -11
- package/dist/model/horizontal-group-bar.js +17 -10
- package/dist/model/index.js +93 -69
- package/dist/model/line-group.js +20 -13
- package/dist/model/line.js +19 -12
- package/dist/model/map-bubble.js +17 -10
- package/dist/model/map.js +19 -12
- package/dist/model/mirror.js +20 -13
- package/dist/model/pie.js +19 -12
- package/dist/model/ring.js +19 -12
- package/dist/model/scatter.js +17 -10
- package/dist/model/stacked-horizontal-bar.js +18 -11
- package/dist/model/table-element.js +12 -5
- package/dist/model/table.js +14 -7
- package/dist/model/tree-map.js +14 -7
- package/dist/model/trend.js +18 -11
- package/dist/model/user.js +7 -1
- package/dist/model/world-map-bubble.js +19 -12
- package/dist/model/world-map.js +19 -12
- package/dist/services/map-json.js +13 -7
- package/dist/settings/advance-bar-settings/data-settings.js +46 -42
- package/dist/settings/advance-bar-settings/index.js +20 -3
- package/dist/settings/advance-bar-settings/style-settings.js +73 -69
- package/dist/settings/bar-settings/data-settings.js +49 -45
- package/dist/settings/bar-settings/index.js +20 -3
- package/dist/settings/bar-settings/style-settings.js +59 -55
- package/dist/settings/basic-number-card/data-settings.js +57 -49
- package/dist/settings/basic-number-card/index.js +20 -3
- package/dist/settings/basic-number-card/style-settings.js +26 -18
- package/dist/settings/combination-settings/data-settings.js +65 -60
- package/dist/settings/combination-settings/index.js +20 -3
- package/dist/settings/combination-settings/style-settings.js +74 -69
- package/dist/settings/completeness-settings/callbacks/callbacks.js +27 -16
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +28 -21
- package/dist/settings/completeness-settings/data-settings/data-settings.js +32 -25
- package/dist/settings/completeness-settings/index.js +20 -3
- package/dist/settings/completeness-settings/style-settings.js +26 -19
- package/dist/settings/dashboard-settings/data-settings.js +51 -43
- package/dist/settings/dashboard-settings/index.js +13 -2
- package/dist/settings/data-settings.js +79 -72
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +19 -12
- package/dist/settings/funnel-settings/components/dnd-list.js +23 -15
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +40 -32
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +30 -22
- package/dist/settings/funnel-settings/data-settings.js +31 -23
- package/dist/settings/funnel-settings/index.js +20 -3
- package/dist/settings/funnel-settings/style-settings.js +19 -11
- package/dist/settings/heat-map-settings/data-settings.js +26 -18
- package/dist/settings/heat-map-settings/index.js +20 -3
- package/dist/settings/heat-map-settings/style-settings.js +26 -18
- package/dist/settings/horizontal-bar-settings/data-settings.js +19 -12
- package/dist/settings/horizontal-bar-settings/index.js +20 -3
- package/dist/settings/horizontal-bar-settings/style-settings.js +19 -12
- package/dist/settings/index.js +75 -58
- package/dist/settings/map-settings/components/location-field-selector.js +17 -10
- package/dist/settings/map-settings/components/map-level-selector.js +18 -11
- package/dist/settings/map-settings/components/map-province-city-selector.js +26 -19
- package/dist/settings/map-settings/index.js +20 -3
- package/dist/settings/map-settings/map-data-settings.js +30 -23
- package/dist/settings/map-settings/map-style-settings.js +34 -26
- package/dist/settings/mirror-settings/data-settings.js +34 -26
- package/dist/settings/mirror-settings/index.js +13 -2
- package/dist/settings/pie-settings/data-settings.js +41 -33
- package/dist/settings/pie-settings/index.js +20 -3
- package/dist/settings/pie-settings/style-settings.js +55 -47
- package/dist/settings/scatter/data-settings.js +34 -27
- package/dist/settings/scatter/index.js +12 -3
- package/dist/settings/stacks-settings/index.js +27 -19
- package/dist/settings/stacks-settings/stack-item-settings.js +27 -19
- package/dist/settings/style-settings.js +72 -64
- package/dist/settings/table-element-settings/components/data-filter.js +37 -29
- package/dist/settings/table-element-settings/data-settings.js +29 -21
- package/dist/settings/table-element-settings/index.js +13 -2
- package/dist/settings/table-settings/data-settings.js +119 -111
- package/dist/settings/table-settings/index.js +13 -2
- package/dist/settings/time-comparison-settings/data-settings.js +51 -43
- package/dist/settings/time-comparison-settings/index.js +20 -3
- package/dist/settings/time-comparison-settings/style-settings.js +50 -42
- package/dist/settings/trend-settings/data-settings.js +32 -24
- package/dist/settings/trend-settings/index.js +20 -3
- package/dist/settings/trend-settings/style-setting.js +25 -17
- package/dist/settings/widgets/basic-summary/index.js +66 -66
- package/dist/settings/widgets/chart-type/index.js +34 -19
- package/dist/settings/widgets/color-settings/index.js +80 -72
- package/dist/settings/widgets/common-data-settings.js +30 -25
- package/dist/settings/widgets/data-filter/index.js +40 -32
- package/dist/settings/widgets/data-sort.js +24 -16
- package/dist/settings/widgets/date-summary-item.js +32 -24
- package/dist/settings/widgets/display-values-settings/index.js +22 -14
- package/dist/settings/widgets/divider/index.js +16 -8
- package/dist/settings/widgets/font-settings/font-color-settings.js +19 -11
- package/dist/settings/widgets/font-settings/font-size-settings.js +22 -14
- package/dist/settings/widgets/font-settings/font-weight-settings.js +25 -17
- package/dist/settings/widgets/font-settings/index.js +27 -4
- package/dist/settings/widgets/group-by.js +59 -51
- package/dist/settings/widgets/min-max-setting.js +18 -10
- package/dist/settings/widgets/mininum-slice-percent.js +18 -10
- package/dist/settings/widgets/numeric-summary-item.js +31 -23
- package/dist/settings/widgets/select-line-type/index.js +17 -10
- package/dist/settings/widgets/select-table/index.js +16 -9
- package/dist/settings/widgets/select-view/index.js +28 -20
- package/dist/settings/widgets/stack.js +22 -14
- package/dist/settings/widgets/summary-method-setting.js +25 -17
- package/dist/settings/widgets/summary-settings.js +80 -72
- package/dist/settings/widgets/switch/index.js +15 -8
- package/dist/settings/widgets/text-horizontal-settings.js +23 -15
- package/dist/settings/widgets/time-picker.js +37 -29
- package/dist/settings/widgets/title-settings/index.js +37 -29
- package/dist/settings/widgets/title-settings/title-text.js +12 -5
- package/dist/settings/widgets/x-axios.js +1 -0
- package/dist/settings/widgets/y-axis-group-settings.js +71 -63
- package/dist/utils/cell-format-utils.js +29 -19
- package/dist/utils/cell-value-utils.js +11 -4
- package/dist/utils/chart-utils/base-utils.js +290 -279
- package/dist/utils/chart-utils/index.js +39 -26
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +84 -77
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +20 -13
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +52 -45
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +26 -19
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +39 -32
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +23 -16
- package/dist/utils/chart-utils/original-data-utils/index.js +57 -50
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +26 -19
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +96 -90
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +25 -18
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +34 -27
- package/dist/utils/chart-utils/sql-statistics-utils.js +237 -229
- package/dist/utils/chart.js +17 -9
- package/dist/utils/collaborator-manager.js +9 -3
- package/dist/utils/collaborator-utils.js +30 -18
- package/dist/utils/collaborator.js +13 -4
- package/dist/utils/color-utils.js +29 -18
- package/dist/utils/column-utils.js +88 -63
- package/dist/utils/common-utils.js +52 -27
- package/dist/utils/concurrency-manager.js +7 -1
- package/dist/utils/contexts.js +11 -4
- package/dist/utils/custom-g2.js +241 -212
- package/dist/utils/date-translate.js +19 -11
- package/dist/utils/digital-sign-utils.js +14 -7
- package/dist/utils/event-bus.js +7 -1
- package/dist/utils/hotkey.js +11 -5
- package/dist/utils/index.js +219 -53
- package/dist/utils/key-generator.js +9 -2
- package/dist/utils/map.js +31 -22
- package/dist/utils/object-utils.js +7 -1
- package/dist/utils/options-utils.js +16 -8
- package/dist/utils/row-record-utils.js +164 -152
- package/dist/utils/row-utils.js +38 -27
- package/dist/utils/search.js +32 -24
- package/dist/utils/sql/chart-data-sql.js +55 -49
- package/dist/utils/sql/column-2-sql-column.js +153 -143
- package/dist/utils/sql/index.js +27 -3
- package/dist/utils/trend-utils.js +45 -37
- package/dist/view/index.js +96 -87
- package/dist/view/title/index.js +23 -15
- package/dist/view/wrapper/area.js +46 -39
- package/dist/view/wrapper/bar-custom.js +40 -33
- package/dist/view/wrapper/bar-group.js +58 -51
- package/dist/view/wrapper/bar.js +42 -35
- package/dist/view/wrapper/basic-number-card.js +25 -17
- package/dist/view/wrapper/chart-component.js +116 -54
- package/dist/view/wrapper/combination.js +82 -75
- package/dist/view/wrapper/compare.js +57 -50
- package/dist/view/wrapper/completeness.js +32 -24
- package/dist/view/wrapper/dashboard.js +21 -14
- package/dist/view/wrapper/funnel.js +26 -19
- package/dist/view/wrapper/heat-map.js +60 -53
- package/dist/view/wrapper/horizontal-bar-group.js +48 -41
- package/dist/view/wrapper/horizontal-bar.js +39 -32
- package/dist/view/wrapper/horizontal-component.js +23 -15
- package/dist/view/wrapper/index.js +148 -96
- package/dist/view/wrapper/line-group.js +41 -34
- package/dist/view/wrapper/line.js +39 -32
- package/dist/view/wrapper/map.js +54 -46
- package/dist/view/wrapper/mirror.js +38 -31
- package/dist/view/wrapper/pie.js +50 -43
- package/dist/view/wrapper/ring.js +59 -52
- package/dist/view/wrapper/scatter.js +30 -22
- package/dist/view/wrapper/table/index.js +21 -13
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +57 -49
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +58 -50
- package/dist/view/wrapper/table/pivot-table-display-name.js +90 -82
- package/dist/view/wrapper/table/two-dimension-table.js +84 -76
- package/dist/view/wrapper/table-element/components/dataset-utils.js +36 -23
- package/dist/view/wrapper/table-element/components/formatter.js +98 -89
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +31 -22
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +16 -9
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +80 -73
- package/dist/view/wrapper/table-element/components/formula-formatter.js +16 -9
- package/dist/view/wrapper/table-element/components/link-formatter.js +80 -73
- package/dist/view/wrapper/table-element/components/record.js +17 -10
- package/dist/view/wrapper/table-element/components/records-body.js +17 -9
- package/dist/view/wrapper/table-element/components/records-header/index.js +16 -8
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +16 -8
- package/dist/view/wrapper/table-element/components/records.js +29 -21
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +13 -6
- package/dist/view/wrapper/table-element/components/utils.js +15 -5
- package/dist/view/wrapper/table-element/components/value-display-utils.js +11 -4
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +13 -6
- package/dist/view/wrapper/table-element/index.js +24 -16
- package/dist/view/wrapper/treemap.js +43 -36
- package/dist/view/wrapper/trend.js +47 -39
- package/dist/view/wrapper/world-map.js +60 -52
- package/dist/view/wrapper/wrappers-d3/bar.js +262 -0
- package/package.json +15 -17
package/dist/view/wrapper/bar.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _lodashEs = require("lodash-es");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _constants = require("../../constants");
|
|
13
|
+
var _utils = require("../../utils");
|
|
14
|
+
var _colorUtils = require("../../utils/color-utils");
|
|
15
|
+
var _intl = _interopRequireDefault(require("../../intl"));
|
|
16
|
+
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
17
|
+
class Bar extends _chartComponent.default {
|
|
11
18
|
constructor(props) {
|
|
12
19
|
super(props);
|
|
13
20
|
this.handleResize = () => {
|
|
@@ -38,7 +45,7 @@ class Bar extends ChartComponent {
|
|
|
38
45
|
let {
|
|
39
46
|
result: data
|
|
40
47
|
} = this.props;
|
|
41
|
-
data = BaseUtils.formatEmptyName(data, '',
|
|
48
|
+
data = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
|
|
42
49
|
if (!Array.isArray(data)) return;
|
|
43
50
|
this.loadData(data);
|
|
44
51
|
this.draw(data);
|
|
@@ -56,7 +63,7 @@ class Bar extends ChartComponent {
|
|
|
56
63
|
chartColorTheme,
|
|
57
64
|
tables
|
|
58
65
|
} = this.props;
|
|
59
|
-
const theme = CHART_THEME_COLOR[globalTheme];
|
|
66
|
+
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
60
67
|
const {
|
|
61
68
|
y_axis_summary_type,
|
|
62
69
|
y_axis_summary_column_key,
|
|
@@ -78,11 +85,11 @@ class Bar extends ChartComponent {
|
|
|
78
85
|
const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
|
|
79
86
|
const singleBarWidth = Math.round(chartWidth / (2 * data.length));
|
|
80
87
|
const singleBarRadius = Math.min(singleBarWidth / 5, 10);
|
|
81
|
-
let chartBarColor = y_axis_label_color || CHART_STYLE_COLORS[0];
|
|
88
|
+
let chartBarColor = y_axis_label_color || _constants.CHART_STYLE_COLORS[0];
|
|
82
89
|
if (chartColorTheme) {
|
|
83
|
-
chartBarColor = BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
|
|
90
|
+
chartBarColor = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
|
|
84
91
|
}
|
|
85
|
-
const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && y_axis_label_color_rules && getConvertedColorRules(y_axis_label_color_rules);
|
|
92
|
+
const colorRules = color_option === _constants.TYPE_COLOR_USING.USE_RULES && y_axis_label_color_rules && (0, _colorUtils.getConvertedColorRules)(y_axis_label_color_rules);
|
|
86
93
|
const title = this.getTitle(tables, table_id, y_axis_summary_type, y_axis_column_key || y_axis_summary_column_key);
|
|
87
94
|
this.drawLabels(data);
|
|
88
95
|
// set Coord type
|
|
@@ -90,12 +97,12 @@ class Bar extends ChartComponent {
|
|
|
90
97
|
this.autoAdjustDataOptions(chart, data, summaryColumn);
|
|
91
98
|
this.chart.interval().label(y_axis_show_value ? 'value' : false, {
|
|
92
99
|
style: {
|
|
93
|
-
fontSize: BaseUtils.getLabelFontSize(label_font_size),
|
|
100
|
+
fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
|
|
94
101
|
fill: theme.labelColor,
|
|
95
102
|
...this.labelStroke
|
|
96
103
|
}
|
|
97
104
|
}).position('name*value').size(singleBarWidth).color('value', value => {
|
|
98
|
-
const color = getLabelColor({
|
|
105
|
+
const color = (0, _colorUtils.getLabelColor)({
|
|
99
106
|
chart: chart.config,
|
|
100
107
|
colorRules,
|
|
101
108
|
value
|
|
@@ -104,7 +111,7 @@ class Bar extends ChartComponent {
|
|
|
104
111
|
}).tooltip('name*value', (name, value) => {
|
|
105
112
|
return {
|
|
106
113
|
title,
|
|
107
|
-
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
114
|
+
value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
108
115
|
name
|
|
109
116
|
};
|
|
110
117
|
}).state({
|
|
@@ -123,7 +130,7 @@ class Bar extends ChartComponent {
|
|
|
123
130
|
}
|
|
124
131
|
this.chart.legend(false);
|
|
125
132
|
this.setToolTip();
|
|
126
|
-
isFunction(customRender) && customRender(this.chart);
|
|
133
|
+
(0, _utils.isFunction)(customRender) && customRender(this.chart);
|
|
127
134
|
this.setNameLabelAndTooltip(theme, this.labelCount);
|
|
128
135
|
this.setValueLabel(theme);
|
|
129
136
|
this.chart.interaction('element-highlight');
|
|
@@ -133,12 +140,12 @@ class Bar extends ChartComponent {
|
|
|
133
140
|
componentDidMount() {
|
|
134
141
|
this.createChart();
|
|
135
142
|
this.drawChart();
|
|
136
|
-
this.debouncedHandleResize = debounce(this.handleResize, 300);
|
|
143
|
+
this.debouncedHandleResize = (0, _lodashEs.debounce)(this.handleResize, 300);
|
|
137
144
|
window.addEventListener('resize', this.debouncedHandleResize);
|
|
138
145
|
}
|
|
139
146
|
componentDidUpdate(prevProps) {
|
|
140
147
|
super.componentDidUpdate(prevProps);
|
|
141
|
-
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
148
|
+
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
142
149
|
var _this$chart;
|
|
143
150
|
((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
|
|
144
151
|
this.createChart();
|
|
@@ -155,8 +162,8 @@ class Bar extends ChartComponent {
|
|
|
155
162
|
const {
|
|
156
163
|
chart
|
|
157
164
|
} = this.props;
|
|
158
|
-
return /*#__PURE__*/
|
|
159
|
-
className:
|
|
165
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
166
|
+
className: (0, _classnames.default)('sea-chart-container', {
|
|
160
167
|
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
161
168
|
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
162
169
|
}),
|
|
@@ -165,16 +172,16 @@ class Bar extends ChartComponent {
|
|
|
165
172
|
}
|
|
166
173
|
}
|
|
167
174
|
Bar.propTypes = {
|
|
168
|
-
canvasStyle:
|
|
169
|
-
chart:
|
|
170
|
-
groupbyColumn:
|
|
171
|
-
columnGroupbyColumn:
|
|
172
|
-
summaryColumn:
|
|
173
|
-
result:
|
|
174
|
-
tables:
|
|
175
|
-
globalTheme:
|
|
176
|
-
chartColorTheme:
|
|
177
|
-
toggleRecords:
|
|
178
|
-
customRender:
|
|
175
|
+
canvasStyle: _propTypes.default.object,
|
|
176
|
+
chart: _propTypes.default.object,
|
|
177
|
+
groupbyColumn: _propTypes.default.object,
|
|
178
|
+
columnGroupbyColumn: _propTypes.default.object,
|
|
179
|
+
summaryColumn: _propTypes.default.object,
|
|
180
|
+
result: _propTypes.default.array,
|
|
181
|
+
tables: _propTypes.default.array,
|
|
182
|
+
globalTheme: _propTypes.default.string,
|
|
183
|
+
chartColorTheme: _propTypes.default.string,
|
|
184
|
+
toggleRecords: _propTypes.default.func,
|
|
185
|
+
customRender: _propTypes.default.func
|
|
179
186
|
};
|
|
180
|
-
|
|
187
|
+
var _default = exports.default = Bar;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _dtableUtils = require("dtable-utils");
|
|
11
|
+
var _utils = require("../../utils");
|
|
12
|
+
var _intl = _interopRequireDefault(require("../../intl"));
|
|
13
|
+
var _constants = require("../../constants");
|
|
14
|
+
class BasicNumericCard extends _react.Component {
|
|
7
15
|
constructor(props) {
|
|
8
16
|
super(props);
|
|
9
17
|
this.setCurrentLineHeight = () => {
|
|
@@ -17,7 +25,7 @@ class BasicNumericCard extends Component {
|
|
|
17
25
|
const currentLineHeight = parseFloat(computedStyle.lineHeight);
|
|
18
26
|
const currentLabelHeight = parseFloat(computedStyle.height);
|
|
19
27
|
if (prevLineHeight === currentLineHeight && prevLabelHeight === currentLabelHeight) return;
|
|
20
|
-
if (isNumber(currentLineHeight) && isNumber(currentLabelHeight)) {
|
|
28
|
+
if ((0, _dtableUtils.isNumber)(currentLineHeight) && (0, _dtableUtils.isNumber)(currentLabelHeight)) {
|
|
21
29
|
this.setState({
|
|
22
30
|
currentLineHeight,
|
|
23
31
|
currentLabelHeight
|
|
@@ -25,7 +33,7 @@ class BasicNumericCard extends Component {
|
|
|
25
33
|
}
|
|
26
34
|
};
|
|
27
35
|
this.formatData = data => {
|
|
28
|
-
if (!data && data !== 0) return
|
|
36
|
+
if (!data && data !== 0) return _intl.default.get(_constants.EMPTY_NAME);
|
|
29
37
|
const {
|
|
30
38
|
chart,
|
|
31
39
|
summaryColumn
|
|
@@ -35,8 +43,8 @@ class BasicNumericCard extends Component {
|
|
|
35
43
|
summary_method
|
|
36
44
|
} = chart.config;
|
|
37
45
|
// COUNT / SUMMARIZE_A_FIELD
|
|
38
|
-
if (summary_type !== BASIC_NUMBER_CARD_CALCULATION_METHOD) {
|
|
39
|
-
const formattedContent = BaseUtils.getSummaryValueDisplayString(summaryColumn, data, summary_method);
|
|
46
|
+
if (summary_type !== _constants.BASIC_NUMBER_CARD_CALCULATION_METHOD) {
|
|
47
|
+
const formattedContent = _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, data, summary_method);
|
|
40
48
|
return formattedContent;
|
|
41
49
|
}
|
|
42
50
|
let string = data + '';
|
|
@@ -82,7 +90,7 @@ class BasicNumericCard extends Component {
|
|
|
82
90
|
chart,
|
|
83
91
|
result
|
|
84
92
|
} = this.props;
|
|
85
|
-
const theme = CHART_THEME_COLOR[globalTheme];
|
|
93
|
+
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
86
94
|
const {
|
|
87
95
|
config
|
|
88
96
|
} = chart;
|
|
@@ -100,20 +108,20 @@ class BasicNumericCard extends Component {
|
|
|
100
108
|
} = config;
|
|
101
109
|
let content = null;
|
|
102
110
|
if (summary_method === 'Distinct_values') {
|
|
103
|
-
content = isNumber(result) ? result : 0;
|
|
111
|
+
content = (0, _dtableUtils.isNumber)(result) ? result : 0;
|
|
104
112
|
} else {
|
|
105
113
|
content = this.formatData(result);
|
|
106
114
|
}
|
|
107
|
-
return /*#__PURE__*/
|
|
115
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
108
116
|
className: "sea-chart-container plugin-number-card"
|
|
109
|
-
}, /*#__PURE__*/
|
|
117
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
110
118
|
style: {
|
|
111
119
|
color: theme.cardColor,
|
|
112
120
|
width: '100%',
|
|
113
121
|
height: '100%',
|
|
114
122
|
position: 'relative'
|
|
115
123
|
}
|
|
116
|
-
}, /*#__PURE__*/
|
|
124
|
+
}, /*#__PURE__*/_react.default.createElement("p", {
|
|
117
125
|
style: {
|
|
118
126
|
position: 'absolute',
|
|
119
127
|
width: '100%',
|
|
@@ -125,7 +133,7 @@ class BasicNumericCard extends Component {
|
|
|
125
133
|
fontWeight: "".concat(font_weight),
|
|
126
134
|
color: "".concat(font_color)
|
|
127
135
|
}
|
|
128
|
-
}, content), /*#__PURE__*/
|
|
136
|
+
}, content), /*#__PURE__*/_react.default.createElement("p", {
|
|
129
137
|
ref: ref => this.labelRef = ref,
|
|
130
138
|
style: {
|
|
131
139
|
position: 'absolute',
|
|
@@ -146,4 +154,4 @@ class BasicNumericCard extends Component {
|
|
|
146
154
|
}, name)));
|
|
147
155
|
}
|
|
148
156
|
}
|
|
149
|
-
|
|
157
|
+
var _default = exports.default = BasicNumericCard;
|
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _dtableUtils = require("dtable-utils");
|
|
11
|
+
var d3 = _interopRequireWildcard(require("d3"));
|
|
12
|
+
var _lodashEs = require("lodash-es");
|
|
13
|
+
var _customG = require("../../utils/custom-g2");
|
|
14
|
+
var _utils = require("../../utils");
|
|
15
|
+
var _constants = require("../../constants");
|
|
16
|
+
var _intl = _interopRequireDefault(require("../../intl"));
|
|
17
|
+
require("../../assets/css/sea-chart-d3-tooltip.css");
|
|
18
|
+
class ChartComponent extends _react.Component {
|
|
9
19
|
constructor(props) {
|
|
10
20
|
var _this;
|
|
11
21
|
super(props);
|
|
12
22
|
_this = this;
|
|
13
23
|
this.initLabelStroke = theme => {
|
|
14
|
-
this.globalTheme = theme || THEME_NAME_MAP.LIGHT;
|
|
15
|
-
this.labelStroke = theme === THEME_NAME_MAP.DARK ? {} : {
|
|
24
|
+
this.globalTheme = theme || _constants.THEME_NAME_MAP.LIGHT;
|
|
25
|
+
this.labelStroke = theme === _constants.THEME_NAME_MAP.DARK ? {} : {
|
|
16
26
|
stroke: '#fff',
|
|
17
27
|
lineWidth: 1
|
|
18
28
|
};
|
|
19
29
|
};
|
|
20
|
-
this.handleResize = debounce(() => {
|
|
30
|
+
this.handleResize = (0, _lodashEs.debounce)(() => {
|
|
21
31
|
var _this$chart;
|
|
22
32
|
if (!this.createChart || !this.drawChart) return;
|
|
23
33
|
((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
|
|
@@ -28,11 +38,11 @@ export default class ChartComponent extends Component {
|
|
|
28
38
|
}
|
|
29
39
|
}, 300);
|
|
30
40
|
this.getTitle = (tables, table_id, yAxisType, yAxisKey) => {
|
|
31
|
-
return yAxisType === CHART_SUMMARY_TYPE.COUNT ?
|
|
41
|
+
return yAxisType === _constants.CHART_SUMMARY_TYPE.COUNT ? _intl.default.get('Amount') : this.getAxisLabel(tables, table_id, yAxisKey);
|
|
32
42
|
};
|
|
33
43
|
this.getColumn = (tables, table_id, columnKey) => {
|
|
34
|
-
const table = getTableById(tables, table_id);
|
|
35
|
-
const column = getTableColumnByKey(table, columnKey) || {};
|
|
44
|
+
const table = (0, _dtableUtils.getTableById)(tables, table_id);
|
|
45
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, columnKey) || {};
|
|
36
46
|
return column;
|
|
37
47
|
};
|
|
38
48
|
this.getAxisLabel = (tables, tableId, columnKey) => {
|
|
@@ -55,7 +65,16 @@ export default class ChartComponent extends Component {
|
|
|
55
65
|
if (appendPadding) {
|
|
56
66
|
config.appendPadding = appendPadding;
|
|
57
67
|
}
|
|
58
|
-
this.chart = new Chart(config);
|
|
68
|
+
this.chart = new _customG.Chart(config);
|
|
69
|
+
};
|
|
70
|
+
this.initD3Chart = container => {
|
|
71
|
+
const {
|
|
72
|
+
width,
|
|
73
|
+
height
|
|
74
|
+
} = container.getBoundingClientRect();
|
|
75
|
+
this.chart = d3.create('svg').attr('width', width).attr('height', height).attr('viewBox', [0, 0, width, height]);
|
|
76
|
+
this.container.appendChild(this.chart.node());
|
|
77
|
+
this.chartBoundingClientRect = this.chart.node().getBoundingClientRect();
|
|
59
78
|
};
|
|
60
79
|
this.loadData = data => {
|
|
61
80
|
this.chart.data(data, {
|
|
@@ -84,7 +103,7 @@ export default class ChartComponent extends Component {
|
|
|
84
103
|
if (item.group_name === 'rest' && isCompleteness) return;
|
|
85
104
|
const groupData = chartGroupData.find(g => g.name === item.name);
|
|
86
105
|
if (!groupData) {
|
|
87
|
-
const newItem = cloneDeep(item);
|
|
106
|
+
const newItem = (0, _lodashEs.cloneDeep)(item);
|
|
88
107
|
newItem.currentGroupCount = 1;
|
|
89
108
|
chartGroupData.push(newItem);
|
|
90
109
|
} else {
|
|
@@ -138,13 +157,13 @@ export default class ChartComponent extends Component {
|
|
|
138
157
|
// mark the first item in each group,but if item value is 0, mark the next item
|
|
139
158
|
let targetMarkItem = item[0],
|
|
140
159
|
i = 1;
|
|
141
|
-
while (!((_targetMarkItem = targetMarkItem)
|
|
160
|
+
while (!((_targetMarkItem = targetMarkItem) !== null && _targetMarkItem !== void 0 && _targetMarkItem.value) && !Number.isNaN((_targetMarkItem2 = targetMarkItem) === null || _targetMarkItem2 === void 0 ? void 0 : _targetMarkItem2.value)) {
|
|
142
161
|
var _targetMarkItem, _targetMarkItem2;
|
|
143
162
|
targetMarkItem = item[i];
|
|
144
163
|
i++;
|
|
145
164
|
if (i >= item.length) break;
|
|
146
165
|
}
|
|
147
|
-
if (!((_targetMarkItem3 = targetMarkItem)
|
|
166
|
+
if (!((_targetMarkItem3 = targetMarkItem) !== null && _targetMarkItem3 !== void 0 && _targetMarkItem3.value)) return;
|
|
148
167
|
targetMarkItem.isFirst = 1;
|
|
149
168
|
} else if (position === 'last') {
|
|
150
169
|
var _targetMarkItem6;
|
|
@@ -152,13 +171,13 @@ export default class ChartComponent extends Component {
|
|
|
152
171
|
const l = item.length;
|
|
153
172
|
let targetMarkItem = item[l - 1],
|
|
154
173
|
i = l - 2;
|
|
155
|
-
while (!((_targetMarkItem4 = targetMarkItem)
|
|
174
|
+
while (!((_targetMarkItem4 = targetMarkItem) !== null && _targetMarkItem4 !== void 0 && _targetMarkItem4.value) && !Number.isNaN((_targetMarkItem5 = targetMarkItem) === null || _targetMarkItem5 === void 0 ? void 0 : _targetMarkItem5.value)) {
|
|
156
175
|
var _targetMarkItem4, _targetMarkItem5;
|
|
157
176
|
targetMarkItem = item[i];
|
|
158
177
|
i--;
|
|
159
178
|
if (i < 0) break;
|
|
160
179
|
}
|
|
161
|
-
if (!((_targetMarkItem6 = targetMarkItem)
|
|
180
|
+
if (!((_targetMarkItem6 = targetMarkItem) !== null && _targetMarkItem6 !== void 0 && _targetMarkItem6.value)) return;
|
|
162
181
|
targetMarkItem.isLast = 1;
|
|
163
182
|
} else {
|
|
164
183
|
console.error('on markFirstOrLast: unknown position');
|
|
@@ -206,7 +225,7 @@ export default class ChartComponent extends Component {
|
|
|
206
225
|
});
|
|
207
226
|
}
|
|
208
227
|
};
|
|
209
|
-
this.renderAxisLabel = (chart, tables) => {
|
|
228
|
+
this.renderAxisLabel = (chart, tables, container) => {
|
|
210
229
|
var _this$chart2;
|
|
211
230
|
if (!this.chart || !chart) return;
|
|
212
231
|
let {
|
|
@@ -227,20 +246,20 @@ export default class ChartComponent extends Component {
|
|
|
227
246
|
if (y_axis_summary_column_key) {
|
|
228
247
|
y_axis_column_key = y_axis_summary_column_key;
|
|
229
248
|
}
|
|
230
|
-
const table = getTableById(tables, table_id);
|
|
249
|
+
const table = (0, _dtableUtils.getTableById)(tables, table_id);
|
|
231
250
|
const autoPadding = ((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) || {
|
|
232
251
|
bottom: 0
|
|
233
252
|
};
|
|
234
253
|
let textColor;
|
|
235
|
-
this.globalTheme === THEME_NAME_MAP.DARK ? textColor = '#fff' : textColor = '#999';
|
|
254
|
+
this.globalTheme === _constants.THEME_NAME_MAP.DARK ? textColor = '#fff' : textColor = '#999';
|
|
236
255
|
const xAxisID = "chart-x-axis-label_".concat(chart.id);
|
|
237
|
-
const chartContainer = this.chart.getCanvas().get('container');
|
|
256
|
+
const chartContainer = container || this.chart.getCanvas().get('container');
|
|
238
257
|
const xLabel = chartContainer === null || chartContainer === void 0 ? void 0 : chartContainer.querySelector("#".concat(xAxisID));
|
|
239
258
|
if (!xLabel && x_axis_show_label) {
|
|
240
259
|
const div = document.createElement('div');
|
|
241
260
|
div.id = xAxisID;
|
|
242
261
|
div.className = 'chart-axis-label';
|
|
243
|
-
const column = getTableColumnByKey(table, x_axis_column_key);
|
|
262
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
|
|
244
263
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
245
264
|
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
|
|
246
265
|
chartContainer.appendChild(div);
|
|
@@ -257,27 +276,27 @@ export default class ChartComponent extends Component {
|
|
|
257
276
|
const div = document.createElement('div');
|
|
258
277
|
div.id = yAxisID;
|
|
259
278
|
div.className = 'chart-axis-label';
|
|
260
|
-
if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
261
|
-
div.innerHTML =
|
|
279
|
+
if (y_axis_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
280
|
+
div.innerHTML = _intl.default.get('Amount');
|
|
262
281
|
} else {
|
|
263
|
-
const column = getTableColumnByKey(table, y_axis_column_key) || {};
|
|
282
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
|
|
264
283
|
div.innerHTML = column.name || '';
|
|
265
|
-
if (type === CHART_TYPE.BAR_STACK) {
|
|
284
|
+
if (type === _constants.CHART_TYPE.BAR_STACK) {
|
|
266
285
|
div.innerHTML = title_name || '';
|
|
267
286
|
}
|
|
268
287
|
}
|
|
269
288
|
const containerHeight = chartContainer.offsetHeight;
|
|
270
289
|
let textAlign = 'center';
|
|
271
|
-
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
272
|
-
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
290
|
+
if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
291
|
+
if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
273
292
|
div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
274
293
|
chartContainer.appendChild(div);
|
|
275
294
|
}
|
|
276
295
|
if (yLabel && y_axis_show_label) {
|
|
277
296
|
const containerHeight = chartContainer.offsetHeight;
|
|
278
297
|
let textAlign = 'center';
|
|
279
|
-
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
280
|
-
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
298
|
+
if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
299
|
+
if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
281
300
|
yLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
282
301
|
}
|
|
283
302
|
if (yLabel && !y_axis_show_label) {
|
|
@@ -301,7 +320,7 @@ export default class ChartComponent extends Component {
|
|
|
301
320
|
} = config;
|
|
302
321
|
if (summaryColumn) {
|
|
303
322
|
valueScaleOptions['formatter'] = value => {
|
|
304
|
-
return BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method);
|
|
323
|
+
return _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method);
|
|
305
324
|
};
|
|
306
325
|
}
|
|
307
326
|
if (y_axis_auto_range === undefined || y_axis_auto_range) {
|
|
@@ -325,7 +344,7 @@ export default class ChartComponent extends Component {
|
|
|
325
344
|
};
|
|
326
345
|
// set axis label and tooltip
|
|
327
346
|
this.setNameLabelAndTooltip = function () {
|
|
328
|
-
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CHART_THEME_COLOR['light'];
|
|
347
|
+
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.CHART_THEME_COLOR['light'];
|
|
329
348
|
let labelCount = arguments.length > 1 ? arguments[1] : undefined;
|
|
330
349
|
if (!_this.chart) return;
|
|
331
350
|
_this.chart.axis('name', {
|
|
@@ -352,10 +371,10 @@ export default class ChartComponent extends Component {
|
|
|
352
371
|
const isString = typeof name === 'string';
|
|
353
372
|
if (!isString) name = String(name);
|
|
354
373
|
if (name === 'undefined') {
|
|
355
|
-
return
|
|
374
|
+
return _intl.default.get(_constants.EMPTY_NAME);
|
|
356
375
|
}
|
|
357
376
|
if (name.length > 10) {
|
|
358
|
-
return formatXAxisLabel(name);
|
|
377
|
+
return (0, _utils.formatXAxisLabel)(name);
|
|
359
378
|
}
|
|
360
379
|
return name;
|
|
361
380
|
}
|
|
@@ -364,7 +383,7 @@ export default class ChartComponent extends Component {
|
|
|
364
383
|
};
|
|
365
384
|
// set value label
|
|
366
385
|
this.setValueLabel = function () {
|
|
367
|
-
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CHART_THEME_COLOR['light'];
|
|
386
|
+
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.CHART_THEME_COLOR['light'];
|
|
368
387
|
if (!_this.chart) return;
|
|
369
388
|
_this.chart.axis('value', {
|
|
370
389
|
label: {
|
|
@@ -390,12 +409,12 @@ export default class ChartComponent extends Component {
|
|
|
390
409
|
label = "".concat(name.slice(0, 10), "...");
|
|
391
410
|
}
|
|
392
411
|
if (name === '' || name === 'undefined') {
|
|
393
|
-
label =
|
|
412
|
+
label = _intl.default.get(_constants.EMPTY_NAME);
|
|
394
413
|
}
|
|
395
414
|
return label;
|
|
396
415
|
};
|
|
397
416
|
this.getLegendConfig = function () {
|
|
398
|
-
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CHART_THEME_COLOR['light'];
|
|
417
|
+
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.CHART_THEME_COLOR['light'];
|
|
399
418
|
let legendPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top-right';
|
|
400
419
|
return {
|
|
401
420
|
// custom: true,
|
|
@@ -408,11 +427,11 @@ export default class ChartComponent extends Component {
|
|
|
408
427
|
},
|
|
409
428
|
formatter: name => {
|
|
410
429
|
if (!name && typeof name !== 'number' || name.trim() === 'undefined' || name.trim() === 'null') {
|
|
411
|
-
return
|
|
430
|
+
return _intl.default.get(_constants.EMPTY_NAME);
|
|
412
431
|
} else if (name === '_Others') {
|
|
413
|
-
return
|
|
432
|
+
return _intl.default.get('Others');
|
|
414
433
|
} else {
|
|
415
|
-
return
|
|
434
|
+
return _intl.default.get(name) || name;
|
|
416
435
|
}
|
|
417
436
|
}
|
|
418
437
|
},
|
|
@@ -466,7 +485,7 @@ export default class ChartComponent extends Component {
|
|
|
466
485
|
};
|
|
467
486
|
// set legend
|
|
468
487
|
this.setLegend = function (legendName) {
|
|
469
|
-
let theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CHART_THEME_COLOR['light'];
|
|
488
|
+
let theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.CHART_THEME_COLOR['light'];
|
|
470
489
|
let legendPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'bottom';
|
|
471
490
|
if (!_this.chart) return;
|
|
472
491
|
const basicLegendConfig = _this.getLegendConfig(theme, legendPosition);
|
|
@@ -474,7 +493,7 @@ export default class ChartComponent extends Component {
|
|
|
474
493
|
};
|
|
475
494
|
// theta is pie or ring chart
|
|
476
495
|
this.setLegendForTheta = function (legendName) {
|
|
477
|
-
let theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CHART_THEME_COLOR['light'];
|
|
496
|
+
let theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.CHART_THEME_COLOR['light'];
|
|
478
497
|
let legendPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'bottom';
|
|
479
498
|
let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
480
499
|
if (!_this.chart) return;
|
|
@@ -487,10 +506,10 @@ export default class ChartComponent extends Component {
|
|
|
487
506
|
};
|
|
488
507
|
this.setColorMap = (data, chartColorTheme) => {
|
|
489
508
|
let currentIdx = 0;
|
|
490
|
-
const defaultColors = CHART_STYLE_COLORS;
|
|
509
|
+
const defaultColors = _constants.CHART_STYLE_COLORS;
|
|
491
510
|
let colors = defaultColors;
|
|
492
511
|
if (chartColorTheme) {
|
|
493
|
-
colors = BaseUtils.getCurrentTheme(chartColorTheme).colors;
|
|
512
|
+
colors = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors;
|
|
494
513
|
}
|
|
495
514
|
const colorMap = data.reduce((acc, cur) => {
|
|
496
515
|
if (cur.group_name && !acc[cur.group_name]) {
|
|
@@ -579,11 +598,11 @@ export default class ChartComponent extends Component {
|
|
|
579
598
|
const name = activeItem.data.name;
|
|
580
599
|
return this.formatedDataByName[name].map(item => {
|
|
581
600
|
return {
|
|
582
|
-
color: useSingleSelectColumnColor ? item.group_color : this.colorMap[item.group_name] || CHART_STYLE_COLORS[0],
|
|
601
|
+
color: useSingleSelectColumnColor ? item.group_color : this.colorMap[item.group_name] || _constants.CHART_STYLE_COLORS[0],
|
|
583
602
|
data: item,
|
|
584
|
-
name: !item.group_name && typeof item.group_name !== 'number' ?
|
|
603
|
+
name: !item.group_name && typeof item.group_name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : item.group_name,
|
|
585
604
|
title: item.name,
|
|
586
|
-
value: BaseUtils.getSummaryValueDisplayString(summaryColumn, item.value, y_axis_summary_method)
|
|
605
|
+
value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, item.value, y_axis_summary_method)
|
|
587
606
|
};
|
|
588
607
|
});
|
|
589
608
|
};
|
|
@@ -594,6 +613,47 @@ export default class ChartComponent extends Component {
|
|
|
594
613
|
const settings = this.getToolTipSettings(isGroup, summaryColumn, y_axis_summary_method, useSingleSelectColumnColor);
|
|
595
614
|
this.chart.tooltip(settings);
|
|
596
615
|
};
|
|
616
|
+
this.getToolTipContainer = (tooltipData, position) => {
|
|
617
|
+
const {
|
|
618
|
+
offsetX,
|
|
619
|
+
offsetY
|
|
620
|
+
} = position || {
|
|
621
|
+
offsetX: -9999,
|
|
622
|
+
offsetY: -9999
|
|
623
|
+
};
|
|
624
|
+
const {
|
|
625
|
+
title,
|
|
626
|
+
items
|
|
627
|
+
} = tooltipData || {
|
|
628
|
+
title: '',
|
|
629
|
+
items: []
|
|
630
|
+
};
|
|
631
|
+
const dom = /*#__PURE__*/_react.default.createElement("div", {
|
|
632
|
+
className: "sea-chart-d3-tooltip-container",
|
|
633
|
+
style: {
|
|
634
|
+
transform: "translate(".concat(offsetX + 50, "px, ").concat(offsetY, "px)")
|
|
635
|
+
}
|
|
636
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
637
|
+
className: "sea-chart-d3-tooltip-title"
|
|
638
|
+
}, title), /*#__PURE__*/_react.default.createElement("ul", {
|
|
639
|
+
className: "sea-chart-d3-tooltip-list"
|
|
640
|
+
}, items.map((item, index) => {
|
|
641
|
+
return /*#__PURE__*/_react.default.createElement("li", {
|
|
642
|
+
className: "sea-chart-d3-tooltip-list-item",
|
|
643
|
+
key: index
|
|
644
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
645
|
+
className: "sea-chart-d3-tooltip-marker",
|
|
646
|
+
style: {
|
|
647
|
+
backgroundColor: item.color
|
|
648
|
+
}
|
|
649
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
650
|
+
className: "sea-chart-d3-tooltip-name"
|
|
651
|
+
}, item.name), /*#__PURE__*/_react.default.createElement("span", {
|
|
652
|
+
className: "sea-chart-d3-tooltip-value"
|
|
653
|
+
}, item.value));
|
|
654
|
+
})));
|
|
655
|
+
return dom;
|
|
656
|
+
};
|
|
597
657
|
this.setToolTipForLine = () => {
|
|
598
658
|
const settings = this.getToolTipSettings();
|
|
599
659
|
const lineToolTipSettings = {
|
|
@@ -655,10 +715,10 @@ export default class ChartComponent extends Component {
|
|
|
655
715
|
let themeColors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
656
716
|
let theme = arguments.length > 1 ? arguments[1] : undefined;
|
|
657
717
|
// dark->custom->light
|
|
658
|
-
if (theme === THEME_NAME_MAP.DARK) {
|
|
659
|
-
themeColors = CHART_THEME_COLOR.dark;
|
|
718
|
+
if (theme === _constants.THEME_NAME_MAP.DARK) {
|
|
719
|
+
themeColors = _constants.CHART_THEME_COLOR.dark;
|
|
660
720
|
}
|
|
661
|
-
return themeColors || CHART_THEME_COLOR[THEME_NAME_MAP.LIGHT];
|
|
721
|
+
return themeColors || _constants.CHART_THEME_COLOR[_constants.THEME_NAME_MAP.LIGHT];
|
|
662
722
|
};
|
|
663
723
|
this.setDispalyGoalLine = (goalLabel, goalValue, chartWidth) => {
|
|
664
724
|
this.chart.annotation().line({
|
|
@@ -683,6 +743,7 @@ export default class ChartComponent extends Component {
|
|
|
683
743
|
});
|
|
684
744
|
};
|
|
685
745
|
this.initLabelStroke(props === null || props === void 0 ? void 0 : props.globalTheme);
|
|
746
|
+
this.chartBoundingClientRect = null;
|
|
686
747
|
}
|
|
687
748
|
componentDidUpdate(prevProps) {
|
|
688
749
|
if (prevProps.globalTheme !== this.props.globalTheme) {
|
|
@@ -695,4 +756,5 @@ export default class ChartComponent extends Component {
|
|
|
695
756
|
componentWillUnmount() {
|
|
696
757
|
window.removeEventListener('resize', this.handleResize);
|
|
697
758
|
}
|
|
698
|
-
}
|
|
759
|
+
}
|
|
760
|
+
exports.default = ChartComponent;
|