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.
Files changed (214) hide show
  1. package/README.md +4 -0
  2. package/lib/assets/icons/area-chart.svg +10 -0
  3. package/lib/assets/icons/bar-chart.svg +12 -0
  4. package/lib/assets/icons/card.svg +22 -0
  5. package/lib/assets/icons/combination-chart.svg +17 -0
  6. package/lib/assets/icons/dtable-logo.svg +16 -0
  7. package/lib/assets/icons/facet-chart.svg +12 -0
  8. package/lib/assets/icons/gauge.svg +18 -0
  9. package/lib/assets/icons/heat-map.svg +14 -0
  10. package/lib/assets/icons/histogram.svg +12 -0
  11. package/lib/assets/icons/line-chart.svg +12 -0
  12. package/lib/assets/icons/map.svg +20 -0
  13. package/lib/assets/icons/pie-chart.svg +11 -0
  14. package/lib/assets/icons/rectangular-tree-diagram.svg +10 -0
  15. package/lib/assets/icons/scatter-chart.svg +15 -0
  16. package/lib/assets/icons/type-change.svg +17 -0
  17. package/lib/assets/img/area-chart.png +0 -0
  18. package/lib/assets/img/area-group-chart.png +0 -0
  19. package/lib/assets/img/bar-group.png +0 -0
  20. package/lib/assets/img/bar-stack.png +0 -0
  21. package/lib/assets/img/bar.png +0 -0
  22. package/lib/assets/img/combination-chart.png +0 -0
  23. package/lib/assets/img/compared-chart.png +0 -0
  24. package/lib/assets/img/completeness-chart.png +0 -0
  25. package/lib/assets/img/custom-bar.png +0 -0
  26. package/lib/assets/img/dashboard-chart.png +0 -0
  27. package/lib/assets/img/group-completeness-chart.png +0 -0
  28. package/lib/assets/img/group_line.png +0 -0
  29. package/lib/assets/img/heat-map.png +0 -0
  30. package/lib/assets/img/horizontal-bar.png +0 -0
  31. package/lib/assets/img/horizontal-group-bar.png +0 -0
  32. package/lib/assets/img/line.png +0 -0
  33. package/lib/assets/img/map-bubble.png +0 -0
  34. package/lib/assets/img/map.png +0 -0
  35. package/lib/assets/img/mirror.png +0 -0
  36. package/lib/assets/img/number-card.png +0 -0
  37. package/lib/assets/img/pie.png +0 -0
  38. package/lib/assets/img/pivot-table.png +0 -0
  39. package/lib/assets/img/ring.png +0 -0
  40. package/lib/assets/img/scatter.png +0 -0
  41. package/lib/assets/img/stacked-horizontal-bar.png +0 -0
  42. package/lib/assets/img/treemap.png +0 -0
  43. package/lib/assets/img/trend-chart.png +0 -0
  44. package/lib/assets/img/world-map-bubble.png +0 -0
  45. package/lib/assets/img/world-map.png +0 -0
  46. package/lib/components/collaborator/index.js +24 -0
  47. package/lib/components/formatter/area.js +162 -0
  48. package/lib/components/formatter/bar-group.js +160 -0
  49. package/lib/components/formatter/bar.js +150 -0
  50. package/lib/components/formatter/basic-number-card.js +138 -0
  51. package/lib/components/formatter/chart-component.js +266 -0
  52. package/lib/components/formatter/combination.js +407 -0
  53. package/lib/components/formatter/dashboard.js +182 -0
  54. package/lib/components/formatter/horizontal-bar-group.js +161 -0
  55. package/lib/components/formatter/horizontal-bar.js +152 -0
  56. package/lib/components/formatter/horizontal-component.js +91 -0
  57. package/lib/components/formatter/index.js +181 -0
  58. package/lib/components/formatter/line-group.js +157 -0
  59. package/lib/components/formatter/line.js +170 -0
  60. package/lib/components/formatter/pie.js +201 -0
  61. package/lib/components/formatter/ring.js +277 -0
  62. package/lib/components/formatter/table/index.css +103 -0
  63. package/lib/components/formatter/table/index.js +42 -0
  64. package/lib/components/formatter/table/one-dimension-table-no-numeric-columns.js +145 -0
  65. package/lib/components/formatter/table/one-dimension-table-with-numeric-columns.js +193 -0
  66. package/lib/components/formatter/table/pivot-table-display-name.js +249 -0
  67. package/lib/components/formatter/table/two-dimension-table.js +241 -0
  68. package/lib/components/formatter/treemap.js +213 -0
  69. package/lib/components/icon/index.css +5 -0
  70. package/lib/components/icon/index.js +22 -0
  71. package/lib/components/index.js +5 -0
  72. package/lib/components/loading/index.css +54 -0
  73. package/lib/components/loading/index.js +10 -0
  74. package/lib/components/number-input/index.js +31 -0
  75. package/lib/components/pixel-editor/index.css +29 -0
  76. package/lib/components/pixel-editor/index.js +42 -0
  77. package/lib/components/select-group/index.css +67 -0
  78. package/lib/components/select-group/index.js +63 -0
  79. package/lib/components/settings/advance-bar-settings/data-settings.js +120 -0
  80. package/lib/components/settings/advance-bar-settings/index.js +3 -0
  81. package/lib/components/settings/advance-bar-settings/style-settings.js +149 -0
  82. package/lib/components/settings/bar-settings/data-settings.js +137 -0
  83. package/lib/components/settings/bar-settings/index.js +3 -0
  84. package/lib/components/settings/bar-settings/style-settings.js +163 -0
  85. package/lib/components/settings/basic-number-card/data-settings.js +121 -0
  86. package/lib/components/settings/basic-number-card/index.js +3 -0
  87. package/lib/components/settings/basic-number-card/style-settings.js +42 -0
  88. package/lib/components/settings/combination-settings/data-settings.js +256 -0
  89. package/lib/components/settings/combination-settings/index.js +3 -0
  90. package/lib/components/settings/combination-settings/style-settings.js +183 -0
  91. package/lib/components/settings/dashboard-settings/data-settings.js +167 -0
  92. package/lib/components/settings/dashboard-settings/index.js +2 -0
  93. package/lib/components/settings/data-settings.js +67 -0
  94. package/lib/components/settings/horizontal-bar-settings/data-settings.js +45 -0
  95. package/lib/components/settings/horizontal-bar-settings/index.js +3 -0
  96. package/lib/components/settings/horizontal-bar-settings/style-settings.js +38 -0
  97. package/lib/components/settings/index.css +73 -0
  98. package/lib/components/settings/index.js +74 -0
  99. package/lib/components/settings/pie-settings/data-settings.js +123 -0
  100. package/lib/components/settings/pie-settings/index.js +3 -0
  101. package/lib/components/settings/pie-settings/style-settings.js +123 -0
  102. package/lib/components/settings/style-settings.js +100 -0
  103. package/lib/components/settings/table-settings/data-settings.js +488 -0
  104. package/lib/components/settings/table-settings/index.js +2 -0
  105. package/lib/components/settings/time-comparison-settings/data-settings.js +157 -0
  106. package/lib/components/settings/time-comparison-settings/index.js +3 -0
  107. package/lib/components/settings/time-comparison-settings/style-settings.js +191 -0
  108. package/lib/components/settings/widgets/basic-summary/index.css +12 -0
  109. package/lib/components/settings/widgets/basic-summary/index.js +173 -0
  110. package/lib/components/settings/widgets/common-data-settings.js +42 -0
  111. package/lib/components/settings/widgets/data-filter/index.css +17 -0
  112. package/lib/components/settings/widgets/data-filter/index.js +76 -0
  113. package/lib/components/settings/widgets/data-sort.js +38 -0
  114. package/lib/components/settings/widgets/date-summary-item.js +126 -0
  115. package/lib/components/settings/widgets/display-values-settings/index.css +13 -0
  116. package/lib/components/settings/widgets/display-values-settings/index.js +37 -0
  117. package/lib/components/settings/widgets/divider/index.css +4 -0
  118. package/lib/components/settings/widgets/divider/index.js +10 -0
  119. package/lib/components/settings/widgets/font-settings/font-size-settings.js +31 -0
  120. package/lib/components/settings/widgets/font-settings/font-weight-settings.js +46 -0
  121. package/lib/components/settings/widgets/font-settings/index.js +3 -0
  122. package/lib/components/settings/widgets/group-by.js +168 -0
  123. package/lib/components/settings/widgets/label-color.js +30 -0
  124. package/lib/components/settings/widgets/min-max-setting.js +64 -0
  125. package/lib/components/settings/widgets/mininum-slice-percent.js +72 -0
  126. package/lib/components/settings/widgets/numeric-summary-item.js +109 -0
  127. package/lib/components/settings/widgets/select-table/index.css +0 -0
  128. package/lib/components/settings/widgets/select-table/index.js +49 -0
  129. package/lib/components/settings/widgets/stack.js +58 -0
  130. package/lib/components/settings/widgets/statistic-type/index.css +31 -0
  131. package/lib/components/settings/widgets/statistic-type/index.js +54 -0
  132. package/lib/components/settings/widgets/summary-method-setting.js +80 -0
  133. package/lib/components/settings/widgets/summary-settings.js +394 -0
  134. package/lib/components/settings/widgets/switch/index.css +37 -0
  135. package/lib/components/settings/widgets/switch/index.js +21 -0
  136. package/lib/components/settings/widgets/text-horizontal-settings.js +23 -0
  137. package/lib/components/settings/widgets/time-picker.js +182 -0
  138. package/lib/components/settings/widgets/title-settings/index.js +58 -0
  139. package/lib/components/settings/widgets/title-settings/title-text.js +31 -0
  140. package/lib/components/settings/widgets/x-axios.js +0 -0
  141. package/lib/components/settings/widgets/y-axis-group-settings.js +399 -0
  142. package/lib/components/types-dialog/index.css +97 -0
  143. package/lib/components/types-dialog/index.js +127 -0
  144. package/lib/constants/geolocation.js +11 -0
  145. package/lib/constants/index.js +164 -0
  146. package/lib/constants/model.js +167 -0
  147. package/lib/constants/style.js +13 -0
  148. package/lib/constants/type-image.js +32 -0
  149. package/lib/constants/type.js +97 -0
  150. package/lib/context.js +49 -0
  151. package/lib/index.js +6 -0
  152. package/lib/intl.js +37 -0
  153. package/lib/layout/index.js +4 -0
  154. package/lib/layout/statistic/index.css +53 -0
  155. package/lib/layout/statistic/index.js +190 -0
  156. package/lib/layout/title/index.css +3 -0
  157. package/lib/layout/title/index.js +41 -0
  158. package/lib/locale/index.js +11 -0
  159. package/lib/locale/lang/de.js +141 -0
  160. package/lib/locale/lang/en.js +143 -0
  161. package/lib/locale/lang/es.js +141 -0
  162. package/lib/locale/lang/fr.js +141 -0
  163. package/lib/locale/lang/pt.js +141 -0
  164. package/lib/locale/lang/ru.js +141 -0
  165. package/lib/locale/lang/zh_CN.js +143 -0
  166. package/lib/model/area-group.js +51 -0
  167. package/lib/model/area.js +42 -0
  168. package/lib/model/bar-group.js +54 -0
  169. package/lib/model/bar-stack.js +51 -0
  170. package/lib/model/bar.js +48 -0
  171. package/lib/model/base-model.js +11 -0
  172. package/lib/model/basic-number-card.js +32 -0
  173. package/lib/model/combination.js +48 -0
  174. package/lib/model/compare-bar.js +49 -0
  175. package/lib/model/completeness-group.js +34 -0
  176. package/lib/model/completeness.js +28 -0
  177. package/lib/model/dashboard.js +26 -0
  178. package/lib/model/generic-model.js +235 -0
  179. package/lib/model/heat-map.js +33 -0
  180. package/lib/model/horizontal-bar.js +48 -0
  181. package/lib/model/horizontal-group-bar.js +53 -0
  182. package/lib/model/index.js +36 -0
  183. package/lib/model/line-group.js +54 -0
  184. package/lib/model/line.js +48 -0
  185. package/lib/model/map-bubble.js +37 -0
  186. package/lib/model/map.js +37 -0
  187. package/lib/model/mirror.js +36 -0
  188. package/lib/model/pie.js +36 -0
  189. package/lib/model/ring.js +36 -0
  190. package/lib/model/scatter.js +29 -0
  191. package/lib/model/stacked-horizontal-bar.js +42 -0
  192. package/lib/model/statistic.js +22 -0
  193. package/lib/model/table.js +33 -0
  194. package/lib/model/tree-map.js +30 -0
  195. package/lib/model/trend.js +34 -0
  196. package/lib/model/user.js +22 -0
  197. package/lib/model/world-map-bubble.js +36 -0
  198. package/lib/model/world-map.js +36 -0
  199. package/lib/utils/cell-format-utils.js +41 -0
  200. package/lib/utils/chart.js +6 -0
  201. package/lib/utils/collaborator-utils.js +40 -0
  202. package/lib/utils/column-utils.js +247 -0
  203. package/lib/utils/custom-g2.js +612 -0
  204. package/lib/utils/data-filter/filter-item-utils.js +80 -0
  205. package/lib/utils/data-filter/filters-utils.js +406 -0
  206. package/lib/utils/data-filter/index.js +3 -0
  207. package/lib/utils/date-translate.js +66 -0
  208. package/lib/utils/index.js +50 -0
  209. package/lib/utils/key-generator.js +13 -0
  210. package/lib/utils/object-utils.js +61 -0
  211. package/lib/utils/options-utils.js +61 -0
  212. package/lib/utils/statistic-column-2-sql-column-utils.js +499 -0
  213. package/lib/utils/statistic-utils.js +1685 -0
  214. package/package.json +160 -0
