sea-chart 2.0.1 → 2.0.2
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/components/cell-factory/SimpleCellFormatter.js +1 -1
- package/dist/components/cell-factory/link-content.js +4 -4
- package/dist/components/color-picker/index.js +1 -1
- package/dist/components/color-popover/color-rules/color-rule.js +1 -1
- package/dist/components/color-popover/color-rules/index.js +1 -1
- package/dist/components/color-popover/color-rules-popover.js +6 -6
- package/dist/components/color-popover/color-selector-popover.js +2 -2
- package/dist/components/color-setting/color-group-selector.js +1 -1
- package/dist/components/common-add-tool/index.js +2 -2
- package/dist/components/data-process-setter/hide-column-setter.js +1 -1
- package/dist/components/data-process-setter/sort-setter.js +2 -2
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +4 -4
- package/dist/components/icon/index.js +2 -2
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +1 -1
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +1 -1
- package/dist/components/popover/sort-popover/sort-popover.js +1 -1
- package/dist/components/row-card/row-card-header-cell.js +2 -2
- package/dist/components/row-card/row-card-header.js +1 -1
- package/dist/components/row-card/row-card-item.js +2 -2
- package/dist/components/row-card/row-card.js +2 -2
- package/dist/components/statistic-record-dialog/index.js +1 -1
- package/dist/components/types-dialog/index.js +7 -7
- package/dist/context.js +2 -2
- package/dist/services/map-json.js +4 -4
- package/dist/settings/basic-number-card/style-settings.js +1 -1
- package/dist/settings/index.js +3 -3
- package/dist/settings/map-settings/map-style-settings.js +1 -1
- package/dist/settings/stacks-settings/index.js +1 -1
- package/dist/settings/style-settings.js +1 -1
- package/dist/settings/table-settings/data-settings.js +1 -1
- package/dist/settings/trend-settings/style-setting.js +2 -2
- package/dist/settings/widgets/chart-type/index.js +3 -3
- package/dist/settings/widgets/date-summary-item.js +2 -2
- package/dist/settings/widgets/numeric-summary-item.js +2 -2
- package/dist/settings/widgets/summary-settings.js +2 -2
- package/dist/settings/widgets/switch/index.js +1 -1
- package/dist/settings/widgets/y-axis-group-settings.js +1 -1
- package/dist/utils/chart-utils/base-utils.js +7 -7
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +1 -1
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +2 -2
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +1 -1
- package/dist/utils/chart-utils/sql-statistics-utils.js +9 -9
- package/dist/utils/collaborator-utils.js +1 -1
- package/dist/utils/collaborator.js +2 -2
- package/dist/utils/column-utils.js +12 -12
- package/dist/utils/common-utils.js +1 -1
- package/dist/utils/date-translate.js +1 -1
- package/dist/utils/object-utils.js +1 -1
- package/dist/utils/options-utils.js +2 -2
- package/dist/utils/row-record-utils.js +2 -2
- package/dist/utils/sql/chart-data-sql.js +58 -58
- package/dist/utils/sql/column-2-sql-column.js +18 -18
- package/dist/view/index.js +2 -5
- package/dist/view/title/index.js +2 -2
- package/dist/view/wrapper/bar.js +168 -93
- package/dist/view/wrapper/basic-number-card.js +8 -8
- package/dist/view/wrapper/chart-component.js +16 -52
- package/dist/view/wrapper/index.js +1 -237
- package/dist/view/wrapper/table/index.js +1 -1
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +3 -3
- package/dist/view/wrapper/table/pivot-table-display-name.js +1 -1
- package/dist/view/wrapper/table/two-dimension-table.js +8 -8
- package/dist/view/wrapper/table-element/components/formatter.js +2 -2
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +1 -1
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +17 -17
- package/dist/view/wrapper/table-element/components/link-formatter.js +17 -17
- package/dist/view/wrapper/table-element/components/record.js +3 -3
- package/dist/view/wrapper/table-element/components/records.js +4 -4
- package/dist/view/wrapper/table-element/components/utils.js +1 -1
- package/dist/view/wrapper/trend.js +18 -18
- package/package.json +5 -11
- package/dist/utils/custom-g2.js +0 -684
- package/dist/view/wrapper/area.js +0 -282
- package/dist/view/wrapper/bar-custom.js +0 -239
- package/dist/view/wrapper/bar-group.js +0 -274
- package/dist/view/wrapper/combination.js +0 -728
- package/dist/view/wrapper/compare.js +0 -383
- package/dist/view/wrapper/completeness.js +0 -174
- package/dist/view/wrapper/dashboard.js +0 -179
- package/dist/view/wrapper/funnel.js +0 -206
- package/dist/view/wrapper/heat-map.js +0 -434
- package/dist/view/wrapper/horizontal-bar-group.js +0 -226
- package/dist/view/wrapper/horizontal-bar.js +0 -175
- package/dist/view/wrapper/horizontal-component.js +0 -89
- package/dist/view/wrapper/line-group.js +0 -219
- package/dist/view/wrapper/line.js +0 -222
- package/dist/view/wrapper/map.js +0 -368
- package/dist/view/wrapper/mirror.js +0 -218
- package/dist/view/wrapper/pie.js +0 -253
- package/dist/view/wrapper/ring.js +0 -328
- package/dist/view/wrapper/scatter.js +0 -140
- package/dist/view/wrapper/treemap.js +0 -206
- package/dist/view/wrapper/world-map.js +0 -413
- package/dist/view/wrapper/wrappers-d3/bar.js +0 -262
|
@@ -1,175 +0,0 @@
|
|
|
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 _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _constants = require("../../constants");
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
|
-
var _colorUtils = require("../../utils/color-utils");
|
|
14
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
15
|
-
var _horizontalComponent = _interopRequireDefault(require("./horizontal-component"));
|
|
16
|
-
class HorizontalBar extends _horizontalComponent.default {
|
|
17
|
-
constructor(props) {
|
|
18
|
-
super(props);
|
|
19
|
-
this.createChart = () => {
|
|
20
|
-
const {
|
|
21
|
-
chart
|
|
22
|
-
} = this.props;
|
|
23
|
-
const {
|
|
24
|
-
display_data
|
|
25
|
-
} = chart.config;
|
|
26
|
-
const appendPadding = [0, display_data ? 17 : 0, 0, 0]; // used to display value on the right
|
|
27
|
-
this.initChart(this.container, {
|
|
28
|
-
appendPadding
|
|
29
|
-
});
|
|
30
|
-
this.chart.on('interval:click', e => {
|
|
31
|
-
this.props.toggleRecords(e.data.data);
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
this.clearChart = () => {
|
|
35
|
-
this.chart.annotation().clear(true);
|
|
36
|
-
this.chart.clear(true);
|
|
37
|
-
};
|
|
38
|
-
this.drawChart = () => {
|
|
39
|
-
let {
|
|
40
|
-
result: data,
|
|
41
|
-
customRender
|
|
42
|
-
} = this.props;
|
|
43
|
-
data = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
|
|
44
|
-
if (!Array.isArray(data)) return;
|
|
45
|
-
this.loadData(data);
|
|
46
|
-
this.draw(data);
|
|
47
|
-
(0, _utils.isFunction)(customRender) && customRender(this.chart);
|
|
48
|
-
requestAnimationFrame(() => {
|
|
49
|
-
this.chart.render();
|
|
50
|
-
this.renderHorizontalLabel(this.props.chart, this.props.tables);
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
this.draw = data => {
|
|
54
|
-
const {
|
|
55
|
-
chart,
|
|
56
|
-
summaryColumn,
|
|
57
|
-
globalTheme,
|
|
58
|
-
chartColorTheme,
|
|
59
|
-
tables
|
|
60
|
-
} = this.props;
|
|
61
|
-
const theme = _constants.CHART_THEME_COLOR[globalTheme];
|
|
62
|
-
const {
|
|
63
|
-
table_id,
|
|
64
|
-
horizontal_axis_summary_type,
|
|
65
|
-
horizontal_axis_summary_method,
|
|
66
|
-
y_axis_summary_type,
|
|
67
|
-
y_axis_column_key,
|
|
68
|
-
y_axis_summary_column_key,
|
|
69
|
-
color_option,
|
|
70
|
-
horizontal_axis_label_color_rules,
|
|
71
|
-
horizontal_axis_label_color,
|
|
72
|
-
display_data,
|
|
73
|
-
label_font_size
|
|
74
|
-
} = chart.config;
|
|
75
|
-
|
|
76
|
-
// y-axis label width:6 + 8
|
|
77
|
-
const chartHeight = this.chart.height - 6 - 10;
|
|
78
|
-
const singleBarWidth = Math.round(chartHeight / (2 * data.length));
|
|
79
|
-
const singleBarRadius = Math.min(singleBarWidth / 5, 10);
|
|
80
|
-
let chartBarColor = horizontal_axis_label_color || _constants.CHART_STYLE_COLORS[0];
|
|
81
|
-
if (chartColorTheme) {
|
|
82
|
-
chartBarColor = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
|
|
83
|
-
}
|
|
84
|
-
const colorRules = color_option === _constants.TYPE_COLOR_USING.USE_RULES && horizontal_axis_label_color_rules && (0, _colorUtils.getConvertedColorRules)(horizontal_axis_label_color_rules);
|
|
85
|
-
const title = this.getTitle(tables, table_id, y_axis_summary_type, y_axis_column_key || y_axis_summary_column_key);
|
|
86
|
-
data.reverse();
|
|
87
|
-
this.drawLabels(data);
|
|
88
|
-
|
|
89
|
-
// set Coord type
|
|
90
|
-
this.chart.coordinate('rect');
|
|
91
|
-
this.autoAdjustDataOptions(chart, data, summaryColumn);
|
|
92
|
-
this.chart.interval().label(display_data ? 'value' : false, {
|
|
93
|
-
style: {
|
|
94
|
-
fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
|
|
95
|
-
fill: theme.labelColor,
|
|
96
|
-
...this.labelStroke
|
|
97
|
-
}
|
|
98
|
-
}).position('name*value').color('value', value => {
|
|
99
|
-
const color = (0, _colorUtils.getLabelColor)({
|
|
100
|
-
chart: chart.config,
|
|
101
|
-
colorRules,
|
|
102
|
-
value
|
|
103
|
-
});
|
|
104
|
-
return color || chartBarColor;
|
|
105
|
-
}).size(singleBarWidth).tooltip('name*value', (name, value) => {
|
|
106
|
-
return {
|
|
107
|
-
title,
|
|
108
|
-
value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, horizontal_axis_summary_method),
|
|
109
|
-
name
|
|
110
|
-
};
|
|
111
|
-
}).state({
|
|
112
|
-
active: {
|
|
113
|
-
style: {
|
|
114
|
-
stroke: null
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}).style('value', value => {
|
|
118
|
-
return {
|
|
119
|
-
radius: [singleBarRadius, singleBarRadius, 0, 0]
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
this.chart.legend(false);
|
|
123
|
-
this.setToolTip();
|
|
124
|
-
this.setNameLabelAndTooltip(theme, this.labelCount);
|
|
125
|
-
this.setValueLabel(theme);
|
|
126
|
-
this.chart.coordinate().transpose();
|
|
127
|
-
this.chart.interaction('element-highlight');
|
|
128
|
-
};
|
|
129
|
-
this.chart = null;
|
|
130
|
-
}
|
|
131
|
-
componentDidMount() {
|
|
132
|
-
this.createChart();
|
|
133
|
-
this.drawChart();
|
|
134
|
-
super.componentDidMount();
|
|
135
|
-
}
|
|
136
|
-
componentDidUpdate(prevProps) {
|
|
137
|
-
super.componentDidUpdate(prevProps);
|
|
138
|
-
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
139
|
-
var _this$chart;
|
|
140
|
-
((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
|
|
141
|
-
this.createChart();
|
|
142
|
-
this.drawChart();
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
componentWillUnmount() {
|
|
146
|
-
var _this$chart2;
|
|
147
|
-
((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
|
|
148
|
-
super.componentWillUnmount();
|
|
149
|
-
}
|
|
150
|
-
render() {
|
|
151
|
-
const {
|
|
152
|
-
chart
|
|
153
|
-
} = this.props;
|
|
154
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
155
|
-
className: (0, _classnames.default)('sea-chart-container', {
|
|
156
|
-
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
157
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
158
|
-
}),
|
|
159
|
-
ref: ref => this.container = ref
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
HorizontalBar.propTypes = {
|
|
164
|
-
canvasStyle: _propTypes.default.object,
|
|
165
|
-
chart: _propTypes.default.object,
|
|
166
|
-
groupbyColumn: _propTypes.default.object,
|
|
167
|
-
columnGroupbyColumn: _propTypes.default.object,
|
|
168
|
-
summaryColumn: _propTypes.default.object,
|
|
169
|
-
result: _propTypes.default.array,
|
|
170
|
-
tables: _propTypes.default.array,
|
|
171
|
-
globalTheme: _propTypes.default.string,
|
|
172
|
-
chartColorTheme: _propTypes.default.string,
|
|
173
|
-
toggleRecords: _propTypes.default.func
|
|
174
|
-
};
|
|
175
|
-
var _default = exports.default = HorizontalBar;
|
|
@@ -1,89 +0,0 @@
|
|
|
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 _dtableUtils = require("dtable-utils");
|
|
9
|
-
var _constants = require("../../constants");
|
|
10
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
11
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
12
|
-
class HorizontalComponent extends _chartComponent.default {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
15
|
-
this.renderHorizontalLabel = (chart, tables) => {
|
|
16
|
-
var _this$chart;
|
|
17
|
-
if (!this.chart || !chart) return;
|
|
18
|
-
let {
|
|
19
|
-
table_id,
|
|
20
|
-
x_axis_column_key,
|
|
21
|
-
y_axis_summary_column_key,
|
|
22
|
-
vertical_axis_label_position,
|
|
23
|
-
horizontal_axis_label_position,
|
|
24
|
-
y_axis_summary_type,
|
|
25
|
-
show_vertical_axis_label,
|
|
26
|
-
show_horizontal_axis_label
|
|
27
|
-
} = chart.config;
|
|
28
|
-
const table = (0, _dtableUtils.getTableById)(tables, table_id);
|
|
29
|
-
const autoPadding = ((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) || {
|
|
30
|
-
bottom: 0
|
|
31
|
-
};
|
|
32
|
-
const textColor = '#999999';
|
|
33
|
-
const xAxisID = `chart-x-axis-label_${chart.id}`;
|
|
34
|
-
const chartContainer = this.chart.getCanvas().get('container');
|
|
35
|
-
const xLabel = chartContainer.querySelector(`#${xAxisID}`);
|
|
36
|
-
if (!xLabel && show_horizontal_axis_label) {
|
|
37
|
-
const div = document.createElement('div');
|
|
38
|
-
div.id = xAxisID;
|
|
39
|
-
div.className = 'chart-axis-label';
|
|
40
|
-
if (y_axis_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
41
|
-
div.innerHTML = _intl.default.get('Amount');
|
|
42
|
-
} else {
|
|
43
|
-
const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_summary_column_key);
|
|
44
|
-
div.innerHTML = `${column ? column.name : ''}`;
|
|
45
|
-
}
|
|
46
|
-
div.setAttribute('style', `color:${textColor}; width: 100%; text-align: ${horizontal_axis_label_position}; bottom: -20px; position: absolute`);
|
|
47
|
-
chartContainer.appendChild(div);
|
|
48
|
-
}
|
|
49
|
-
if (xLabel && show_horizontal_axis_label) {
|
|
50
|
-
xLabel.setAttribute('style', `color:${textColor}; width: 100%; text-align: ${horizontal_axis_label_position}; bottom: -20px; position: absolute`);
|
|
51
|
-
}
|
|
52
|
-
if (xLabel && !show_horizontal_axis_label) {
|
|
53
|
-
xLabel.parentNode.removeChild(xLabel);
|
|
54
|
-
}
|
|
55
|
-
const yAxisID = `chart-y-axis-label_${chart.id}`;
|
|
56
|
-
const yLabel = chartContainer.querySelector(`#${yAxisID}`);
|
|
57
|
-
if (!yLabel && show_vertical_axis_label) {
|
|
58
|
-
const div = document.createElement('div');
|
|
59
|
-
div.id = yAxisID;
|
|
60
|
-
div.className = 'chart-axis-label';
|
|
61
|
-
const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key) || {};
|
|
62
|
-
div.innerHTML = column.name || '';
|
|
63
|
-
const containerHeight = chartContainer.offsetHeight;
|
|
64
|
-
let textAlign = 'center';
|
|
65
|
-
if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
66
|
-
if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
67
|
-
div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 + 12}px, ${(containerHeight - autoPadding.bottom) / 2}px) rotate(-90deg)`);
|
|
68
|
-
chartContainer.appendChild(div);
|
|
69
|
-
}
|
|
70
|
-
if (yLabel && show_horizontal_axis_label) {
|
|
71
|
-
const containerHeight = chartContainer.offsetHeight;
|
|
72
|
-
let textAlign = 'center';
|
|
73
|
-
if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
74
|
-
if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
75
|
-
yLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 + 12}px, ${(containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4}px) rotate(-90deg)`);
|
|
76
|
-
}
|
|
77
|
-
if (yLabel && !show_horizontal_axis_label) {
|
|
78
|
-
yLabel.parentNode.removeChild(yLabel);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
this.isShowVerticalAxisLabel = chart => {
|
|
82
|
-
return !!(chart && chart.config && chart.config.show_vertical_axis_label);
|
|
83
|
-
};
|
|
84
|
-
this.isShowHorizontalAxisLabel = chart => {
|
|
85
|
-
return !!(chart && chart.config && chart.config.show_horizontal_axis_label);
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.default = HorizontalComponent;
|
|
@@ -1,219 +0,0 @@
|
|
|
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 _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _constants = require("dtable-ui-component/lib/constants");
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
|
-
var _intl = _interopRequireDefault(require("../../intl"));
|
|
14
|
-
var _constants2 = require("../../constants");
|
|
15
|
-
var _colorRules = require("../../constants/color-rules");
|
|
16
|
-
var _chartComponent = _interopRequireDefault(require("./chart-component"));
|
|
17
|
-
class LineGroup extends _chartComponent.default {
|
|
18
|
-
constructor(props) {
|
|
19
|
-
super(props);
|
|
20
|
-
this.createChart = () => {
|
|
21
|
-
const {
|
|
22
|
-
chart
|
|
23
|
-
} = this.props;
|
|
24
|
-
const {
|
|
25
|
-
y_axis_show_value
|
|
26
|
-
} = chart.config;
|
|
27
|
-
const appendPadding = [y_axis_show_value ? 17 : 0, 0, 0, 0];
|
|
28
|
-
this.initChart(this.container, {
|
|
29
|
-
appendPadding
|
|
30
|
-
});
|
|
31
|
-
this.chart.on('point:click', e => {
|
|
32
|
-
this.props.toggleRecords(e.data.data);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
this.clearChart = () => {
|
|
36
|
-
this.chart.annotation().clear(true);
|
|
37
|
-
this.chart.clear(true);
|
|
38
|
-
};
|
|
39
|
-
this.drawChart = () => {
|
|
40
|
-
let {
|
|
41
|
-
result: data,
|
|
42
|
-
customRender
|
|
43
|
-
} = this.props;
|
|
44
|
-
data = _utils.BaseUtils.formatEmptyName(data, '', _intl.default.get('Empty'));
|
|
45
|
-
if (!Array.isArray(data)) return;
|
|
46
|
-
this.chart.scale(this.groupName, {
|
|
47
|
-
type: 'cat'
|
|
48
|
-
});
|
|
49
|
-
this.loadData(data);
|
|
50
|
-
this.draw(data);
|
|
51
|
-
(0, _utils.isFunction)(customRender) && customRender(this.chart);
|
|
52
|
-
requestAnimationFrame(() => {
|
|
53
|
-
this.chart.render();
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
this.draw = data => {
|
|
57
|
-
const {
|
|
58
|
-
chart,
|
|
59
|
-
summaryColumn,
|
|
60
|
-
columnGroupbyColumn,
|
|
61
|
-
globalTheme,
|
|
62
|
-
chartColorTheme
|
|
63
|
-
} = this.props;
|
|
64
|
-
const theme = _constants2.CHART_THEME_COLOR[globalTheme];
|
|
65
|
-
const {
|
|
66
|
-
y_axis_show_value,
|
|
67
|
-
label_font_size,
|
|
68
|
-
line_type,
|
|
69
|
-
y_axis_summary_method,
|
|
70
|
-
color_theme
|
|
71
|
-
} = chart.config;
|
|
72
|
-
const chartBarColor = this.groupName;
|
|
73
|
-
const newData = this.getChartGroupData(data);
|
|
74
|
-
this.drawLabels(newData);
|
|
75
|
-
const {
|
|
76
|
-
display_goal_line,
|
|
77
|
-
goal_label,
|
|
78
|
-
goal_value
|
|
79
|
-
} = chart.style_config || {};
|
|
80
|
-
const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
|
|
81
|
-
|
|
82
|
-
const useSingleSelectColumnColor = (columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === _constants.CellType.SINGLE_SELECT && color_theme === _colorRules.SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
|
|
83
|
-
useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme);
|
|
84
|
-
const isSmooth = line_type === _constants2.CHART_LINE_TYPES[1];
|
|
85
|
-
|
|
86
|
-
// set Coord type
|
|
87
|
-
this.chart.coordinate('rect');
|
|
88
|
-
this.autoAdjustDataOptions(chart, data, summaryColumn);
|
|
89
|
-
this.chart.scale({
|
|
90
|
-
group_name: {
|
|
91
|
-
type: 'cat'
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
this.chart.line().label(y_axis_show_value ? 'value' : false, {
|
|
95
|
-
style: {
|
|
96
|
-
fontSize: _utils.BaseUtils.getLabelFontSize(label_font_size),
|
|
97
|
-
fill: theme.labelColor,
|
|
98
|
-
stroke: '#fff',
|
|
99
|
-
lineWidth: 1
|
|
100
|
-
}
|
|
101
|
-
}).animate({
|
|
102
|
-
appear: {
|
|
103
|
-
animation: 'fadeIn',
|
|
104
|
-
duration: 1000,
|
|
105
|
-
easing: 'easeLinear'
|
|
106
|
-
}
|
|
107
|
-
}).position('name*value').color(chartBarColor, group_name => {
|
|
108
|
-
return this.colorMap[group_name];
|
|
109
|
-
}).shape(isSmooth ? 'smooth' : 'line').style({
|
|
110
|
-
lineWidth: 2,
|
|
111
|
-
opacity: 1
|
|
112
|
-
}).tooltip('group_name*name*value', (group_name, name, value) => {
|
|
113
|
-
return {
|
|
114
|
-
title: !name && typeof name !== 'number' ? _intl.default.get(_constants2.EMPTY_NAME) : name,
|
|
115
|
-
value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
116
|
-
name: !group_name && typeof group_name !== 'number' ? _intl.default.get(_constants2.EMPTY_NAME) : group_name
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
let point;
|
|
120
|
-
point = this.chart.point().position('name*value').color(chartBarColor, group_name => {
|
|
121
|
-
return this.colorMap[group_name];
|
|
122
|
-
}).animate({
|
|
123
|
-
appear: {
|
|
124
|
-
animation: 'fadeIn',
|
|
125
|
-
duration: 1000,
|
|
126
|
-
easing: 'easeLinear'
|
|
127
|
-
}
|
|
128
|
-
}).shape('circle').size(3).style({
|
|
129
|
-
stroke: 0,
|
|
130
|
-
fillOpacity: 1,
|
|
131
|
-
opacity: y_axis_show_value ? 1 : 0
|
|
132
|
-
}).tooltip(false);
|
|
133
|
-
|
|
134
|
-
// this.chart.on('tooltip:show', () => {
|
|
135
|
-
// if (line.styleOption.cfg.opacity === 0.3) return;
|
|
136
|
-
// line.style({
|
|
137
|
-
// opacity: 0.3,
|
|
138
|
-
// lineWidth: 3,
|
|
139
|
-
// });
|
|
140
|
-
// if (point) point.style({
|
|
141
|
-
// fillOpacity: 0.3,
|
|
142
|
-
// stroke: 0,
|
|
143
|
-
// });
|
|
144
|
-
// this.chart.render();
|
|
145
|
-
// });
|
|
146
|
-
|
|
147
|
-
// this.chart.on('tooltip:hide', () => {
|
|
148
|
-
// if (line.styleOption.cfg.opacity === 1) return;
|
|
149
|
-
// line.style({
|
|
150
|
-
// opacity: 1,
|
|
151
|
-
// lineWidth: 3,
|
|
152
|
-
// });
|
|
153
|
-
// if (point) point.style({
|
|
154
|
-
// fillOpacity: 1,
|
|
155
|
-
// stroke: 0,
|
|
156
|
-
// });
|
|
157
|
-
// this.chart.render();
|
|
158
|
-
// });
|
|
159
|
-
|
|
160
|
-
if (display_goal_line && goal_label && goal_value) {
|
|
161
|
-
this.setDispalyGoalLine(goal_label, goal_value, chartWidth);
|
|
162
|
-
}
|
|
163
|
-
this.setToolTipForLine();
|
|
164
|
-
this.setNameLabelAndTooltip(theme, this.labelCount);
|
|
165
|
-
this.setValueLabel(theme);
|
|
166
|
-
this.setLegend(this.groupName, theme, 'top-right');
|
|
167
|
-
};
|
|
168
|
-
this.chart = null;
|
|
169
|
-
this.groupName = 'group_name';
|
|
170
|
-
this.needRenderAxisLabel = true;
|
|
171
|
-
}
|
|
172
|
-
componentDidMount() {
|
|
173
|
-
this.createChart();
|
|
174
|
-
this.drawChart();
|
|
175
|
-
this.renderAxisLabel(this.props.chart, this.props.tables);
|
|
176
|
-
super.componentDidMount();
|
|
177
|
-
}
|
|
178
|
-
componentDidUpdate(prevProps) {
|
|
179
|
-
super.componentDidUpdate(prevProps);
|
|
180
|
-
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
181
|
-
var _this$chart;
|
|
182
|
-
((_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.autoPadding) && this.chart.destroy();
|
|
183
|
-
this.createChart();
|
|
184
|
-
this.drawChart();
|
|
185
|
-
this.renderAxisLabel(prevProps.chart, prevProps.tables);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
componentWillUnmount() {
|
|
189
|
-
var _this$chart2;
|
|
190
|
-
((_this$chart2 = this.chart) === null || _this$chart2 === void 0 ? void 0 : _this$chart2.autoPadding) && this.chart.destroy();
|
|
191
|
-
super.componentWillUnmount();
|
|
192
|
-
}
|
|
193
|
-
render() {
|
|
194
|
-
const {
|
|
195
|
-
chart
|
|
196
|
-
} = this.props;
|
|
197
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
198
|
-
className: (0, _classnames.default)('sea-chart-container ', {
|
|
199
|
-
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
200
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
201
|
-
}),
|
|
202
|
-
ref: ref => this.container = ref
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
LineGroup.propTypes = {
|
|
207
|
-
canvasStyle: _propTypes.default.object,
|
|
208
|
-
chart: _propTypes.default.object,
|
|
209
|
-
groupbyColumn: _propTypes.default.object,
|
|
210
|
-
columnGroupbyColumn: _propTypes.default.object,
|
|
211
|
-
summaryColumn: _propTypes.default.object,
|
|
212
|
-
result: _propTypes.default.array,
|
|
213
|
-
tables: _propTypes.default.array,
|
|
214
|
-
globalTheme: _propTypes.default.string,
|
|
215
|
-
chartColorTheme: _propTypes.default.string,
|
|
216
|
-
toggleRecords: _propTypes.default.func,
|
|
217
|
-
customRender: _propTypes.default.func
|
|
218
|
-
};
|
|
219
|
-
var _default = exports.default = LineGroup;
|