sea-chart 2.0.54 → 2.0.56
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/settings/widgets/basic-summary/index.css +3 -2
- package/dist/settings/widgets/numeric-summary-item.js +1 -4
- package/dist/view/index.css +6 -0
- package/dist/view/index.js +7 -8
- package/dist/view/wrapper/chart-component.js +37 -9
- package/dist/view/wrapper/treemap.js +10 -12
- package/package.json +3 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
.sea-chart-settings .summary-type-explanation {
|
|
2
|
-
color:
|
|
2
|
+
color: var(--bs-icon-color);
|
|
3
3
|
font-size: 12px;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.sea-chart-settings .chart-summary-types__option--is-selected .summary-type-explanation {
|
|
7
|
-
color:
|
|
7
|
+
color: var(--bs-icon-color) !important;
|
|
8
|
+
margin-top: 4px;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
.sea-chart-settings .chart-summary-types__value-container .summary-type-explanation {
|
|
@@ -141,10 +141,7 @@ class NumericSummaryItem extends _react.Component {
|
|
|
141
141
|
value: selectedColumnOption,
|
|
142
142
|
placeholder: _intl.default.get('Select_a_column'),
|
|
143
143
|
onChange: option => this.props.onColumnOptionChange(option, index, selectedColumnOption, currentAxisesIndex),
|
|
144
|
-
options: availableOptions
|
|
145
|
-
style: {
|
|
146
|
-
color: '#6e7687'
|
|
147
|
-
}
|
|
144
|
+
options: availableOptions
|
|
148
145
|
})), /*#__PURE__*/_react.default.createElement(_reactstrap.FormGroup, {
|
|
149
146
|
className: "sea-chart-parameter-item summary-method"
|
|
150
147
|
}, /*#__PURE__*/_react.default.createElement(_reactstrap.Label, null, _intl.default.get('Summary_method')), /*#__PURE__*/_react.default.createElement(_DTableSelect2.default, {
|
package/dist/view/index.css
CHANGED
package/dist/view/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var _concurrencyManager = _interopRequireDefault(require("../utils/concurrency-m
|
|
|
20
20
|
var _wrapper = _interopRequireDefault(require("./wrapper"));
|
|
21
21
|
var _title = _interopRequireDefault(require("./title"));
|
|
22
22
|
require("./index.css");
|
|
23
|
+
const NO_STATISTIC_RESULTS = 'There_are_no_statistic_results_yet';
|
|
23
24
|
class View extends _react.default.PureComponent {
|
|
24
25
|
constructor(props) {
|
|
25
26
|
var _this;
|
|
@@ -67,7 +68,7 @@ class View extends _react.default.PureComponent {
|
|
|
67
68
|
if (!data) {
|
|
68
69
|
this.setState({
|
|
69
70
|
errorMessage: '',
|
|
70
|
-
tipMessage:
|
|
71
|
+
tipMessage: NO_STATISTIC_RESULTS,
|
|
71
72
|
data: null,
|
|
72
73
|
isCalculated: true
|
|
73
74
|
});
|
|
@@ -295,16 +296,12 @@ class View extends _react.default.PureComponent {
|
|
|
295
296
|
className: (0, _classnames.default)('error', validClassName, tipBackgroundColorClassName)
|
|
296
297
|
}, /*#__PURE__*/_react.default.createElement("span", null, errorMessage));
|
|
297
298
|
}
|
|
298
|
-
if (tipMessage) {
|
|
299
|
+
if (tipMessage && tipMessage !== NO_STATISTIC_RESULTS) {
|
|
299
300
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
300
301
|
className: (0, _classnames.default)('error', validClassName, tipBackgroundColorClassName)
|
|
301
302
|
}, /*#__PURE__*/_react.default.createElement("span", null, _intl.default.get(tipMessage)));
|
|
302
303
|
}
|
|
303
|
-
|
|
304
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
305
|
-
className: (0, _classnames.default)('error', validClassName, tipBackgroundColorClassName)
|
|
306
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, _intl.default.get('There_are_no_statistic_results_yet')));
|
|
307
|
-
}
|
|
304
|
+
const isEmptyResult = tipMessage === NO_STATISTIC_RESULTS || _chartUtils.BaseUtils.imEmptyChartResult(data) && !chartType.includes('map');
|
|
308
305
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
309
306
|
className: validClassName
|
|
310
307
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -313,7 +310,9 @@ class View extends _react.default.PureComponent {
|
|
|
313
310
|
})
|
|
314
311
|
}, !hideTitle && /*#__PURE__*/_react.default.createElement(_title.default, {
|
|
315
312
|
chart: chart
|
|
316
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
313
|
+
}), isEmptyResult ? /*#__PURE__*/_react.default.createElement("div", {
|
|
314
|
+
className: (0, _classnames.default)('sea-chart-empty-result', tipBackgroundColorClassName)
|
|
315
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, _intl.default.get(NO_STATISTIC_RESULTS))) : /*#__PURE__*/_react.default.createElement("div", {
|
|
317
316
|
id: `sea-chart-cavans-container-${chart.id}`,
|
|
318
317
|
className: (0, _classnames.default)('sea-chart-cavans-container')
|
|
319
318
|
}, /*#__PURE__*/_react.default.createElement(_wrapper.default, {
|
|
@@ -565,6 +565,26 @@ class ChartComponent extends _react.Component {
|
|
|
565
565
|
return _intl.default.get(name) || name;
|
|
566
566
|
}
|
|
567
567
|
};
|
|
568
|
+
this.truncateLegendText = (textNode, maxWidth) => {
|
|
569
|
+
if (!textNode || !Number.isFinite(maxWidth) || maxWidth <= 0) return false;
|
|
570
|
+
const fullText = textNode.textContent || '';
|
|
571
|
+
const getTextWidth = () => {
|
|
572
|
+
if (typeof textNode.getComputedTextLength === 'function') {
|
|
573
|
+
return textNode.getComputedTextLength();
|
|
574
|
+
}
|
|
575
|
+
return textNode.getBoundingClientRect().width;
|
|
576
|
+
};
|
|
577
|
+
if (!fullText || getTextWidth() <= maxWidth) return false;
|
|
578
|
+
const ellipsis = '...';
|
|
579
|
+
let textLength = fullText.length;
|
|
580
|
+
while (textLength > 0) {
|
|
581
|
+
textNode.textContent = `${fullText.slice(0, textLength)}${ellipsis}`;
|
|
582
|
+
if (getTextWidth() <= maxWidth) return true;
|
|
583
|
+
textLength--;
|
|
584
|
+
}
|
|
585
|
+
textNode.textContent = ellipsis;
|
|
586
|
+
return true;
|
|
587
|
+
};
|
|
568
588
|
this.setLegend = _ref => {
|
|
569
589
|
var _chart$config, _chart$config2;
|
|
570
590
|
let {
|
|
@@ -756,11 +776,6 @@ class ChartComponent extends _react.Component {
|
|
|
756
776
|
let [groupName] = _ref5;
|
|
757
777
|
return groupName;
|
|
758
778
|
}).call(g => {
|
|
759
|
-
// Add text
|
|
760
|
-
g.nodes().forEach(rect => {
|
|
761
|
-
const parentNode = rect.parentNode;
|
|
762
|
-
d3.select(parentNode).append('text').attr('x', legendRectWidth + legendRecTextGap).attr('fill', theme.legendTextColor).attr('font-size', theme.legendFontSize).text(this.formatterLegendName(rect.dataset.text)).attr('data-text', rect.dataset.text).attr('y', legendItemTextPaddingTop);
|
|
763
|
-
});
|
|
764
779
|
const legendItems = Array.from(legendWrapper.node().children).filter(item => item.getAttribute('class') !== 'legend-flip-page');
|
|
765
780
|
const {
|
|
766
781
|
start,
|
|
@@ -768,6 +783,18 @@ class ChartComponent extends _react.Component {
|
|
|
768
783
|
top,
|
|
769
784
|
bottom
|
|
770
785
|
} = this.getLegendBoundary(legendPosition);
|
|
786
|
+
const legendTranslateX = legendPosition === 'center-right' ? start - 50 : start;
|
|
787
|
+
const maxLegendTextWidth = legendPosition === 'center-right' ? end - legendTranslateX - legendRectWidth - legendRecTextGap : null;
|
|
788
|
+
|
|
789
|
+
// Add text
|
|
790
|
+
g.nodes().forEach(rect => {
|
|
791
|
+
const parentNode = rect.parentNode;
|
|
792
|
+
const label = this.formatterLegendName(rect.dataset.text);
|
|
793
|
+
const textNode = d3.select(parentNode).append('text').attr('x', legendRectWidth + legendRecTextGap).attr('fill', theme.legendTextColor).attr('font-size', theme.legendFontSize).text(label).attr('data-text', rect.dataset.text).attr('y', legendItemTextPaddingTop).node();
|
|
794
|
+
if (this.truncateLegendText(textNode, maxLegendTextWidth)) {
|
|
795
|
+
d3.select(textNode).append('title').text(label);
|
|
796
|
+
}
|
|
797
|
+
});
|
|
771
798
|
if (top && bottom) {
|
|
772
799
|
// update g translateY
|
|
773
800
|
legendItems.forEach((item, index) => {
|
|
@@ -780,7 +807,8 @@ class ChartComponent extends _react.Component {
|
|
|
780
807
|
const prevTranslateY = Number(prevItem.getAttribute('data-translateY'));
|
|
781
808
|
translateY = prevTranslateY + height + legendItemMargin;
|
|
782
809
|
}
|
|
783
|
-
|
|
810
|
+
const translateX = legendPosition === 'center-right' ? start - 50 : start;
|
|
811
|
+
d3.select(item).attr('transform', `translate(${translateX},${translateY})`).attr('data-translateY', translateY);
|
|
784
812
|
this.bindLegendItemInteraction(item);
|
|
785
813
|
});
|
|
786
814
|
} else {
|
|
@@ -798,7 +826,7 @@ class ChartComponent extends _react.Component {
|
|
|
798
826
|
d3.select(item).attr('transform', `translate(${translateX},0)`).attr('data-translateX', translateX);
|
|
799
827
|
this.bindLegendItemInteraction(item);
|
|
800
828
|
|
|
801
|
-
// legend items add offset
|
|
829
|
+
// legend items add offset
|
|
802
830
|
if (legendPosition === 'top-right') {
|
|
803
831
|
d3.select(item).attr('opacity', 0);
|
|
804
832
|
// Execute only once
|
|
@@ -1588,7 +1616,7 @@ class ChartComponent extends _react.Component {
|
|
|
1588
1616
|
allTicks.forEach(tick => {
|
|
1589
1617
|
const opacityVal = tick.getAttribute('opacity');
|
|
1590
1618
|
if (Number(opacityVal) !== 0) {
|
|
1591
|
-
// roate
|
|
1619
|
+
// roate
|
|
1592
1620
|
d3.select(tick).select('text').attr('transform', 'rotate(30)').style('text-anchor', 'end').attr('dy', '1em').attr('dx', '-0.5em');
|
|
1593
1621
|
}
|
|
1594
1622
|
});
|
|
@@ -1622,7 +1650,7 @@ class ChartComponent extends _react.Component {
|
|
|
1622
1650
|
allTicks.forEach(tick => {
|
|
1623
1651
|
const opacityVal = tick.getAttribute('opacity');
|
|
1624
1652
|
if (Number(opacityVal) !== 0) {
|
|
1625
|
-
// roate
|
|
1653
|
+
// roate
|
|
1626
1654
|
d3.select(tick).select('text').attr('transform', 'rotate(45)').style('text-anchor', 'start').attr('dy', '0.4em').attr('dx', '0.4em');
|
|
1627
1655
|
}
|
|
1628
1656
|
});
|
|
@@ -55,7 +55,7 @@ class Treemap extends _chartComponent.default {
|
|
|
55
55
|
offsetY
|
|
56
56
|
} = event;
|
|
57
57
|
const newTooltipData = {
|
|
58
|
-
title: data.name,
|
|
58
|
+
title: this.getDisplayName(data.name),
|
|
59
59
|
items: [{
|
|
60
60
|
color: '',
|
|
61
61
|
name: _intl.default.get('Amount'),
|
|
@@ -120,7 +120,7 @@ class Treemap extends _chartComponent.default {
|
|
|
120
120
|
width,
|
|
121
121
|
height
|
|
122
122
|
} = group.getBoundingClientRect();
|
|
123
|
-
d3.select(group.parentNode).append('text').attr('stroke', '#fff').attr('stroke-width', 0.5).attr('paint-order', 'stroke').attr('fill', '#fff').text(name).call(t => {
|
|
123
|
+
d3.select(group.parentNode).append('text').attr('stroke', '#fff').attr('stroke-width', 0.5).attr('paint-order', 'stroke').attr('fill', '#fff').text(this.getDisplayName(name)).call(t => {
|
|
124
124
|
const {
|
|
125
125
|
width: tWidth,
|
|
126
126
|
height: tHeight
|
|
@@ -143,18 +143,16 @@ class Treemap extends _chartComponent.default {
|
|
|
143
143
|
});
|
|
144
144
|
};
|
|
145
145
|
this.getFullData = data => {
|
|
146
|
-
|
|
146
|
+
return {
|
|
147
147
|
name: 'root',
|
|
148
|
-
children: data.map(item => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (name === '_Others') {
|
|
152
|
-
item.name = _intl.default.get('Others');
|
|
153
|
-
}
|
|
154
|
-
return item;
|
|
155
|
-
})
|
|
148
|
+
children: data.map(item => ({
|
|
149
|
+
...item
|
|
150
|
+
}))
|
|
156
151
|
};
|
|
157
|
-
|
|
152
|
+
};
|
|
153
|
+
this.getDisplayName = name => {
|
|
154
|
+
if (name === '_Others') return _intl.default.get('Others');
|
|
155
|
+
return (0, _dtableUtils.isEmpty)(name) ? _intl.default.get(_constants.EMPTY_NAME) : name;
|
|
158
156
|
};
|
|
159
157
|
this.chart = null;
|
|
160
158
|
this.state = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sea-chart",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.56",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@dnd-kit/core": "^6.1.0",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"@babel/cli": "7.22.10",
|
|
78
78
|
"@babel/core": "7.22.11",
|
|
79
79
|
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
|
|
80
|
+
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
|
|
80
81
|
"@babel/plugin-transform-runtime": "^7.23.9",
|
|
81
82
|
"@babel/preset-env": "7.22.14",
|
|
82
83
|
"@babel/runtime": "^7.10.2",
|
|
@@ -102,7 +103,7 @@
|
|
|
102
103
|
"dotenv": "6.2.0",
|
|
103
104
|
"dotenv-expand": "5.1.0",
|
|
104
105
|
"dtable-store": "~6.0.11",
|
|
105
|
-
"dtable-ui-component": "7.0.
|
|
106
|
+
"dtable-ui-component": "7.0.7",
|
|
106
107
|
"ejs": "3.1.10",
|
|
107
108
|
"eslint": "^6.8.0",
|
|
108
109
|
"eslint-config-react-app": "^5.0.2",
|