@@ -0,0 +1,126 @@
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, { Component } from 'react';
6
+ import { FormGroup, Label } from 'reactstrap';
7
+ import DTableSelect from "dtable-ui-component/lib/DTableSelect";
8
+ import { getTableById } from 'dtable-utils';
9
+ import { STATISTIC_TYPE, STATISTIC_DATE_SUMMARY_CALCULATION_METHOD, STATISTIC_SUMMARY_SHOW, STATISTIC_DATE_COLUMN_LIST } from '../../../constants';
10
+ import intl from '../../../intl';
11
+ var DateSummaryItem = /*#__PURE__*/function (_Component) {
12
+ _inherits(DateSummaryItem, _Component);
13
+ var _super = _createSuper(DateSummaryItem);
14
+ function DateSummaryItem(_props) {
15
+ var _this;
16
+ _classCallCheck(this, DateSummaryItem);
17
+ _this = _super.call(this, _props);
18
+ _this.initSummaryMethodOptions = function () {
19
+ _this.summaryMethodOptions = STATISTIC_DATE_SUMMARY_CALCULATION_METHOD.map(function (item) {
20
+ return {
21
+ value: item,
22
+ label: intl.get(STATISTIC_SUMMARY_SHOW[item])
23
+ };
24
+ });
25
+ };
26
+ _this.initDateColumnOptions = function (props) {
27
+ var tables = props.tables,
28
+ statistic = props.statistic;
29
+ var table_id = statistic.config.table_id;
30
+ var selectedTable = getTableById(tables, table_id);
31
+ if (!selectedTable) {
32
+ _this.dateColumnOptions = [];
33
+ return;
34
+ }
35
+ var columns = selectedTable.columns;
36
+ _this.dateColumnOptions = columns.filter(function (column) {
37
+ return STATISTIC_DATE_COLUMN_LIST.includes(column.type);
38
+ }).map(function (column) {
39
+ return {
40
+ value: column.key,
41
+ label: column.name
42
+ };
43
+ });
44
+ };
45
+ _this.onToggleExpand = function () {
46
+ _this.setState({
47
+ isExpand: !_this.state.isExpand
48
+ });
49
+ };
50
+ _this.state = {
51
+ isExpand: true
52
+ };
53
+ _this.initDateColumnOptions(_props);
54
+ _this.initSummaryMethodOptions();
55
+ return _this;
56
+ }
57
+ _createClass(DateSummaryItem, [{
58
+ key: "UNSAFE_componentWillReceiveProps",
59
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
60
+ var statistic = nextProps.statistic;
61
+ if (statistic.config.table_id !== this.props.statistic.config.table_id) {
62
+ this.initDateColumnOptions(nextProps);
63
+ }
64
+ }
65
+ }, {
66
+ key: "render",
67
+ value: function render() {
68
+ var _this2 = this;
69
+ var _this$props = this.props,
70
+ index = _this$props.index,
71
+ statistic = _this$props.statistic,
72
+ value = _this$props.value;
73
+ var type = statistic.config.type;
74
+ var column_key = value.column_key,
75
+ summary_method = value.summary_method;
76
+ var selectedColumnOption = this.dateColumnOptions.find(function (option) {
77
+ return option.value === column_key;
78
+ });
79
+ var selectedSummaryMethodOption = this.summaryMethodOptions.find(function (option) {
80
+ return option.value === summary_method;
81
+ });
82
+ var isExpand = this.state.isExpand;
83
+ return /*#__PURE__*/React.createElement(FormGroup, {
84
+ style: {
85
+ paddingBottom: isExpand ? '14px' : '7px'
86
+ },
87
+ className: "seastatistic-parameter-item container"
88
+ }, /*#__PURE__*/React.createElement("div", {
89
+ className: "numeric-summary-item"
90
+ }, /*#__PURE__*/React.createElement("span", {
91
+ className: "title-item title-left"
92
+ }, /*#__PURE__*/React.createElement("i", {
93
+ onClick: this.onToggleExpand,
94
+ className: "icon dtable-font ".concat(isExpand ? 'dtable-icon-drop-down' : 'dtable-icon-right-slide')
95
+ }), /*#__PURE__*/React.createElement("label", null, (type === STATISTIC_TYPE.TABLE ? intl.get('Summary_field') : intl.get('Numeric_field')) + (1 + index))), /*#__PURE__*/React.createElement("span", {
96
+ className: "title-item title-right"
97
+ }, index !== 0 && /*#__PURE__*/React.createElement("i", {
98
+ className: "dtable-font dtable-icon-fork-number close-icon",
99
+ onClick: function onClick() {
100
+ return _this2.props.onDelete(index);
101
+ }
102
+ }))), /*#__PURE__*/React.createElement("div", {
103
+ className: "".concat(isExpand ? 'expanded-numeric-summary-content' : 'collapsed-numeric-summary-content')
104
+ }, /*#__PURE__*/React.createElement(FormGroup, {
105
+ className: "seastatistic-parameter-item numeric-column"
106
+ }, /*#__PURE__*/React.createElement(DTableSelect, {
107
+ value: selectedColumnOption,
108
+ placeholder: intl.get('Select_a_column'),
109
+ onChange: function onChange(option) {
110
+ return _this2.props.onColumnOptionChange(option, index);
111
+ },
112
+ options: this.dateColumnOptions
113
+ })), /*#__PURE__*/React.createElement(FormGroup, {
114
+ className: "seastatistic-parameter-item summary-method"
115
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get('Summary_method')), /*#__PURE__*/React.createElement(DTableSelect, {
116
+ value: selectedSummaryMethodOption,
117
+ onChange: function onChange(option) {
118
+ return _this2.props.onSummaryMethodChange(option, index);
119
+ },
120
+ options: this.summaryMethodOptions
121
+ }))));
122
+ }
123
+ }]);
124
+ return DateSummaryItem;
125
+ }(Component);
126
+ export default DateSummaryItem;
@@ -0,0 +1,13 @@
1
+ .seastatistic-settings .display-value-settings {
2
+ margin-bottom: 12px;
3
+ }
4
+
5
+ .seastatistic-settings .display-value-settings .custom-switch {
6
+ width: 100%;
7
+ justify-content: space-between;
8
+ }
9
+
10
+ .seastatistic-settings .display-value-settings .custom-switch .custom-switch-description {
11
+ flex: 1;
12
+ white-space: unset !important;
13
+ }
@@ -0,0 +1,37 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import React, { useCallback } from 'react';
3
+ import DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
4
+ import { FormGroup } from 'reactstrap';
5
+ import { FontSizeSettings } from '../font-settings';
6
+ import { eventStopPropagation } from '../../../../utils';
7
+ import intl from '../../../../intl';
8
+ import './index.css';
9
+ var DisplayValuesSettings = function DisplayValuesSettings(_ref) {
10
+ var isShowValueKey = _ref.isShowValueKey,
11
+ isShowValue = _ref.isShowValue,
12
+ fontSizeKey = _ref.fontSizeKey,
13
+ fontSize = _ref.fontSize,
14
+ onChange = _ref.onChange;
15
+ var onDisplayValueChange = useCallback(function (event) {
16
+ eventStopPropagation(event);
17
+ onChange && onChange(_defineProperty({}, isShowValueKey, !isShowValue));
18
+ }, [isShowValueKey, isShowValue, onChange]);
19
+ var onFontSizeChange = useCallback(function (value) {
20
+ onChange && onChange(_defineProperty({}, fontSizeKey, value));
21
+ }, [fontSizeKey, onChange]);
22
+ return /*#__PURE__*/React.createElement(FormGroup, {
23
+ className: "seastatistic-parameter-item"
24
+ }, /*#__PURE__*/React.createElement(DTableSwitch, {
25
+ switchClassName: "display-value-settings",
26
+ checked: isShowValue,
27
+ disabled: false,
28
+ placeholder: intl.get('Display_value'),
29
+ onChange: onDisplayValueChange
30
+ }), isShowValue && /*#__PURE__*/React.createElement(FontSizeSettings, {
31
+ title: intl.get('Label_font_size'),
32
+ fontSize: fontSize,
33
+ defaultFontSize: 12,
34
+ modifyFontSize: onFontSizeChange
35
+ }));
36
+ };
37
+ export default DisplayValuesSettings;
@@ -0,0 +1,4 @@
1
+ .seastatistic-settings .seastatistic-divider {
2
+ border-bottom: 1px solid #e4e4e4;
3
+ margin-bottom: 14px;
4
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+ import './index.css';
4
+ var Divider = function Divider(_ref) {
5
+ var className = _ref.className;
6
+ return /*#__PURE__*/React.createElement("div", {
7
+ className: classnames('seastatistic-divider', className)
8
+ });
9
+ };
10
+ export default Divider;
@@ -0,0 +1,31 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import classnames from 'classnames';
3
+ import { FormGroup, Label } from 'reactstrap';
4
+ import { isNumber } from 'dtable-utils';
5
+ import PixelEditor from '../../../pixel-editor';
6
+ import intl from '../../../../intl';
7
+ var FontSizeSettings = function FontSizeSettings(_ref) {
8
+ var fontSize = _ref.fontSize,
9
+ defaultFontSize = _ref.defaultFontSize,
10
+ modifyFontSize = _ref.modifyFontSize,
11
+ className = _ref.className,
12
+ title = _ref.title;
13
+ var initialFontSize = useMemo(function () {
14
+ if (isNumber(fontSize)) return fontSize;
15
+ if (isNumber(defaultFontSize)) return defaultFontSize;
16
+ return null;
17
+ }, [fontSize, defaultFontSize]);
18
+ var onChange = useCallback(function (currFontSize) {
19
+ var parsedFontSize = parseInt(currFontSize);
20
+ if (!fontSize && !parsedFontSize || parsedFontSize === fontSize) return;
21
+ modifyFontSize(parsedFontSize);
22
+ }, [fontSize, modifyFontSize]);
23
+ return /*#__PURE__*/React.createElement(FormGroup, {
24
+ className: classnames('seastatistic-setting-item font-size-setting', className)
25
+ }, /*#__PURE__*/React.createElement(Label, null, title || intl.get('Font_size')), /*#__PURE__*/React.createElement(PixelEditor, {
26
+ pixel: initialFontSize,
27
+ defaultPixel: defaultFontSize,
28
+ modifyPixel: onChange
29
+ }));
30
+ };
31
+ export default FontSizeSettings;
@@ -0,0 +1,46 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
3
+ import classnames from 'classnames';
4
+ import { FormGroup, Label } from 'reactstrap';
5
+ import DTableCustomizeSelect from "dtable-ui-component/lib/DTableCustomizeSelect";
6
+ import { generatorCommonOptions } from '../../../../utils';
7
+ import intl from '../../../../intl';
8
+ var FontWeightSettings = function FontWeightSettings(props) {
9
+ var _useState = useState(props.fontWeight),
10
+ _useState2 = _slicedToArray(_useState, 2),
11
+ fontWeight = _useState2[0],
12
+ setFontWeight = _useState2[1];
13
+ var mountRef = useRef(false);
14
+ useEffect(function () {
15
+ if (!mountRef.current) {
16
+ mountRef.current = true;
17
+ } else {
18
+ setFontWeight(props.fontWeight);
19
+ }
20
+ }, [props.fontWeight]);
21
+ var fontWeightOptions = useMemo(function () {
22
+ return generatorCommonOptions(props.supportFontWeights, fontWeight);
23
+ }, [props.supportFontWeights, fontWeight]);
24
+ var selectedFontWeightOption = useMemo(function () {
25
+ return {
26
+ label: /*#__PURE__*/React.createElement("span", {
27
+ className: "common-selected-font"
28
+ }, fontWeight)
29
+ };
30
+ }, [fontWeight]);
31
+ var modifyFontWeight = function modifyFontWeight(fontWeightOption) {
32
+ var nextFontWeight = fontWeightOption.value;
33
+ if (nextFontWeight === fontWeight) return;
34
+ setFontWeight(nextFontWeight);
35
+ props.modifyFontWeight(nextFontWeight);
36
+ };
37
+ return /*#__PURE__*/React.createElement(FormGroup, {
38
+ className: classnames('setting-item seastatistic-font-weight-setting')
39
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get('Font_weight')), /*#__PURE__*/React.createElement(DTableCustomizeSelect, {
40
+ className: "seastatistic-font-weight",
41
+ value: selectedFontWeightOption,
42
+ options: fontWeightOptions,
43
+ onSelectOption: modifyFontWeight
44
+ }));
45
+ };
46
+ export default FontWeightSettings;
@@ -0,0 +1,3 @@
1
+ import FontSizeSettings from './font-size-settings';
2
+ import FontWeightSettings from './font-weight-settings';
3
+ export { FontSizeSettings, FontWeightSettings };
@@ -0,0 +1,168 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+ import React, { Component } from 'react';
7
+ import classnames from 'classnames';
8
+ import { Label, FormGroup } from 'reactstrap';
9
+ import DTableSelect from "dtable-ui-component/lib/DTableSelect";
10
+ import { CellType, COLUMNS_ICON_CONFIG, DATE_COLUMN_OPTIONS, getTableById, getTableColumnByKey } from 'dtable-utils';
11
+ import { STATISTIC_SUPPORT_COLUMNS, DATE_GRANULATES, GEOLOCATION_GRANULATES, STATISTIC_SUMMARY_SHOW, GEOLOCATION_FORMAT_MAP } from '../../../constants';
12
+ import intl from '../../../intl';
13
+ var GroupBy = /*#__PURE__*/function (_Component) {
14
+ _inherits(GroupBy, _Component);
15
+ var _super = _createSuper(GroupBy);
16
+ function GroupBy(_props) {
17
+ var _this;
18
+ _classCallCheck(this, GroupBy);
19
+ _this = _super.call(this, _props);
20
+ _this.generatorGranulatesOptions = function (granulates) {
21
+ return granulates.map(function (item) {
22
+ return {
23
+ value: item,
24
+ label: /*#__PURE__*/React.createElement("span", {
25
+ className: "select-module select-module-name ml-0"
26
+ }, intl.get(STATISTIC_SUMMARY_SHOW[item]))
27
+ };
28
+ });
29
+ };
30
+ _this.initOptions = function (props) {
31
+ var tables = props.tables,
32
+ selectedTableId = props.selectedTableId;
33
+ _this.selectedTable = getTableById(tables, selectedTableId);
34
+ var columns = _this.selectedTable && Array.isArray(_this.selectedTable.columns) ? _this.selectedTable.columns : [];
35
+ _this.validColumns = _this.getAvailableColumns(columns);
36
+ _this.columnOptions = _this.getColumnOptions(_this.validColumns);
37
+ };
38
+ _this.initGeolocationOptions = function (props) {
39
+ var selectedColumnKey = props.selectedColumnKey;
40
+ if (!selectedColumnKey) {
41
+ _this.geolocationGranulatesOptions = [];
42
+ return;
43
+ }
44
+ var groupbyColumn = getTableColumnByKey(_this.selectedTable, selectedColumnKey);
45
+ if (!groupbyColumn) {
46
+ _this.geolocationGranulatesOptions = [];
47
+ return;
48
+ }
49
+ var _ref = groupbyColumn.data || {},
50
+ geo_format = _ref.geo_format;
51
+ if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE) {
52
+ _this.geolocationGranulatesOptions = _this.generatorGranulatesOptions(GEOLOCATION_GRANULATES.filter(function (item) {
53
+ return item === GEOLOCATION_FORMAT_MAP.PROVINCE;
54
+ }));
55
+ return;
56
+ }
57
+ if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE_CITY) {
58
+ _this.geolocationGranulatesOptions = _this.generatorGranulatesOptions(GEOLOCATION_GRANULATES.filter(function (item) {
59
+ return item === 'district';
60
+ }));
61
+ return;
62
+ }
63
+ if (geo_format === GEOLOCATION_FORMAT_MAP.COUNTRY_REGION || geo_format === GEOLOCATION_FORMAT_MAP.LNG_LAT) {
64
+ _this.geolocationGranulatesOptions = [];
65
+ return;
66
+ }
67
+ _this.geolocationGranulatesOptions = _this.generatorGranulatesOptions(GEOLOCATION_GRANULATES);
68
+ };
69
+ _this.getAvailableColumns = function (columns) {
70
+ if (!columns || !Array.isArray(columns)) return [];
71
+ return columns.filter(function (column) {
72
+ return STATISTIC_SUPPORT_COLUMNS.includes(column.type);
73
+ });
74
+ };
75
+ _this.getColumnOptions = function (columns) {
76
+ return columns.map(function (column) {
77
+ return {
78
+ value: column,
79
+ label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
80
+ className: "header-icon"
81
+ }, /*#__PURE__*/React.createElement("i", {
82
+ className: COLUMNS_ICON_CONFIG[column.type]
83
+ })), /*#__PURE__*/React.createElement("span", {
84
+ className: 'select-module select-module-name ml-0'
85
+ }, column.name))
86
+ };
87
+ });
88
+ };
89
+ _this.renderSelector = function () {
90
+ var selectedColumnKey = _this.props.selectedColumnKey;
91
+ var selectedOption = selectedColumnKey ? _this.columnOptions.find(function (option) {
92
+ return option.value.key === selectedColumnKey;
93
+ }) : null;
94
+ return /*#__PURE__*/React.createElement(DTableSelect, {
95
+ value: selectedOption,
96
+ classNamePrefix: "select-column",
97
+ options: _this.columnOptions,
98
+ onChange: _this.props.onGroupByChange,
99
+ noOptionsMessage: function noOptionsMessage() {
100
+ return /*#__PURE__*/React.createElement("span", null, intl.get('No_column'));
101
+ }
102
+ });
103
+ };
104
+ _this.renderGroupbyDateGranulates = function () {
105
+ var selectedDateGranularity = _this.props.selectedDateGranularity;
106
+ var selectedOption = _this.dateGranulatesOptions.find(function (option) {
107
+ return option.value === selectedDateGranularity;
108
+ });
109
+ return /*#__PURE__*/React.createElement("div", {
110
+ className: "seastatistic-parameter-item mt-4"
111
+ }, /*#__PURE__*/React.createElement(DTableSelect, {
112
+ value: selectedOption,
113
+ options: _this.dateGranulatesOptions,
114
+ onChange: _this.props.onGroupbyDateGranularityChange
115
+ }));
116
+ };
117
+ _this.renderGroupbyGeolocationGranulates = function () {
118
+ var selectedGeolocationGranularity = _this.props.selectedGeolocationGranularity;
119
+ var selectedOption = _this.geolocationGranulatesOptions.find(function (option) {
120
+ return option.value === selectedGeolocationGranularity;
121
+ });
122
+ return /*#__PURE__*/React.createElement("div", {
123
+ className: "seastatistic-parameter-item mt-4"
124
+ }, /*#__PURE__*/React.createElement(DTableSelect, {
125
+ value: selectedOption,
126
+ options: _this.geolocationGranulatesOptions,
127
+ onChange: _this.props.onGroupbyGeolocationGranularityChange
128
+ }));
129
+ };
130
+ _this.renderGroupBy = function () {
131
+ var selectedColumnKey = _this.props.selectedColumnKey;
132
+ if (!selectedColumnKey) return null;
133
+ var groupbyColumn = getTableColumnByKey(_this.selectedTable, selectedColumnKey);
134
+ if (!groupbyColumn) return null;
135
+ var groupbyColumnType = groupbyColumn.type;
136
+ return /*#__PURE__*/React.createElement(React.Fragment, null, DATE_COLUMN_OPTIONS.includes(groupbyColumnType) && _this.renderGroupbyDateGranulates(), groupbyColumnType === CellType.GEOLOCATION && _this.geolocationGranulatesOptions.length > 0 && _this.renderGroupbyGeolocationGranulates());
137
+ };
138
+ _this.dateGranulatesOptions = _this.generatorGranulatesOptions(DATE_GRANULATES);
139
+ _this.initOptions(_props);
140
+ _this.initGeolocationOptions(_props);
141
+ return _this;
142
+ }
143
+ _createClass(GroupBy, [{
144
+ key: "UNSAFE_componentWillReceiveProps",
145
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
146
+ var selectedTableId = nextProps.selectedTableId,
147
+ selectedColumnKey = nextProps.selectedColumnKey;
148
+ if (selectedTableId !== this.props.selectedTableId) {
149
+ this.initOptions(nextProps);
150
+ }
151
+ if (selectedColumnKey !== this.props.selectedColumnKey) {
152
+ this.initGeolocationOptions(nextProps);
153
+ }
154
+ }
155
+ }, {
156
+ key: "render",
157
+ value: function render() {
158
+ var _this$props = this.props,
159
+ label = _this$props.label,
160
+ className = _this$props.className;
161
+ return /*#__PURE__*/React.createElement(FormGroup, {
162
+ className: classnames('seastatistic-setting-item table-setting', _defineProperty({}, className, className))
163
+ }, /*#__PURE__*/React.createElement(Label, null, label), this.renderSelector(), this.renderGroupBy());
164
+ }
165
+ }]);
166
+ return GroupBy;
167
+ }(Component);
168
+ export default GroupBy;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { FormGroup, Label } from 'reactstrap';
3
+ import { LABEL_COLORS } from '../../../constants';
4
+ import intl from '../../../intl';
5
+ function LabelColor(props) {
6
+ var labelColor = props.labelColor;
7
+ return /*#__PURE__*/React.createElement(FormGroup, {
8
+ className: "seastatistic-parameter-item"
9
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get('Color')), /*#__PURE__*/React.createElement("div", {
10
+ className: "d-flex align-items-center justify-content-between"
11
+ }, LABEL_COLORS.map(function (item, index) {
12
+ return /*#__PURE__*/React.createElement("div", {
13
+ key: "y-axis-label-color-".concat(index)
14
+ }, /*#__PURE__*/React.createElement("div", {
15
+ className: "colorinput"
16
+ }, /*#__PURE__*/React.createElement("span", {
17
+ className: "colorinput-color statistic-colorinput d-flex justify-content-center align-items-center",
18
+ onClick: function onClick(event) {
19
+ return props.onChange(event, item);
20
+ },
21
+ style: {
22
+ backgroundColor: item,
23
+ borderColor: item
24
+ }
25
+ }, item === (labelColor || LABEL_COLORS[0]) && /*#__PURE__*/React.createElement("i", {
26
+ className: "dtable-font dtable-icon-check-mark statistic-check-mark"
27
+ }))));
28
+ })));
29
+ }
30
+ export default LabelColor;
@@ -0,0 +1,64 @@
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, { Component } from 'react';
6
+ import { FormGroup, Label, Input } from 'reactstrap';
7
+ import intl from '../../../intl';
8
+ var MinMaxSetting = /*#__PURE__*/function (_Component) {
9
+ _inherits(MinMaxSetting, _Component);
10
+ var _super = _createSuper(MinMaxSetting);
11
+ function MinMaxSetting(props) {
12
+ var _this;
13
+ _classCallCheck(this, MinMaxSetting);
14
+ _this = _super.call(this, props);
15
+ _this.onMinChange = function (e) {
16
+ var min = e.target.value;
17
+ _this.setState({
18
+ min: min
19
+ }, function () {
20
+ _this.props.onMinChange(min);
21
+ });
22
+ };
23
+ _this.onMaxChange = function (e) {
24
+ var max = e.target.value;
25
+ _this.setState({
26
+ max: max
27
+ }, function () {
28
+ _this.props.onMaxChange(max);
29
+ });
30
+ };
31
+ _this.state = {
32
+ min: props.min,
33
+ max: props.max
34
+ };
35
+ return _this;
36
+ }
37
+ _createClass(MinMaxSetting, [{
38
+ key: "render",
39
+ value: function render() {
40
+ var _this$state = this.state,
41
+ min = _this$state.min,
42
+ max = _this$state.max;
43
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
44
+ className: "mb-2"
45
+ }, /*#__PURE__*/React.createElement(Label, {
46
+ for: "min"
47
+ }, intl.get('Min')), /*#__PURE__*/React.createElement(Input, {
48
+ id: "min",
49
+ type: "number",
50
+ value: min,
51
+ onChange: this.onMinChange
52
+ })), /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Label, {
53
+ for: "max"
54
+ }, intl.get('Max')), /*#__PURE__*/React.createElement(Input, {
55
+ id: "max",
56
+ type: "number",
57
+ value: max,
58
+ onChange: this.onMaxChange
59
+ })));
60
+ }
61
+ }]);
62
+ return MinMaxSetting;
63
+ }(Component);
64
+ export default MinMaxSetting;
@@ -0,0 +1,72 @@
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, { Component } from 'react';
6
+ import { FormGroup, Label } from 'reactstrap';
7
+ import NumberInput from '../../../components/number-input';
8
+ import intl from '../../../intl';
9
+ var MiniNumSlicePercent = /*#__PURE__*/function (_Component) {
10
+ _inherits(MiniNumSlicePercent, _Component);
11
+ var _super = _createSuper(MiniNumSlicePercent);
12
+ function MiniNumSlicePercent(props) {
13
+ var _this;
14
+ _classCallCheck(this, MiniNumSlicePercent);
15
+ _this = _super.call(this, props);
16
+ _this.replaceNumberNotAllowInput = function (value) {
17
+ if (!value) {
18
+ return '';
19
+ }
20
+ value = value.replace(/。/g, '.');
21
+ value = value.replace(/-/g, '');
22
+ return value.replace(/[^.-\d,]/g, '');
23
+ };
24
+ _this.onKeyDown = function (event) {
25
+ if (event.keyCode === 13) {
26
+ event.preventDefault();
27
+ event.target.blur();
28
+ }
29
+ };
30
+ _this.onPercentChange = function (event) {
31
+ var value = _this.replaceNumberNotAllowInput(event.target.value);
32
+ if (value === _this.state.value) return;
33
+ _this.setState({
34
+ value: value
35
+ }, function () {
36
+ _this.onCommit();
37
+ });
38
+ };
39
+ _this.onBlur = function () {
40
+ _this.onCommit();
41
+ };
42
+ _this.onCommit = function () {
43
+ var value = _this.state.value;
44
+ if (value === _this.props.value) return;
45
+ var validValue = value || value === 0 ? Number(value) : 1.5;
46
+ _this.props.onChange(validValue);
47
+ };
48
+ _this.state = {
49
+ value: props.value
50
+ };
51
+ return _this;
52
+ }
53
+ _createClass(MiniNumSlicePercent, [{
54
+ key: "render",
55
+ value: function render() {
56
+ var value = this.props.value;
57
+ return /*#__PURE__*/React.createElement(FormGroup, {
58
+ className: "seastatistic-parameter-item"
59
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get('Minimum_slice_percent')), /*#__PURE__*/React.createElement(NumberInput, {
60
+ value: value,
61
+ onChange: this.onPercentChange,
62
+ step: 0.1,
63
+ min: 0,
64
+ max: 100,
65
+ onBlur: this.onBlur,
66
+ onKeyDown: this.onKeyDown
67
+ }));
68
+ }
69
+ }]);
70
+ return MiniNumSlicePercent;
71
+ }(Component);
72
+ export default MiniNumSlicePercent;