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,181 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { STATISTIC_TYPE, STATISTIC_THEME_COLOR } from '../../constants';
|
|
3
|
+
import { StatisticsUtils, eventStopPropagation } from '../../utils';
|
|
4
|
+
import Table from './table';
|
|
5
|
+
import Bar from './bar';
|
|
6
|
+
import BarGroup from './bar-group';
|
|
7
|
+
import Line from './line';
|
|
8
|
+
import LineGroup from './line-group';
|
|
9
|
+
import Pie from './pie';
|
|
10
|
+
import Ring from './ring';
|
|
11
|
+
import HorizontalBar from './horizontal-bar';
|
|
12
|
+
import HorizontalBarGroup from './horizontal-bar-group';
|
|
13
|
+
import Area from './area';
|
|
14
|
+
import BasicNumericCard from './basic-number-card';
|
|
15
|
+
import Treemap from './treemap';
|
|
16
|
+
import Combination from './combination';
|
|
17
|
+
import Dashboard from './dashboard';
|
|
18
|
+
var Formatter = function Formatter(_ref) {
|
|
19
|
+
var data = _ref.data,
|
|
20
|
+
statistic = _ref.statistic,
|
|
21
|
+
tables = _ref.tables,
|
|
22
|
+
canvasStyle = _ref.canvasStyle;
|
|
23
|
+
// const [statisticRecords, setStatisticRecords] = useState({});
|
|
24
|
+
// const [isStatisticRecordsDialogShow, setIsStatisticRecordsDialogShow] = useState(false);
|
|
25
|
+
// const [selectedCell, setSelectedCell] = useState({});
|
|
26
|
+
|
|
27
|
+
var toggleStatisticRecordsDialog = useCallback(function (statisticRecords, selectedCell) {
|
|
28
|
+
// setIsStatisticRecordsDialogShow(!isStatisticRecordsDialogShow)
|
|
29
|
+
// setSelectedCell(selectedCell);
|
|
30
|
+
// setStatisticRecords(statisticRecords);
|
|
31
|
+
}, []);
|
|
32
|
+
var onTableClick = useCallback(function (event) {
|
|
33
|
+
eventStopPropagation(event);
|
|
34
|
+
}, []);
|
|
35
|
+
var result = data.result,
|
|
36
|
+
groupbyColumn = data.groupbyColumn,
|
|
37
|
+
columnGroupbyColumn = data.columnGroupbyColumn,
|
|
38
|
+
summaryColumn = data.summaryColumn,
|
|
39
|
+
statisticTableColumns = data.statisticTableColumns;
|
|
40
|
+
var _statistic$config = statistic.config,
|
|
41
|
+
type = _statistic$config.type,
|
|
42
|
+
summary_columns = _statistic$config.summary_columns,
|
|
43
|
+
summary_method = _statistic$config.summary_method;
|
|
44
|
+
var baseProps = {
|
|
45
|
+
statistic: statistic,
|
|
46
|
+
result: result,
|
|
47
|
+
tables: tables,
|
|
48
|
+
groupbyColumn: groupbyColumn,
|
|
49
|
+
columnGroupbyColumn: columnGroupbyColumn,
|
|
50
|
+
summaryColumn: summaryColumn,
|
|
51
|
+
theme: STATISTIC_THEME_COLOR['light'],
|
|
52
|
+
toggleRecords: toggleStatisticRecordsDialog
|
|
53
|
+
};
|
|
54
|
+
switch (type) {
|
|
55
|
+
case STATISTIC_TYPE.TABLE:
|
|
56
|
+
{
|
|
57
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: "statistic-table-wrapper",
|
|
59
|
+
onClick: onTableClick
|
|
60
|
+
}, result && /*#__PURE__*/React.createElement(Table, Object.assign({}, baseProps, {
|
|
61
|
+
summaryColumns: summary_columns,
|
|
62
|
+
summaryMethod: summary_method,
|
|
63
|
+
statisticTableColumns: statisticTableColumns
|
|
64
|
+
})));
|
|
65
|
+
}
|
|
66
|
+
case STATISTIC_TYPE.COMBINATION:
|
|
67
|
+
{
|
|
68
|
+
return /*#__PURE__*/React.createElement(Combination, Object.assign({}, baseProps, {
|
|
69
|
+
canvasStyle: canvasStyle
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
case STATISTIC_TYPE.BAR:
|
|
73
|
+
{
|
|
74
|
+
return /*#__PURE__*/React.createElement(Bar, Object.assign({}, baseProps, {
|
|
75
|
+
canvasStyle: canvasStyle
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
case STATISTIC_TYPE.BAR_GROUP:
|
|
79
|
+
{
|
|
80
|
+
var config = statistic.config;
|
|
81
|
+
var column_groupby_column_key = config.column_groupby_column_key,
|
|
82
|
+
column_groupby_multiple_numeric_column = config.column_groupby_multiple_numeric_column;
|
|
83
|
+
var BarGroupComponent = column_groupby_column_key || column_groupby_multiple_numeric_column ? BarGroup : Bar;
|
|
84
|
+
return /*#__PURE__*/React.createElement(BarGroupComponent, Object.assign({}, baseProps, {
|
|
85
|
+
canvasStyle: canvasStyle
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
case STATISTIC_TYPE.HORIZONTAL_BAR:
|
|
89
|
+
{
|
|
90
|
+
var _config = statistic.config,
|
|
91
|
+
id = statistic.id,
|
|
92
|
+
style_config = statistic.style_config;
|
|
93
|
+
var newConfig = StatisticsUtils.convertStatisticConfig(_config);
|
|
94
|
+
var newStatistic = {
|
|
95
|
+
id: id,
|
|
96
|
+
config: newConfig,
|
|
97
|
+
style_config: style_config
|
|
98
|
+
};
|
|
99
|
+
return /*#__PURE__*/React.createElement(HorizontalBar, Object.assign({}, baseProps, {
|
|
100
|
+
canvasStyle: canvasStyle,
|
|
101
|
+
statistic: newStatistic
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
case STATISTIC_TYPE.HORIZONTAL_GROUP_BAR:
|
|
105
|
+
{
|
|
106
|
+
var _config2 = statistic.config,
|
|
107
|
+
_id = statistic.id,
|
|
108
|
+
_style_config = statistic.style_config;
|
|
109
|
+
var _newConfig = StatisticsUtils.convertStatisticConfig(_config2);
|
|
110
|
+
var _newStatistic = {
|
|
111
|
+
id: _id,
|
|
112
|
+
config: _newConfig,
|
|
113
|
+
style_config: _style_config
|
|
114
|
+
};
|
|
115
|
+
var _column_groupby_column_key = _config2.column_groupby_column_key,
|
|
116
|
+
_column_groupby_multiple_numeric_column = _config2.column_groupby_multiple_numeric_column;
|
|
117
|
+
var HorizontalComponent = _column_groupby_column_key || _column_groupby_multiple_numeric_column ? HorizontalBarGroup : HorizontalBar;
|
|
118
|
+
return /*#__PURE__*/React.createElement(HorizontalComponent, Object.assign({}, baseProps, {
|
|
119
|
+
canvasStyle: canvasStyle,
|
|
120
|
+
statistic: _newStatistic
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
case STATISTIC_TYPE.LINE_GROUP:
|
|
124
|
+
{
|
|
125
|
+
var _config3 = statistic.config;
|
|
126
|
+
var _column_groupby_column_key2 = _config3.column_groupby_column_key,
|
|
127
|
+
_column_groupby_multiple_numeric_column2 = _config3.column_groupby_multiple_numeric_column;
|
|
128
|
+
var LineGroupComponent = _column_groupby_column_key2 || _column_groupby_multiple_numeric_column2 ? LineGroup : Line;
|
|
129
|
+
return /*#__PURE__*/React.createElement(LineGroupComponent, Object.assign({}, baseProps, {
|
|
130
|
+
canvasStyle: canvasStyle
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
case STATISTIC_TYPE.LINE:
|
|
134
|
+
{
|
|
135
|
+
return /*#__PURE__*/React.createElement(Line, Object.assign({}, baseProps, {
|
|
136
|
+
canvasStyle: canvasStyle
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
case STATISTIC_TYPE.BASIC_NUMBER_CARD:
|
|
140
|
+
{
|
|
141
|
+
return /*#__PURE__*/React.createElement(BasicNumericCard, Object.assign({}, baseProps, {
|
|
142
|
+
canvasStyle: canvasStyle
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
case STATISTIC_TYPE.AREA:
|
|
146
|
+
{
|
|
147
|
+
return /*#__PURE__*/React.createElement(Area, Object.assign({}, baseProps, {
|
|
148
|
+
canvasStyle: canvasStyle
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
case STATISTIC_TYPE.PIE:
|
|
152
|
+
{
|
|
153
|
+
return /*#__PURE__*/React.createElement(Pie, Object.assign({}, baseProps, {
|
|
154
|
+
canvasStyle: canvasStyle
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
case STATISTIC_TYPE.RING:
|
|
158
|
+
{
|
|
159
|
+
return /*#__PURE__*/React.createElement(Ring, Object.assign({}, baseProps, {
|
|
160
|
+
canvasStyle: canvasStyle
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
case STATISTIC_TYPE.TREE_MAP:
|
|
164
|
+
{
|
|
165
|
+
return /*#__PURE__*/React.createElement(Treemap, Object.assign({}, baseProps, {
|
|
166
|
+
canvasStyle: canvasStyle
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
case STATISTIC_TYPE.DASHBOARD:
|
|
170
|
+
{
|
|
171
|
+
return /*#__PURE__*/React.createElement(Dashboard, Object.assign({}, baseProps, {
|
|
172
|
+
canvasStyle: canvasStyle
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
default:
|
|
176
|
+
{
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
export default Formatter;
|
|
@@ -0,0 +1,157 @@
|
|
|
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 classnames from 'classnames';
|
|
8
|
+
import { EMPTY_NAME } from '../../constants';
|
|
9
|
+
import { StatisticsUtils } from '../../utils';
|
|
10
|
+
import intl from '../../intl';
|
|
11
|
+
import ChartComponent from './chart-component';
|
|
12
|
+
var LineGroup = /*#__PURE__*/function (_ChartComponent) {
|
|
13
|
+
_inherits(LineGroup, _ChartComponent);
|
|
14
|
+
var _super = _createSuper(LineGroup);
|
|
15
|
+
function LineGroup(props) {
|
|
16
|
+
var _this;
|
|
17
|
+
_classCallCheck(this, LineGroup);
|
|
18
|
+
_this = _super.call(this, props);
|
|
19
|
+
_this.createChart = function () {
|
|
20
|
+
var statistic = _this.props.statistic;
|
|
21
|
+
var y_axis_show_value = statistic.config.y_axis_show_value;
|
|
22
|
+
var appendPadding = [y_axis_show_value ? 17 : 0, 0, 0, 0];
|
|
23
|
+
_this.initChart(_this.container, {
|
|
24
|
+
appendPadding: appendPadding
|
|
25
|
+
});
|
|
26
|
+
_this.chart.on('statistic:click', function (e) {
|
|
27
|
+
_this.props.toggleRecords(e.data.data);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
_this.clearChart = function () {
|
|
31
|
+
_this.chart.annotation().clear(true);
|
|
32
|
+
_this.chart.clear(true);
|
|
33
|
+
};
|
|
34
|
+
_this.drawChart = function () {
|
|
35
|
+
var data = _this.props.result;
|
|
36
|
+
data = StatisticsUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
37
|
+
if (!Array.isArray(data)) return;
|
|
38
|
+
_this.chart.scale(_this.groupName, {
|
|
39
|
+
type: 'cat'
|
|
40
|
+
});
|
|
41
|
+
_this.loadData(data);
|
|
42
|
+
_this.draw(data);
|
|
43
|
+
_this.chart.render();
|
|
44
|
+
};
|
|
45
|
+
_this.draw = function (data) {
|
|
46
|
+
var _this$props = _this.props,
|
|
47
|
+
statistic = _this$props.statistic,
|
|
48
|
+
summaryColumn = _this$props.summaryColumn,
|
|
49
|
+
theme = _this$props.theme;
|
|
50
|
+
var _statistic$config = statistic.config,
|
|
51
|
+
y_axis_summary_method = _statistic$config.y_axis_summary_method,
|
|
52
|
+
y_axis_show_value = _statistic$config.y_axis_show_value,
|
|
53
|
+
label_font_size = _statistic$config.label_font_size;
|
|
54
|
+
var chartBarColor = _this.groupName;
|
|
55
|
+
var newData = _this.getChartGroupData(data);
|
|
56
|
+
_this.drawLabels(newData);
|
|
57
|
+
|
|
58
|
+
// set Coord type
|
|
59
|
+
_this.chart.coordinate('rect');
|
|
60
|
+
_this.autoAdjustDataOptions(statistic, data, summaryColumn);
|
|
61
|
+
_this.chart.scale({
|
|
62
|
+
group_name: {
|
|
63
|
+
type: 'cat'
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
_this.chart.line().position('name*value').color(chartBarColor);
|
|
67
|
+
_this.chart.point().label(y_axis_show_value ? 'value' : false, {
|
|
68
|
+
style: {
|
|
69
|
+
fontSize: StatisticsUtils.getLabelFontSize(label_font_size),
|
|
70
|
+
fill: theme.textColor
|
|
71
|
+
}
|
|
72
|
+
}).position('name*value').size(3).color(chartBarColor).tooltip('name*value*group_name', function (name, value, group_name) {
|
|
73
|
+
return {
|
|
74
|
+
title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
75
|
+
value: StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
76
|
+
name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
|
|
77
|
+
};
|
|
78
|
+
}).shape('circle').style({
|
|
79
|
+
lineWidth: 1,
|
|
80
|
+
stroke: '#fff'
|
|
81
|
+
});
|
|
82
|
+
_this.chart.tooltip({
|
|
83
|
+
showCrosshairs: true,
|
|
84
|
+
showTitle: true,
|
|
85
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
86
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
87
|
+
domStyles: {
|
|
88
|
+
'g2-tooltip': {
|
|
89
|
+
borderRadius: '2px',
|
|
90
|
+
backgroundColor: '#fff',
|
|
91
|
+
padding: '10px'
|
|
92
|
+
},
|
|
93
|
+
'tooltip-item': {
|
|
94
|
+
marginTop: '5px'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
_this.setNameLabelAndTooltip(theme, _this.labelCount);
|
|
99
|
+
_this.setValueLabel(theme);
|
|
100
|
+
_this.setLegend(_this.groupName, theme, 'bottom');
|
|
101
|
+
};
|
|
102
|
+
_this.chart = null;
|
|
103
|
+
_this.groupName = 'group_name';
|
|
104
|
+
return _this;
|
|
105
|
+
}
|
|
106
|
+
_createClass(LineGroup, [{
|
|
107
|
+
key: "componentDidMount",
|
|
108
|
+
value: function componentDidMount() {
|
|
109
|
+
this.createChart();
|
|
110
|
+
this.drawChart();
|
|
111
|
+
this.renderAxisLabel(this.props.statistic, this.props.tables);
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "componentDidUpdate",
|
|
115
|
+
value: function componentDidUpdate(prevProps) {
|
|
116
|
+
if (StatisticsUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
117
|
+
this.chart && this.chart.destroy();
|
|
118
|
+
this.createChart();
|
|
119
|
+
this.drawChart();
|
|
120
|
+
this.renderAxisLabel(prevProps.statistic, prevProps.tables);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "componentWillUnmount",
|
|
125
|
+
value: function componentWillUnmount() {
|
|
126
|
+
this.chart && this.chart.destroy();
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "render",
|
|
130
|
+
value: function render() {
|
|
131
|
+
var _this2 = this;
|
|
132
|
+
var statistic = this.props.statistic;
|
|
133
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
134
|
+
className: classnames('seastatistic-container w-100', {
|
|
135
|
+
'show-x-axis-label': this.isShowXAxisLabel(statistic),
|
|
136
|
+
'show-y-axis-label': this.isShowYAxisLabel(statistic)
|
|
137
|
+
}),
|
|
138
|
+
ref: function ref(_ref) {
|
|
139
|
+
return _this2.container = _ref;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}]);
|
|
144
|
+
return LineGroup;
|
|
145
|
+
}(ChartComponent);
|
|
146
|
+
LineGroup.propTypes = {
|
|
147
|
+
canvasStyle: PropTypes.object,
|
|
148
|
+
statistic: PropTypes.object,
|
|
149
|
+
groupbyColumn: PropTypes.object,
|
|
150
|
+
columnGroupbyColumn: PropTypes.object,
|
|
151
|
+
summaryColumn: PropTypes.object,
|
|
152
|
+
result: PropTypes.array,
|
|
153
|
+
tables: PropTypes.array,
|
|
154
|
+
theme: PropTypes.object,
|
|
155
|
+
toggleRecords: PropTypes.func
|
|
156
|
+
};
|
|
157
|
+
export default LineGroup;
|
|
@@ -0,0 +1,170 @@
|
|
|
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 classnames from 'classnames';
|
|
8
|
+
import { STATISTIC_SUMMARY_TYPE, STATISTIC_SUMMARY_SHOW } from '../../constants';
|
|
9
|
+
import { StatisticsUtils } from '../../utils';
|
|
10
|
+
import ChartComponent from './chart-component';
|
|
11
|
+
import intl from '../../intl';
|
|
12
|
+
var Line = /*#__PURE__*/function (_ChartComponent) {
|
|
13
|
+
_inherits(Line, _ChartComponent);
|
|
14
|
+
var _super = _createSuper(Line);
|
|
15
|
+
function Line(props) {
|
|
16
|
+
var _this;
|
|
17
|
+
_classCallCheck(this, Line);
|
|
18
|
+
_this = _super.call(this, props);
|
|
19
|
+
_this.createChart = function () {
|
|
20
|
+
var statistic = _this.props.statistic;
|
|
21
|
+
var y_axis_show_value = statistic.config.y_axis_show_value;
|
|
22
|
+
var appendPadding = [y_axis_show_value ? 17 : 0, 0, 0, 0];
|
|
23
|
+
_this.initChart(_this.container, {
|
|
24
|
+
appendPadding: appendPadding
|
|
25
|
+
});
|
|
26
|
+
_this.chart.on('point:click', function (e) {
|
|
27
|
+
_this.props.toggleRecords(e.data.data);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
_this.clearChart = function () {
|
|
31
|
+
_this.chart.annotation().clear(true);
|
|
32
|
+
_this.chart.clear(true);
|
|
33
|
+
};
|
|
34
|
+
_this.drawChart = function () {
|
|
35
|
+
var _this$props = _this.props,
|
|
36
|
+
data = _this$props.result,
|
|
37
|
+
statistic = _this$props.statistic,
|
|
38
|
+
summaryColumn = _this$props.summaryColumn;
|
|
39
|
+
data = StatisticsUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
40
|
+
if (!Array.isArray(data)) return;
|
|
41
|
+
_this.loadData(data);
|
|
42
|
+
_this.draw(data);
|
|
43
|
+
_this.autoAdjustDataOptions(statistic, data, summaryColumn);
|
|
44
|
+
_this.chart.render();
|
|
45
|
+
};
|
|
46
|
+
_this.draw = function (data) {
|
|
47
|
+
var _this$props2 = _this.props,
|
|
48
|
+
summaryColumn = _this$props2.summaryColumn,
|
|
49
|
+
statistic = _this$props2.statistic,
|
|
50
|
+
theme = _this$props2.theme;
|
|
51
|
+
var _statistic$config = statistic.config,
|
|
52
|
+
y_axis_summary_type = _statistic$config.y_axis_summary_type,
|
|
53
|
+
y_axis_summary_method = _statistic$config.y_axis_summary_method,
|
|
54
|
+
y_axis_label_color = _statistic$config.y_axis_label_color,
|
|
55
|
+
y_axis_show_value = _statistic$config.y_axis_show_value,
|
|
56
|
+
label_font_size = _statistic$config.label_font_size;
|
|
57
|
+
var chartBarColor = y_axis_label_color || '#2a67d1';
|
|
58
|
+
_this.drawLabels(data);
|
|
59
|
+
|
|
60
|
+
// set Coord type
|
|
61
|
+
_this.chart.coordinate('rect');
|
|
62
|
+
_this.chart.line().label(y_axis_show_value ? 'value' : false, {
|
|
63
|
+
style: {
|
|
64
|
+
fontSize: StatisticsUtils.getLabelFontSize(label_font_size),
|
|
65
|
+
fill: theme.textColor
|
|
66
|
+
}
|
|
67
|
+
}).position('name*value').color(chartBarColor).tooltip('name*value', function (name, value) {
|
|
68
|
+
return {
|
|
69
|
+
name: y_axis_summary_type === STATISTIC_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(STATISTIC_SUMMARY_SHOW[y_axis_summary_method]),
|
|
70
|
+
value: StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method)
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
_this.chart.point().position('name*value').color(chartBarColor).shape('circle').size(3).style({
|
|
74
|
+
lineWidth: 1,
|
|
75
|
+
stroke: '#fff'
|
|
76
|
+
}).tooltip('name*value', function (name, value) {
|
|
77
|
+
return {
|
|
78
|
+
name: name,
|
|
79
|
+
value: StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
|
|
80
|
+
title: y_axis_summary_type === STATISTIC_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(STATISTIC_SUMMARY_SHOW[y_axis_summary_method])
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
_this.chart.tooltip({
|
|
84
|
+
showCrosshairs: true,
|
|
85
|
+
showTitle: true,
|
|
86
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
87
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
88
|
+
domStyles: {
|
|
89
|
+
'g2-tooltip': {
|
|
90
|
+
borderRadius: '2px',
|
|
91
|
+
backgroundColor: '#fff',
|
|
92
|
+
padding: '10px'
|
|
93
|
+
},
|
|
94
|
+
'tooltip-item': {
|
|
95
|
+
marginTop: '5px'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
_this.setNameLabelAndTooltip(theme, _this.labelCount);
|
|
100
|
+
_this.setValueLabel(theme);
|
|
101
|
+
_this.chart.theme({
|
|
102
|
+
geometries: {
|
|
103
|
+
point: {
|
|
104
|
+
circle: {
|
|
105
|
+
active: {
|
|
106
|
+
style: {
|
|
107
|
+
stroke: 'rgba(0, 0, 0, 0)',
|
|
108
|
+
r: 4
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
_this.chart = null;
|
|
117
|
+
return _this;
|
|
118
|
+
}
|
|
119
|
+
_createClass(Line, [{
|
|
120
|
+
key: "componentDidMount",
|
|
121
|
+
value: function componentDidMount() {
|
|
122
|
+
this.createChart();
|
|
123
|
+
this.drawChart();
|
|
124
|
+
this.renderAxisLabel(this.props.statistic, this.props.tables);
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "componentDidUpdate",
|
|
128
|
+
value: function componentDidUpdate(prevProps) {
|
|
129
|
+
if (StatisticsUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
130
|
+
this.chart && this.chart.destroy();
|
|
131
|
+
this.createChart();
|
|
132
|
+
this.drawChart();
|
|
133
|
+
this.renderAxisLabel(prevProps.statistic, prevProps.tables);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "componentWillUnmount",
|
|
138
|
+
value: function componentWillUnmount() {
|
|
139
|
+
this.chart && this.chart.destroy();
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "render",
|
|
143
|
+
value: function render() {
|
|
144
|
+
var _this2 = this;
|
|
145
|
+
var statistic = this.props.statistic;
|
|
146
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
className: classnames('seastatistic-container w-100', {
|
|
148
|
+
'show-x-axis-label': this.isShowXAxisLabel(statistic),
|
|
149
|
+
'show-y-axis-label': this.isShowYAxisLabel(statistic)
|
|
150
|
+
}),
|
|
151
|
+
ref: function ref(_ref) {
|
|
152
|
+
return _this2.container = _ref;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}]);
|
|
157
|
+
return Line;
|
|
158
|
+
}(ChartComponent);
|
|
159
|
+
Line.propTypes = {
|
|
160
|
+
canvasStyle: PropTypes.object,
|
|
161
|
+
statistic: PropTypes.object,
|
|
162
|
+
groupbyColumn: PropTypes.object,
|
|
163
|
+
columnGroupbyColumn: PropTypes.object,
|
|
164
|
+
summaryColumn: PropTypes.object,
|
|
165
|
+
result: PropTypes.array,
|
|
166
|
+
tables: PropTypes.array,
|
|
167
|
+
theme: PropTypes.object,
|
|
168
|
+
toggleRecords: PropTypes.func
|
|
169
|
+
};
|
|
170
|
+
export default Line;
|