sea-chart 2.0.42 → 2.0.44
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/color-popover/color-rules/rule-filters/number-input.js +2 -2
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +2 -2
- package/dist/components/tooltip/index.js +11 -4
- package/dist/constants/index.js +8 -3
- package/dist/context.js +10 -7
- package/dist/model/base-model.js +4 -0
- package/dist/model/combination.js +4 -0
- package/dist/model/horizontal-bar.js +4 -0
- package/dist/model/horizontal-group-bar.js +5 -1
- package/dist/model/stacked-horizontal-bar.js +4 -0
- package/dist/settings/advance-bar-settings/style-settings.js +24 -7
- package/dist/settings/bar-settings/style-settings.js +24 -7
- package/dist/settings/combination-settings/style-settings.js +35 -10
- package/dist/settings/time-comparison-settings/style-settings.js +24 -7
- package/dist/settings/widgets/axis-title-font-settings/index.js +39 -0
- package/dist/utils/cell-format-utils.js +2 -2
- package/dist/utils/chart-utils/base-utils.js +49 -13
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +4 -3
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +3 -3
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +2 -2
- package/dist/utils/chart-utils/sql-statistics-utils.js +64 -18
- package/dist/utils/row-record-utils.js +21 -5
- package/dist/utils/sql/column-2-sql-column.js +2 -0
- package/dist/view/index.css +0 -17
- package/dist/view/wrapper/area-group.js +14 -25
- package/dist/view/wrapper/area.js +14 -27
- package/dist/view/wrapper/bar-compare.js +10 -15
- package/dist/view/wrapper/bar-custom-stack.js +19 -81
- package/dist/view/wrapper/bar-group.js +15 -50
- package/dist/view/wrapper/bar-stack.js +12 -40
- package/dist/view/wrapper/bar.js +10 -23
- package/dist/view/wrapper/basic-number-card.js +9 -2
- package/dist/view/wrapper/chart-component.js +461 -76
- package/dist/view/wrapper/combination.js +17 -29
- package/dist/view/wrapper/completeness-group.js +13 -59
- package/dist/view/wrapper/completeness.js +14 -60
- package/dist/view/wrapper/dashboard.js +8 -14
- package/dist/view/wrapper/funnel.js +6 -18
- package/dist/view/wrapper/heat-map.js +80 -50
- package/dist/view/wrapper/horizontal-bar-group.js +14 -25
- package/dist/view/wrapper/horizontal-bar-stack.js +16 -61
- package/dist/view/wrapper/horizontal-bar.js +10 -25
- package/dist/view/wrapper/index.js +3 -0
- package/dist/view/wrapper/line-group.js +11 -21
- package/dist/view/wrapper/line.js +11 -23
- package/dist/view/wrapper/map-bubble.js +9 -14
- package/dist/view/wrapper/map-world-bubble.js +9 -14
- package/dist/view/wrapper/map-world.js +9 -14
- package/dist/view/wrapper/map.js +9 -13
- package/dist/view/wrapper/mirror.js +7 -20
- package/dist/view/wrapper/pie.js +9 -12
- package/dist/view/wrapper/ring.js +10 -13
- package/dist/view/wrapper/scatter.js +13 -23
- package/dist/view/wrapper/table/pivot-table-display-name.js +2 -2
- package/dist/view/wrapper/table-element/components/formatter.js +2 -2
- package/dist/view/wrapper/table-element/components/records-body.js +8 -2
- package/dist/view/wrapper/table-element/components/records.js +2 -4
- package/dist/view/wrapper/treemap.js +8 -18
- package/dist/view/wrapper/trend.js +3 -2
- package/package.json +2 -2
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { CellType } from 'dtable-utils';
|
|
4
|
-
import {
|
|
4
|
+
import { isNaN, cloneDeep } from 'lodash-es';
|
|
5
5
|
import * as d3 from 'd3';
|
|
6
|
-
import classNames from 'classnames';
|
|
7
6
|
import intl from '../../intl';
|
|
8
7
|
import { sortDataByGroupSum } from '../../utils/column-utils';
|
|
9
8
|
import { EMPTY_NAME, CHART_THEME_COLOR, CHART_STYLE_COLORS } from '../../constants';
|
|
@@ -14,11 +13,6 @@ import ChartComponent from './chart-component';
|
|
|
14
13
|
class BarStack extends ChartComponent {
|
|
15
14
|
constructor(props) {
|
|
16
15
|
super(props);
|
|
17
|
-
this.handleResize = () => {
|
|
18
|
-
this.destroyChart();
|
|
19
|
-
this.createChart();
|
|
20
|
-
this.drawChart();
|
|
21
|
-
};
|
|
22
16
|
this.createChart = () => {
|
|
23
17
|
const {
|
|
24
18
|
chart
|
|
@@ -31,8 +25,8 @@ class BarStack extends ChartComponent {
|
|
|
31
25
|
const initConfig = {
|
|
32
26
|
insertPadding: 30,
|
|
33
27
|
borderRadius: 0.2,
|
|
34
|
-
marginLeft: y_axis_show_label ?
|
|
35
|
-
marginBottom: x_axis_show_label ?
|
|
28
|
+
marginLeft: y_axis_show_label ? this.getAxisTitleHeight(chart.config.y_axis_label_font_size) : 0,
|
|
29
|
+
marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0,
|
|
36
30
|
marginTop: display_each_block_data ? 15 : 0
|
|
37
31
|
};
|
|
38
32
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
@@ -145,7 +139,6 @@ class BarStack extends ChartComponent {
|
|
|
145
139
|
if (Number(firstEl.getAttribute('height')) === 0) {
|
|
146
140
|
firstEl = reverseGroup.slice(1).find(item => Number(item.getAttribute('height')) !== 0);
|
|
147
141
|
}
|
|
148
|
-
// Add mask rect
|
|
149
142
|
firstEl && this.addMaskRect((_firstEl = firstEl) === null || _firstEl === void 0 ? void 0 : _firstEl.parentNode, firstEl, x.bandwidth());
|
|
150
143
|
});
|
|
151
144
|
const [topG] = g._parents.slice(-1);
|
|
@@ -159,8 +152,11 @@ class BarStack extends ChartComponent {
|
|
|
159
152
|
if (y_axis_show_value) {
|
|
160
153
|
this.handleLabelToRectCenter(g, x.bandwidth());
|
|
161
154
|
}
|
|
155
|
+
this.animateFadeIn(this.contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
156
|
+
this.animateStackGrowInY(g);
|
|
162
157
|
}).on('click', (event, data) => {
|
|
163
|
-
|
|
158
|
+
const resultItem = data.data[1].get(data.key);
|
|
159
|
+
this.toggleRecords(resultItem);
|
|
164
160
|
}).on('mouseover', event => {
|
|
165
161
|
this.showTooltip(event);
|
|
166
162
|
this.handleAcitveAndInActiveState('inActive', event);
|
|
@@ -202,7 +198,7 @@ class BarStack extends ChartComponent {
|
|
|
202
198
|
} = this.props;
|
|
203
199
|
const {
|
|
204
200
|
y_axis_summary_method
|
|
205
|
-
} = chart;
|
|
201
|
+
} = chart.config;
|
|
206
202
|
const offsetX = d3.pointer(event)[0];
|
|
207
203
|
const offsetY = d3.pointer(event)[1];
|
|
208
204
|
const curRect = event.currentTarget;
|
|
@@ -247,24 +243,7 @@ class BarStack extends ChartComponent {
|
|
|
247
243
|
this.setActiveAndInActiveState(state, allGroup, curGroupName);
|
|
248
244
|
};
|
|
249
245
|
this.addMaskRect = (topG, rect, xWidth) => {
|
|
250
|
-
|
|
251
|
-
borderRadius
|
|
252
|
-
} = this.chartBoundingClientRect;
|
|
253
|
-
// Add mask rect
|
|
254
|
-
d3.select(topG).append('foreignObject').attr('x', rect.getAttribute('x')).attr('y', rect.getAttribute('y')).attr('opacity', rect.getAttribute('opacity')).attr('width', xWidth).attr('height', rect.getAttribute('height')).attr('data-groupName', rect.getAttribute('data-groupName')).attr('data-value', rect.getAttribute('data-value')).on('click', (event, data) => {
|
|
255
|
-
this.props.toggleRecords(data);
|
|
256
|
-
}).on('mouseover', event => {
|
|
257
|
-
this.showTooltip(event);
|
|
258
|
-
this.handleAcitveAndInActiveState('inActive', event);
|
|
259
|
-
}).on('mousemove', event => {
|
|
260
|
-
this.moveTooltip(event);
|
|
261
|
-
}).on('mouseleave', (event, data) => {
|
|
262
|
-
this.hiddenTooltip();
|
|
263
|
-
this.handleAcitveAndInActiveState('active', event);
|
|
264
|
-
}).append('xhtml:div').attr('style', `width: 100%; height: 100%; background-color: ${rect.getAttribute('fill')}; border-radius: ${xWidth * borderRadius}px ${xWidth * borderRadius}px 0px 0px`);
|
|
265
|
-
|
|
266
|
-
// Remove old rect
|
|
267
|
-
d3.select(rect).remove();
|
|
246
|
+
return this.addRoundedClip(rect, 'y', xWidth);
|
|
268
247
|
};
|
|
269
248
|
this.addLabelByEachStack = (data, topG, rect, x) => {
|
|
270
249
|
const {
|
|
@@ -328,8 +307,7 @@ class BarStack extends ChartComponent {
|
|
|
328
307
|
componentDidMount() {
|
|
329
308
|
this.createChart();
|
|
330
309
|
this.drawChart();
|
|
331
|
-
|
|
332
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
310
|
+
super.componentDidMount();
|
|
333
311
|
}
|
|
334
312
|
componentDidUpdate(prevProps) {
|
|
335
313
|
super.componentDidUpdate(prevProps);
|
|
@@ -341,22 +319,16 @@ class BarStack extends ChartComponent {
|
|
|
341
319
|
}
|
|
342
320
|
componentWillUnmount() {
|
|
343
321
|
this.destroyChart();
|
|
344
|
-
|
|
322
|
+
super.componentWillUnmount();
|
|
345
323
|
}
|
|
346
324
|
render() {
|
|
347
|
-
const {
|
|
348
|
-
chart
|
|
349
|
-
} = this.props;
|
|
350
325
|
const {
|
|
351
326
|
tooltipData,
|
|
352
327
|
toolTipPosition
|
|
353
328
|
} = this.state;
|
|
354
329
|
return /*#__PURE__*/React.createElement("div", {
|
|
355
330
|
ref: ref => this.container = ref,
|
|
356
|
-
className:
|
|
357
|
-
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
358
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
359
|
-
})
|
|
331
|
+
className: "sea-chart-container"
|
|
360
332
|
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
361
333
|
tooltipData: tooltipData,
|
|
362
334
|
toolTipPosition: toolTipPosition,
|
package/dist/view/wrapper/bar.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { debounce } from 'lodash-es';
|
|
4
3
|
import * as d3 from 'd3';
|
|
5
|
-
import classNames from 'classnames';
|
|
6
4
|
import { TYPE_COLOR_USING, CHART_STYLE_COLORS, CHART_THEME_COLOR } from '../../constants';
|
|
7
5
|
import { BaseUtils, isFunction } from '../../utils';
|
|
8
6
|
import { getLabelColor, getConvertedColorRules } from '../../utils/color-utils';
|
|
@@ -12,11 +10,6 @@ import ChartComponent from './chart-component';
|
|
|
12
10
|
class Bar extends ChartComponent {
|
|
13
11
|
constructor(props) {
|
|
14
12
|
super(props);
|
|
15
|
-
this.handleResize = () => {
|
|
16
|
-
this.destroyChart();
|
|
17
|
-
this.createChart();
|
|
18
|
-
this.drawChart();
|
|
19
|
-
};
|
|
20
13
|
this.createChart = () => {
|
|
21
14
|
const {
|
|
22
15
|
chart
|
|
@@ -29,8 +22,8 @@ class Bar extends ChartComponent {
|
|
|
29
22
|
const initConfig = {
|
|
30
23
|
insertPadding: 30,
|
|
31
24
|
borderRadius: 0.2,
|
|
32
|
-
marginLeft: y_axis_show_label ?
|
|
33
|
-
marginBottom: x_axis_show_label ?
|
|
25
|
+
marginLeft: y_axis_show_label ? this.getAxisTitleHeight(chart.config.y_axis_label_font_size) : 0,
|
|
26
|
+
marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0,
|
|
34
27
|
marginTop: y_axis_show_value ? 15 : 0
|
|
35
28
|
};
|
|
36
29
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
@@ -169,7 +162,7 @@ class Bar extends ChartComponent {
|
|
|
169
162
|
this.checkTickOverlap(g);
|
|
170
163
|
});
|
|
171
164
|
const contentWrapper = this.chart.append('g').attr('class', 'content-wrapper');
|
|
172
|
-
contentWrapper.selectAll().data(data).join('rect').attr('opacity', 1).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('data-groupName', d => d.name).attr('
|
|
165
|
+
contentWrapper.selectAll().data(data).join('rect').attr('opacity', 1).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('data-groupName', d => d.name).attr('x', d => x(d.name)).attr('y', d => y(d.value)).attr('width', x.bandwidth()).attr('height', d => y(0) - y(d.value)).call(g => {
|
|
173
166
|
g.nodes().forEach(path => {
|
|
174
167
|
// Add label
|
|
175
168
|
if (y_axis_show_value) {
|
|
@@ -185,9 +178,7 @@ class Bar extends ChartComponent {
|
|
|
185
178
|
}
|
|
186
179
|
// add rect borderRadius
|
|
187
180
|
this.addClipPath({
|
|
188
|
-
rect: path
|
|
189
|
-
parentNode: path.parentNode,
|
|
190
|
-
rectId: path.getAttribute('data-slugid')
|
|
181
|
+
rect: path
|
|
191
182
|
});
|
|
192
183
|
});
|
|
193
184
|
}).on('click', (event, data) => {
|
|
@@ -200,6 +191,9 @@ class Bar extends ChartComponent {
|
|
|
200
191
|
}).on('mouseleave', event => {
|
|
201
192
|
this.hiddenTooltip(event);
|
|
202
193
|
this.handleAcitveAndInActiveState('active', event);
|
|
194
|
+
}).call(g => {
|
|
195
|
+
this.animateRectGrowInY(g);
|
|
196
|
+
this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
203
197
|
});
|
|
204
198
|
if (display_goal_line && goal_label && goal_value) {
|
|
205
199
|
this.setDispalyGoalLine(goal_label, goal_value, insertPadding, y);
|
|
@@ -214,8 +208,7 @@ class Bar extends ChartComponent {
|
|
|
214
208
|
componentDidMount() {
|
|
215
209
|
this.createChart();
|
|
216
210
|
this.drawChart();
|
|
217
|
-
|
|
218
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
211
|
+
super.componentDidMount();
|
|
219
212
|
}
|
|
220
213
|
componentDidUpdate(prevProps) {
|
|
221
214
|
super.componentDidUpdate(prevProps);
|
|
@@ -227,22 +220,16 @@ class Bar extends ChartComponent {
|
|
|
227
220
|
}
|
|
228
221
|
componentWillUnmount() {
|
|
229
222
|
this.destroyChart();
|
|
230
|
-
|
|
223
|
+
super.componentWillUnmount();
|
|
231
224
|
}
|
|
232
225
|
render() {
|
|
233
|
-
const {
|
|
234
|
-
chart
|
|
235
|
-
} = this.props;
|
|
236
226
|
const {
|
|
237
227
|
tooltipData,
|
|
238
228
|
toolTipPosition
|
|
239
229
|
} = this.state;
|
|
240
230
|
return /*#__PURE__*/React.createElement("div", {
|
|
241
231
|
ref: ref => this.container = ref,
|
|
242
|
-
className:
|
|
243
|
-
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
244
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
245
|
-
})
|
|
232
|
+
className: "sea-chart-container"
|
|
246
233
|
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
247
234
|
tooltipData: tooltipData,
|
|
248
235
|
toolTipPosition: toolTipPosition,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { isNumber } from 'dtable-utils';
|
|
2
|
+
import { isNumber, isEmpty } from 'dtable-utils';
|
|
3
3
|
import { BaseUtils } from '../../utils';
|
|
4
4
|
import intl from '../../intl';
|
|
5
5
|
import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_THEME_COLOR } from '../../constants';
|
|
@@ -43,7 +43,7 @@ class BasicNumericCard extends Component {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
this.formatData = data => {
|
|
46
|
-
if (
|
|
46
|
+
if (isEmpty(data)) return intl.get(EMPTY_NAME);
|
|
47
47
|
const {
|
|
48
48
|
chart,
|
|
49
49
|
summaryColumn
|
|
@@ -58,6 +58,10 @@ class BasicNumericCard extends Component {
|
|
|
58
58
|
return formattedContent;
|
|
59
59
|
}
|
|
60
60
|
let string = data + '';
|
|
61
|
+
const isNegative = string.startsWith('-');
|
|
62
|
+
if (isNegative) {
|
|
63
|
+
string = string.slice(1);
|
|
64
|
+
}
|
|
61
65
|
const isFloat = string.indexOf('.') > 0;
|
|
62
66
|
if (isFloat) {
|
|
63
67
|
string = string.slice(0, string.indexOf('.'));
|
|
@@ -76,6 +80,9 @@ class BasicNumericCard extends Component {
|
|
|
76
80
|
if (content[0] === ',') {
|
|
77
81
|
content = content.slice(1);
|
|
78
82
|
}
|
|
83
|
+
if (isNegative) {
|
|
84
|
+
content = '-' + content;
|
|
85
|
+
}
|
|
79
86
|
if (isFloat) {
|
|
80
87
|
const initString = data + '';
|
|
81
88
|
content = content + initString.slice(initString.indexOf('.'));
|