sea-chart 0.0.1
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/README.md +4 -0
- package/lib/assets/icons/area-chart.svg +10 -0
- package/lib/assets/icons/bar-chart.svg +12 -0
- package/lib/assets/icons/card.svg +22 -0
- package/lib/assets/icons/combination-chart.svg +17 -0
- package/lib/assets/icons/dtable-logo.svg +16 -0
- package/lib/assets/icons/facet-chart.svg +12 -0
- package/lib/assets/icons/gauge.svg +18 -0
- package/lib/assets/icons/heat-map.svg +14 -0
- package/lib/assets/icons/histogram.svg +12 -0
- package/lib/assets/icons/line-chart.svg +12 -0
- package/lib/assets/icons/map.svg +20 -0
- package/lib/assets/icons/pie-chart.svg +11 -0
- package/lib/assets/icons/rectangular-tree-diagram.svg +10 -0
- package/lib/assets/icons/scatter-chart.svg +15 -0
- package/lib/assets/icons/type-change.svg +17 -0
- package/lib/assets/img/area-chart.png +0 -0
- package/lib/assets/img/area-group-chart.png +0 -0
- package/lib/assets/img/bar-group.png +0 -0
- package/lib/assets/img/bar-stack.png +0 -0
- package/lib/assets/img/bar.png +0 -0
- package/lib/assets/img/combination-chart.png +0 -0
- package/lib/assets/img/compared-chart.png +0 -0
- package/lib/assets/img/completeness-chart.png +0 -0
- package/lib/assets/img/custom-bar.png +0 -0
- package/lib/assets/img/dashboard-chart.png +0 -0
- package/lib/assets/img/group-completeness-chart.png +0 -0
- package/lib/assets/img/group_line.png +0 -0
- package/lib/assets/img/heat-map.png +0 -0
- package/lib/assets/img/horizontal-bar.png +0 -0
- package/lib/assets/img/horizontal-group-bar.png +0 -0
- package/lib/assets/img/line.png +0 -0
- package/lib/assets/img/map-bubble.png +0 -0
- package/lib/assets/img/map.png +0 -0
- package/lib/assets/img/mirror.png +0 -0
- package/lib/assets/img/number-card.png +0 -0
- package/lib/assets/img/pie.png +0 -0
- package/lib/assets/img/pivot-table.png +0 -0
- package/lib/assets/img/ring.png +0 -0
- package/lib/assets/img/scatter.png +0 -0
- package/lib/assets/img/stacked-horizontal-bar.png +0 -0
- package/lib/assets/img/treemap.png +0 -0
- package/lib/assets/img/trend-chart.png +0 -0
- package/lib/assets/img/world-map-bubble.png +0 -0
- package/lib/assets/img/world-map.png +0 -0
- package/lib/components/collaborator/index.js +24 -0
- package/lib/components/formatter/area.js +162 -0
- package/lib/components/formatter/bar-group.js +160 -0
- package/lib/components/formatter/bar.js +150 -0
- package/lib/components/formatter/basic-number-card.js +138 -0
- package/lib/components/formatter/chart-component.js +266 -0
- package/lib/components/formatter/combination.js +407 -0
- package/lib/components/formatter/dashboard.js +182 -0
- package/lib/components/formatter/horizontal-bar-group.js +161 -0
- package/lib/components/formatter/horizontal-bar.js +152 -0
- package/lib/components/formatter/horizontal-component.js +91 -0
- package/lib/components/formatter/index.js +181 -0
- package/lib/components/formatter/line-group.js +157 -0
- package/lib/components/formatter/line.js +170 -0
- package/lib/components/formatter/pie.js +201 -0
- package/lib/components/formatter/ring.js +277 -0
- package/lib/components/formatter/table/index.css +103 -0
- package/lib/components/formatter/table/index.js +42 -0
- package/lib/components/formatter/table/one-dimension-table-no-numeric-columns.js +145 -0
- package/lib/components/formatter/table/one-dimension-table-with-numeric-columns.js +193 -0
- package/lib/components/formatter/table/pivot-table-display-name.js +249 -0
- package/lib/components/formatter/table/two-dimension-table.js +241 -0
- package/lib/components/formatter/treemap.js +213 -0
- package/lib/components/icon/index.css +5 -0
- package/lib/components/icon/index.js +22 -0
- package/lib/components/index.js +5 -0
- package/lib/components/loading/index.css +54 -0
- package/lib/components/loading/index.js +10 -0
- package/lib/components/number-input/index.js +31 -0
- package/lib/components/pixel-editor/index.css +29 -0
- package/lib/components/pixel-editor/index.js +42 -0
- package/lib/components/select-group/index.css +67 -0
- package/lib/components/select-group/index.js +63 -0
- package/lib/components/settings/advance-bar-settings/data-settings.js +120 -0
- package/lib/components/settings/advance-bar-settings/index.js +3 -0
- package/lib/components/settings/advance-bar-settings/style-settings.js +149 -0
- package/lib/components/settings/bar-settings/data-settings.js +137 -0
- package/lib/components/settings/bar-settings/index.js +3 -0
- package/lib/components/settings/bar-settings/style-settings.js +163 -0
- package/lib/components/settings/basic-number-card/data-settings.js +121 -0
- package/lib/components/settings/basic-number-card/index.js +3 -0
- package/lib/components/settings/basic-number-card/style-settings.js +42 -0
- package/lib/components/settings/combination-settings/data-settings.js +256 -0
- package/lib/components/settings/combination-settings/index.js +3 -0
- package/lib/components/settings/combination-settings/style-settings.js +183 -0
- package/lib/components/settings/dashboard-settings/data-settings.js +167 -0
- package/lib/components/settings/dashboard-settings/index.js +2 -0
- package/lib/components/settings/data-settings.js +67 -0
- package/lib/components/settings/horizontal-bar-settings/data-settings.js +45 -0
- package/lib/components/settings/horizontal-bar-settings/index.js +3 -0
- package/lib/components/settings/horizontal-bar-settings/style-settings.js +38 -0
- package/lib/components/settings/index.css +73 -0
- package/lib/components/settings/index.js +74 -0
- package/lib/components/settings/pie-settings/data-settings.js +123 -0
- package/lib/components/settings/pie-settings/index.js +3 -0
- package/lib/components/settings/pie-settings/style-settings.js +123 -0
- package/lib/components/settings/style-settings.js +100 -0
- package/lib/components/settings/table-settings/data-settings.js +488 -0
- package/lib/components/settings/table-settings/index.js +2 -0
- package/lib/components/settings/time-comparison-settings/data-settings.js +157 -0
- package/lib/components/settings/time-comparison-settings/index.js +3 -0
- package/lib/components/settings/time-comparison-settings/style-settings.js +191 -0
- package/lib/components/settings/widgets/basic-summary/index.css +12 -0
- package/lib/components/settings/widgets/basic-summary/index.js +173 -0
- package/lib/components/settings/widgets/common-data-settings.js +42 -0
- package/lib/components/settings/widgets/data-filter/index.css +17 -0
- package/lib/components/settings/widgets/data-filter/index.js +76 -0
- package/lib/components/settings/widgets/data-sort.js +38 -0
- package/lib/components/settings/widgets/date-summary-item.js +126 -0
- package/lib/components/settings/widgets/display-values-settings/index.css +13 -0
- package/lib/components/settings/widgets/display-values-settings/index.js +37 -0
- package/lib/components/settings/widgets/divider/index.css +4 -0
- package/lib/components/settings/widgets/divider/index.js +10 -0
- package/lib/components/settings/widgets/font-settings/font-size-settings.js +31 -0
- package/lib/components/settings/widgets/font-settings/font-weight-settings.js +46 -0
- package/lib/components/settings/widgets/font-settings/index.js +3 -0
- package/lib/components/settings/widgets/group-by.js +168 -0
- package/lib/components/settings/widgets/label-color.js +30 -0
- package/lib/components/settings/widgets/min-max-setting.js +64 -0
- package/lib/components/settings/widgets/mininum-slice-percent.js +72 -0
- package/lib/components/settings/widgets/numeric-summary-item.js +109 -0
- package/lib/components/settings/widgets/select-table/index.css +0 -0
- package/lib/components/settings/widgets/select-table/index.js +49 -0
- package/lib/components/settings/widgets/stack.js +58 -0
- package/lib/components/settings/widgets/statistic-type/index.css +31 -0
- package/lib/components/settings/widgets/statistic-type/index.js +54 -0
- package/lib/components/settings/widgets/summary-method-setting.js +80 -0
- package/lib/components/settings/widgets/summary-settings.js +394 -0
- package/lib/components/settings/widgets/switch/index.css +37 -0
- package/lib/components/settings/widgets/switch/index.js +21 -0
- package/lib/components/settings/widgets/text-horizontal-settings.js +23 -0
- package/lib/components/settings/widgets/time-picker.js +182 -0
- package/lib/components/settings/widgets/title-settings/index.js +58 -0
- package/lib/components/settings/widgets/title-settings/title-text.js +31 -0
- package/lib/components/settings/widgets/x-axios.js +0 -0
- package/lib/components/settings/widgets/y-axis-group-settings.js +399 -0
- package/lib/components/types-dialog/index.css +97 -0
- package/lib/components/types-dialog/index.js +127 -0
- package/lib/constants/geolocation.js +11 -0
- package/lib/constants/index.js +164 -0
- package/lib/constants/model.js +167 -0
- package/lib/constants/style.js +13 -0
- package/lib/constants/type-image.js +32 -0
- package/lib/constants/type.js +97 -0
- package/lib/context.js +49 -0
- package/lib/index.js +6 -0
- package/lib/intl.js +37 -0
- package/lib/layout/index.js +4 -0
- package/lib/layout/statistic/index.css +53 -0
- package/lib/layout/statistic/index.js +190 -0
- package/lib/layout/title/index.css +3 -0
- package/lib/layout/title/index.js +41 -0
- package/lib/locale/index.js +11 -0
- package/lib/locale/lang/de.js +141 -0
- package/lib/locale/lang/en.js +143 -0
- package/lib/locale/lang/es.js +141 -0
- package/lib/locale/lang/fr.js +141 -0
- package/lib/locale/lang/pt.js +141 -0
- package/lib/locale/lang/ru.js +141 -0
- package/lib/locale/lang/zh_CN.js +143 -0
- package/lib/model/area-group.js +51 -0
- package/lib/model/area.js +42 -0
- package/lib/model/bar-group.js +54 -0
- package/lib/model/bar-stack.js +51 -0
- package/lib/model/bar.js +48 -0
- package/lib/model/base-model.js +11 -0
- package/lib/model/basic-number-card.js +32 -0
- package/lib/model/combination.js +48 -0
- package/lib/model/compare-bar.js +49 -0
- package/lib/model/completeness-group.js +34 -0
- package/lib/model/completeness.js +28 -0
- package/lib/model/dashboard.js +26 -0
- package/lib/model/generic-model.js +235 -0
- package/lib/model/heat-map.js +33 -0
- package/lib/model/horizontal-bar.js +48 -0
- package/lib/model/horizontal-group-bar.js +53 -0
- package/lib/model/index.js +36 -0
- package/lib/model/line-group.js +54 -0
- package/lib/model/line.js +48 -0
- package/lib/model/map-bubble.js +37 -0
- package/lib/model/map.js +37 -0
- package/lib/model/mirror.js +36 -0
- package/lib/model/pie.js +36 -0
- package/lib/model/ring.js +36 -0
- package/lib/model/scatter.js +29 -0
- package/lib/model/stacked-horizontal-bar.js +42 -0
- package/lib/model/statistic.js +22 -0
- package/lib/model/table.js +33 -0
- package/lib/model/tree-map.js +30 -0
- package/lib/model/trend.js +34 -0
- package/lib/model/user.js +22 -0
- package/lib/model/world-map-bubble.js +36 -0
- package/lib/model/world-map.js +36 -0
- package/lib/utils/cell-format-utils.js +41 -0
- package/lib/utils/chart.js +6 -0
- package/lib/utils/collaborator-utils.js +40 -0
- package/lib/utils/column-utils.js +247 -0
- package/lib/utils/custom-g2.js +612 -0
- package/lib/utils/data-filter/filter-item-utils.js +80 -0
- package/lib/utils/data-filter/filters-utils.js +406 -0
- package/lib/utils/data-filter/index.js +3 -0
- package/lib/utils/date-translate.js +66 -0
- package/lib/utils/index.js +50 -0
- package/lib/utils/key-generator.js +13 -0
- package/lib/utils/object-utils.js +61 -0
- package/lib/utils/options-utils.js +61 -0
- package/lib/utils/statistic-column-2-sql-column-utils.js +499 -0
- package/lib/utils/statistic-utils.js +1685 -0
- package/package.json +160 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { STATISTIC_LABEL_POSITIONS, STATISTIC_LABEL_FORMATS } from '../../constants';
|
|
8
|
+
import { StatisticsUtils } from '../../utils';
|
|
9
|
+
import ChartComponent from './chart-component';
|
|
10
|
+
import intl from '../../intl';
|
|
11
|
+
var Pie = /*#__PURE__*/function (_ChartComponent) {
|
|
12
|
+
_inherits(Pie, _ChartComponent);
|
|
13
|
+
var _super = _createSuper(Pie);
|
|
14
|
+
function Pie(props) {
|
|
15
|
+
var _this;
|
|
16
|
+
_classCallCheck(this, Pie);
|
|
17
|
+
_this = _super.call(this, props);
|
|
18
|
+
_this.createChart = function () {
|
|
19
|
+
var canvasStyle = _this.props.canvasStyle;
|
|
20
|
+
_this.initChart(_this.container, canvasStyle, 0);
|
|
21
|
+
};
|
|
22
|
+
_this.destroyChart = function () {
|
|
23
|
+
_this.chart.destroy();
|
|
24
|
+
_this.chart = null;
|
|
25
|
+
};
|
|
26
|
+
_this.clearChart = function () {
|
|
27
|
+
_this.chart.annotation().clear(true);
|
|
28
|
+
_this.chart.clear(true);
|
|
29
|
+
};
|
|
30
|
+
_this.drawChart = function () {
|
|
31
|
+
var _this$props = _this.props,
|
|
32
|
+
data = _this$props.result,
|
|
33
|
+
statistic = _this$props.statistic,
|
|
34
|
+
tables = _this$props.tables,
|
|
35
|
+
theme = _this$props.theme,
|
|
36
|
+
summaryColumn = _this$props.summaryColumn;
|
|
37
|
+
if (data.length === 0) return;
|
|
38
|
+
_this.chart.coordinate('theta', {
|
|
39
|
+
radius: 0.95
|
|
40
|
+
});
|
|
41
|
+
var _statistic$config = statistic.config,
|
|
42
|
+
show_legend = _statistic$config.show_legend,
|
|
43
|
+
display_label = _statistic$config.display_label,
|
|
44
|
+
label_position = _statistic$config.label_position,
|
|
45
|
+
label_font_size = _statistic$config.label_font_size,
|
|
46
|
+
summary_method = _statistic$config.summary_method;
|
|
47
|
+
var _StatisticsUtils$form = StatisticsUtils.formatPieChartData(data, statistic, tables),
|
|
48
|
+
newData = _StatisticsUtils$form.data,
|
|
49
|
+
colorSet = _StatisticsUtils$form.colorSet;
|
|
50
|
+
if (!Array.isArray(newData)) return;
|
|
51
|
+
_this.loadData(newData);
|
|
52
|
+
_this.chart.on('interval:click', function (e) {
|
|
53
|
+
_this.props.toggleRecords(e.data.data);
|
|
54
|
+
});
|
|
55
|
+
if (show_legend) {
|
|
56
|
+
_this.chart.legend('name', {
|
|
57
|
+
position: 'right',
|
|
58
|
+
custom: true,
|
|
59
|
+
itemName: {
|
|
60
|
+
style: {
|
|
61
|
+
fill: theme.textColor
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
items: newData.map(function (obj, index) {
|
|
65
|
+
var name = obj.name;
|
|
66
|
+
if (!obj.name && typeof obj.name !== 'number') {
|
|
67
|
+
name = intl.get('Empty');
|
|
68
|
+
} else if (obj.name === '_Others') {
|
|
69
|
+
name = intl.get('Others');
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
name: name,
|
|
73
|
+
value: obj.value,
|
|
74
|
+
marker: {
|
|
75
|
+
symbol: 'circle',
|
|
76
|
+
style: {
|
|
77
|
+
r: 5,
|
|
78
|
+
fill: colorSet[index]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
_this.chart.legend(false);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Do not automatically adjust the maximum and minimum values in pie chart
|
|
89
|
+
_this.chart.scale({
|
|
90
|
+
value: {
|
|
91
|
+
nice: false
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
_this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('value*percent', function (value, percent) {
|
|
95
|
+
var displayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
96
|
+
return {
|
|
97
|
+
content: _this.getLabel(displayValue, percent)
|
|
98
|
+
};
|
|
99
|
+
}, {
|
|
100
|
+
offset: !label_position || label_position === STATISTIC_LABEL_POSITIONS[0] ? -2 : undefined,
|
|
101
|
+
style: {
|
|
102
|
+
fill: '#000000',
|
|
103
|
+
fontSize: StatisticsUtils.getLabelFontSize(label_font_size),
|
|
104
|
+
shadowBlur: 2,
|
|
105
|
+
shadowColor: 'rgba(0, 0, 0, .45)'
|
|
106
|
+
}
|
|
107
|
+
}).tooltip('name*value*percent', function (name, value, percent) {
|
|
108
|
+
var title = name;
|
|
109
|
+
if (!name || name === 'undefined') {
|
|
110
|
+
title = intl.get('Empty');
|
|
111
|
+
} else if (name === '_Others') {
|
|
112
|
+
title = intl.get('Others');
|
|
113
|
+
}
|
|
114
|
+
var displayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
115
|
+
return {
|
|
116
|
+
name: title,
|
|
117
|
+
value: display_label ? _this.getLabel(displayValue, percent) : displayValue
|
|
118
|
+
};
|
|
119
|
+
}).state({
|
|
120
|
+
active: {
|
|
121
|
+
style: {
|
|
122
|
+
fillOpacity: 0.7,
|
|
123
|
+
border: 'none',
|
|
124
|
+
stroke: 0
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
_this.chart.tooltip({
|
|
129
|
+
showTitle: false,
|
|
130
|
+
showMarkers: false,
|
|
131
|
+
itemTpl: '<div class="g2-tooltip-list-item"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</div>'
|
|
132
|
+
});
|
|
133
|
+
_this.chart.interaction('statistic-active');
|
|
134
|
+
_this.chart.render();
|
|
135
|
+
};
|
|
136
|
+
_this.getLabel = function (value, percent) {
|
|
137
|
+
var _this$props$statistic = _this.props.statistic.config,
|
|
138
|
+
display_label = _this$props$statistic.display_label,
|
|
139
|
+
label_format = _this$props$statistic.label_format;
|
|
140
|
+
if (!display_label) {
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
switch (label_format) {
|
|
144
|
+
case STATISTIC_LABEL_FORMATS[0]:
|
|
145
|
+
return percent;
|
|
146
|
+
case STATISTIC_LABEL_FORMATS[1]:
|
|
147
|
+
return value;
|
|
148
|
+
case STATISTIC_LABEL_FORMATS[2]:
|
|
149
|
+
return "".concat(value, " (").concat(percent, ")");
|
|
150
|
+
default:
|
|
151
|
+
return percent;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
_this.chart = null;
|
|
155
|
+
return _this;
|
|
156
|
+
}
|
|
157
|
+
_createClass(Pie, [{
|
|
158
|
+
key: "componentDidMount",
|
|
159
|
+
value: function componentDidMount() {
|
|
160
|
+
this.createChart();
|
|
161
|
+
this.drawChart();
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "componentDidUpdate",
|
|
165
|
+
value: function componentDidUpdate(prevProps) {
|
|
166
|
+
if (StatisticsUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
167
|
+
this.chart && this.destroyChart();
|
|
168
|
+
this.createChart();
|
|
169
|
+
this.drawChart();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "componentWillUnmount",
|
|
174
|
+
value: function componentWillUnmount() {
|
|
175
|
+
this.chart && this.destroyChart();
|
|
176
|
+
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "render",
|
|
179
|
+
value: function render() {
|
|
180
|
+
var _this2 = this;
|
|
181
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
182
|
+
className: "seastatistic-container w-100",
|
|
183
|
+
ref: function ref(_ref) {
|
|
184
|
+
return _this2.container = _ref;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}]);
|
|
189
|
+
return Pie;
|
|
190
|
+
}(ChartComponent);
|
|
191
|
+
Pie.propTypes = {
|
|
192
|
+
canvasStyle: PropTypes.object,
|
|
193
|
+
statistic: PropTypes.object,
|
|
194
|
+
groupbyColumn: PropTypes.object,
|
|
195
|
+
summaryColumn: PropTypes.object,
|
|
196
|
+
result: PropTypes.array,
|
|
197
|
+
tables: PropTypes.array,
|
|
198
|
+
theme: PropTypes.object,
|
|
199
|
+
toggleRecords: PropTypes.func
|
|
200
|
+
};
|
|
201
|
+
export default Pie;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { STATISTIC_LABEL_POSITIONS, STATISTIC_LABEL_FORMATS } from '../../constants';
|
|
8
|
+
import { StatisticsUtils } from '../../utils';
|
|
9
|
+
import ChartComponent from './chart-component';
|
|
10
|
+
import intl from '../../intl';
|
|
11
|
+
var Ring = /*#__PURE__*/function (_ChartComponent) {
|
|
12
|
+
_inherits(Ring, _ChartComponent);
|
|
13
|
+
var _super = _createSuper(Ring);
|
|
14
|
+
function Ring(props) {
|
|
15
|
+
var _this;
|
|
16
|
+
_classCallCheck(this, Ring);
|
|
17
|
+
_this = _super.call(this, props);
|
|
18
|
+
_this.createChart = function () {
|
|
19
|
+
var canvasStyle = _this.props.canvasStyle;
|
|
20
|
+
_this.initChart(_this.container, canvasStyle, 0);
|
|
21
|
+
};
|
|
22
|
+
_this.destroyChart = function () {
|
|
23
|
+
_this.chart.destroy();
|
|
24
|
+
_this.chart = null;
|
|
25
|
+
};
|
|
26
|
+
_this.clearChart = function () {
|
|
27
|
+
_this.chart.annotation().clear(true);
|
|
28
|
+
_this.chart.clear(true);
|
|
29
|
+
};
|
|
30
|
+
_this.drawChart = function () {
|
|
31
|
+
var _this$props = _this.props,
|
|
32
|
+
data = _this$props.result,
|
|
33
|
+
statistic = _this$props.statistic,
|
|
34
|
+
tables = _this$props.tables,
|
|
35
|
+
summaryColumn = _this$props.summaryColumn;
|
|
36
|
+
if (data.length === 0) return;
|
|
37
|
+
_this.sum = data.total;
|
|
38
|
+
_this.chart.coordinate('theta', {
|
|
39
|
+
radius: 0.95,
|
|
40
|
+
innerRadius: 0.7
|
|
41
|
+
});
|
|
42
|
+
var _statistic$config = statistic.config,
|
|
43
|
+
show_legend = _statistic$config.show_legend,
|
|
44
|
+
display_label = _statistic$config.display_label,
|
|
45
|
+
label_position = _statistic$config.label_position,
|
|
46
|
+
label_font_size = _statistic$config.label_font_size,
|
|
47
|
+
summary_method = _statistic$config.summary_method;
|
|
48
|
+
var _StatisticsUtils$form = StatisticsUtils.formatPieChartData(data, statistic, tables),
|
|
49
|
+
newData = _StatisticsUtils$form.data,
|
|
50
|
+
colorSet = _StatisticsUtils$form.colorSet,
|
|
51
|
+
total = _StatisticsUtils$form.total;
|
|
52
|
+
if (!Array.isArray(newData)) return;
|
|
53
|
+
_this.sum = total;
|
|
54
|
+
_this.loadData(newData);
|
|
55
|
+
_this.chart.on('interval:click', function (e) {
|
|
56
|
+
_this.props.toggleRecords(e.data.data);
|
|
57
|
+
});
|
|
58
|
+
if (show_legend) {
|
|
59
|
+
_this.chart.legend('name', {
|
|
60
|
+
position: 'right',
|
|
61
|
+
custom: true,
|
|
62
|
+
itemName: {
|
|
63
|
+
style: {
|
|
64
|
+
fill: '#6e6e6e'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
items: newData.map(function (obj, index) {
|
|
68
|
+
var name = obj.name;
|
|
69
|
+
if (!obj.name && typeof obj.name !== 'number') {
|
|
70
|
+
name = intl.get('Empty');
|
|
71
|
+
} else if (obj.name === '_Others') {
|
|
72
|
+
name = intl.get('Others');
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
name: name,
|
|
76
|
+
value: obj.value,
|
|
77
|
+
marker: {
|
|
78
|
+
symbol: 'circle',
|
|
79
|
+
style: {
|
|
80
|
+
r: 5,
|
|
81
|
+
fill: colorSet[index]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
_this.chart.legend(false);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Do not automatically adjust the maximum and minimum values in pie chart
|
|
92
|
+
_this.chart.scale({
|
|
93
|
+
value: {
|
|
94
|
+
nice: false
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
_this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('value*percent', function (value, percent) {
|
|
98
|
+
var displayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
99
|
+
return {
|
|
100
|
+
content: _this.getLabel(displayValue, percent)
|
|
101
|
+
};
|
|
102
|
+
}, {
|
|
103
|
+
offset: !label_position || label_position === STATISTIC_LABEL_POSITIONS[0] ? -2 : undefined,
|
|
104
|
+
style: {
|
|
105
|
+
fill: '#000000',
|
|
106
|
+
fontSize: StatisticsUtils.getLabelFontSize(label_font_size),
|
|
107
|
+
shadowBlur: 2,
|
|
108
|
+
shadowColor: 'rgba(0, 0, 0, .45)'
|
|
109
|
+
}
|
|
110
|
+
}).tooltip('name*value*percent', function (name, value, percent) {
|
|
111
|
+
var title = name;
|
|
112
|
+
if (!name || name === 'undefined') {
|
|
113
|
+
title = intl.get('Empty');
|
|
114
|
+
} else if (name === '_Others') {
|
|
115
|
+
title = intl.get('Others');
|
|
116
|
+
}
|
|
117
|
+
var displayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
118
|
+
return {
|
|
119
|
+
name: title,
|
|
120
|
+
value: display_label ? _this.getLabel(displayValue, percent) : displayValue
|
|
121
|
+
};
|
|
122
|
+
}).state({
|
|
123
|
+
active: {
|
|
124
|
+
style: {
|
|
125
|
+
fillOpacity: 0.7,
|
|
126
|
+
border: 'none',
|
|
127
|
+
stroke: 0
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
_this.chart.tooltip({
|
|
132
|
+
showTitle: false,
|
|
133
|
+
showMarkers: false,
|
|
134
|
+
itemTpl: '<div class="g2-tooltip-list-item"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</div>'
|
|
135
|
+
});
|
|
136
|
+
_this.chart.interaction('statistic-active');
|
|
137
|
+
_this.setAnnotation({
|
|
138
|
+
name: intl.get('Total'),
|
|
139
|
+
value: StatisticsUtils.getSummaryValueDisplayString(summaryColumn, _this.sum, summary_method)
|
|
140
|
+
}, '#000000');
|
|
141
|
+
_this.chart.on('interval:mouseenter', function (evt) {
|
|
142
|
+
return _this.onEnterRingChart(evt, '#000000', {
|
|
143
|
+
summaryColumn: summaryColumn,
|
|
144
|
+
summaryMethod: summary_method
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
_this.chart.on('interval:mouseleave', function (evt) {
|
|
148
|
+
return _this.onLeaveRingChart(evt, '#000000', {
|
|
149
|
+
summaryColumn: summaryColumn,
|
|
150
|
+
summaryMethod: summary_method
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
_this.chart.render();
|
|
154
|
+
};
|
|
155
|
+
_this.getLabel = function (value, percent) {
|
|
156
|
+
var _this$props$statistic = _this.props.statistic.config,
|
|
157
|
+
display_label = _this$props$statistic.display_label,
|
|
158
|
+
label_format = _this$props$statistic.label_format;
|
|
159
|
+
if (!display_label) {
|
|
160
|
+
return '';
|
|
161
|
+
}
|
|
162
|
+
switch (label_format) {
|
|
163
|
+
case STATISTIC_LABEL_FORMATS[0]:
|
|
164
|
+
return percent;
|
|
165
|
+
case STATISTIC_LABEL_FORMATS[1]:
|
|
166
|
+
return value;
|
|
167
|
+
case STATISTIC_LABEL_FORMATS[2]:
|
|
168
|
+
return "".concat(value, " (").concat(percent, ")");
|
|
169
|
+
default:
|
|
170
|
+
return percent;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
_this.setAnnotation = function (content, fontColor) {
|
|
174
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
175
|
+
summaryColumn = _ref.summaryColumn,
|
|
176
|
+
summaryMethod = _ref.summaryMethod;
|
|
177
|
+
var name = content.name;
|
|
178
|
+
if (!name || name === 'undefined') {
|
|
179
|
+
name = intl.get('Empty');
|
|
180
|
+
} else if (name === '_Others') {
|
|
181
|
+
name = intl.get('Others');
|
|
182
|
+
}
|
|
183
|
+
_this.chart.annotation().text({
|
|
184
|
+
content: name,
|
|
185
|
+
position: ['50%', '50%'],
|
|
186
|
+
style: {
|
|
187
|
+
fontSize: 12,
|
|
188
|
+
fill: fontColor,
|
|
189
|
+
fontWeight: '300',
|
|
190
|
+
textAlign: 'center'
|
|
191
|
+
},
|
|
192
|
+
offsetY: -20
|
|
193
|
+
}).text({
|
|
194
|
+
position: ['50%', '50%'],
|
|
195
|
+
content: summaryColumn ? StatisticsUtils.getSummaryValueDisplayString(summaryColumn, content.value, summaryMethod) : content.value,
|
|
196
|
+
style: {
|
|
197
|
+
fontSize: 20,
|
|
198
|
+
fill: fontColor,
|
|
199
|
+
textAlign: 'center'
|
|
200
|
+
},
|
|
201
|
+
offsetY: 20
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
_this.onEnterRingChart = function (ev, color, _ref2) {
|
|
205
|
+
var summaryColumn = _ref2.summaryColumn,
|
|
206
|
+
summaryMethod = _ref2.summaryMethod;
|
|
207
|
+
var item = ev.data.data;
|
|
208
|
+
_this.chart.annotation().clear(true);
|
|
209
|
+
_this.setAnnotation(item, color, {
|
|
210
|
+
summaryColumn: summaryColumn,
|
|
211
|
+
summaryMethod: summaryMethod
|
|
212
|
+
});
|
|
213
|
+
_this.chart.render(true);
|
|
214
|
+
};
|
|
215
|
+
_this.onLeaveRingChart = function (ev, color, _ref3) {
|
|
216
|
+
var summaryColumn = _ref3.summaryColumn,
|
|
217
|
+
summaryMethod = _ref3.summaryMethod;
|
|
218
|
+
_this.chart.annotation().clear(true);
|
|
219
|
+
_this.setAnnotation({
|
|
220
|
+
name: intl.get('Total'),
|
|
221
|
+
value: _this.sum
|
|
222
|
+
}, color, {
|
|
223
|
+
summaryColumn: summaryColumn,
|
|
224
|
+
summaryMethod: summaryMethod
|
|
225
|
+
});
|
|
226
|
+
_this.chart.render(true);
|
|
227
|
+
};
|
|
228
|
+
_this.sum = 0;
|
|
229
|
+
_this.chart = null;
|
|
230
|
+
return _this;
|
|
231
|
+
}
|
|
232
|
+
_createClass(Ring, [{
|
|
233
|
+
key: "componentDidMount",
|
|
234
|
+
value: function componentDidMount() {
|
|
235
|
+
this.createChart();
|
|
236
|
+
this.drawChart();
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "componentDidUpdate",
|
|
240
|
+
value: function componentDidUpdate(prevProps) {
|
|
241
|
+
if (StatisticsUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
242
|
+
this.chart && this.destroyChart();
|
|
243
|
+
this.sum = 0;
|
|
244
|
+
this.createChart();
|
|
245
|
+
this.drawChart();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}, {
|
|
249
|
+
key: "componentWillUnmount",
|
|
250
|
+
value: function componentWillUnmount() {
|
|
251
|
+
this.chart && this.destroyChart();
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "render",
|
|
255
|
+
value: function render() {
|
|
256
|
+
var _this2 = this;
|
|
257
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
258
|
+
className: "seastatistic-container w-100",
|
|
259
|
+
ref: function ref(_ref4) {
|
|
260
|
+
return _this2.container = _ref4;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}]);
|
|
265
|
+
return Ring;
|
|
266
|
+
}(ChartComponent);
|
|
267
|
+
Ring.propTypes = {
|
|
268
|
+
canvasStyle: PropTypes.object,
|
|
269
|
+
statistic: PropTypes.object,
|
|
270
|
+
groupbyColumn: PropTypes.object,
|
|
271
|
+
columnGroupbyColumn: PropTypes.object,
|
|
272
|
+
summaryColumn: PropTypes.object,
|
|
273
|
+
result: PropTypes.array,
|
|
274
|
+
tables: PropTypes.array,
|
|
275
|
+
toggleRecords: PropTypes.func
|
|
276
|
+
};
|
|
277
|
+
export default Ring;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
.seastatistic-pivot-table {
|
|
2
|
+
width: 100%;
|
|
3
|
+
position: relative;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.seastatistic-pivot-table thead {
|
|
7
|
+
border-top: 1px solid #ccc;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.seastatistic-pivot-table tr {
|
|
11
|
+
border-bottom: 1px solid #ccc;
|
|
12
|
+
text-align: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.seastatistic-pivot-table th {
|
|
16
|
+
color: #212529;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.seastatistic-pivot-table th,
|
|
20
|
+
.seastatistic-pivot-table td {
|
|
21
|
+
padding: 10px;
|
|
22
|
+
border-right: 1px solid #ccc;
|
|
23
|
+
border-left: 1px solid #ccc;
|
|
24
|
+
border-bottom: none;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
min-width: 100px;
|
|
27
|
+
width: 150px;
|
|
28
|
+
max-width: 150px;
|
|
29
|
+
font-weight: 400;
|
|
30
|
+
text-overflow: ellipsis;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
text-align: center;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.seastatistic-pivot-table .column-title,
|
|
36
|
+
.seastatistic-pivot-table .row-title {
|
|
37
|
+
padding: 0;
|
|
38
|
+
text-align: center;
|
|
39
|
+
color: inherit;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.seastatistic-pivot-table .column-title {
|
|
43
|
+
caption-side: top;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.seastatistic-pivot-table .row-title {
|
|
47
|
+
position: absolute;
|
|
48
|
+
transform: rotate(-90deg);
|
|
49
|
+
width: 100px;
|
|
50
|
+
left: -60px;
|
|
51
|
+
top: 50%;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.seastatistic-pivot-table .pivot-cell {
|
|
58
|
+
position: relative;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.seastatistic-pivot-table .pivot-cell:hover {
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.seastatistic-pivot-table .selected-pivot-cell {
|
|
67
|
+
border-bottom: 1px solid #66afe9;
|
|
68
|
+
border-right: 1px solid #66afe9;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.seastatistic-pivot-table .selected-pivot-cell-top {
|
|
72
|
+
border-bottom: 1px solid #66afe9;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.seastatistic-pivot-table .selected-pivot-cell-left {
|
|
76
|
+
border-right: 1px solid #66afe9 ;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.seastatistic-pivot-table .selected-pivot-cell-border {
|
|
80
|
+
display: inline-block;
|
|
81
|
+
width: 100%;
|
|
82
|
+
height: 100%;
|
|
83
|
+
position: absolute;
|
|
84
|
+
top: 0px;
|
|
85
|
+
left: 0px;
|
|
86
|
+
border: 1px solid #66afe9;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.seastatistic-pivot-table .pivot-empty-cell i {
|
|
90
|
+
display: inline-block;
|
|
91
|
+
height: 6px;
|
|
92
|
+
width: 16px;
|
|
93
|
+
border-radius: 6px;
|
|
94
|
+
background: #f1f1f1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.seastatistic-pivot-table td>div {
|
|
98
|
+
white-space: nowrap;
|
|
99
|
+
text-overflow: ellipsis;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
font-size: 13px;
|
|
102
|
+
max-width: 100%;
|
|
103
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React, { PureComponent } from 'react';
|
|
6
|
+
import TwoDimensionTable from './two-dimension-table';
|
|
7
|
+
import OneDimensionTableNoNumericColumns from './one-dimension-table-no-numeric-columns';
|
|
8
|
+
import OneDimensionTableWithNumericColumns from './one-dimension-table-with-numeric-columns';
|
|
9
|
+
import intl from '../../../intl';
|
|
10
|
+
import './index.css';
|
|
11
|
+
var Table = /*#__PURE__*/function (_PureComponent) {
|
|
12
|
+
_inherits(Table, _PureComponent);
|
|
13
|
+
var _super = _createSuper(Table);
|
|
14
|
+
function Table() {
|
|
15
|
+
_classCallCheck(this, Table);
|
|
16
|
+
return _super.apply(this, arguments);
|
|
17
|
+
}
|
|
18
|
+
_createClass(Table, [{
|
|
19
|
+
key: "render",
|
|
20
|
+
value: function render() {
|
|
21
|
+
var _this$props = this.props,
|
|
22
|
+
groupbyColumn = _this$props.groupbyColumn,
|
|
23
|
+
columnGroupbyColumn = _this$props.columnGroupbyColumn,
|
|
24
|
+
result = _this$props.result;
|
|
25
|
+
var pivot_columns = result.pivot_columns;
|
|
26
|
+
if (!groupbyColumn) return '';
|
|
27
|
+
if (Array.isArray(pivot_columns) && pivot_columns.length > 100) {
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", null, intl.get('There_are_too_many_statistics_entries_to_display'));
|
|
29
|
+
}
|
|
30
|
+
if (columnGroupbyColumn) {
|
|
31
|
+
return /*#__PURE__*/React.createElement(TwoDimensionTable, this.props);
|
|
32
|
+
}
|
|
33
|
+
if (!Array.isArray(pivot_columns)) return null;
|
|
34
|
+
if (pivot_columns.length < 2) {
|
|
35
|
+
return /*#__PURE__*/React.createElement(OneDimensionTableNoNumericColumns, this.props);
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/React.createElement(OneDimensionTableWithNumericColumns, this.props);
|
|
38
|
+
}
|
|
39
|
+
}]);
|
|
40
|
+
return Table;
|
|
41
|
+
}(PureComponent);
|
|
42
|
+
export default Table;
|