sea-chart 2.0.29 → 2.0.31
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/types-dialog/index.js +1 -1
- package/dist/utils/chart-utils/base-utils.js +2 -0
- package/dist/view/index.js +8 -3
- package/dist/view/wrapper/area-group.js +3 -3
- package/dist/view/wrapper/area.js +3 -3
- package/dist/view/wrapper/bar-compare.js +2 -1
- package/dist/view/wrapper/bar-custom-stack.js +3 -3
- package/dist/view/wrapper/bar-group.js +3 -2
- package/dist/view/wrapper/bar-stack.js +3 -2
- package/dist/view/wrapper/bar.js +3 -2
- package/dist/view/wrapper/chart-component.js +76 -36
- package/dist/view/wrapper/combination.js +3 -2
- package/dist/view/wrapper/completeness-group.js +4 -2
- package/dist/view/wrapper/completeness.js +4 -2
- package/dist/view/wrapper/heat-map.js +323 -0
- package/dist/view/wrapper/horizontal-bar-group.js +3 -4
- package/dist/view/wrapper/horizontal-bar-stack.js +2 -2
- package/dist/view/wrapper/horizontal-bar.js +4 -2
- package/dist/view/wrapper/index.js +17 -1
- package/dist/view/wrapper/line-group.js +3 -2
- package/dist/view/wrapper/line.js +3 -2
- package/dist/view/wrapper/map-bubble.js +3 -2
- package/dist/view/wrapper/map-world-bubble.js +3 -2
- package/dist/view/wrapper/map-world.js +3 -2
- package/dist/view/wrapper/map.js +3 -2
- package/dist/view/wrapper/mirror.js +320 -0
- package/dist/view/wrapper/pie.js +7 -7
- package/dist/view/wrapper/ring.js +7 -7
- package/dist/view/wrapper/scatter.js +3 -2
- package/package.json +2 -2
|
@@ -69,7 +69,7 @@ const TypesDialog = _ref => {
|
|
|
69
69
|
}, [onChange, selectedType, onToggle]);
|
|
70
70
|
const handleFilterTypes = (0, _react.useCallback)(() => {
|
|
71
71
|
if (hideTypeToggle) {
|
|
72
|
-
const newChartTypes = _constants.CHART_TYPES.filter(item => ['Histogram', 'Bar_chart', 'Line_chart', 'Area', 'Pie_chart', 'Scatter_chart', 'Combination_chart', 'Map'].includes(item.name));
|
|
72
|
+
const newChartTypes = _constants.CHART_TYPES.filter(item => ['Histogram', 'Bar_chart', 'Line_chart', 'Area', 'Pie_chart', 'Scatter_chart', 'Combination_chart', 'Map', 'Heat_map', 'Facet_chart'].includes(item.name));
|
|
73
73
|
return newChartTypes;
|
|
74
74
|
}
|
|
75
75
|
return _constants.CHART_TYPES;
|
|
@@ -503,6 +503,8 @@ BaseUtils.shouldChartComponentUpdate = (prevProps, currentProps) => {
|
|
|
503
503
|
// global theme changed
|
|
504
504
|
!(0, _shallowequal.default)(prevProps.chartColorTheme, currentProps.chartColorTheme) ||
|
|
505
505
|
// chart color theme changed
|
|
506
|
+
!(0, _shallowequal.default)(prevProps.resizeSignal, currentProps.resizeSignal) ||
|
|
507
|
+
// chart container resize changed
|
|
506
508
|
_BaseUtils._isChartDataChange(prevProps, currentProps) || _BaseUtils.isChartStyleChanged(prevProps.chart, currentProps.chart);
|
|
507
509
|
};
|
|
508
510
|
BaseUtils._isCombinationDataChange = (prevResult, currentResult) => {
|
package/dist/view/index.js
CHANGED
|
@@ -250,16 +250,20 @@ class View extends _react.default.PureComponent {
|
|
|
250
250
|
render() {
|
|
251
251
|
var _title$text, _chart$config3;
|
|
252
252
|
const {
|
|
253
|
-
|
|
253
|
+
// style
|
|
254
254
|
className,
|
|
255
|
-
tables,
|
|
256
255
|
canvasStyle,
|
|
257
256
|
render,
|
|
258
257
|
hideTitle = false,
|
|
259
258
|
globalTheme,
|
|
260
259
|
chartColorTheme,
|
|
260
|
+
resizeSignal,
|
|
261
|
+
// data
|
|
262
|
+
chart,
|
|
263
|
+
tables,
|
|
261
264
|
isCalculateByView,
|
|
262
265
|
dtableStoreValue,
|
|
266
|
+
// event
|
|
263
267
|
integratedEventTypes,
|
|
264
268
|
integratedEventBus,
|
|
265
269
|
isBigScreenPlugin
|
|
@@ -329,6 +333,7 @@ class View extends _react.default.PureComponent {
|
|
|
329
333
|
isCalculateByView: isCalculateByView,
|
|
330
334
|
isBigScreenPlugin: isBigScreenPlugin,
|
|
331
335
|
chartColorTheme: chartColorTheme,
|
|
336
|
+
resizeSignal: resizeSignal,
|
|
332
337
|
integratedEventTypes: integratedEventTypes,
|
|
333
338
|
integratedEventBus: integratedEventBus
|
|
334
339
|
}))));
|
|
@@ -344,7 +349,7 @@ const propTypes = exports.propTypes = {
|
|
|
344
349
|
hideTitle: _propTypes.default.bool,
|
|
345
350
|
render: _propTypes.default.func,
|
|
346
351
|
// User-defined rendering content
|
|
347
|
-
|
|
352
|
+
resizeSignal: _propTypes.default.number,
|
|
348
353
|
// data
|
|
349
354
|
chart: _propTypes.default.object.isRequired,
|
|
350
355
|
tables: _propTypes.default.array.isRequired,
|
|
@@ -22,7 +22,7 @@ class AreaGroup extends _chartComponent.default {
|
|
|
22
22
|
constructor(props) {
|
|
23
23
|
super(props);
|
|
24
24
|
this.handleResize = () => {
|
|
25
|
-
this.
|
|
25
|
+
this.destroyChart();
|
|
26
26
|
this.createChart();
|
|
27
27
|
this.drawChart();
|
|
28
28
|
};
|
|
@@ -370,13 +370,13 @@ class AreaGroup extends _chartComponent.default {
|
|
|
370
370
|
componentDidUpdate(prevProps) {
|
|
371
371
|
super.componentDidUpdate(prevProps);
|
|
372
372
|
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
373
|
-
this.
|
|
373
|
+
this.destroyChart();
|
|
374
374
|
this.createChart();
|
|
375
375
|
this.drawChart();
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
componentWillUnmount() {
|
|
379
|
-
this.
|
|
379
|
+
this.destroyChart();
|
|
380
380
|
window.removeEventListener('resize', this.debouncedHandleResize);
|
|
381
381
|
super.componentWillUnmount();
|
|
382
382
|
}
|
|
@@ -20,7 +20,7 @@ class Area extends _chartComponent.default {
|
|
|
20
20
|
constructor(props) {
|
|
21
21
|
super(props);
|
|
22
22
|
this.handleResize = () => {
|
|
23
|
-
this.
|
|
23
|
+
this.destroyChart();
|
|
24
24
|
this.createChart();
|
|
25
25
|
this.drawChart();
|
|
26
26
|
};
|
|
@@ -343,13 +343,13 @@ class Area extends _chartComponent.default {
|
|
|
343
343
|
componentDidUpdate(prevProps) {
|
|
344
344
|
super.componentDidUpdate(prevProps);
|
|
345
345
|
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
346
|
-
this.
|
|
346
|
+
this.destroyChart();
|
|
347
347
|
this.createChart();
|
|
348
348
|
this.drawChart();
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
componentWillUnmount() {
|
|
352
|
-
this.
|
|
352
|
+
this.destroyChart();
|
|
353
353
|
window.removeEventListener('resize', this.debouncedHandleResize);
|
|
354
354
|
super.componentWillUnmount();
|
|
355
355
|
}
|
|
@@ -299,12 +299,13 @@ class BarCompare extends _chartComponent.default {
|
|
|
299
299
|
componentDidUpdate(prevProps) {
|
|
300
300
|
super.componentDidUpdate(prevProps);
|
|
301
301
|
if (_chartUtils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
302
|
+
this.destroyChart();
|
|
302
303
|
this.createChart();
|
|
303
304
|
this.drawChart();
|
|
304
305
|
}
|
|
305
306
|
}
|
|
306
307
|
componentWillUnmount() {
|
|
307
|
-
this.
|
|
308
|
+
this.destroyChart();
|
|
308
309
|
}
|
|
309
310
|
render() {
|
|
310
311
|
const {
|
|
@@ -21,7 +21,7 @@ class BarCustom extends _chartComponent.default {
|
|
|
21
21
|
constructor(props) {
|
|
22
22
|
super(props);
|
|
23
23
|
this.handleResize = (0, _lodashEs.debounce)(() => {
|
|
24
|
-
this.
|
|
24
|
+
this.destroyChart();
|
|
25
25
|
this.createChart();
|
|
26
26
|
this.drawChart();
|
|
27
27
|
}, 300);
|
|
@@ -361,13 +361,13 @@ class BarCustom extends _chartComponent.default {
|
|
|
361
361
|
componentDidUpdate(prevProps) {
|
|
362
362
|
super.componentDidUpdate(prevProps);
|
|
363
363
|
if (_chartUtils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
364
|
-
this.
|
|
364
|
+
this.destroyChart();
|
|
365
365
|
this.createChart();
|
|
366
366
|
this.drawChart();
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
componentWillUnmount() {
|
|
370
|
-
this.
|
|
370
|
+
this.destroyChart();
|
|
371
371
|
window.removeEventListener('resize', this.handleResize);
|
|
372
372
|
}
|
|
373
373
|
render() {
|
|
@@ -22,7 +22,7 @@ class BarGroup extends _chartComponent.default {
|
|
|
22
22
|
constructor(props) {
|
|
23
23
|
super(props);
|
|
24
24
|
this.handleResize = () => {
|
|
25
|
-
this.
|
|
25
|
+
this.destroyChart();
|
|
26
26
|
this.createChart();
|
|
27
27
|
this.drawChart();
|
|
28
28
|
};
|
|
@@ -239,12 +239,13 @@ class BarGroup extends _chartComponent.default {
|
|
|
239
239
|
componentDidUpdate(prevProps) {
|
|
240
240
|
super.componentDidUpdate(prevProps);
|
|
241
241
|
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
242
|
+
this.destroyChart();
|
|
242
243
|
this.createChart();
|
|
243
244
|
this.drawChart();
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
componentWillUnmount() {
|
|
247
|
-
this.
|
|
248
|
+
this.destroyChart();
|
|
248
249
|
window.removeEventListener('resize', this.debouncedHandleResize);
|
|
249
250
|
}
|
|
250
251
|
render() {
|
|
@@ -23,7 +23,7 @@ class BarStack extends _chartComponent.default {
|
|
|
23
23
|
constructor(props) {
|
|
24
24
|
super(props);
|
|
25
25
|
this.handleResize = () => {
|
|
26
|
-
this.
|
|
26
|
+
this.destroyChart();
|
|
27
27
|
this.createChart();
|
|
28
28
|
this.drawChart();
|
|
29
29
|
};
|
|
@@ -342,12 +342,13 @@ class BarStack extends _chartComponent.default {
|
|
|
342
342
|
componentDidUpdate(prevProps) {
|
|
343
343
|
super.componentDidUpdate(prevProps);
|
|
344
344
|
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
345
|
+
this.destroyChart();
|
|
345
346
|
this.createChart();
|
|
346
347
|
this.drawChart();
|
|
347
348
|
}
|
|
348
349
|
}
|
|
349
350
|
componentWillUnmount() {
|
|
350
|
-
this.
|
|
351
|
+
this.destroyChart();
|
|
351
352
|
window.removeEventListener('resize', this.debouncedHandleResize);
|
|
352
353
|
}
|
|
353
354
|
render() {
|
package/dist/view/wrapper/bar.js
CHANGED
|
@@ -21,7 +21,7 @@ class Bar extends _chartComponent.default {
|
|
|
21
21
|
constructor(props) {
|
|
22
22
|
super(props);
|
|
23
23
|
this.handleResize = () => {
|
|
24
|
-
this.
|
|
24
|
+
this.destroyChart();
|
|
25
25
|
this.createChart();
|
|
26
26
|
this.drawChart();
|
|
27
27
|
};
|
|
@@ -228,12 +228,13 @@ class Bar extends _chartComponent.default {
|
|
|
228
228
|
componentDidUpdate(prevProps) {
|
|
229
229
|
super.componentDidUpdate(prevProps);
|
|
230
230
|
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
231
|
+
this.destroyChart();
|
|
231
232
|
this.createChart();
|
|
232
233
|
this.drawChart();
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
236
|
componentWillUnmount() {
|
|
236
|
-
this.
|
|
237
|
+
this.destroyChart();
|
|
237
238
|
window.removeEventListener('resize', this.debouncedHandleResize);
|
|
238
239
|
}
|
|
239
240
|
render() {
|
|
@@ -12,6 +12,7 @@ var _lodashEs = require("lodash-es");
|
|
|
12
12
|
var _dtableUtils = require("dtable-utils");
|
|
13
13
|
var _utils = require("../../utils");
|
|
14
14
|
var _constants = require("../../constants");
|
|
15
|
+
var _style = require("../../constants/style");
|
|
15
16
|
var _intl = _interopRequireDefault(require("../../intl"));
|
|
16
17
|
require("../../assets/css/sea-chart-d3-tooltip.css");
|
|
17
18
|
class ChartComponent extends _react.Component {
|
|
@@ -27,15 +28,17 @@ class ChartComponent extends _react.Component {
|
|
|
27
28
|
};
|
|
28
29
|
};
|
|
29
30
|
this.handleResize = (0, _lodashEs.debounce)(() => {
|
|
30
|
-
var _this$chart;
|
|
31
31
|
if (!this.createChart || !this.drawChart) return;
|
|
32
|
-
|
|
32
|
+
this.destroyChart();
|
|
33
33
|
this.createChart();
|
|
34
34
|
this.drawChart();
|
|
35
35
|
if (this.needRenderAxisLabel) {
|
|
36
36
|
this.renderAxisLabel(this.props.chart, this.props.tables);
|
|
37
37
|
}
|
|
38
38
|
}, 300);
|
|
39
|
+
this.destroyChart = () => {
|
|
40
|
+
this.chart.node() && this.chart.node().remove();
|
|
41
|
+
};
|
|
39
42
|
this.getTitle = (tables, table_id, yAxisType, yAxisKey) => {
|
|
40
43
|
return yAxisType === _constants.CHART_SUMMARY_TYPE.COUNT ? _intl.default.get('Amount') : this.getAxisLabel(tables, table_id, yAxisKey);
|
|
41
44
|
};
|
|
@@ -57,10 +60,12 @@ class ChartComponent extends _react.Component {
|
|
|
57
60
|
const {
|
|
58
61
|
marginLeft = 0,
|
|
59
62
|
marginRight = 0,
|
|
60
|
-
marginBottom = 0
|
|
63
|
+
marginBottom = 0,
|
|
64
|
+
customWidth,
|
|
65
|
+
customHeight
|
|
61
66
|
} = initConfig;
|
|
62
|
-
const width = containerWidth - marginLeft - marginRight;
|
|
63
|
-
const height = containerHeight - marginBottom;
|
|
67
|
+
const width = customWidth ? customWidth : containerWidth - marginLeft - marginRight;
|
|
68
|
+
const height = customHeight ? customHeight : containerHeight - marginBottom;
|
|
64
69
|
_this.chart = d3.create('svg').attr('id', id).attr('width', width).attr('height', height).attr('viewBox', [0, 0, width, height]);
|
|
65
70
|
_this.container.appendChild(_this.chart.node());
|
|
66
71
|
_this.chartBoundingClientRect = {
|
|
@@ -645,8 +650,31 @@ class ChartComponent extends _react.Component {
|
|
|
645
650
|
return _intl.default.get(name) || name;
|
|
646
651
|
}
|
|
647
652
|
};
|
|
653
|
+
// set legend for heat map
|
|
654
|
+
this.setLegendForHeatMap = _ref => {
|
|
655
|
+
let {
|
|
656
|
+
exampleColors,
|
|
657
|
+
themeColors
|
|
658
|
+
} = _ref;
|
|
659
|
+
const legendOffsetY = 3;
|
|
660
|
+
const legendItemTextWidth = 32;
|
|
661
|
+
const legendItemWidth = 12;
|
|
662
|
+
const legendItemHeight = 12;
|
|
663
|
+
const legendItemGap = 3;
|
|
664
|
+
const legendItemRadius = 2;
|
|
665
|
+
const legendWrapper = this.chart.append('g').attr('class', 'legend-heat-map-wrapper').attr('transform', "translate(0, ".concat(legendOffsetY, ")"));
|
|
666
|
+
|
|
667
|
+
// less
|
|
668
|
+
legendWrapper.append('text').attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(_intl.default.get('Less'));
|
|
669
|
+
// rect
|
|
670
|
+
exampleColors.forEach((color, index) => {
|
|
671
|
+
legendWrapper.append('rect').attr('x', legendItemTextWidth + index * legendItemWidth + index * legendItemGap).attr('width', legendItemWidth).attr('height', legendItemHeight).attr('rx', legendItemRadius).attr('fill', color).attr('stroke', _style.FILL_BORDER_COLOR_MAP[color]).attr('stroke-width', 1);
|
|
672
|
+
});
|
|
673
|
+
// more
|
|
674
|
+
legendWrapper.append('text').attr('x', 182).attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(_intl.default.get('More'));
|
|
675
|
+
};
|
|
648
676
|
// set continuous legend
|
|
649
|
-
this.setContinuousLegend =
|
|
677
|
+
this.setContinuousLegend = _ref2 => {
|
|
650
678
|
var _this$chart$node2;
|
|
651
679
|
let {
|
|
652
680
|
previewType,
|
|
@@ -657,7 +685,7 @@ class ChartComponent extends _react.Component {
|
|
|
657
685
|
legendTextRange,
|
|
658
686
|
bubbleColor,
|
|
659
687
|
type
|
|
660
|
-
} =
|
|
688
|
+
} = _ref2;
|
|
661
689
|
const {
|
|
662
690
|
width: chartWidth,
|
|
663
691
|
height: chartHeight,
|
|
@@ -700,8 +728,8 @@ class ChartComponent extends _react.Component {
|
|
|
700
728
|
});
|
|
701
729
|
};
|
|
702
730
|
// set legend
|
|
703
|
-
this.setLegend =
|
|
704
|
-
var _chart$config, _chart$config2
|
|
731
|
+
this.setLegend = _ref3 => {
|
|
732
|
+
var _chart$config, _chart$config2;
|
|
705
733
|
let {
|
|
706
734
|
legendName,
|
|
707
735
|
theme = _constants.CHART_THEME_COLOR['light'],
|
|
@@ -710,12 +738,12 @@ class ChartComponent extends _react.Component {
|
|
|
710
738
|
colorScale,
|
|
711
739
|
groupColumn,
|
|
712
740
|
chart
|
|
713
|
-
} =
|
|
741
|
+
} = _ref3;
|
|
714
742
|
if (!this.chart) return;
|
|
715
743
|
this.legendConfig = {
|
|
716
|
-
legendRectWidth: (chart === null || chart === void 0 ? void 0 : (_chart$config = chart.config) === null || _chart$config === void 0 ? void 0 : _chart$config.type)
|
|
717
|
-
legendRectHeight: (chart === null || chart === void 0 ? void 0 : (_chart$config2 = chart.config) === null || _chart$config2 === void 0 ? void 0 : _chart$config2.type)
|
|
718
|
-
r: (chart
|
|
744
|
+
legendRectWidth: [_constants.CHART_TYPE.SCATTER, _constants.CHART_TYPE.MIRROR].includes(chart === null || chart === void 0 ? void 0 : (_chart$config = chart.config) === null || _chart$config === void 0 ? void 0 : _chart$config.type) ? 8 : 20,
|
|
745
|
+
legendRectHeight: [_constants.CHART_TYPE.SCATTER, _constants.CHART_TYPE.MIRROR].includes(chart === null || chart === void 0 ? void 0 : (_chart$config2 = chart.config) === null || _chart$config2 === void 0 ? void 0 : _chart$config2.type) ? 8 : 6,
|
|
746
|
+
r: this.getLegendR(chart),
|
|
719
747
|
legendItemPaddingTop: 5,
|
|
720
748
|
legendItemTextPaddingTop: 13,
|
|
721
749
|
legendItemMargin: 20,
|
|
@@ -744,12 +772,13 @@ class ChartComponent extends _react.Component {
|
|
|
744
772
|
// legend offset bottom and When there is only one line of legend, it is displayed in the center (for scatter chart)
|
|
745
773
|
if (bottomLegendSpace) {
|
|
746
774
|
queueMicrotask(() => {
|
|
775
|
+
const {
|
|
776
|
+
width,
|
|
777
|
+
height
|
|
778
|
+
} = legendWrapper.node().getBoundingClientRect();
|
|
747
779
|
let curTranslateX = 0;
|
|
748
|
-
const curTranslateY = bottomLegendSpace ? chartHeight -
|
|
780
|
+
const curTranslateY = bottomLegendSpace ? chartHeight - height : 0;
|
|
749
781
|
if (groupsData.length === 1) {
|
|
750
|
-
const {
|
|
751
|
-
width
|
|
752
|
-
} = legendWrapper.node().getBoundingClientRect();
|
|
753
782
|
curTranslateX = (chartWidth - width - insertPadding * 2) / 2;
|
|
754
783
|
}
|
|
755
784
|
legendWrapper.attr('transform', "translate(".concat(curTranslateX, ",").concat(curTranslateY, ")"));
|
|
@@ -829,14 +858,14 @@ class ChartComponent extends _react.Component {
|
|
|
829
858
|
});
|
|
830
859
|
}
|
|
831
860
|
};
|
|
832
|
-
this.renderLegend =
|
|
861
|
+
this.renderLegend = _ref4 => {
|
|
833
862
|
let {
|
|
834
863
|
legendWrapper,
|
|
835
864
|
groupData,
|
|
836
865
|
colorScale,
|
|
837
866
|
theme,
|
|
838
867
|
text
|
|
839
|
-
} =
|
|
868
|
+
} = _ref4;
|
|
840
869
|
const {
|
|
841
870
|
legendItemPaddingTop,
|
|
842
871
|
legendItemTextPaddingTop,
|
|
@@ -862,15 +891,15 @@ class ChartComponent extends _react.Component {
|
|
|
862
891
|
d3.select(item).remove();
|
|
863
892
|
});
|
|
864
893
|
}
|
|
865
|
-
legendWrapper.selectAll().data(groupData).join('g').attr('data-groupName',
|
|
866
|
-
let [groupName] = _ref4;
|
|
867
|
-
return groupName;
|
|
868
|
-
}).append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('y', legendItemPaddingTop).attr('rx', r).attr('fill', _ref5 => {
|
|
894
|
+
legendWrapper.selectAll().data(groupData).join('g').attr('data-groupName', _ref5 => {
|
|
869
895
|
let [groupName] = _ref5;
|
|
896
|
+
return groupName;
|
|
897
|
+
}).append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('y', legendItemPaddingTop).attr('rx', r).attr('fill', _ref6 => {
|
|
898
|
+
let [groupName] = _ref6;
|
|
870
899
|
if (colorScale) return colorScale(groupName);
|
|
871
900
|
return this.colorMap[groupName] || _constants.CHART_STYLE_COLORS[0];
|
|
872
|
-
}).attr('data-text',
|
|
873
|
-
let [groupName] =
|
|
901
|
+
}).attr('data-text', _ref7 => {
|
|
902
|
+
let [groupName] = _ref7;
|
|
874
903
|
return groupName;
|
|
875
904
|
}).call(g => {
|
|
876
905
|
// Add text
|
|
@@ -1076,6 +1105,17 @@ class ChartComponent extends _react.Component {
|
|
|
1076
1105
|
item.name = item['oldName'];
|
|
1077
1106
|
});
|
|
1078
1107
|
};
|
|
1108
|
+
this.getLegendR = chart => {
|
|
1109
|
+
const {
|
|
1110
|
+
config
|
|
1111
|
+
} = chart;
|
|
1112
|
+
const {
|
|
1113
|
+
type
|
|
1114
|
+
} = config;
|
|
1115
|
+
if (type === _constants.CHART_TYPE.SCATTER) return 4;
|
|
1116
|
+
if (type === _constants.CHART_TYPE.MIRROR) return 0;
|
|
1117
|
+
return 3;
|
|
1118
|
+
};
|
|
1079
1119
|
// theta is pie or ring chart
|
|
1080
1120
|
this.setLegendForTheta = function (legendName) {
|
|
1081
1121
|
let theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.CHART_THEME_COLOR['light'];
|
|
@@ -1370,7 +1410,7 @@ class ChartComponent extends _react.Component {
|
|
|
1370
1410
|
annotationWrapper.append('text').attr('x', chartWidth - insertPadding - 30).attr('y', yScale(goal_value) - 10).attr('fill', '#666').text(goal_label);
|
|
1371
1411
|
});
|
|
1372
1412
|
};
|
|
1373
|
-
this.addLabelToRectTop =
|
|
1413
|
+
this.addLabelToRectTop = _ref8 => {
|
|
1374
1414
|
let {
|
|
1375
1415
|
container,
|
|
1376
1416
|
x,
|
|
@@ -1379,7 +1419,7 @@ class ChartComponent extends _react.Component {
|
|
|
1379
1419
|
theme,
|
|
1380
1420
|
label_font_size,
|
|
1381
1421
|
text
|
|
1382
|
-
} =
|
|
1422
|
+
} = _ref8;
|
|
1383
1423
|
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('y', Number(y) - 10).attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1384
1424
|
const {
|
|
1385
1425
|
width
|
|
@@ -1387,7 +1427,7 @@ class ChartComponent extends _react.Component {
|
|
|
1387
1427
|
g.attr('x', Number(x) + Number(xWidth) / 2 - width / 2);
|
|
1388
1428
|
});
|
|
1389
1429
|
};
|
|
1390
|
-
this.addLabelToRectRight =
|
|
1430
|
+
this.addLabelToRectRight = _ref9 => {
|
|
1391
1431
|
let {
|
|
1392
1432
|
container,
|
|
1393
1433
|
x,
|
|
@@ -1397,7 +1437,7 @@ class ChartComponent extends _react.Component {
|
|
|
1397
1437
|
theme,
|
|
1398
1438
|
label_font_size,
|
|
1399
1439
|
text
|
|
1400
|
-
} =
|
|
1440
|
+
} = _ref9;
|
|
1401
1441
|
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('x', Number(x) + Number(xWidth) + 10).attr('y', Number(y)).attr('fill', theme.labelColor).attr('dominant-baseline', 'hanging').attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1402
1442
|
if (g.node()) {
|
|
1403
1443
|
var _g$node;
|
|
@@ -1408,7 +1448,7 @@ class ChartComponent extends _react.Component {
|
|
|
1408
1448
|
}
|
|
1409
1449
|
});
|
|
1410
1450
|
};
|
|
1411
|
-
this.addLabelToRectCenter =
|
|
1451
|
+
this.addLabelToRectCenter = _ref10 => {
|
|
1412
1452
|
let {
|
|
1413
1453
|
chartType,
|
|
1414
1454
|
container,
|
|
@@ -1419,7 +1459,7 @@ class ChartComponent extends _react.Component {
|
|
|
1419
1459
|
theme,
|
|
1420
1460
|
label_font_size,
|
|
1421
1461
|
text
|
|
1422
|
-
} =
|
|
1462
|
+
} = _ref10;
|
|
1423
1463
|
d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
|
|
1424
1464
|
const {
|
|
1425
1465
|
width,
|
|
@@ -1461,13 +1501,13 @@ class ChartComponent extends _react.Component {
|
|
|
1461
1501
|
}
|
|
1462
1502
|
};
|
|
1463
1503
|
// Use clipPath to make rectangle rounded corners
|
|
1464
|
-
this.addClipPath =
|
|
1504
|
+
this.addClipPath = _ref11 => {
|
|
1465
1505
|
let {
|
|
1466
1506
|
rect,
|
|
1467
1507
|
parentNode,
|
|
1468
1508
|
attr,
|
|
1469
1509
|
rectId
|
|
1470
|
-
} =
|
|
1510
|
+
} = _ref11;
|
|
1471
1511
|
const {
|
|
1472
1512
|
borderRadius
|
|
1473
1513
|
} = this.chartBoundingClientRect;
|
|
@@ -1676,14 +1716,14 @@ class ChartComponent extends _react.Component {
|
|
|
1676
1716
|
this.transitionDuration = 500;
|
|
1677
1717
|
this.areaTransitionDuration = 200;
|
|
1678
1718
|
}
|
|
1719
|
+
componentDidMount() {
|
|
1720
|
+
window.addEventListener('resize', this.handleResize);
|
|
1721
|
+
}
|
|
1679
1722
|
componentDidUpdate(prevProps) {
|
|
1680
1723
|
if (prevProps.globalTheme !== this.props.globalTheme) {
|
|
1681
1724
|
this.initLabelStroke(this.props.globalTheme);
|
|
1682
1725
|
}
|
|
1683
1726
|
}
|
|
1684
|
-
componentDidMount() {
|
|
1685
|
-
window.addEventListener('resize', this.handleResize);
|
|
1686
|
-
}
|
|
1687
1727
|
componentWillUnmount() {
|
|
1688
1728
|
window.removeEventListener('resize', this.handleResize);
|
|
1689
1729
|
}
|
|
@@ -21,7 +21,7 @@ class Combination extends _chartComponent.default {
|
|
|
21
21
|
constructor(props) {
|
|
22
22
|
super(props);
|
|
23
23
|
this.handleResize = () => {
|
|
24
|
-
this.
|
|
24
|
+
this.destroyChart();
|
|
25
25
|
this.createChart();
|
|
26
26
|
this.drawChart();
|
|
27
27
|
};
|
|
@@ -458,12 +458,13 @@ class Combination extends _chartComponent.default {
|
|
|
458
458
|
componentDidUpdate(prevProps) {
|
|
459
459
|
super.componentDidUpdate(prevProps);
|
|
460
460
|
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
461
|
+
this.destroyChart();
|
|
461
462
|
this.createChart();
|
|
462
463
|
this.drawChart();
|
|
463
464
|
}
|
|
464
465
|
}
|
|
465
466
|
componentWillUnmount() {
|
|
466
|
-
this.
|
|
467
|
+
this.destroyChart();
|
|
467
468
|
window.removeEventListener('resize', this.debouncedHandleResize);
|
|
468
469
|
}
|
|
469
470
|
render() {
|
|
@@ -20,7 +20,7 @@ class Completeness extends _chartComponent.default {
|
|
|
20
20
|
constructor(props) {
|
|
21
21
|
super(props);
|
|
22
22
|
this.handleResize = () => {
|
|
23
|
-
this.
|
|
23
|
+
this.destroyChart();
|
|
24
24
|
this.createChart();
|
|
25
25
|
this.drawChart();
|
|
26
26
|
};
|
|
@@ -357,12 +357,14 @@ class Completeness extends _chartComponent.default {
|
|
|
357
357
|
componentDidUpdate(prevProps) {
|
|
358
358
|
super.componentDidUpdate(prevProps);
|
|
359
359
|
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
360
|
+
this.destroyChart();
|
|
361
|
+
this.createChart();
|
|
360
362
|
this.drawChart();
|
|
361
363
|
}
|
|
362
364
|
}
|
|
363
365
|
componentWillUnmount() {
|
|
364
366
|
super.componentWillUnmount();
|
|
365
|
-
this.
|
|
367
|
+
this.destroyChart();
|
|
366
368
|
window.removeEventListener('resize', this.debouncedHandleResize);
|
|
367
369
|
}
|
|
368
370
|
render() {
|
|
@@ -20,7 +20,7 @@ class Completeness extends _chartComponent.default {
|
|
|
20
20
|
constructor(props) {
|
|
21
21
|
super(props);
|
|
22
22
|
this.handleResize = () => {
|
|
23
|
-
this.
|
|
23
|
+
this.destroyChart();
|
|
24
24
|
this.createChart();
|
|
25
25
|
this.drawChart();
|
|
26
26
|
};
|
|
@@ -300,12 +300,14 @@ class Completeness extends _chartComponent.default {
|
|
|
300
300
|
componentDidUpdate(prevProps) {
|
|
301
301
|
super.componentDidUpdate(prevProps);
|
|
302
302
|
if (_utils.BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
303
|
+
this.destroyChart();
|
|
304
|
+
this.createChart();
|
|
303
305
|
this.drawChart();
|
|
304
306
|
}
|
|
305
307
|
}
|
|
306
308
|
componentWillUnmount() {
|
|
307
309
|
super.componentWillUnmount();
|
|
308
|
-
this.
|
|
310
|
+
this.destroyChart();
|
|
309
311
|
window.removeEventListener('resize', this.debouncedHandleResize);
|
|
310
312
|
}
|
|
311
313
|
render() {
|