sea-chart 2.0.43 → 2.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +4 -11
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +4 -11
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +27 -35
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +11 -18
- package/dist/components/color-popover/color-rules/color-rule.js +25 -33
- package/dist/components/color-popover/color-rules/index.js +6 -14
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +10 -18
- package/dist/components/color-popover/color-rules-popover.js +26 -34
- package/dist/components/color-popover/color-selector-popover.js +10 -18
- package/dist/components/color-setting/color-group-selector.js +12 -20
- package/dist/components/common-add-tool/index.js +6 -13
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +12 -19
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +16 -24
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +42 -50
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +4 -11
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +4 -11
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +25 -33
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +54 -64
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +15 -22
- package/dist/components/row-card/row-card-header.js +14 -21
- package/dist/components/row-card/row-card-item.js +33 -41
- package/dist/components/row-card/row-card.js +15 -23
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +21 -21
- package/dist/components/types-dialog/index.js +56 -64
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +149 -273
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +20 -24
- package/dist/editor/index.js +8 -15
- package/dist/index.js +13 -104
- package/dist/intl.js +10 -17
- package/dist/locale/index.js +16 -23
- package/dist/locale/lang/de.js +1 -7
- package/dist/locale/lang/en.js +1 -7
- package/dist/locale/lang/es.js +1 -7
- package/dist/locale/lang/fr.js +1 -7
- package/dist/locale/lang/pt.js +1 -7
- package/dist/locale/lang/ru.js +1 -7
- package/dist/locale/lang/zh_CN.js +1 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +8 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +19 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +15 -18
- package/dist/model/horizontal-group-bar.js +14 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +12 -19
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +15 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +7 -13
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +83 -74
- package/dist/settings/bar-settings/data-settings.js +39 -47
- package/dist/settings/bar-settings/index.js +3 -20
- package/dist/settings/bar-settings/style-settings.js +69 -60
- package/dist/settings/basic-number-card/data-settings.js +49 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +18 -26
- package/dist/settings/combination-settings/data-settings.js +55 -63
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +94 -77
- package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
- package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
- package/dist/settings/completeness-settings/index.js +3 -20
- package/dist/settings/completeness-settings/style-settings.js +19 -26
- package/dist/settings/dashboard-settings/data-settings.js +43 -51
- package/dist/settings/dashboard-settings/index.js +2 -13
- package/dist/settings/data-settings.js +72 -79
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
- package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
- package/dist/settings/funnel-settings/data-settings.js +23 -31
- package/dist/settings/funnel-settings/index.js +3 -20
- package/dist/settings/funnel-settings/style-settings.js +11 -19
- package/dist/settings/heat-map-settings/data-settings.js +18 -26
- package/dist/settings/heat-map-settings/index.js +3 -20
- package/dist/settings/heat-map-settings/style-settings.js +18 -26
- package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
- package/dist/settings/horizontal-bar-settings/index.js +3 -20
- package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
- package/dist/settings/index.js +52 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +26 -34
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +64 -72
- package/dist/settings/table-element-settings/components/data-filter.js +30 -38
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +111 -119
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +62 -53
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +17 -25
- package/dist/settings/widgets/axis-title-font-settings/index.js +39 -0
- package/dist/settings/widgets/basic-summary/index.js +55 -63
- package/dist/settings/widgets/chart-type/index.js +18 -26
- package/dist/settings/widgets/color-settings/index.js +72 -80
- package/dist/settings/widgets/common-data-settings.js +21 -29
- package/dist/settings/widgets/data-filter/index.js +35 -43
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +24 -32
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +51 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +23 -31
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +72 -80
- package/dist/settings/widgets/switch/index.js +8 -15
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +63 -71
- package/dist/utils/cell-format-utils.js +18 -28
- package/dist/utils/cell-value-utils.js +5 -12
- package/dist/utils/chart-utils/base-utils.js +362 -334
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +80 -86
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +32 -39
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +91 -97
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
- package/dist/utils/chart-utils/sql-statistics-utils.js +284 -246
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +18 -30
- package/dist/utils/collaborator.js +4 -13
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +65 -92
- package/dist/utils/common-utils.js +27 -52
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +11 -19
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +1 -7
- package/dist/utils/options-utils.js +8 -16
- package/dist/utils/row-record-utils.js +182 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +49 -55
- package/dist/utils/sql/column-2-sql-column.js +146 -154
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.css +0 -17
- package/dist/view/index.js +89 -95
- package/dist/view/title/index.js +15 -23
- package/dist/view/wrapper/area-group.js +57 -74
- package/dist/view/wrapper/area.js +51 -72
- package/dist/view/wrapper/bar-compare.js +47 -58
- package/dist/view/wrapper/bar-custom-stack.js +53 -121
- package/dist/view/wrapper/bar-group.js +55 -96
- package/dist/view/wrapper/bar-stack.js +58 -92
- package/dist/view/wrapper/bar.js +45 -66
- package/dist/view/wrapper/basic-number-card.js +25 -26
- package/dist/view/wrapper/chart-component.js +600 -166
- package/dist/view/wrapper/combination.js +79 -87
- package/dist/view/wrapper/completeness-group.js +46 -98
- package/dist/view/wrapper/completeness.js +45 -97
- package/dist/view/wrapper/dashboard.js +33 -47
- package/dist/view/wrapper/funnel.js +65 -64
- package/dist/view/wrapper/heat-map.js +126 -104
- package/dist/view/wrapper/horizontal-bar-group.js +61 -78
- package/dist/view/wrapper/horizontal-bar-stack.js +60 -111
- package/dist/view/wrapper/horizontal-bar.js +45 -68
- package/dist/view/wrapper/index.js +110 -115
- package/dist/view/wrapper/line-group.js +52 -68
- package/dist/view/wrapper/line.js +47 -67
- package/dist/view/wrapper/map-bubble.js +46 -59
- package/dist/view/wrapper/map-world-bubble.js +45 -58
- package/dist/view/wrapper/map-world.js +47 -60
- package/dist/view/wrapper/map.js +48 -60
- package/dist/view/wrapper/mirror.js +45 -64
- package/dist/view/wrapper/pie.js +51 -59
- package/dist/view/wrapper/ring.js +57 -64
- package/dist/view/wrapper/scatter.js +53 -69
- package/dist/view/wrapper/table/index.js +13 -21
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +50 -58
- package/dist/view/wrapper/table/pivot-table-display-name.js +83 -91
- package/dist/view/wrapper/table/two-dimension-table.js +76 -84
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +96 -105
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +22 -31
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +73 -80
- package/dist/view/wrapper/table-element/components/record.js +10 -17
- package/dist/view/wrapper/table-element/components/records-body.js +17 -19
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +23 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
- package/dist/view/wrapper/table-element/components/utils.js +5 -15
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +39 -57
- package/dist/view/wrapper/trend.js +41 -48
- package/package.json +1 -1
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
var _dtableUtils = require("dtable-utils");
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
var _chartUtils = require("../../utils/chart-utils");
|
|
16
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
17
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
18
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
19
|
-
class BarCompare extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import { getNumberDisplayString } from 'dtable-utils';
|
|
5
|
+
import { CHART_SUMMARY_SHOW, TITLE_AMOUNT, TITLE_INCREASE, CHART_THEME_COLOR } from '../../constants';
|
|
6
|
+
import { BaseUtils } from '../../utils/chart-utils';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
import ToolTip from '../../components/tooltip';
|
|
9
|
+
import ChartComponent from './chart-component';
|
|
10
|
+
class BarCompare extends ChartComponent {
|
|
20
11
|
constructor(props) {
|
|
21
12
|
super(props);
|
|
22
13
|
this.createChart = () => {
|
|
@@ -30,8 +21,8 @@ class BarCompare extends _chartComponent.default {
|
|
|
30
21
|
const initConfig = {
|
|
31
22
|
insertPadding: 30,
|
|
32
23
|
borderRadius: 0.2,
|
|
33
|
-
marginLeft: y_axis_show_label ?
|
|
34
|
-
marginBottom: x_axis_show_label ?
|
|
24
|
+
marginLeft: y_axis_show_label ? this.getAxisTitleHeight(chart.config.y_axis_label_font_size) : 0,
|
|
25
|
+
marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0
|
|
35
26
|
};
|
|
36
27
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
37
28
|
};
|
|
@@ -39,19 +30,21 @@ class BarCompare extends _chartComponent.default {
|
|
|
39
30
|
let {
|
|
40
31
|
result: data
|
|
41
32
|
} = this.props;
|
|
42
|
-
data =
|
|
33
|
+
data = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
43
34
|
if (!Array.isArray(data)) return;
|
|
44
35
|
this.draw(data);
|
|
45
36
|
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
46
37
|
};
|
|
47
38
|
this.draw = data => {
|
|
39
|
+
const fullData = data;
|
|
40
|
+
data = this.getVisibleLegendData(data, 'group_name');
|
|
48
41
|
const {
|
|
49
42
|
chart,
|
|
50
43
|
globalTheme,
|
|
51
44
|
chartColorTheme,
|
|
52
45
|
columnGroupbyColumn
|
|
53
46
|
} = this.props;
|
|
54
|
-
const theme =
|
|
47
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
55
48
|
const {
|
|
56
49
|
display_increase,
|
|
57
50
|
y_axis_auto_range = true,
|
|
@@ -68,9 +61,9 @@ class BarCompare extends _chartComponent.default {
|
|
|
68
61
|
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]);
|
|
69
62
|
|
|
70
63
|
// Y axis
|
|
71
|
-
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', `translate(${insertPadding},0)`).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d =>
|
|
64
|
+
this.chart.append('g').attr('class', 'y-axis-wrapper').attr('transform', `translate(${insertPadding},0)`).call(d3.axisLeft(y).tickSizeInner(0).ticks(5).tickFormat(d => BaseUtils.getSummaryValueDisplayString(columnGroupbyColumn, d, y_axis_summary_method))).call(g => this.drawYaxis(g, theme));
|
|
72
65
|
const fx = d3.scaleBand().domain(d3.group(data, d => d.name).keys()).range([insertPadding + this.horizontalOverflowOffset, chartWidth - insertPadding]).paddingInner(0.5).paddingOuter(0.1);
|
|
73
|
-
const color = d3.scaleOrdinal().domain(d3.group(data, d => d.group_name).keys()).range(
|
|
66
|
+
const color = d3.scaleOrdinal().domain(d3.group(data, d => d.group_name).keys()).range(BaseUtils.getCurrentTheme(chartColorTheme).colors).unknown('#ccc');
|
|
74
67
|
const x = d3.scaleBand().domain(d3.group(data, d => d.group_name).keys()).range([0, fx.bandwidth()]).paddingInner(0).paddingOuter(0);
|
|
75
68
|
|
|
76
69
|
// X axis
|
|
@@ -93,14 +86,11 @@ class BarCompare extends _chartComponent.default {
|
|
|
93
86
|
.selectAll().data(_ref2 => {
|
|
94
87
|
let [a, d] = _ref2;
|
|
95
88
|
return d;
|
|
96
|
-
}).join('rect').attr('opacity', 1).attr('x', (d, index) => index * x.bandwidth()).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value) === 0 ? 0 : y(0) - y(d.value)).attr('fill', d => color(d.group_name)).attr('data-value', d => d.value).attr('data-groupName', d => d.name).
|
|
89
|
+
}).join('rect').attr('opacity', 1).attr('x', (d, index) => index * x.bandwidth()).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value) === 0 ? 0 : y(0) - y(d.value)).attr('fill', d => color(d.group_name)).attr('data-value', d => d.value).attr('data-groupName', d => d.name).call(g => {
|
|
97
90
|
g.nodes().forEach(rect => {
|
|
98
|
-
const parentNode = rect.parentNode;
|
|
99
91
|
// add rect borderRadius
|
|
100
92
|
this.addClipPath({
|
|
101
|
-
rect
|
|
102
|
-
parentNode,
|
|
103
|
-
rectId: rect.getAttribute('data-slugid')
|
|
93
|
+
rect
|
|
104
94
|
});
|
|
105
95
|
});
|
|
106
96
|
}).on('click', (event, data) => {
|
|
@@ -113,17 +103,20 @@ class BarCompare extends _chartComponent.default {
|
|
|
113
103
|
}).on('mouseleave', event => {
|
|
114
104
|
this.hiddenTooltip();
|
|
115
105
|
this.handleAcitveAndInActiveState('active', event);
|
|
106
|
+
}).call(g => {
|
|
107
|
+
this.animateRectGrowInY(g);
|
|
108
|
+
this.animateFadeIn(this.chart.select('.content-wrapper').selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
116
109
|
});
|
|
117
110
|
if (display_increase) {
|
|
118
111
|
const increaseData = this.getIncreaseData(data);
|
|
119
112
|
this.drawIncreaseLine(increaseData);
|
|
120
113
|
}
|
|
121
|
-
this.setColorMap(
|
|
114
|
+
this.setColorMap(fullData, chartColorTheme);
|
|
122
115
|
this.setLegend({
|
|
123
116
|
legendName: 'group_name',
|
|
124
117
|
theme,
|
|
125
118
|
legendPosition: 'top-right',
|
|
126
|
-
data
|
|
119
|
+
data: fullData
|
|
127
120
|
});
|
|
128
121
|
};
|
|
129
122
|
this.showTooltip = (event, colorScale, isCircle) => {
|
|
@@ -140,7 +133,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
140
133
|
if (isCircle) {
|
|
141
134
|
const circleEl = event.target;
|
|
142
135
|
newTooltipData = {
|
|
143
|
-
title:
|
|
136
|
+
title: intl.get(TITLE_INCREASE),
|
|
144
137
|
items: [{
|
|
145
138
|
color: increase_line_color || '#fbd44a',
|
|
146
139
|
name: circleEl.getAttribute('data-name'),
|
|
@@ -151,7 +144,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
151
144
|
const curGroup = event.target.parentNode;
|
|
152
145
|
const [, data] = curGroup.__data__;
|
|
153
146
|
newTooltipData = {
|
|
154
|
-
title: y_axis_summary_type === 'count' ?
|
|
147
|
+
title: y_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]),
|
|
155
148
|
items: data.map(item => {
|
|
156
149
|
return {
|
|
157
150
|
color: colorScale(item.group_name),
|
|
@@ -193,7 +186,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
193
186
|
chart,
|
|
194
187
|
globalTheme
|
|
195
188
|
} = this.props;
|
|
196
|
-
const theme =
|
|
189
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
197
190
|
const {
|
|
198
191
|
label_font_size,
|
|
199
192
|
y_axis_min,
|
|
@@ -248,7 +241,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
248
241
|
// circle label
|
|
249
242
|
if (display_increase_percentage) {
|
|
250
243
|
const curCircleEl = g.node();
|
|
251
|
-
wrapper.append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size',
|
|
244
|
+
wrapper.append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size', BaseUtils.getLabelFontSize(label_font_size)).text(curCircleEl.getAttribute('data-text')).call(g => {
|
|
252
245
|
const {
|
|
253
246
|
width
|
|
254
247
|
} = g.node().getBoundingClientRect();
|
|
@@ -275,7 +268,7 @@ class BarCompare extends _chartComponent.default {
|
|
|
275
268
|
const increaseValue = value.filter(d => (d === null || d === void 0 ? void 0 : d.increase_value) !== undefined) || [{
|
|
276
269
|
increaseValue: 0
|
|
277
270
|
}];
|
|
278
|
-
const formatValue =
|
|
271
|
+
const formatValue = getNumberDisplayString((_increaseValue$ = increaseValue[0]) === null || _increaseValue$ === void 0 ? void 0 : _increaseValue$.increase_value, {
|
|
279
272
|
format: 'percent'
|
|
280
273
|
});
|
|
281
274
|
const data = {
|
|
@@ -311,10 +304,11 @@ class BarCompare extends _chartComponent.default {
|
|
|
311
304
|
componentDidMount() {
|
|
312
305
|
this.createChart();
|
|
313
306
|
this.drawChart();
|
|
307
|
+
super.componentDidMount();
|
|
314
308
|
}
|
|
315
309
|
componentDidUpdate(prevProps) {
|
|
316
310
|
super.componentDidUpdate(prevProps);
|
|
317
|
-
if (
|
|
311
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
318
312
|
this.destroyChart();
|
|
319
313
|
this.createChart();
|
|
320
314
|
this.drawChart();
|
|
@@ -322,22 +316,17 @@ class BarCompare extends _chartComponent.default {
|
|
|
322
316
|
}
|
|
323
317
|
componentWillUnmount() {
|
|
324
318
|
this.destroyChart();
|
|
319
|
+
super.componentWillUnmount();
|
|
325
320
|
}
|
|
326
321
|
render() {
|
|
327
|
-
const {
|
|
328
|
-
chart
|
|
329
|
-
} = this.props;
|
|
330
322
|
const {
|
|
331
323
|
tooltipData,
|
|
332
324
|
toolTipPosition
|
|
333
325
|
} = this.state;
|
|
334
|
-
return /*#__PURE__*/
|
|
326
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
335
327
|
ref: ref => this.container = ref,
|
|
336
|
-
className:
|
|
337
|
-
|
|
338
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
339
|
-
})
|
|
340
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
328
|
+
className: "sea-chart-container"
|
|
329
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
341
330
|
tooltipData: tooltipData,
|
|
342
331
|
toolTipPosition: toolTipPosition,
|
|
343
332
|
chart: this.chart
|
|
@@ -345,15 +334,15 @@ class BarCompare extends _chartComponent.default {
|
|
|
345
334
|
}
|
|
346
335
|
}
|
|
347
336
|
BarCompare.propTypes = {
|
|
348
|
-
canvasStyle:
|
|
349
|
-
chart:
|
|
350
|
-
groupbyColumn:
|
|
351
|
-
columnGroupbyColumn:
|
|
352
|
-
summaryColumn:
|
|
353
|
-
result:
|
|
354
|
-
tables:
|
|
355
|
-
globalTheme:
|
|
356
|
-
chartColorTheme:
|
|
357
|
-
toggleRecords:
|
|
337
|
+
canvasStyle: PropTypes.object,
|
|
338
|
+
chart: PropTypes.object,
|
|
339
|
+
groupbyColumn: PropTypes.object,
|
|
340
|
+
columnGroupbyColumn: PropTypes.object,
|
|
341
|
+
summaryColumn: PropTypes.object,
|
|
342
|
+
result: PropTypes.array,
|
|
343
|
+
tables: PropTypes.array,
|
|
344
|
+
globalTheme: PropTypes.string,
|
|
345
|
+
chartColorTheme: PropTypes.string,
|
|
346
|
+
toggleRecords: PropTypes.func
|
|
358
347
|
};
|
|
359
|
-
|
|
348
|
+
export default BarCompare;
|
|
@@ -1,30 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _lodashEs = require("lodash-es");
|
|
12
|
-
var d3 = _interopRequireWildcard(require("d3"));
|
|
13
|
-
var _slugid = _interopRequireDefault(require("slugid"));
|
|
14
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
16
|
-
var _chartUtils = require("../../utils/chart-utils");
|
|
17
|
-
var _constants = require("../../constants");
|
|
18
|
-
var _tooltip = _interopRequireDefault(require("../../components/tooltip"));
|
|
19
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
20
|
-
class BarCustom extends _chartComponent.default {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import slugid from 'slugid';
|
|
5
|
+
import intl from '../../intl';
|
|
6
|
+
import { BaseUtils } from '../../utils/chart-utils';
|
|
7
|
+
import { EMPTY_NAME, CHART_THEME_COLOR } from '../../constants';
|
|
8
|
+
import ToolTip from '../../components/tooltip';
|
|
9
|
+
import ChartComponent from './chart-component';
|
|
10
|
+
class BarCustom extends ChartComponent {
|
|
21
11
|
constructor(props) {
|
|
22
12
|
super(props);
|
|
23
|
-
this.handleResize = (0, _lodashEs.debounce)(() => {
|
|
24
|
-
this.destroyChart();
|
|
25
|
-
this.createChart();
|
|
26
|
-
this.drawChart();
|
|
27
|
-
}, 300);
|
|
28
13
|
this.createChart = () => {
|
|
29
14
|
const {
|
|
30
15
|
chart
|
|
@@ -36,8 +21,8 @@ class BarCustom extends _chartComponent.default {
|
|
|
36
21
|
const initConfig = {
|
|
37
22
|
insertPadding: 30,
|
|
38
23
|
borderRadius: 0.2,
|
|
39
|
-
marginLeft: y_axis_show_label ?
|
|
40
|
-
marginBottom: x_axis_show_label ?
|
|
24
|
+
marginLeft: y_axis_show_label ? this.getAxisTitleHeight(chart.config.y_axis_label_font_size) : 0,
|
|
25
|
+
marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0
|
|
41
26
|
};
|
|
42
27
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
43
28
|
};
|
|
@@ -45,7 +30,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
45
30
|
let {
|
|
46
31
|
result: data
|
|
47
32
|
} = this.props;
|
|
48
|
-
data =
|
|
33
|
+
data = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
49
34
|
if (!Array.isArray(data)) return;
|
|
50
35
|
this.draw(data);
|
|
51
36
|
this.renderAxisLabel(this.props.chart, this.props.tables, this.container);
|
|
@@ -106,7 +91,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
106
91
|
key: itemKey,
|
|
107
92
|
value,
|
|
108
93
|
series,
|
|
109
|
-
slugid:
|
|
94
|
+
slugid: slugid.nice()
|
|
110
95
|
});
|
|
111
96
|
});
|
|
112
97
|
stacksData.push({
|
|
@@ -128,12 +113,14 @@ class BarCustom extends _chartComponent.default {
|
|
|
128
113
|
return allSeries;
|
|
129
114
|
};
|
|
130
115
|
this.draw = data => {
|
|
116
|
+
const fullData = data;
|
|
117
|
+
data = this.getVisibleLegendData(data, 'group_name');
|
|
131
118
|
const {
|
|
132
119
|
chart,
|
|
133
120
|
globalTheme,
|
|
134
121
|
chartColorTheme
|
|
135
122
|
} = this.props;
|
|
136
|
-
const theme =
|
|
123
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
137
124
|
const {
|
|
138
125
|
display_each_block_data
|
|
139
126
|
} = chart.config;
|
|
@@ -148,7 +135,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
148
135
|
insertPadding
|
|
149
136
|
} = this.chartBoundingClientRect;
|
|
150
137
|
const organizedData = this.organizeData(data);
|
|
151
|
-
const color = d3.scaleOrdinal().domain(d3.group(
|
|
138
|
+
const color = d3.scaleOrdinal().domain(d3.group(fullData, d => d.group_name).keys()).range(BaseUtils.getCurrentTheme(chartColorTheme).colors).unknown('#ccc');
|
|
152
139
|
const allSeries = this.getAllSeries(organizedData);
|
|
153
140
|
const niceEnd = d3.nice(0, d3.max(allSeries, d => d[1]), 5)[1];
|
|
154
141
|
const y = d3.scaleLinear().domain([0, niceEnd]).range([chartHeight - insertPadding, insertPadding]);
|
|
@@ -182,9 +169,6 @@ class BarCustom extends _chartComponent.default {
|
|
|
182
169
|
const height = y(d[0][0]) - y(d[0][1]);
|
|
183
170
|
return isNaN(height) ? 0 : height;
|
|
184
171
|
}).attr('fill', d => color(d.key)).attr('data-value', d => d.stackData.value).attr('data-rectId', d => d.stackData.slugId).attr('data-groupName', d => d.stackData.group_name).attr('data-title', d => d.stackData.name).call(g => {
|
|
185
|
-
const {
|
|
186
|
-
borderRadius
|
|
187
|
-
} = this.chartBoundingClientRect;
|
|
188
172
|
const xWidth = x.bandwidth();
|
|
189
173
|
const stackGroupNodes = Array.from(g._parents);
|
|
190
174
|
const nameGroups = [];
|
|
@@ -196,28 +180,19 @@ class BarCustom extends _chartComponent.default {
|
|
|
196
180
|
});
|
|
197
181
|
nameGroups.forEach(nameGroup => {
|
|
198
182
|
const stackGroups = Array.from(nameGroup.children);
|
|
199
|
-
let groupBorderRadius = Infinity;
|
|
200
183
|
stackGroups.forEach(stackGroup => {
|
|
201
184
|
const topRect = Array.from(stackGroup.children).reverse().find(rect => Number(rect.getAttribute('height')) !== 0);
|
|
202
185
|
if (!topRect) return;
|
|
203
|
-
|
|
204
|
-
const computedBorderRadius = Math.min(xWidth * borderRadius, rectHeight / 2, xWidth / 2);
|
|
205
|
-
groupBorderRadius = Math.min(groupBorderRadius, computedBorderRadius);
|
|
206
|
-
});
|
|
207
|
-
if (!Number.isFinite(groupBorderRadius)) {
|
|
208
|
-
groupBorderRadius = 0;
|
|
209
|
-
}
|
|
210
|
-
stackGroups.forEach(stackGroup => {
|
|
211
|
-
const topRect = Array.from(stackGroup.children).reverse().find(rect => Number(rect.getAttribute('height')) !== 0);
|
|
212
|
-
if (!topRect) return;
|
|
213
|
-
this.addMaskRect(stackGroup, topRect, xWidth, color, groupBorderRadius);
|
|
186
|
+
this.addMaskRect(stackGroup, topRect, xWidth);
|
|
214
187
|
});
|
|
215
188
|
});
|
|
216
189
|
if (display_each_block_data) {
|
|
217
190
|
this.handleLabelToRectCenter(g, xWidth);
|
|
218
191
|
}
|
|
192
|
+
this.animateFadeIn(this.chart.select('.content-wrapper').selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
193
|
+
this.animateStackGrowInY(g, rect => rect.parentNode.getAttribute('data-slugid'));
|
|
219
194
|
}).on('click', (event, data) => {
|
|
220
|
-
this.props.toggleRecords(data);
|
|
195
|
+
this.props.toggleRecords(data.stackData);
|
|
221
196
|
}).on('mouseover', event => {
|
|
222
197
|
this.showTooltip(event, color);
|
|
223
198
|
this.handleStacksAcitveAndInActiveState('inActive', event);
|
|
@@ -234,7 +209,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
234
209
|
legendName: 'group_name',
|
|
235
210
|
theme,
|
|
236
211
|
legendPosition: 'top-right',
|
|
237
|
-
data,
|
|
212
|
+
data: fullData,
|
|
238
213
|
colorScale: color
|
|
239
214
|
});
|
|
240
215
|
};
|
|
@@ -246,10 +221,9 @@ class BarCustom extends _chartComponent.default {
|
|
|
246
221
|
const {
|
|
247
222
|
label_font_size
|
|
248
223
|
} = chart.config;
|
|
249
|
-
const theme =
|
|
224
|
+
const theme = CHART_THEME_COLOR[globalTheme];
|
|
250
225
|
Array.from(g._parents).forEach(group => {
|
|
251
226
|
Array.from(group.children).forEach(rect => {
|
|
252
|
-
// The height is 0, and the label is not displayed.
|
|
253
227
|
if (Number(rect.getAttribute('height')) === 0) return;
|
|
254
228
|
this.addLabelToRectCenter({
|
|
255
229
|
container: rect.parentNode,
|
|
@@ -264,28 +238,8 @@ class BarCustom extends _chartComponent.default {
|
|
|
264
238
|
});
|
|
265
239
|
});
|
|
266
240
|
};
|
|
267
|
-
this.addMaskRect = (topG, rect, xWidth
|
|
268
|
-
|
|
269
|
-
borderRadius
|
|
270
|
-
} = this.chartBoundingClientRect;
|
|
271
|
-
const rectHeight = Number(rect.getAttribute('height'));
|
|
272
|
-
const computedBorderRadius = Math.min(xWidth * borderRadius, rectHeight / 2, xWidth / 2);
|
|
273
|
-
const safeBorderRadius = Math.min(borderRadiusVal !== null && borderRadiusVal !== void 0 ? borderRadiusVal : computedBorderRadius, rectHeight / 2, xWidth / 2);
|
|
274
|
-
// Add mask rect
|
|
275
|
-
d3.select(topG).append('foreignObject').attr('class', 'stack-wrapper').attr('opacity', rect.getAttribute('opacity')).attr('x', rect.getAttribute('x')).attr('data-x', topG.parentNode.getAttribute('data-transform')).attr('y', rect.getAttribute('y')).attr('width', xWidth).attr('height', rect.getAttribute('height')).attr('data-groupName', rect.getAttribute('data-groupName')).attr('data-value', rect.getAttribute('data-value')).attr('data-title', rect.getAttribute('data-title')).attr('data-rectId', rect.getAttribute('data-rectId')).on('click', (event, data) => {
|
|
276
|
-
this.props.toggleRecords(data);
|
|
277
|
-
}).on('mouseover', event => {
|
|
278
|
-
this.showTooltip(event, colorScale, true);
|
|
279
|
-
this.handleStacksAcitveAndInActiveState('inActive', event);
|
|
280
|
-
}).on('mousemove', event => {
|
|
281
|
-
this.moveTooltip(event, true);
|
|
282
|
-
}).on('mouseleave', (event, data) => {
|
|
283
|
-
this.hiddenTooltip();
|
|
284
|
-
this.handleStacksAcitveAndInActiveState('active', event);
|
|
285
|
-
}).append('xhtml:div').attr('class', 'stack').attr('data-rectId', rect.getAttribute('data-rectId')).attr('style', `width: 100%; height: 100%; background-color: ${rect.getAttribute('fill')}; border-radius: ${safeBorderRadius}px ${safeBorderRadius}px 0px 0px`);
|
|
286
|
-
|
|
287
|
-
// Remove old rect
|
|
288
|
-
d3.select(rect).remove();
|
|
241
|
+
this.addMaskRect = (topG, rect, xWidth) => {
|
|
242
|
+
return this.addRoundedClip(rect, 'y', xWidth);
|
|
289
243
|
};
|
|
290
244
|
this.handleStacksAcitveAndInActiveState = (state, event) => {
|
|
291
245
|
const rectsWrapper = event.currentTarget.parentNode.parentNode.parentNode;
|
|
@@ -294,10 +248,8 @@ class BarCustom extends _chartComponent.default {
|
|
|
294
248
|
allGroup.forEach(group => {
|
|
295
249
|
Array.from(group.children).forEach(rectGroup => {
|
|
296
250
|
Array.from(rectGroup.children).forEach(rect => {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (curRect.getAttribute('class') === 'stack') {
|
|
300
|
-
isDiv ? d3.select(curRect.parentNode).transition().duration(this.transitionDuration).attr('opacity', 1) : d3.select(curRect).transition().duration(this.transitionDuration).attr('opacity', 1);
|
|
251
|
+
if (rect.getAttribute('class') === 'stack') {
|
|
252
|
+
d3.select(rect).transition().duration(this.interactionDuration).attr('opacity', 1);
|
|
301
253
|
}
|
|
302
254
|
});
|
|
303
255
|
});
|
|
@@ -308,35 +260,27 @@ class BarCustom extends _chartComponent.default {
|
|
|
308
260
|
allGroup.forEach(group => {
|
|
309
261
|
Array.from(group.children).forEach(rectGroup => {
|
|
310
262
|
Array.from(rectGroup.children).forEach(rect => {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (curRect.getAttribute('class') === 'stack' && curRect.getAttribute('data-rectId') !== curRectId) {
|
|
314
|
-
isDiv ? d3.select(curRect.parentNode).transition().duration(this.transitionDuration).attr('opacity', 0.3) : d3.select(curRect).transition().duration(this.transitionDuration).attr('opacity', 0.3);
|
|
263
|
+
if (rect.getAttribute('class') === 'stack' && rect.getAttribute('data-rectId') !== curRectId) {
|
|
264
|
+
d3.select(rect).transition().duration(this.interactionDuration).attr('opacity', 0.3);
|
|
315
265
|
}
|
|
316
266
|
});
|
|
317
267
|
});
|
|
318
268
|
});
|
|
319
269
|
}
|
|
320
270
|
};
|
|
321
|
-
this.showTooltip = (event, colorScale
|
|
322
|
-
|
|
271
|
+
this.showTooltip = (event, colorScale) => {
|
|
272
|
+
const {
|
|
323
273
|
offsetX,
|
|
324
274
|
offsetY
|
|
325
275
|
} = event;
|
|
326
|
-
if (isDiv) {
|
|
327
|
-
const initX = Number(event.currentTarget.getAttribute('data-x'));
|
|
328
|
-
const initY = Number(event.currentTarget.getAttribute('y'));
|
|
329
|
-
offsetX = offsetX + initX;
|
|
330
|
-
offsetY = offsetY + initY;
|
|
331
|
-
}
|
|
332
276
|
const title = event.currentTarget.getAttribute('data-title');
|
|
333
277
|
const name = event.currentTarget.getAttribute('data-groupName');
|
|
334
278
|
const value = event.currentTarget.getAttribute('data-value');
|
|
335
279
|
const newTooltipData = {
|
|
336
|
-
title: !title && typeof title !== 'number' ?
|
|
280
|
+
title: !title && typeof title !== 'number' ? intl.get(EMPTY_NAME) : title,
|
|
337
281
|
items: [{
|
|
338
282
|
color: colorScale(name),
|
|
339
|
-
name: !name && typeof name !== 'number' ?
|
|
283
|
+
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
340
284
|
value
|
|
341
285
|
}]
|
|
342
286
|
};
|
|
@@ -350,17 +294,11 @@ class BarCustom extends _chartComponent.default {
|
|
|
350
294
|
}
|
|
351
295
|
});
|
|
352
296
|
};
|
|
353
|
-
this.moveTooltip =
|
|
354
|
-
|
|
297
|
+
this.moveTooltip = event => {
|
|
298
|
+
const {
|
|
355
299
|
offsetX,
|
|
356
300
|
offsetY
|
|
357
301
|
} = event;
|
|
358
|
-
if (isDiv) {
|
|
359
|
-
const initX = Number(event.currentTarget.getAttribute('data-x'));
|
|
360
|
-
const initY = Number(event.currentTarget.getAttribute('y'));
|
|
361
|
-
offsetX = offsetX + initX;
|
|
362
|
-
offsetY = offsetY + initY;
|
|
363
|
-
}
|
|
364
302
|
this.setState({
|
|
365
303
|
toolTipPosition: {
|
|
366
304
|
offsetX,
|
|
@@ -382,11 +320,11 @@ class BarCustom extends _chartComponent.default {
|
|
|
382
320
|
componentDidMount() {
|
|
383
321
|
this.createChart();
|
|
384
322
|
this.drawChart();
|
|
385
|
-
|
|
323
|
+
super.componentDidMount();
|
|
386
324
|
}
|
|
387
325
|
componentDidUpdate(prevProps) {
|
|
388
326
|
super.componentDidUpdate(prevProps);
|
|
389
|
-
if (
|
|
327
|
+
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
390
328
|
this.destroyChart();
|
|
391
329
|
this.createChart();
|
|
392
330
|
this.drawChart();
|
|
@@ -394,23 +332,17 @@ class BarCustom extends _chartComponent.default {
|
|
|
394
332
|
}
|
|
395
333
|
componentWillUnmount() {
|
|
396
334
|
this.destroyChart();
|
|
397
|
-
|
|
335
|
+
super.componentWillUnmount();
|
|
398
336
|
}
|
|
399
337
|
render() {
|
|
400
|
-
const {
|
|
401
|
-
chart
|
|
402
|
-
} = this.props;
|
|
403
338
|
const {
|
|
404
339
|
tooltipData,
|
|
405
340
|
toolTipPosition
|
|
406
341
|
} = this.state;
|
|
407
|
-
return /*#__PURE__*/
|
|
342
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
408
343
|
ref: ref => this.container = ref,
|
|
409
|
-
className:
|
|
410
|
-
|
|
411
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
412
|
-
})
|
|
413
|
-
}, /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
344
|
+
className: "sea-chart-container"
|
|
345
|
+
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
414
346
|
tooltipData: tooltipData,
|
|
415
347
|
toolTipPosition: toolTipPosition,
|
|
416
348
|
chart: this.chart
|
|
@@ -418,15 +350,15 @@ class BarCustom extends _chartComponent.default {
|
|
|
418
350
|
}
|
|
419
351
|
}
|
|
420
352
|
BarCustom.propTypes = {
|
|
421
|
-
canvasStyle:
|
|
422
|
-
chart:
|
|
423
|
-
groupbyColumn:
|
|
424
|
-
columnGroupbyColumn:
|
|
425
|
-
summaryColumn:
|
|
426
|
-
result:
|
|
427
|
-
tables:
|
|
428
|
-
globalTheme:
|
|
429
|
-
chartColorTheme:
|
|
430
|
-
toggleRecords:
|
|
353
|
+
canvasStyle: PropTypes.object,
|
|
354
|
+
chart: PropTypes.object,
|
|
355
|
+
groupbyColumn: PropTypes.object,
|
|
356
|
+
columnGroupbyColumn: PropTypes.object,
|
|
357
|
+
summaryColumn: PropTypes.object,
|
|
358
|
+
result: PropTypes.array,
|
|
359
|
+
tables: PropTypes.array,
|
|
360
|
+
globalTheme: PropTypes.string,
|
|
361
|
+
chartColorTheme: PropTypes.string,
|
|
362
|
+
toggleRecords: PropTypes.func
|
|
431
363
|
};
|
|
432
|
-
|
|
364
|
+
export default BarCustom;
|