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
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
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 _colorUtils = require("../../../utils/color-utils");
|
|
16
|
+
var _intl = _interopRequireDefault(require("../../../intl"));
|
|
17
|
+
var _chartComponent = _interopRequireDefault(require("../chart-component"));
|
|
18
|
+
class Bar extends _chartComponent.default {
|
|
19
|
+
constructor(props) {
|
|
20
|
+
super(props);
|
|
21
|
+
this.handleResize = () => {
|
|
22
|
+
this.chart.node() && this.chart.node().remove();
|
|
23
|
+
this.createChart();
|
|
24
|
+
this.drawChart();
|
|
25
|
+
};
|
|
26
|
+
this.createChart = () => {
|
|
27
|
+
this.initD3Chart(this.container);
|
|
28
|
+
};
|
|
29
|
+
this.drawChart = () => {
|
|
30
|
+
const {
|
|
31
|
+
customRender
|
|
32
|
+
} = this.props;
|
|
33
|
+
let {
|
|
34
|
+
result: data
|
|
35
|
+
} = this.props;
|
|
36
|
+
data = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
|
|
37
|
+
if (!Array.isArray(data)) return;
|
|
38
|
+
this.draw(data);
|
|
39
|
+
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
40
|
+
(0, _utils.isFunction)(customRender) && customRender(this.chart);
|
|
41
|
+
};
|
|
42
|
+
this.getFillColor = data => {
|
|
43
|
+
const {
|
|
44
|
+
chart,
|
|
45
|
+
chartColorTheme
|
|
46
|
+
} = this.props;
|
|
47
|
+
const {
|
|
48
|
+
y_axis_label_color,
|
|
49
|
+
color_option,
|
|
50
|
+
y_axis_label_color_rules
|
|
51
|
+
} = chart.config;
|
|
52
|
+
let chartBarColor = y_axis_label_color || _constants.CHART_STYLE_COLORS[0];
|
|
53
|
+
if (chartColorTheme) {
|
|
54
|
+
chartBarColor = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
|
|
55
|
+
}
|
|
56
|
+
const colorRules = color_option === _constants.TYPE_COLOR_USING.USE_RULES && y_axis_label_color_rules && (0, _colorUtils.getConvertedColorRules)(y_axis_label_color_rules);
|
|
57
|
+
const color = (0, _colorUtils.getLabelColor)({
|
|
58
|
+
chart: chart.config,
|
|
59
|
+
colorRules,
|
|
60
|
+
value: data.value
|
|
61
|
+
});
|
|
62
|
+
return color || chartBarColor;
|
|
63
|
+
};
|
|
64
|
+
this.showTooltip = (event, data, title) => {
|
|
65
|
+
const {
|
|
66
|
+
offsetX,
|
|
67
|
+
offsetY
|
|
68
|
+
} = event;
|
|
69
|
+
const newTooltipData = {
|
|
70
|
+
title: title,
|
|
71
|
+
items: [{
|
|
72
|
+
color: this.getFillColor(data),
|
|
73
|
+
name: data.name,
|
|
74
|
+
value: data.value
|
|
75
|
+
}]
|
|
76
|
+
};
|
|
77
|
+
this.setState({
|
|
78
|
+
tooltipData: newTooltipData
|
|
79
|
+
});
|
|
80
|
+
this.setState({
|
|
81
|
+
toolTipPosition: {
|
|
82
|
+
offsetX,
|
|
83
|
+
offsetY
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
this.moveTooltip = event => {
|
|
88
|
+
const {
|
|
89
|
+
offsetX,
|
|
90
|
+
offsetY
|
|
91
|
+
} = event;
|
|
92
|
+
this.setState({
|
|
93
|
+
toolTipPosition: {
|
|
94
|
+
offsetX,
|
|
95
|
+
offsetY
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
this.hiddenTooltip = event => {
|
|
100
|
+
this.setState({
|
|
101
|
+
toolTipPosition: null
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
this.setActiveAndInActiveState = (state, data) => {
|
|
105
|
+
const {
|
|
106
|
+
chart
|
|
107
|
+
} = this.props;
|
|
108
|
+
const paths = d3.selectAll(".rects-wrapper-".concat(chart === null || chart === void 0 ? void 0 : chart.id, " path"));
|
|
109
|
+
if (state === 'active') {
|
|
110
|
+
paths.nodes().forEach(path => {
|
|
111
|
+
d3.select(path).attr('opacity', 1);
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
paths.nodes().forEach(path => {
|
|
116
|
+
if (path.id !== data.slugId) {
|
|
117
|
+
d3.select(path).attr('opacity', 0.3);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
this.draw = data => {
|
|
122
|
+
const {
|
|
123
|
+
chart,
|
|
124
|
+
globalTheme,
|
|
125
|
+
tables
|
|
126
|
+
} = this.props;
|
|
127
|
+
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
128
|
+
const {
|
|
129
|
+
display_goal_line,
|
|
130
|
+
goal_value,
|
|
131
|
+
goal_label
|
|
132
|
+
} = chart.style_config || {};
|
|
133
|
+
const {
|
|
134
|
+
y_axis_summary_type,
|
|
135
|
+
y_axis_summary_column_key,
|
|
136
|
+
y_axis_column_key,
|
|
137
|
+
y_axis_show_value,
|
|
138
|
+
label_font_size,
|
|
139
|
+
table_id,
|
|
140
|
+
y_axis_max,
|
|
141
|
+
y_axis_min,
|
|
142
|
+
y_axis_auto_range
|
|
143
|
+
} = chart.config;
|
|
144
|
+
const tooltipTitle = this.getTitle(tables, table_id, y_axis_summary_type, y_axis_column_key || y_axis_summary_column_key);
|
|
145
|
+
const {
|
|
146
|
+
width: chartWidth,
|
|
147
|
+
height: chartHeight
|
|
148
|
+
} = this.chartBoundingClientRect;
|
|
149
|
+
const insertPadding = 30;
|
|
150
|
+
const borderRadius = 10;
|
|
151
|
+
const x = d3.scaleBand().domain(data.map(item => item.name)).range([insertPadding, chartWidth - insertPadding]).paddingInner(0.4).paddingOuter(0.1);
|
|
152
|
+
const y = d3.scaleLinear().domain(y_axis_auto_range ? [0, d3.max(data, d => d.value)] : [y_axis_min, y_axis_max]).range([chartHeight - insertPadding, insertPadding]);
|
|
153
|
+
this.chart.append('g').attr('transform', "translate(0, ".concat(chartHeight - insertPadding, ")")).call(d3.axisBottom(x).tickSizeOuter(0).tickSizeInner(5)).call(g => {
|
|
154
|
+
g.selectAll('.domain').attr('stroke', theme.XAxisColor);
|
|
155
|
+
g.selectAll('.tick line').attr('stroke', theme.XAxisColor);
|
|
156
|
+
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
157
|
+
g.selectAll('text').attr('fill', theme.textColor);
|
|
158
|
+
});
|
|
159
|
+
this.chart.append('g').attr('transform', "translate(".concat(insertPadding, ", 0)")).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => d)).call(g => {
|
|
160
|
+
g.select('.domain').remove();
|
|
161
|
+
g.selectAll('line').node().remove(); // delete the first line
|
|
162
|
+
g.selectAll('.tick line').clone().attr('x2', chartWidth - insertPadding * 2).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
|
|
163
|
+
g.selectAll('text').attr('font-size', theme.fontSize);
|
|
164
|
+
g.selectAll('text').attr('fill', theme.textColor);
|
|
165
|
+
});
|
|
166
|
+
this.chart.append('g').attr('class', "rects-wrapper-".concat(chart === null || chart === void 0 ? void 0 : chart.id)).selectAll().data(data).join('path').attr('fill', d => d3.color(this.getFillColor(d))).attr('data-x', d => x(d.name)).attr('data-y', d => y(d.value)).attr('data-width', x.bandwidth()).attr('data-value', d => d.value).attr('id', (d, index) => d.slugId).attr('d', d => {
|
|
167
|
+
// Do not draw if the range is smaller than the minimum
|
|
168
|
+
if (!y_axis_auto_range && d.value <= y_axis_min) {
|
|
169
|
+
return '';
|
|
170
|
+
}
|
|
171
|
+
const path = d3.path();
|
|
172
|
+
const startX = x(d.name);
|
|
173
|
+
const startY = y(d.value);
|
|
174
|
+
path.moveTo(startX, startY + borderRadius);
|
|
175
|
+
path.quadraticCurveTo(startX, startY, startX + borderRadius, startY);
|
|
176
|
+
path.lineTo(startX + x.bandwidth() - borderRadius, startY);
|
|
177
|
+
path.quadraticCurveTo(startX + x.bandwidth(), startY, startX + x.bandwidth(), startY + borderRadius);
|
|
178
|
+
path.lineTo(startX + x.bandwidth(), y_axis_auto_range ? y(0) : y(y_axis_min));
|
|
179
|
+
path.lineTo(startX, y_axis_auto_range ? y(0) : y(y_axis_min));
|
|
180
|
+
path.closePath();
|
|
181
|
+
return path.toString();
|
|
182
|
+
}).call(g => {
|
|
183
|
+
const parentNode = d3.select('.rects-wrapper');
|
|
184
|
+
g.nodes().forEach(path => {
|
|
185
|
+
// Add label
|
|
186
|
+
if (y_axis_show_value) {
|
|
187
|
+
parentNode.append('text').attr('y', Number(path.dataset.y) - 10).attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(path.dataset.value).call(g => {
|
|
188
|
+
const {
|
|
189
|
+
width
|
|
190
|
+
} = g.node().getBoundingClientRect();
|
|
191
|
+
g.attr('x', Number(path.dataset.x) + Number(path.dataset.width) / 2 - width);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}).on('click', (event, data) => {
|
|
196
|
+
this.props.toggleRecords(data);
|
|
197
|
+
}).on('mouseover', (event, data) => {
|
|
198
|
+
this.showTooltip(event, data, tooltipTitle);
|
|
199
|
+
this.setActiveAndInActiveState('inActive', data);
|
|
200
|
+
}).on('mousemove', event => {
|
|
201
|
+
this.moveTooltip(event);
|
|
202
|
+
}).on('mouseleave', (event, data) => {
|
|
203
|
+
this.hiddenTooltip();
|
|
204
|
+
this.setActiveAndInActiveState('active', data);
|
|
205
|
+
});
|
|
206
|
+
if (display_goal_line) {
|
|
207
|
+
this.chart.append('g').attr('class', 'annotation-wrapper').append('line').attr('stroke', '#aaa').attr('x1', insertPadding).attr('y1', y(goal_value)).attr('x2', chartWidth - insertPadding).attr('y2', y(goal_value)).call(g => {
|
|
208
|
+
const parentNode = d3.select('.annotation-wrapper');
|
|
209
|
+
parentNode.append('text').attr('x', chartWidth - insertPadding - 30).attr('y', y(goal_value) - 10).attr('fill', '#666').text(goal_label);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
this.chart = null;
|
|
214
|
+
this.state = {
|
|
215
|
+
tooltipData: null,
|
|
216
|
+
toolTipPosition: null
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
componentDidMount() {
|
|
220
|
+
this.createChart();
|
|
221
|
+
this.drawChart();
|
|
222
|
+
this.debouncedHandleResize = (0, _lodashEs.debounce)(this.handleResize, 300);
|
|
223
|
+
window.addEventListener('resize', this.debouncedHandleResize);
|
|
224
|
+
}
|
|
225
|
+
componentDidUpdate(prevProps) {
|
|
226
|
+
super.componentDidUpdate(prevProps);
|
|
227
|
+
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
228
|
+
var _this$chart;
|
|
229
|
+
((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
|
|
230
|
+
this.createChart();
|
|
231
|
+
this.drawChart();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
componentWillUnmount() {
|
|
235
|
+
this.chart.node() && this.chart.node().remove();
|
|
236
|
+
window.removeEventListener('resize', this.debouncedHandleResize);
|
|
237
|
+
}
|
|
238
|
+
render() {
|
|
239
|
+
const {
|
|
240
|
+
tooltipData,
|
|
241
|
+
toolTipPosition
|
|
242
|
+
} = this.state;
|
|
243
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
244
|
+
className: "sea-chart-container",
|
|
245
|
+
ref: ref => this.container = ref
|
|
246
|
+
}, this.getToolTipContainer(tooltipData, toolTipPosition));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
Bar.propTypes = {
|
|
250
|
+
canvasStyle: _propTypes.default.object,
|
|
251
|
+
chart: _propTypes.default.object,
|
|
252
|
+
groupbyColumn: _propTypes.default.object,
|
|
253
|
+
columnGroupbyColumn: _propTypes.default.object,
|
|
254
|
+
summaryColumn: _propTypes.default.object,
|
|
255
|
+
result: _propTypes.default.array,
|
|
256
|
+
tables: _propTypes.default.array,
|
|
257
|
+
globalTheme: _propTypes.default.string,
|
|
258
|
+
chartColorTheme: _propTypes.default.string,
|
|
259
|
+
toggleRecords: _propTypes.default.func,
|
|
260
|
+
customRender: _propTypes.default.func
|
|
261
|
+
};
|
|
262
|
+
var _default = exports.default = Bar;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sea-chart",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@antv/data-set": "0.11.8",
|
|
@@ -12,26 +12,27 @@
|
|
|
12
12
|
"@seafile/seafile-calendar": "^0.0.24",
|
|
13
13
|
"@seafile/seafile-editor": "^1.0.133",
|
|
14
14
|
"classnames": "^2.3.2",
|
|
15
|
+
"d3": "~7.9.0",
|
|
15
16
|
"dayjs": "1.10.7",
|
|
16
17
|
"is-hotkey": "0.2.0",
|
|
17
18
|
"lodash-es": "^4.17.21",
|
|
18
19
|
"rc-slider": "^10.5.0",
|
|
19
|
-
"react-color": "^2.19.3",
|
|
20
20
|
"react-i18next": "^14.1.2",
|
|
21
|
-
"react-select": "5.
|
|
22
|
-
"react-sweet-progress": "
|
|
23
|
-
"reactstrap": "
|
|
21
|
+
"react-select": "~5.10.0",
|
|
22
|
+
"react-sweet-progress": "~1.1.2",
|
|
23
|
+
"reactstrap": "~9.2.3",
|
|
24
24
|
"shallowequal": "^1.1.0",
|
|
25
|
+
"slugid": "~5.0.1",
|
|
25
26
|
"svg-sprite-loader": "^6.0.11",
|
|
26
27
|
"svgo-loader": "^3.0.0"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
30
|
"@antv/scale": "0.3.14",
|
|
30
|
-
"dtable-ui-component": "
|
|
31
|
+
"dtable-ui-component": "6.0.2",
|
|
31
32
|
"dtable-utils": "~5.0.*",
|
|
32
33
|
"prop-types": "15.8.1",
|
|
33
|
-
"react": "
|
|
34
|
-
"react-dom": "
|
|
34
|
+
"react": "18.3.1",
|
|
35
|
+
"react-dom": "18.3.1"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
38
|
"clean": "rimraf dist && mkdirp dist",
|
|
@@ -93,7 +94,7 @@
|
|
|
93
94
|
"babel-loader": "8.0.6",
|
|
94
95
|
"babel-plugin-import": "^1.13.8",
|
|
95
96
|
"babel-plugin-named-asset-import": "^0.3.4",
|
|
96
|
-
"babel-preset-react-app": "
|
|
97
|
+
"babel-preset-react-app": "~10.0.1",
|
|
97
98
|
"browserslist": "^4.8.0",
|
|
98
99
|
"camelcase": "^5.2.0",
|
|
99
100
|
"case-sensitive-paths-webpack-plugin": "2.2.0",
|
|
@@ -112,8 +113,7 @@
|
|
|
112
113
|
"eslint-plugin-flowtype": "3.13.0",
|
|
113
114
|
"eslint-plugin-import": "^2.18.2",
|
|
114
115
|
"eslint-plugin-jsx-a11y": "6.2.3",
|
|
115
|
-
"eslint-plugin-react": "7.
|
|
116
|
-
"eslint-plugin-react-hooks": "^1.6.1",
|
|
116
|
+
"eslint-plugin-react": "~7.37.4",
|
|
117
117
|
"file-loader": "6.2.0",
|
|
118
118
|
"fs-extra": "^10.1.0",
|
|
119
119
|
"html-webpack-plugin": "^5.6.0",
|
|
@@ -138,14 +138,12 @@
|
|
|
138
138
|
"postcss-preset-env": "^7.0.1",
|
|
139
139
|
"postcss-safe-parser": "^6.0.0",
|
|
140
140
|
"raf": "3.4.0",
|
|
141
|
-
"react": "
|
|
142
|
-
"react-app-polyfill": "
|
|
143
|
-
"react-color": "2.19.3",
|
|
141
|
+
"react": "~18.3.1",
|
|
142
|
+
"react-app-polyfill": "~3.0.0",
|
|
143
|
+
"react-color": "~2.19.3",
|
|
144
144
|
"react-cookies": "0.1.1",
|
|
145
145
|
"react-dev-utils": "^12.0.1",
|
|
146
|
-
"react-dom": "
|
|
147
|
-
"react-hot-loader": "4.13.1",
|
|
148
|
-
"react-mentions": "4.4.7",
|
|
146
|
+
"react-dom": "~18.3.1",
|
|
149
147
|
"regenerator-runtime": "^0.14.1",
|
|
150
148
|
"release-it": "16.2.1",
|
|
151
149
|
"resolve": "1.12.0",
|