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,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { getTableColumnByKey, getTableById } from 'dtable-utils';
|
|
4
|
-
import { debounce } from 'lodash-es';
|
|
5
4
|
import * as d3 from 'd3';
|
|
6
|
-
import classNames from 'classnames';
|
|
7
5
|
import intl from '../../intl';
|
|
8
6
|
import { EMPTY_NAME, CHART_THEME_COLOR, CHART_LINE_TYPES } from '../../constants';
|
|
9
7
|
import { BaseUtils, isFunction } from '../../utils';
|
|
@@ -12,11 +10,6 @@ import ChartComponent from './chart-component';
|
|
|
12
10
|
class Combination 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
|
|
@@ -30,9 +23,9 @@ class Combination extends ChartComponent {
|
|
|
30
23
|
const initConfig = {
|
|
31
24
|
insertPadding: 30,
|
|
32
25
|
borderRadius: 0.2,
|
|
33
|
-
marginLeft: show_y_axis_left_label ?
|
|
34
|
-
marginRight: show_y_axis_right_label ?
|
|
35
|
-
marginBottom: x_axis_show_label ?
|
|
26
|
+
marginLeft: show_y_axis_left_label ? this.getAxisTitleHeight(chart.config.y_axis_left_label_font_size) : 0,
|
|
27
|
+
marginRight: show_y_axis_right_label ? this.getAxisTitleHeight(chart.config.y_axis_right_label_font_size) : 0,
|
|
28
|
+
marginBottom: x_axis_show_label ? this.getAxisTitleHeight(chart.config.x_axis_label_font_size) : 0,
|
|
36
29
|
marginTop: display_data ? 15 : 0
|
|
37
30
|
};
|
|
38
31
|
this.initChart(this.container, chart === null || chart === void 0 ? void 0 : chart.id, initConfig);
|
|
@@ -100,7 +93,7 @@ class Combination extends ChartComponent {
|
|
|
100
93
|
showRightValue = true;
|
|
101
94
|
}
|
|
102
95
|
this.setCombinationColorMap(data, leftSummaryColumn, rightSummaryColumn);
|
|
103
|
-
const rightNiceEnd = d3.nice(0, d3.max(data, d => d.value_right), 5)[1];
|
|
96
|
+
const rightNiceEnd = d3.nice(0, d3.max(data, d => d.value_right) || 0, 5)[1];
|
|
104
97
|
const rightY = d3.scaleLinear().domain(y_axis_auto_range_right ? [d3.min(data, d => d.value_right), rightNiceEnd] : [y_axis_min_right, y_axis_max_right]).range([chartHeight - insertPadding, insertPadding + marginTop]);
|
|
105
98
|
|
|
106
99
|
// Y axis (right)
|
|
@@ -146,14 +139,12 @@ class Combination extends ChartComponent {
|
|
|
146
139
|
return currentTheme.colors[0];
|
|
147
140
|
}
|
|
148
141
|
return d.color;
|
|
149
|
-
}).attr('data-value', d => BaseUtils.getSummaryValueDisplayString(leftSummaryColumn, d.value_left, y_axis_left_summary_method)).attr('data-groupName', d => d.name).
|
|
142
|
+
}).attr('data-value', d => BaseUtils.getSummaryValueDisplayString(leftSummaryColumn, d.value_left, y_axis_left_summary_method)).attr('data-groupName', d => d.name).call(g => {
|
|
150
143
|
g.nodes().forEach(rect => {
|
|
151
144
|
const parentNode = rect.parentNode;
|
|
152
145
|
// add rect borderRadius
|
|
153
146
|
this.addClipPath({
|
|
154
|
-
rect
|
|
155
|
-
parentNode,
|
|
156
|
-
rectId: rect.getAttribute('data-slugid')
|
|
147
|
+
rect
|
|
157
148
|
});
|
|
158
149
|
|
|
159
150
|
// Add label
|
|
@@ -185,6 +176,9 @@ class Combination extends ChartComponent {
|
|
|
185
176
|
}).on('mouseleave', (event, data) => {
|
|
186
177
|
this.hiddenTooltip();
|
|
187
178
|
this.handleAcitveAndInActiveState('active', event);
|
|
179
|
+
}).call(g => {
|
|
180
|
+
this.animateRectGrowInY(g);
|
|
181
|
+
this.animateFadeIn(this.chart.select('.content-wrapper').selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
188
182
|
});
|
|
189
183
|
|
|
190
184
|
// Line group
|
|
@@ -306,7 +300,7 @@ class Combination extends ChartComponent {
|
|
|
306
300
|
const rightContentWrapper = this.chart.append('g').attr('class', 'lines-wrapper');
|
|
307
301
|
|
|
308
302
|
// line
|
|
309
|
-
rightContentWrapper.append('path').attr('fill', 'none').attr('stroke', currentTheme.colors[1]).attr('stroke-width', 2).attr('d', () => line(data));
|
|
303
|
+
rightContentWrapper.append('path').attr('fill', 'none').attr('stroke', currentTheme.colors[1]).attr('stroke-width', 2).attr('d', () => line(data)).call(g => this.animateFadeIn(g));
|
|
310
304
|
|
|
311
305
|
// circle
|
|
312
306
|
circleData.forEach(item => {
|
|
@@ -337,6 +331,8 @@ class Combination extends ChartComponent {
|
|
|
337
331
|
this.updateCombinationCircleStyle(event, 'zoomOut');
|
|
338
332
|
});
|
|
339
333
|
});
|
|
334
|
+
this.animateFadeIn(rightContentWrapper.selectAll('circle'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
335
|
+
this.animateFadeIn(rightContentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
340
336
|
};
|
|
341
337
|
this.showTooltip = (event, _ref4) => {
|
|
342
338
|
let {
|
|
@@ -415,11 +411,11 @@ class Combination extends ChartComponent {
|
|
|
415
411
|
};
|
|
416
412
|
this.updateCombinationCircleStyle = (event, state) => {
|
|
417
413
|
if (state === 'zoomIn') {
|
|
418
|
-
d3.select(event.currentTarget).transition().duration(this.
|
|
414
|
+
d3.select(event.currentTarget).transition().duration(this.interactionDuration).attr('r', 5);
|
|
419
415
|
return;
|
|
420
416
|
}
|
|
421
417
|
const circles = d3.select(event.currentTarget.parentNode).selectAll('circle').nodes();
|
|
422
|
-
circles.forEach(circle => d3.select(circle).transition().duration(this.
|
|
418
|
+
circles.forEach(circle => d3.select(circle).transition().duration(this.interactionDuration).attr('r', 3));
|
|
423
419
|
};
|
|
424
420
|
this.updateLastLegendToCircle = () => {
|
|
425
421
|
const legendWrapper = this.chart.select('.legend-wrapper').node();
|
|
@@ -444,8 +440,7 @@ class Combination extends ChartComponent {
|
|
|
444
440
|
componentDidMount() {
|
|
445
441
|
this.createChart();
|
|
446
442
|
this.drawChart();
|
|
447
|
-
|
|
448
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
443
|
+
super.componentDidMount();
|
|
449
444
|
}
|
|
450
445
|
componentDidUpdate(prevProps) {
|
|
451
446
|
super.componentDidUpdate(prevProps);
|
|
@@ -457,23 +452,16 @@ class Combination extends ChartComponent {
|
|
|
457
452
|
}
|
|
458
453
|
componentWillUnmount() {
|
|
459
454
|
this.destroyChart();
|
|
460
|
-
|
|
455
|
+
super.componentWillUnmount();
|
|
461
456
|
}
|
|
462
457
|
render() {
|
|
463
|
-
const {
|
|
464
|
-
chart
|
|
465
|
-
} = this.props;
|
|
466
458
|
const {
|
|
467
459
|
tooltipData,
|
|
468
460
|
toolTipPosition
|
|
469
461
|
} = this.state;
|
|
470
462
|
return /*#__PURE__*/React.createElement("div", {
|
|
471
463
|
ref: ref => this.container = ref,
|
|
472
|
-
className:
|
|
473
|
-
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
474
|
-
'show-y-axis-left-label': this.isShowYAxisLeftLabel(chart),
|
|
475
|
-
'show-y-axis-right-label': this.isShowYAxisRightLabel(chart)
|
|
476
|
-
})
|
|
464
|
+
className: "sea-chart-container"
|
|
477
465
|
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
478
466
|
tooltipData: tooltipData,
|
|
479
467
|
toolTipPosition: toolTipPosition,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { cloneDeep } from 'lodash-es';
|
|
4
4
|
import * as d3 from 'd3';
|
|
5
|
-
import classNames from 'classnames';
|
|
6
5
|
import { CHART_THEME_COLOR } from '../../constants';
|
|
7
6
|
import { BaseUtils } from '../../utils';
|
|
8
7
|
import intl from '../../intl';
|
|
@@ -11,11 +10,6 @@ import ChartComponent from './chart-component';
|
|
|
11
10
|
class Completeness extends ChartComponent {
|
|
12
11
|
constructor(props) {
|
|
13
12
|
super(props);
|
|
14
|
-
this.handleResize = () => {
|
|
15
|
-
this.destroyChart();
|
|
16
|
-
this.createChart();
|
|
17
|
-
this.drawChart();
|
|
18
|
-
};
|
|
19
13
|
this.createChart = () => {
|
|
20
14
|
const {
|
|
21
15
|
chart
|
|
@@ -139,7 +133,7 @@ class Completeness extends ChartComponent {
|
|
|
139
133
|
}).selectAll().data(_ref6 => {
|
|
140
134
|
let [_, d] = _ref6;
|
|
141
135
|
return d;
|
|
142
|
-
}).join('rect').attr('class', 'rect').attr('opacity', 1).attr('x', d => x(d[0]) - Number(yAxis.node().getAttribute('data-axisWidth'))).attr('y', d => localY(d.groupby)).attr('
|
|
136
|
+
}).join('rect').attr('class', 'rect').attr('opacity', 1).attr('x', d => x(d[0]) - Number(yAxis.node().getAttribute('data-axisWidth'))).attr('y', d => localY(d.groupby)).attr('width', d => x(d[1]) - x(d[0])).attr('height', localY.bandwidth()).attr('fill', d => {
|
|
143
137
|
const key = d.key;
|
|
144
138
|
const groupby = d.groupby;
|
|
145
139
|
if (key === 'rest') {
|
|
@@ -150,7 +144,7 @@ class Completeness extends ChartComponent {
|
|
|
150
144
|
}
|
|
151
145
|
return colors[0];
|
|
152
146
|
}).attr('data-value', d => d.rawData.value).attr('data-groupName', d => d.rawData.slugId).attr('data-tooltipTitle', d => d.rawData.name).attr('data-tooltipName', d => d.key).attr('data-groupBy', d => d.groupby).on('click', (event, data) => {
|
|
153
|
-
self.
|
|
147
|
+
self.toggleRecords(data.rawData);
|
|
154
148
|
}).on('mouseover', event => {
|
|
155
149
|
self.showTooltip(event);
|
|
156
150
|
self.handleAcitveAndInActiveState('inActive', event);
|
|
@@ -191,6 +185,8 @@ class Completeness extends ChartComponent {
|
|
|
191
185
|
});
|
|
192
186
|
}
|
|
193
187
|
});
|
|
188
|
+
this.animateStackGrowInX(contentWrapper.selectAll('rect'));
|
|
189
|
+
this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
194
190
|
this.setLegend({
|
|
195
191
|
legendName: 'groupby',
|
|
196
192
|
theme,
|
|
@@ -217,17 +213,11 @@ class Completeness extends ChartComponent {
|
|
|
217
213
|
const curGroupName = event.currentTarget.getAttribute('data-groupName');
|
|
218
214
|
this.setActiveAndInActiveState(state, allGroup, curGroupName);
|
|
219
215
|
};
|
|
220
|
-
this.showTooltip =
|
|
221
|
-
|
|
216
|
+
this.showTooltip = event => {
|
|
217
|
+
const {
|
|
222
218
|
offsetX,
|
|
223
219
|
offsetY
|
|
224
220
|
} = event;
|
|
225
|
-
if (isDiv) {
|
|
226
|
-
const initX = Number(event.currentTarget.getAttribute('data-x'));
|
|
227
|
-
const initY = Number(event.currentTarget.getAttribute('data-y'));
|
|
228
|
-
offsetX = offsetX + initX;
|
|
229
|
-
offsetY = offsetY + initY;
|
|
230
|
-
}
|
|
231
221
|
const groupby = event.currentTarget.getAttribute('data-groupBy');
|
|
232
222
|
const newTooltipData = {
|
|
233
223
|
title: event.currentTarget.getAttribute('data-tooltipTitle'),
|
|
@@ -247,17 +237,11 @@ class Completeness extends ChartComponent {
|
|
|
247
237
|
}
|
|
248
238
|
});
|
|
249
239
|
};
|
|
250
|
-
this.moveTooltip =
|
|
251
|
-
|
|
240
|
+
this.moveTooltip = event => {
|
|
241
|
+
const {
|
|
252
242
|
offsetX,
|
|
253
243
|
offsetY
|
|
254
244
|
} = event;
|
|
255
|
-
if (isDiv) {
|
|
256
|
-
const initX = Number(event.currentTarget.getAttribute('data-x'));
|
|
257
|
-
const initY = Number(event.currentTarget.getAttribute('data-y'));
|
|
258
|
-
offsetX = offsetX + initX;
|
|
259
|
-
offsetY = offsetY + initY;
|
|
260
|
-
}
|
|
261
245
|
this.setState({
|
|
262
246
|
toolTipPosition: {
|
|
263
247
|
offsetX,
|
|
@@ -365,28 +349,7 @@ class Completeness extends ChartComponent {
|
|
|
365
349
|
return allGroup;
|
|
366
350
|
};
|
|
367
351
|
this.addMaskRect = (topG, rect, yAxis) => {
|
|
368
|
-
|
|
369
|
-
const {
|
|
370
|
-
borderRadius
|
|
371
|
-
} = this.chartBoundingClientRect;
|
|
372
|
-
// Add mask rect
|
|
373
|
-
d3.select(topG).append('foreignObject').attr('class', rect.getAttribute('class')).attr('opacity', rect.getAttribute('opacity')).attr('x', rect.getAttribute('x')).attr('y', rect.getAttribute('y')).attr('data-y', rect.parentNode.parentNode.getAttribute('data-transform')).attr('width', rect.getAttribute('width')).attr('height', rect.getAttribute('height')).attr('data-groupName', rect.getAttribute('data-groupName')).attr('data-value', rect.getAttribute('data-value')).attr('data-tooltipTitle', rect.getAttribute('data-tooltipTitle')).attr('data-tooltipName', rect.getAttribute('data-tooltipName')).attr('data-groupBy', rect.getAttribute('data-groupBy')).attr('data-x', () => {
|
|
374
|
-
const x = Number(rect.getAttribute('x'));
|
|
375
|
-
return x + Number(yAxis.node().getAttribute('data-axisWidth'));
|
|
376
|
-
}).on('click', (event, data) => {
|
|
377
|
-
this.props.toggleRecords(data);
|
|
378
|
-
}).on('mouseover', event => {
|
|
379
|
-
this.showTooltip(event, true);
|
|
380
|
-
this.handleAcitveAndInActiveState('inActive', event);
|
|
381
|
-
}).on('mousemove', event => {
|
|
382
|
-
this.moveTooltip(event, true);
|
|
383
|
-
}).on('mouseleave', event => {
|
|
384
|
-
this.hiddenTooltip();
|
|
385
|
-
this.handleAcitveAndInActiveState('active', event);
|
|
386
|
-
}).append('xhtml:div').attr('style', `width: 100%; height: 100%; background-color: ${rect.getAttribute('fill')}; border-radius: 0px ${xWidth * borderRadius}px ${xWidth * borderRadius}px 0px`);
|
|
387
|
-
|
|
388
|
-
// Remove old rect
|
|
389
|
-
d3.select(rect).remove();
|
|
352
|
+
return this.addRoundedClip(rect, 'x');
|
|
390
353
|
};
|
|
391
354
|
this.chart = null;
|
|
392
355
|
this.state = {
|
|
@@ -395,11 +358,9 @@ class Completeness extends ChartComponent {
|
|
|
395
358
|
};
|
|
396
359
|
}
|
|
397
360
|
componentDidMount() {
|
|
398
|
-
super.componentDidMount();
|
|
399
361
|
this.createChart();
|
|
400
362
|
this.drawChart();
|
|
401
|
-
|
|
402
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
363
|
+
super.componentDidMount();
|
|
403
364
|
}
|
|
404
365
|
componentDidUpdate(prevProps) {
|
|
405
366
|
super.componentDidUpdate(prevProps);
|
|
@@ -410,24 +371,17 @@ class Completeness extends ChartComponent {
|
|
|
410
371
|
}
|
|
411
372
|
}
|
|
412
373
|
componentWillUnmount() {
|
|
413
|
-
super.componentWillUnmount();
|
|
414
374
|
this.destroyChart();
|
|
415
|
-
|
|
375
|
+
super.componentWillUnmount();
|
|
416
376
|
}
|
|
417
377
|
render() {
|
|
418
|
-
const {
|
|
419
|
-
chart
|
|
420
|
-
} = this.props;
|
|
421
378
|
const {
|
|
422
379
|
tooltipData,
|
|
423
380
|
toolTipPosition
|
|
424
381
|
} = this.state;
|
|
425
382
|
return /*#__PURE__*/React.createElement("div", {
|
|
426
383
|
ref: ref => this.container = ref,
|
|
427
|
-
className:
|
|
428
|
-
'show-x-axis-label': this.isShowHorizontalAxisLabel(chart),
|
|
429
|
-
'show-y-axis-label': this.isShowVerticalAxisLabel(chart)
|
|
430
|
-
})
|
|
384
|
+
className: "sea-chart-container"
|
|
431
385
|
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
432
386
|
tooltipData: tooltipData,
|
|
433
387
|
toolTipPosition: toolTipPosition,
|
|
@@ -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 { CHART_THEME_COLOR } from '../../constants';
|
|
7
5
|
import { BaseUtils } from '../../utils';
|
|
8
6
|
import intl from '../../intl';
|
|
@@ -11,11 +9,6 @@ import ChartComponent from './chart-component';
|
|
|
11
9
|
class Completeness extends ChartComponent {
|
|
12
10
|
constructor(props) {
|
|
13
11
|
super(props);
|
|
14
|
-
this.handleResize = () => {
|
|
15
|
-
this.destroyChart();
|
|
16
|
-
this.createChart();
|
|
17
|
-
this.drawChart();
|
|
18
|
-
};
|
|
19
12
|
this.createChart = () => {
|
|
20
13
|
const {
|
|
21
14
|
chart
|
|
@@ -83,7 +76,7 @@ class Completeness extends ChartComponent {
|
|
|
83
76
|
});
|
|
84
77
|
|
|
85
78
|
// X axis
|
|
86
|
-
const niceEnd = d3.nice(0, d3.max(newSeries, d => d[1].sumValue), 5)[1];
|
|
79
|
+
const niceEnd = d3.nice(0, d3.max(newSeries, d => d[1].sumValue) || 0, 5)[1];
|
|
87
80
|
const x = d3.scaleLinear().domain(y_axis_auto_range ? [0, niceEnd] : [y_axis_min || 0, y_axis_max || niceEnd]).range([Number(yAxis.node().getAttribute('data-axisWidth')), chartWidth - insertPadding - marginRight]);
|
|
88
81
|
this.chart.append('g').attr('class', 'x-axis-wrapper').attr('transform', `translate(0, ${chartHeight - insertPadding})`).call(d3.axisBottom(x).tickSizeInner(0).ticks(5)).call(g => {
|
|
89
82
|
g.selectAll('.domain').remove();
|
|
@@ -134,7 +127,7 @@ class Completeness extends ChartComponent {
|
|
|
134
127
|
});
|
|
135
128
|
}
|
|
136
129
|
}).on('click', (event, data) => {
|
|
137
|
-
this.
|
|
130
|
+
this.toggleRecords(data.data);
|
|
138
131
|
}).on('mouseover', event => {
|
|
139
132
|
this.showTooltip(event);
|
|
140
133
|
this.handleAcitveAndInActiveState('inActive', event);
|
|
@@ -143,6 +136,9 @@ class Completeness extends ChartComponent {
|
|
|
143
136
|
}).on('mouseleave', (event, data) => {
|
|
144
137
|
this.hiddenTooltip();
|
|
145
138
|
this.handleAcitveAndInActiveState('active', event);
|
|
139
|
+
}).call(g => {
|
|
140
|
+
this.animateStackGrowInX(g);
|
|
141
|
+
this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
146
142
|
});
|
|
147
143
|
this.setLegend({
|
|
148
144
|
legendName: 'group_name',
|
|
@@ -157,17 +153,11 @@ class Completeness extends ChartComponent {
|
|
|
157
153
|
const curGroupName = event.currentTarget.getAttribute('data-groupName');
|
|
158
154
|
this.setActiveAndInActiveState(state, allGroup, curGroupName);
|
|
159
155
|
};
|
|
160
|
-
this.showTooltip =
|
|
161
|
-
|
|
156
|
+
this.showTooltip = event => {
|
|
157
|
+
const {
|
|
162
158
|
offsetX,
|
|
163
159
|
offsetY
|
|
164
160
|
} = event;
|
|
165
|
-
if (isDiv) {
|
|
166
|
-
const initX = Number(event.currentTarget.getAttribute('data-x'));
|
|
167
|
-
const initY = Number(event.currentTarget.getAttribute('y'));
|
|
168
|
-
offsetX = offsetX + initX;
|
|
169
|
-
offsetY = offsetY + initY;
|
|
170
|
-
}
|
|
171
161
|
const {
|
|
172
162
|
chartColorTheme
|
|
173
163
|
} = this.props;
|
|
@@ -175,7 +165,7 @@ class Completeness extends ChartComponent {
|
|
|
175
165
|
const newTooltipData = {
|
|
176
166
|
title: event.currentTarget.getAttribute('data-tooltipTitle'),
|
|
177
167
|
items: [{
|
|
178
|
-
color: event.currentTarget.getAttribute('data-
|
|
168
|
+
color: event.currentTarget.getAttribute('data-tooltipName') === 'rest' ? '#bdbdbd' : colors[0],
|
|
179
169
|
name: intl.get(event.currentTarget.getAttribute('data-tooltipName')),
|
|
180
170
|
value: event.currentTarget.getAttribute('data-value')
|
|
181
171
|
}]
|
|
@@ -190,17 +180,11 @@ class Completeness extends ChartComponent {
|
|
|
190
180
|
}
|
|
191
181
|
});
|
|
192
182
|
};
|
|
193
|
-
this.moveTooltip =
|
|
194
|
-
|
|
183
|
+
this.moveTooltip = event => {
|
|
184
|
+
const {
|
|
195
185
|
offsetX,
|
|
196
186
|
offsetY
|
|
197
187
|
} = event;
|
|
198
|
-
if (isDiv) {
|
|
199
|
-
const initX = Number(event.currentTarget.getAttribute('data-x'));
|
|
200
|
-
const initY = Number(event.currentTarget.getAttribute('y'));
|
|
201
|
-
offsetX = offsetX + initX;
|
|
202
|
-
offsetY = offsetY + initY;
|
|
203
|
-
}
|
|
204
188
|
this.setState({
|
|
205
189
|
toolTipPosition: {
|
|
206
190
|
offsetX,
|
|
@@ -253,28 +237,7 @@ class Completeness extends ChartComponent {
|
|
|
253
237
|
return allGroup;
|
|
254
238
|
};
|
|
255
239
|
this.addMaskRect = (topG, rect, yAxis) => {
|
|
256
|
-
|
|
257
|
-
const {
|
|
258
|
-
borderRadius
|
|
259
|
-
} = this.chartBoundingClientRect;
|
|
260
|
-
// Add mask rect
|
|
261
|
-
d3.select(topG).append('foreignObject').attr('opacity', rect.getAttribute('opacity')).attr('x', rect.getAttribute('x')).attr('y', rect.getAttribute('y')).attr('width', rect.getAttribute('width')).attr('height', rect.getAttribute('height')).attr('data-groupName', rect.getAttribute('data-groupName')).attr('data-value', rect.getAttribute('data-value')).attr('data-tooltipTitle', rect.getAttribute('data-tooltipTitle')).attr('data-tooltipName', rect.getAttribute('data-tooltipName')).attr('data-x', () => {
|
|
262
|
-
const x = Number(rect.getAttribute('x'));
|
|
263
|
-
return x + Number(yAxis.node().getAttribute('data-axisWidth'));
|
|
264
|
-
}).on('click', (event, data) => {
|
|
265
|
-
this.props.toggleRecords(data);
|
|
266
|
-
}).on('mouseover', event => {
|
|
267
|
-
this.showTooltip(event, true);
|
|
268
|
-
this.handleAcitveAndInActiveState('inActive', event);
|
|
269
|
-
}).on('mousemove', event => {
|
|
270
|
-
this.moveTooltip(event, true);
|
|
271
|
-
}).on('mouseleave', event => {
|
|
272
|
-
this.hiddenTooltip();
|
|
273
|
-
this.handleAcitveAndInActiveState('active', event);
|
|
274
|
-
}).append('xhtml:div').attr('style', `width: 100%; height: 100%; background-color: ${rect.getAttribute('fill')}; border-radius: 0px ${xWidth * borderRadius}px ${xWidth * borderRadius}px 0px`);
|
|
275
|
-
|
|
276
|
-
// Remove old rect
|
|
277
|
-
d3.select(rect).remove();
|
|
240
|
+
return this.addRoundedClip(rect, 'x');
|
|
278
241
|
};
|
|
279
242
|
this.chart = null;
|
|
280
243
|
this.state = {
|
|
@@ -283,11 +246,9 @@ class Completeness extends ChartComponent {
|
|
|
283
246
|
};
|
|
284
247
|
}
|
|
285
248
|
componentDidMount() {
|
|
286
|
-
super.componentDidMount();
|
|
287
249
|
this.createChart();
|
|
288
250
|
this.drawChart();
|
|
289
|
-
|
|
290
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
251
|
+
super.componentDidMount();
|
|
291
252
|
}
|
|
292
253
|
componentDidUpdate(prevProps) {
|
|
293
254
|
super.componentDidUpdate(prevProps);
|
|
@@ -298,24 +259,17 @@ class Completeness extends ChartComponent {
|
|
|
298
259
|
}
|
|
299
260
|
}
|
|
300
261
|
componentWillUnmount() {
|
|
301
|
-
super.componentWillUnmount();
|
|
302
262
|
this.destroyChart();
|
|
303
|
-
|
|
263
|
+
super.componentWillUnmount();
|
|
304
264
|
}
|
|
305
265
|
render() {
|
|
306
|
-
const {
|
|
307
|
-
chart
|
|
308
|
-
} = this.props;
|
|
309
266
|
const {
|
|
310
267
|
tooltipData,
|
|
311
268
|
toolTipPosition
|
|
312
269
|
} = this.state;
|
|
313
270
|
return /*#__PURE__*/React.createElement("div", {
|
|
314
271
|
ref: ref => this.container = ref,
|
|
315
|
-
className:
|
|
316
|
-
'show-x-axis-label': this.isShowHorizontalAxisLabel(chart),
|
|
317
|
-
'show-y-axis-label': this.isShowVerticalAxisLabel(chart)
|
|
318
|
-
})
|
|
272
|
+
className: "sea-chart-container"
|
|
319
273
|
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
320
274
|
tooltipData: tooltipData,
|
|
321
275
|
toolTipPosition: toolTipPosition,
|
|
@@ -1,6 +1,5 @@
|
|
|
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
4
|
import { CHART_THEME_COLOR } from '../../constants';
|
|
6
5
|
import { BaseUtils, isFunction } from '../../utils';
|
|
@@ -25,17 +24,6 @@ class Dashboard extends ChartComponent {
|
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
|
-
this.componentDidMount = () => {
|
|
29
|
-
this.createChart();
|
|
30
|
-
this.drawChart();
|
|
31
|
-
this.debouncedHandleResize = debounce(this.handleResize, 300);
|
|
32
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
33
|
-
};
|
|
34
|
-
this.handleResize = () => {
|
|
35
|
-
this.destroyChart();
|
|
36
|
-
this.createChart();
|
|
37
|
-
this.drawChart();
|
|
38
|
-
};
|
|
39
27
|
this.createChart = () => {
|
|
40
28
|
const {
|
|
41
29
|
chart
|
|
@@ -59,7 +47,7 @@ class Dashboard extends ChartComponent {
|
|
|
59
47
|
height: chartHeight,
|
|
60
48
|
insertPadding
|
|
61
49
|
} = this.chartBoundingClientRect;
|
|
62
|
-
const value = Number(data) * 100;
|
|
50
|
+
const value = (Number(data) || 0) * 100;
|
|
63
51
|
const formatValue = value >= 100 ? 100 : value.toFixed(1);
|
|
64
52
|
const innerRadius = Math.min(chartWidth, chartHeight) / 2 * 0.7;
|
|
65
53
|
const outerRadius = Math.min(chartWidth, chartHeight) / 2 * 0.75;
|
|
@@ -98,6 +86,7 @@ class Dashboard extends ChartComponent {
|
|
|
98
86
|
// Draw total
|
|
99
87
|
this.drawTotal(g.node().parentNode, formatValue);
|
|
100
88
|
});
|
|
89
|
+
this.animateFadeIn(this.chart.selectAll('path, circle, rect, line, text'));
|
|
101
90
|
};
|
|
102
91
|
this.drawTicks = (left, offsetX, top, offsetY, startAngle, endAngle, arc) => {
|
|
103
92
|
const {
|
|
@@ -226,6 +215,11 @@ class Dashboard extends ChartComponent {
|
|
|
226
215
|
toolTipPosition: null
|
|
227
216
|
};
|
|
228
217
|
}
|
|
218
|
+
componentDidMount() {
|
|
219
|
+
this.createChart();
|
|
220
|
+
this.drawChart();
|
|
221
|
+
super.componentDidMount();
|
|
222
|
+
}
|
|
229
223
|
componentDidUpdate(prevProps) {
|
|
230
224
|
super.componentDidUpdate(prevProps);
|
|
231
225
|
if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
@@ -236,7 +230,7 @@ class Dashboard extends ChartComponent {
|
|
|
236
230
|
}
|
|
237
231
|
componentWillUnmount() {
|
|
238
232
|
this.destroyChart();
|
|
239
|
-
|
|
233
|
+
super.componentWillUnmount();
|
|
240
234
|
}
|
|
241
235
|
render() {
|
|
242
236
|
const {
|
|
@@ -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 { FUNNEL_LABEL_FORMAT, FUNNEL_LABEL_POSITIONS, CHART_THEME_COLOR } from '../../constants';
|
|
7
5
|
import { BaseUtils, getSortedDataByGivenOrder } from '../../utils';
|
|
8
6
|
import ToolTip from '../../components/tooltip';
|
|
@@ -10,11 +8,6 @@ import ChartComponent from './chart-component';
|
|
|
10
8
|
class Funnel extends ChartComponent {
|
|
11
9
|
constructor(props) {
|
|
12
10
|
super(props);
|
|
13
|
-
this.handleResize = () => {
|
|
14
|
-
this.destroyChart();
|
|
15
|
-
this.createChart();
|
|
16
|
-
this.drawChart();
|
|
17
|
-
};
|
|
18
11
|
this.createChart = () => {
|
|
19
12
|
const {
|
|
20
13
|
chart
|
|
@@ -134,7 +127,7 @@ class Funnel extends ChartComponent {
|
|
|
134
127
|
let points3X = x(curValue) + curOffsetX;
|
|
135
128
|
let points3Y = y(curName) + y.bandwidth();
|
|
136
129
|
let points4X = x(0) + curOffsetX;
|
|
137
|
-
let points4Y = y(curName) +
|
|
130
|
+
let points4Y = y(curName) + y.bandwidth();
|
|
138
131
|
const nextD = data[index + 1];
|
|
139
132
|
if (nextD) {
|
|
140
133
|
const {
|
|
@@ -210,6 +203,8 @@ class Funnel extends ChartComponent {
|
|
|
210
203
|
this.hiddenTooltip(event);
|
|
211
204
|
});
|
|
212
205
|
});
|
|
206
|
+
this.animateFadeIn(contentWrapper.selectAll('polygon'));
|
|
207
|
+
this.animateFadeIn(contentWrapper.selectAll('text'), this.transitionDuration, this.transitionDuration * 0.5);
|
|
213
208
|
if (funnel_show_legend) {
|
|
214
209
|
this.setLegend({
|
|
215
210
|
legendName: 'name',
|
|
@@ -250,8 +245,7 @@ class Funnel extends ChartComponent {
|
|
|
250
245
|
componentDidMount() {
|
|
251
246
|
this.createChart();
|
|
252
247
|
this.drawChart();
|
|
253
|
-
|
|
254
|
-
window.addEventListener('resize', this.debouncedHandleResize);
|
|
248
|
+
super.componentDidMount();
|
|
255
249
|
}
|
|
256
250
|
componentDidUpdate(prevProps) {
|
|
257
251
|
super.componentDidUpdate(prevProps);
|
|
@@ -263,22 +257,16 @@ class Funnel extends ChartComponent {
|
|
|
263
257
|
}
|
|
264
258
|
componentWillUnmount() {
|
|
265
259
|
this.destroyChart();
|
|
266
|
-
|
|
260
|
+
super.componentWillUnmount();
|
|
267
261
|
}
|
|
268
262
|
render() {
|
|
269
|
-
const {
|
|
270
|
-
chart
|
|
271
|
-
} = this.props;
|
|
272
263
|
const {
|
|
273
264
|
tooltipData,
|
|
274
265
|
toolTipPosition
|
|
275
266
|
} = this.state;
|
|
276
267
|
return /*#__PURE__*/React.createElement("div", {
|
|
277
268
|
ref: ref => this.container = ref,
|
|
278
|
-
className:
|
|
279
|
-
'show-x-axis-label': this.isShowXAxisLabel(chart),
|
|
280
|
-
'show-y-axis-label': this.isShowYAxisLabel(chart)
|
|
281
|
-
})
|
|
269
|
+
className: "sea-chart-container"
|
|
282
270
|
}, /*#__PURE__*/React.createElement(ToolTip, {
|
|
283
271
|
tooltipData: tooltipData,
|
|
284
272
|
toolTipPosition: toolTipPosition,
|