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,183 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import React, { useCallback, useMemo } from 'react';
3
+ import { Label, FormGroup } from 'reactstrap';
4
+ import DTableSelect from "dtable-ui-component/lib/DTableSelect";
5
+ import Switch from '../widgets/switch';
6
+ import Divider from '../widgets/divider';
7
+ import MinMaxSetting from '../widgets/min-max-setting';
8
+ import DisplayValuesSettings from '../widgets/display-values-settings';
9
+ import { eventStopPropagation } from '../../../utils';
10
+ import { X_LABEL_POSITIONS, Y_LABEL_POSITIONS, LABEL_POSITION_TYPE_SHOW } from '../../../constants';
11
+ import intl from '../../../intl';
12
+ var StyleSettings = function StyleSettings(_ref) {
13
+ var statistic = _ref.statistic,
14
+ onChange = _ref.onChange,
15
+ xLabel = _ref.xLabel;
16
+ var xAxisLabelOptions = useMemo(function () {
17
+ return X_LABEL_POSITIONS.map(function (item) {
18
+ return {
19
+ value: item,
20
+ label: intl.get(LABEL_POSITION_TYPE_SHOW[item])
21
+ };
22
+ });
23
+ }, []);
24
+ var yAxisLabelOptions = useMemo(function () {
25
+ return Y_LABEL_POSITIONS.map(function (item) {
26
+ return {
27
+ value: item,
28
+ label: intl.get(LABEL_POSITION_TYPE_SHOW[item])
29
+ };
30
+ });
31
+ }, []);
32
+ var onAxisLabelShowChange = useCallback(function (event, labelKey) {
33
+ eventStopPropagation(event);
34
+ var config = statistic.config;
35
+ var value = config[labelKey];
36
+ onChange && onChange(_defineProperty({}, labelKey, !value));
37
+ }, [statistic, onChange]);
38
+ var onAxisLabelPositionChange = useCallback(function (option, positionKey) {
39
+ var position = option.value;
40
+ var config = statistic.config;
41
+ var oldValue = config[positionKey];
42
+ if (position === oldValue) return;
43
+ onChange && onChange(_defineProperty({}, positionKey, position));
44
+ }, [statistic, onChange]);
45
+ var onToggleYAxisAutoRange = useCallback(function (key) {
46
+ var config = statistic.config;
47
+ var update = _defineProperty({}, key, config[key] === undefined ? false : !config[key]);
48
+ onChange && onChange(update);
49
+ }, [statistic, onChange]);
50
+ var onYAxisMinChange = useCallback(function (key, min) {
51
+ var newMin = parseInt(min);
52
+ if (Number.isNaN(newMin)) return;
53
+ var update = _defineProperty({}, key, newMin);
54
+ onChange && onChange(update);
55
+ }, [onChange]);
56
+ var onYAxisMaxChange = useCallback(function (key, max) {
57
+ var newMax = parseInt(max);
58
+ if (Number.isNaN(newMax)) return;
59
+ var update = _defineProperty({}, key, newMax);
60
+ onChange && onChange(update);
61
+ }, [onChange]);
62
+ var onDisplayValueChange = useCallback(function (update) {
63
+ onChange && onChange(update);
64
+ }, [onChange]);
65
+ var config = statistic.config;
66
+ var x_axis_show_label = config.x_axis_show_label,
67
+ x_axis_label_position = config.x_axis_label_position,
68
+ show_y_axis_left_label = config.show_y_axis_left_label,
69
+ y_axis_left_label_position = config.y_axis_left_label_position,
70
+ y_axis_right_label_position = config.y_axis_right_label_position,
71
+ show_y_axis_right_label = config.show_y_axis_right_label,
72
+ y_axis_min_left = config.y_axis_min_left,
73
+ y_axis_auto_range_left = config.y_axis_auto_range_left,
74
+ y_axis_max_left = config.y_axis_max_left,
75
+ y_axis_auto_range_right = config.y_axis_auto_range_right,
76
+ y_axis_min_right = config.y_axis_min_right,
77
+ y_axis_max_right = config.y_axis_max_right,
78
+ display_data = config.display_data,
79
+ label_font_size = config.label_font_size;
80
+ var xAxisLabelPosition = xAxisLabelOptions.find(function (option) {
81
+ return option.value === x_axis_label_position;
82
+ }) || xAxisLabelOptions[0];
83
+ var yLeftAxisLabelPosition = yAxisLabelOptions.find(function (option) {
84
+ return option.value === y_axis_left_label_position;
85
+ }) || yAxisLabelOptions[0];
86
+ var yRightAxisLabelPosition = yAxisLabelOptions.find(function (option) {
87
+ return option.value === y_axis_right_label_position;
88
+ }) || yAxisLabelOptions[0];
89
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
90
+ className: "seastatistic-parameter-item"
91
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get(xLabel)), /*#__PURE__*/React.createElement(Switch, {
92
+ key: "x_axis_show_label",
93
+ checked: x_axis_show_label || false,
94
+ placeholder: intl.get('Display_title'),
95
+ onChange: function onChange(event) {
96
+ return onAxisLabelShowChange(event, 'x_axis_show_label');
97
+ }
98
+ }), x_axis_show_label && /*#__PURE__*/React.createElement(DTableSelect, {
99
+ value: xAxisLabelPosition,
100
+ options: xAxisLabelOptions,
101
+ onChange: function onChange(option) {
102
+ return onAxisLabelPositionChange(option, 'x_axis_label_position');
103
+ }
104
+ })), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(FormGroup, {
105
+ className: "seastatistic-parameter-item"
106
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get('Y-axis(left side)')), /*#__PURE__*/React.createElement(Switch, {
107
+ key: "show_y_axis_left_label",
108
+ checked: show_y_axis_left_label || false,
109
+ placeholder: intl.get('Display_title'),
110
+ onChange: function onChange(event) {
111
+ return onAxisLabelShowChange(event, 'show_y_axis_left_label');
112
+ }
113
+ }), show_y_axis_left_label && /*#__PURE__*/React.createElement("div", {
114
+ className: "seastatistic-parameter-container"
115
+ }, /*#__PURE__*/React.createElement(DTableSelect, {
116
+ value: yLeftAxisLabelPosition,
117
+ classNamePrefix: "chart-y-axis-label-position",
118
+ options: yAxisLabelOptions,
119
+ onChange: function onChange(option) {
120
+ return onAxisLabelPositionChange(option, 'y_axis_left_label_position');
121
+ }
122
+ })), /*#__PURE__*/React.createElement(Switch, {
123
+ key: "y_axis_auto_range_left",
124
+ checked: y_axis_auto_range_left,
125
+ placeholder: intl.get('Auto_range'),
126
+ onChange: function onChange() {
127
+ return onToggleYAxisAutoRange('y_axis_auto_range_left');
128
+ }
129
+ }), !y_axis_auto_range_left && /*#__PURE__*/React.createElement(MinMaxSetting, {
130
+ min: y_axis_min_left,
131
+ max: y_axis_max_left,
132
+ onMinChange: function onMinChange(value) {
133
+ return onYAxisMinChange('y_axis_min_left', value);
134
+ },
135
+ onMaxChange: function onMaxChange(value) {
136
+ return onYAxisMaxChange('y_axis_max_left', value);
137
+ }
138
+ })), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(FormGroup, {
139
+ className: "seastatistic-parameter-item"
140
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get('Y-axis(right side)')), /*#__PURE__*/React.createElement(Switch, {
141
+ key: "show_y_axis_right_label",
142
+ checked: show_y_axis_right_label || false,
143
+ placeholder: intl.get('Display_title'),
144
+ onChange: function onChange(event) {
145
+ return onAxisLabelShowChange(event, 'show_y_axis_right_label');
146
+ }
147
+ }), show_y_axis_right_label && /*#__PURE__*/React.createElement("div", {
148
+ className: "seastatistic-parameter-container"
149
+ }, /*#__PURE__*/React.createElement(DTableSelect, {
150
+ value: yRightAxisLabelPosition,
151
+ classNamePrefix: "chart-y-axis-label-position",
152
+ options: yAxisLabelOptions,
153
+ onChange: function onChange(option) {
154
+ return onAxisLabelPositionChange(option, 'y_axis_right_label_position');
155
+ }
156
+ })), /*#__PURE__*/React.createElement(Switch, {
157
+ key: "y_axis_auto_range_right",
158
+ checked: y_axis_auto_range_right,
159
+ placeholder: intl.get('Auto_range'),
160
+ onChange: function onChange() {
161
+ return onToggleYAxisAutoRange('y_axis_auto_range_right');
162
+ }
163
+ }), !y_axis_auto_range_right && /*#__PURE__*/React.createElement(MinMaxSetting, {
164
+ min: y_axis_min_right,
165
+ max: y_axis_max_right,
166
+ onMinChange: function onMinChange(value) {
167
+ return onYAxisMinChange('y_axis_min_right', value);
168
+ },
169
+ onMaxChange: function onMaxChange(value) {
170
+ return onYAxisMaxChange('y_axis_max_right', value);
171
+ }
172
+ })), /*#__PURE__*/React.createElement(DisplayValuesSettings, {
173
+ isShowValueKey: "display_data",
174
+ isShowValue: display_data,
175
+ fontSizeKey: "label_font_size",
176
+ fontSize: label_font_size,
177
+ onChange: onDisplayValueChange
178
+ }));
179
+ };
180
+ StyleSettings.defaultProps = {
181
+ xLabel: 'X_axis'
182
+ };
183
+ export default StyleSettings;
@@ -0,0 +1,167 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import React, { Fragment, useCallback, useMemo } from 'react';
3
+ import { FormGroup } from 'reactstrap';
4
+ import { COLUMNS_ICON_CONFIG, getTableById } from 'dtable-utils';
5
+ import DTableSelect from "dtable-ui-component/lib/DTableSelect";
6
+ import CommonDataSettings from '../widgets/common-data-settings';
7
+ import { StatisticsUtils } from '../../../utils';
8
+ import { STATISTIC_SUMMARY_SHOW, STATISTIC_SUMMARY_CALCULATION_METHOD, STATISTIC_SUPPORT_COLUMNS, BASIC_NUMBER_CARD_CALCULATION_METHOD } from '../../../constants';
9
+ import intl from '../../../intl';
10
+ var DataSettings = function DataSettings(_ref) {
11
+ var tables = _ref.tables,
12
+ statistic = _ref.statistic,
13
+ FilterSettings = _ref.FilterSettings,
14
+ onChange = _ref.onChange;
15
+ var summaryMethodsOptions = useMemo(function () {
16
+ var numberCardSummaryMethod = [BASIC_NUMBER_CARD_CALCULATION_METHOD].concat(_toConsumableArray(STATISTIC_SUMMARY_CALCULATION_METHOD));
17
+ return numberCardSummaryMethod.map(function (method) {
18
+ return {
19
+ label: /*#__PURE__*/React.createElement("span", {
20
+ className: "select-option-name"
21
+ }, intl.get(STATISTIC_SUMMARY_SHOW[method])),
22
+ value: method
23
+ };
24
+ });
25
+ }, []);
26
+ var selectedTable = useMemo(function () {
27
+ var selectedTableId = statistic.config.table_id;
28
+ return getTableById(tables, selectedTableId);
29
+ }, [statistic.config, tables]);
30
+ var validColumns = useMemo(function () {
31
+ var columns = selectedTable && Array.isArray(selectedTable.columns) ? selectedTable.columns : [];
32
+ if (!columns || !Array.isArray(columns)) return [];
33
+ return columns.filter(function (column) {
34
+ return STATISTIC_SUPPORT_COLUMNS.includes(column.type);
35
+ });
36
+ }, [selectedTable]);
37
+ var numericColumns = useMemo(function () {
38
+ return validColumns.filter(function (column) {
39
+ return StatisticsUtils.isNumericSummaryColumn(column);
40
+ });
41
+ }, [validColumns]);
42
+ var numericColumnOptions = useMemo(function () {
43
+ var options = numericColumns.map(function (column) {
44
+ return {
45
+ value: column,
46
+ label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
47
+ className: "header-icon"
48
+ }, /*#__PURE__*/React.createElement("i", {
49
+ className: COLUMNS_ICON_CONFIG[column.type]
50
+ })), /*#__PURE__*/React.createElement("span", {
51
+ className: 'select-module select-module-name ml-0'
52
+ }, column.name))
53
+ };
54
+ });
55
+ return [{
56
+ value: {
57
+ key: 'Groupby_null'
58
+ },
59
+ label: /*#__PURE__*/React.createElement("span", {
60
+ className: 'select-module select-module-name null-option-name ml-0'
61
+ }, intl.get('Select_a_column')),
62
+ style: {
63
+ color: 'rgba(0, 0, 0, .25)'
64
+ }
65
+ }].concat(_toConsumableArray(options));
66
+ }, [numericColumns]);
67
+ var onSelectTargetValueColumn = useCallback(function (option) {
68
+ var config = statistic.config;
69
+ var target_value_column_key = config.target_value_column_key;
70
+ var newColumnKey = option.value.key;
71
+ if (target_value_column_key === newColumnKey) return;
72
+ onChange && onChange({
73
+ target_value_column_key: newColumnKey
74
+ });
75
+ }, [statistic, onChange]);
76
+ var onSelectTotalValueColumn = useCallback(function (option) {
77
+ var config = statistic.config;
78
+ var total_value_column_key = config.total_value_column_key;
79
+ var newColumnKey = option.value.key;
80
+ if (total_value_column_key === newColumnKey) return;
81
+ onChange && onChange({
82
+ total_value_column_key: newColumnKey
83
+ });
84
+ }, [statistic, onChange]);
85
+ var getSelectedMethodOption = useCallback(function (method, summaryMethodsOptions) {
86
+ return summaryMethodsOptions.find(function (m) {
87
+ return m.value === method;
88
+ }) || summaryMethodsOptions[0];
89
+ }, []);
90
+ var onSelectTargetValueColumnSummaryMethod = useCallback(function (option) {
91
+ var config = statistic.config;
92
+ var target_value_column_summary_method = config.target_value_column_summary_method;
93
+ var newSummaryMethod = option.value;
94
+ if (target_value_column_summary_method === newSummaryMethod) return;
95
+ onChange && onChange({
96
+ target_value_column_summary_method: newSummaryMethod
97
+ });
98
+ }, [statistic, onChange]);
99
+ var onSelectTotalValueColumnSummaryMethod = useCallback(function (option) {
100
+ var config = statistic.config;
101
+ var total_value_column_summary_method = config.total_value_column_summary_method;
102
+ var newSummaryMethod = option.value;
103
+ if (total_value_column_summary_method === newSummaryMethod) return;
104
+ onChange && onChange({
105
+ total_value_column_summary_method: newSummaryMethod
106
+ });
107
+ }, [statistic, onChange]);
108
+ var renderSummaryMethod = useCallback(function (option) {
109
+ var config = statistic.config;
110
+ var target_value_column_summary_method = config.target_value_column_summary_method,
111
+ total_value_column_summary_method = config.total_value_column_summary_method;
112
+ var summary_method, onSelectSummaryMethod;
113
+ if (option.targetColumn === 'target_value_column') {
114
+ summary_method = target_value_column_summary_method;
115
+ onSelectSummaryMethod = onSelectTargetValueColumnSummaryMethod;
116
+ } else {
117
+ summary_method = total_value_column_summary_method;
118
+ onSelectSummaryMethod = onSelectTotalValueColumnSummaryMethod;
119
+ }
120
+ var selectedMethodOption = getSelectedMethodOption(summary_method, summaryMethodsOptions);
121
+ return /*#__PURE__*/React.createElement("div", {
122
+ className: "dtable-plugin-stat-parameter-item"
123
+ }, /*#__PURE__*/React.createElement("label", null, intl.get('Summary_method')), /*#__PURE__*/React.createElement(DTableSelect, {
124
+ value: selectedMethodOption,
125
+ onChange: onSelectSummaryMethod,
126
+ options: summaryMethodsOptions
127
+ }));
128
+ }, [statistic, summaryMethodsOptions, getSelectedMethodOption, onSelectTargetValueColumnSummaryMethod, onSelectTotalValueColumnSummaryMethod]);
129
+ var _statistic$config = statistic.config,
130
+ target_value_column_key = _statistic$config.target_value_column_key,
131
+ total_value_column_key = _statistic$config.total_value_column_key;
132
+ var selectedTargetValueColumnOption = numericColumnOptions.filter(function (option) {
133
+ return option.value.key === target_value_column_key;
134
+ })[0];
135
+ var selectedTotalValueColumnOption = numericColumnOptions.filter(function (option) {
136
+ return option.value.key === total_value_column_key;
137
+ })[0];
138
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(CommonDataSettings, {
139
+ statistic: statistic,
140
+ tables: tables,
141
+ FilterSettings: FilterSettings,
142
+ onChange: onChange
143
+ }), /*#__PURE__*/React.createElement(FormGroup, {
144
+ className: "seastatistic-parameter-item"
145
+ }, /*#__PURE__*/React.createElement("label", null, intl.get('Current_value_field')), /*#__PURE__*/React.createElement(DTableSelect, {
146
+ value: selectedTargetValueColumnOption,
147
+ options: numericColumnOptions,
148
+ placeholder: intl.get('Select_a_column'),
149
+ onChange: onSelectTargetValueColumn
150
+ })), /*#__PURE__*/React.createElement(FormGroup, {
151
+ className: "seastatistic-parameter-item"
152
+ }, renderSummaryMethod({
153
+ targetColumn: 'target_value_column'
154
+ })), /*#__PURE__*/React.createElement(FormGroup, {
155
+ className: "seastatistic-parameter-item"
156
+ }, /*#__PURE__*/React.createElement("label", null, intl.get('Total_value_field')), /*#__PURE__*/React.createElement(DTableSelect, {
157
+ value: selectedTotalValueColumnOption,
158
+ options: numericColumnOptions,
159
+ placeholder: intl.get('Select_a_column'),
160
+ onChange: onSelectTotalValueColumn
161
+ })), /*#__PURE__*/React.createElement(FormGroup, {
162
+ className: "seastatistic-parameter-item"
163
+ }, renderSummaryMethod({
164
+ targetColumn: 'total_value_column'
165
+ })));
166
+ };
167
+ export default DataSettings;
@@ -0,0 +1,2 @@
1
+ import DashboardDataSettings from './data-settings';
2
+ export { DashboardDataSettings };
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import { STATISTIC_TYPE } from '../../constants';
3
+ import { BarDataSettings } from './bar-settings';
4
+ import { AdvanceBarDataSettings } from './advance-bar-settings';
5
+ import { TimeComparisonDataSettings } from './time-comparison-settings';
6
+ import { PieDataSettings } from './pie-settings';
7
+ import { TableDataSettings } from './table-settings';
8
+ import { HorizontalDataSettings } from './horizontal-bar-settings';
9
+ import { BasicNumberCardDataSettings } from './basic-number-card';
10
+ import { CombinationDataSettings } from './combination-settings';
11
+ import { DashboardDataSettings } from './dashboard-settings';
12
+ var DataSettings = function DataSettings(props) {
13
+ var statistic = props.statistic;
14
+ var config = statistic.config;
15
+ var type = config.type;
16
+ switch (type) {
17
+ case STATISTIC_TYPE.BAR:
18
+ case STATISTIC_TYPE.LINE:
19
+ case STATISTIC_TYPE.AREA:
20
+ {
21
+ return /*#__PURE__*/React.createElement(BarDataSettings, props);
22
+ }
23
+ case STATISTIC_TYPE.COMBINATION:
24
+ {
25
+ return /*#__PURE__*/React.createElement(CombinationDataSettings, props);
26
+ }
27
+ case STATISTIC_TYPE.HORIZONTAL_BAR:
28
+ case STATISTIC_TYPE.HORIZONTAL_GROUP_BAR:
29
+ {
30
+ return /*#__PURE__*/React.createElement(HorizontalDataSettings, props);
31
+ }
32
+ case STATISTIC_TYPE.BAR_GROUP:
33
+ case STATISTIC_TYPE.BAR_STACK:
34
+ case STATISTIC_TYPE.LINE_GROUP:
35
+ case STATISTIC_TYPE.AREA_GROUP:
36
+ {
37
+ return /*#__PURE__*/React.createElement(AdvanceBarDataSettings, props);
38
+ }
39
+ case STATISTIC_TYPE.COMPARE_BAR:
40
+ {
41
+ return /*#__PURE__*/React.createElement(TimeComparisonDataSettings, props);
42
+ }
43
+ case STATISTIC_TYPE.PIE:
44
+ case STATISTIC_TYPE.RING:
45
+ case STATISTIC_TYPE.TREE_MAP:
46
+ {
47
+ return /*#__PURE__*/React.createElement(PieDataSettings, props);
48
+ }
49
+ case STATISTIC_TYPE.BASIC_NUMBER_CARD:
50
+ {
51
+ return /*#__PURE__*/React.createElement(BasicNumberCardDataSettings, props);
52
+ }
53
+ case STATISTIC_TYPE.DASHBOARD:
54
+ {
55
+ return /*#__PURE__*/React.createElement(DashboardDataSettings, props);
56
+ }
57
+ case STATISTIC_TYPE.TABLE:
58
+ {
59
+ return /*#__PURE__*/React.createElement(TableDataSettings, props);
60
+ }
61
+ default:
62
+ {
63
+ return null;
64
+ }
65
+ }
66
+ };
67
+ export default DataSettings;
@@ -0,0 +1,45 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import React, { useCallback } from 'react';
3
+ import { BarDataSettings } from '../bar-settings';
4
+ import { AdvanceBarDataSettings } from '../advance-bar-settings';
5
+ import { StatisticsUtils } from '../../../utils';
6
+ import { BAR_MAP_TO_HORIZONTAL_MAP, STATISTIC_TYPE } from '../../../constants/';
7
+ var DataSettings = function DataSettings(_ref) {
8
+ var statistic = _ref.statistic,
9
+ tables = _ref.tables,
10
+ oldOnChange = _ref.onChange;
11
+ var onChange = useCallback(function (update) {
12
+ var oldConfig = statistic.config;
13
+ if (update.type && update.type !== oldConfig.type) {
14
+ oldOnChange && oldOnChange(update);
15
+ return;
16
+ }
17
+ var updateConfig = {};
18
+ var newConfig = _objectSpread(_objectSpread({}, oldConfig), update);
19
+ Object.keys(newConfig).forEach(function (key) {
20
+ if (BAR_MAP_TO_HORIZONTAL_MAP[key]) {
21
+ updateConfig[BAR_MAP_TO_HORIZONTAL_MAP[key]] = newConfig[key];
22
+ } else {
23
+ updateConfig[key] = newConfig[key];
24
+ }
25
+ });
26
+ oldOnChange && oldOnChange(updateConfig);
27
+ }, [statistic, oldOnChange]);
28
+ var config = statistic.config,
29
+ id = statistic.id;
30
+ var newConfig = StatisticsUtils.convertStatisticConfig(config);
31
+ var newStatistic = {
32
+ id: id,
33
+ config: newConfig
34
+ };
35
+ var type = config.type;
36
+ var BarGroupComponent = type === STATISTIC_TYPE.HORIZONTAL_BAR ? BarDataSettings : AdvanceBarDataSettings;
37
+ return /*#__PURE__*/React.createElement(BarGroupComponent, {
38
+ xLabel: 'Vertical_axis',
39
+ yLabel: 'Horizontal_axis',
40
+ statistic: newStatistic,
41
+ tables: tables,
42
+ onChange: onChange
43
+ });
44
+ };
45
+ export default DataSettings;
@@ -0,0 +1,3 @@
1
+ import HorizontalDataSettings from './data-settings';
2
+ import HorizontalStyleSettings from './style-settings';
3
+ export { HorizontalDataSettings, HorizontalStyleSettings };
@@ -0,0 +1,38 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import React, { useCallback } from 'react';
3
+ import { AdvanceBarStyleSettings } from '../advance-bar-settings';
4
+ import { BarStyleSettings } from '../bar-settings';
5
+ import { StatisticsUtils } from '../../../utils';
6
+ import { BAR_MAP_TO_HORIZONTAL_MAP, STATISTIC_TYPE } from '../../../constants';
7
+ var StyleSettings = function StyleSettings(_ref) {
8
+ var statistic = _ref.statistic,
9
+ oldOnChange = _ref.onChange;
10
+ var onChange = useCallback(function (update) {
11
+ var updateConfig = {};
12
+ var newConfig = _objectSpread(_objectSpread({}, statistic.config), update);
13
+ Object.keys(newConfig).forEach(function (key) {
14
+ if (BAR_MAP_TO_HORIZONTAL_MAP[key]) {
15
+ updateConfig[BAR_MAP_TO_HORIZONTAL_MAP[key]] = newConfig[key];
16
+ } else {
17
+ updateConfig[key] = newConfig[key];
18
+ }
19
+ });
20
+ oldOnChange && oldOnChange(updateConfig);
21
+ }, [statistic, oldOnChange]);
22
+ var config = statistic.config,
23
+ id = statistic.id;
24
+ var newConfig = StatisticsUtils.convertStatisticConfig(config);
25
+ var newStatistic = {
26
+ id: id,
27
+ config: newConfig
28
+ };
29
+ var type = config.type;
30
+ var BarStyleComponent = type === STATISTIC_TYPE.HORIZONTAL_BAR ? BarStyleSettings : AdvanceBarStyleSettings;
31
+ return /*#__PURE__*/React.createElement(BarStyleComponent, {
32
+ xLabel: 'Vertical_axis',
33
+ yLabel: 'Horizontal_axis',
34
+ statistic: newStatistic,
35
+ onChange: onChange
36
+ });
37
+ };
38
+ export default StyleSettings;
@@ -0,0 +1,73 @@
1
+ .seastatistic-settings {
2
+ height: 100%;
3
+ width: 100%;
4
+ padding: 0;
5
+ overflow: hidden;
6
+ }
7
+
8
+ .seastatistic-settings .seastatistic-settings-type {
9
+ height: 49px;
10
+ width: 100%;
11
+ display: flex;
12
+ align-items: center;
13
+ flex-direction: row;
14
+ border-bottom: 1px solid #e4e4e4;
15
+ background: #fff;
16
+ padding-left: 10px;
17
+ }
18
+
19
+ .seastatistic-settings .seastatistic-settings-type .seastatistic-settings-type-item {
20
+ text-align: center;
21
+ line-height: 48px;
22
+ height: 48px;
23
+ font-weight: 500;
24
+ cursor: pointer;
25
+ }
26
+
27
+ .seastatistic-settings .seastatistic-settings-type .seastatistic-settings-type-item.selected {
28
+ color: #ff8000;
29
+ border-bottom: 2px solid #ff8000;
30
+ }
31
+
32
+ .seastatistic-settings .statistic-settings-container {
33
+ height: calc(100% - 37px);
34
+ overflow-y: scroll;
35
+ padding: 16px 16px 150px;
36
+ }
37
+
38
+ .seastatistic-settings .statistics-add-number-columns {
39
+ color: #bbb;
40
+ line-height: 1;
41
+ margin-bottom: 10px;
42
+ }
43
+
44
+ .seastatistic-settings .statistics-add-number-columns:hover {
45
+ cursor: pointer;
46
+ color: #212529;
47
+ }
48
+
49
+ .seastatistic-settings .statistics-add-number-columns .dtable-icon-add-table {
50
+ margin-right: 5px;
51
+ display: inline-block;
52
+ transform: scale(.8);
53
+ }
54
+
55
+ .seastatistic-settings .statistics-add-number-columns .add-number-column-description {
56
+ font-size: 14px;
57
+ line-height: 14px;
58
+ }
59
+
60
+ .seastatistic-settings .delete-numeric-summary-item-content {
61
+ height: 20px;
62
+ width: 20px;
63
+ line-height: 20px;
64
+ font-weight: 400;
65
+ }
66
+
67
+ .seastatistic-settings .delete-numeric-summary-item-content:hover {
68
+ cursor: pointer;
69
+ }
70
+
71
+ .seastatistic-settings .delete-numeric-summary-item-content .delete-icon {
72
+ font-size: 14px;
73
+ }
@@ -0,0 +1,74 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import React, { useCallback, useState } from 'react';
4
+ import classnames from 'classnames';
5
+ import { eventStopPropagation } from '../../utils';
6
+ import DataSettings from './data-settings';
7
+ import StyleSettings from './style-settings';
8
+ import { STATISTIC_SETTINGS_TYPE } from '../../constants';
9
+ import intl from '../../intl';
10
+ import './index.css';
11
+ var Settings = function Settings(_ref) {
12
+ var statistic = _ref.statistic,
13
+ tables = _ref.tables,
14
+ onChange = _ref.onChange,
15
+ FilterSettings = _ref.FilterSettings,
16
+ CustomStyleSettings = _ref.CustomStyleSettings;
17
+ var _useState = useState(STATISTIC_SETTINGS_TYPE.DATA),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ type = _useState2[0],
20
+ setType = _useState2[1];
21
+ var onChartSettingsTypeChange = useCallback(function (event) {
22
+ eventStopPropagation(event);
23
+ var newType = event.target.getAttribute('data');
24
+ if (type === newType) return;
25
+ setType(newType);
26
+ }, [type]);
27
+ var modifyStatistic = useCallback(function (update) {
28
+ var newStatistic = _objectSpread(_objectSpread({}, statistic), {}, {
29
+ config: _objectSpread(_objectSpread({}, statistic.config), update)
30
+ });
31
+ onChange && onChange(newStatistic, STATISTIC_SETTINGS_TYPE.DATA);
32
+ }, [statistic, onChange]);
33
+ var modifyStyle = useCallback(function (update) {
34
+ var newStatistic = _objectSpread(_objectSpread({}, statistic), update);
35
+ onChange && onChange(newStatistic, STATISTIC_SETTINGS_TYPE.STYLE);
36
+ }, [statistic, onChange]);
37
+ var renderStyleSettings = useCallback(function () {
38
+ if (CustomStyleSettings) return /*#__PURE__*/React.createElement(CustomStyleSettings, {
39
+ statistic: statistic,
40
+ onChange: modifyStyle
41
+ });
42
+ return /*#__PURE__*/React.createElement(StyleSettings, {
43
+ statistic: statistic,
44
+ onChange: modifyStyle
45
+ });
46
+ }, [CustomStyleSettings, statistic, modifyStyle]);
47
+ return /*#__PURE__*/React.createElement("div", {
48
+ className: "seastatistic-settings"
49
+ }, /*#__PURE__*/React.createElement("div", {
50
+ className: "seastatistic-settings-type",
51
+ onClick: onChartSettingsTypeChange
52
+ }, /*#__PURE__*/React.createElement("div", {
53
+ className: classnames('seastatistic-settings-type-item', {
54
+ 'selected': type === STATISTIC_SETTINGS_TYPE.DATA
55
+ }),
56
+ data: STATISTIC_SETTINGS_TYPE.DATA
57
+ }, intl.get('Data_settings')), /*#__PURE__*/React.createElement("div", {
58
+ className: classnames('seastatistic-settings-type-item ml-4', {
59
+ 'selected': type === STATISTIC_SETTINGS_TYPE.STYLE
60
+ }),
61
+ data: STATISTIC_SETTINGS_TYPE.STYLE
62
+ }, intl.get('Style_settings'))), /*#__PURE__*/React.createElement("div", {
63
+ className: "statistic-settings-container position-relative"
64
+ }, /*#__PURE__*/React.createElement("div", {
65
+ className: "statistic-settings-content"
66
+ }, type === STATISTIC_SETTINGS_TYPE.DATA && /*#__PURE__*/React.createElement(DataSettings, {
67
+ statistic: statistic,
68
+ tables: tables,
69
+ FilterSettings: FilterSettings,
70
+ onChange: modifyStatistic
71
+ }), type === STATISTIC_SETTINGS_TYPE.STYLE && renderStyleSettings())));
72
+ };
73
+ export default Settings;
74
+ export { StyleSettings };