sea-chart 0.0.1-beta

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 (213) hide show
  1. package/README.md +120 -0
  2. package/dist/assets/icons/area-chart.svg +10 -0
  3. package/dist/assets/icons/bar-chart.svg +12 -0
  4. package/dist/assets/icons/card.svg +22 -0
  5. package/dist/assets/icons/combination-chart.svg +17 -0
  6. package/dist/assets/icons/dtable-logo.svg +16 -0
  7. package/dist/assets/icons/facet-chart.svg +12 -0
  8. package/dist/assets/icons/gauge.svg +18 -0
  9. package/dist/assets/icons/heat-map.svg +14 -0
  10. package/dist/assets/icons/histogram.svg +12 -0
  11. package/dist/assets/icons/line-chart.svg +12 -0
  12. package/dist/assets/icons/map.svg +20 -0
  13. package/dist/assets/icons/pie-chart.svg +11 -0
  14. package/dist/assets/icons/rectangular-tree-diagram.svg +10 -0
  15. package/dist/assets/icons/scatter-chart.svg +15 -0
  16. package/dist/assets/icons/type-change.svg +17 -0
  17. package/dist/assets/img/area-chart.png +0 -0
  18. package/dist/assets/img/area-group-chart.png +0 -0
  19. package/dist/assets/img/bar-group.png +0 -0
  20. package/dist/assets/img/bar-stack.png +0 -0
  21. package/dist/assets/img/bar.png +0 -0
  22. package/dist/assets/img/combination-chart.png +0 -0
  23. package/dist/assets/img/compared-chart.png +0 -0
  24. package/dist/assets/img/completeness-chart.png +0 -0
  25. package/dist/assets/img/custom-bar.png +0 -0
  26. package/dist/assets/img/dashboard-chart.png +0 -0
  27. package/dist/assets/img/group-completeness-chart.png +0 -0
  28. package/dist/assets/img/group_line.png +0 -0
  29. package/dist/assets/img/heat-map.png +0 -0
  30. package/dist/assets/img/horizontal-bar.png +0 -0
  31. package/dist/assets/img/horizontal-group-bar.png +0 -0
  32. package/dist/assets/img/line.png +0 -0
  33. package/dist/assets/img/map-bubble.png +0 -0
  34. package/dist/assets/img/map.png +0 -0
  35. package/dist/assets/img/mirror.png +0 -0
  36. package/dist/assets/img/number-card.png +0 -0
  37. package/dist/assets/img/pie.png +0 -0
  38. package/dist/assets/img/pivot-table.png +0 -0
  39. package/dist/assets/img/ring.png +0 -0
  40. package/dist/assets/img/scatter.png +0 -0
  41. package/dist/assets/img/stacked-horizontal-bar.png +0 -0
  42. package/dist/assets/img/treemap.png +0 -0
  43. package/dist/assets/img/trend-chart.png +0 -0
  44. package/dist/assets/img/world-map-bubble.png +0 -0
  45. package/dist/assets/img/world-map.png +0 -0
  46. package/dist/components/collaborator/index.js +26 -0
  47. package/dist/components/icon/index.css +5 -0
  48. package/dist/components/icon/index.js +24 -0
  49. package/dist/components/index.js +8 -0
  50. package/dist/components/loading/index.css +54 -0
  51. package/dist/components/loading/index.js +12 -0
  52. package/dist/components/number-input/index.js +31 -0
  53. package/dist/components/pixel-editor/index.css +29 -0
  54. package/dist/components/pixel-editor/index.js +38 -0
  55. package/dist/components/select-group/index.css +67 -0
  56. package/dist/components/select-group/index.js +52 -0
  57. package/dist/components/types-dialog/index.css +97 -0
  58. package/dist/components/types-dialog/index.js +116 -0
  59. package/dist/constants/geolocation.js +11 -0
  60. package/dist/constants/index.js +184 -0
  61. package/dist/constants/model.js +187 -0
  62. package/dist/constants/style.js +15 -0
  63. package/dist/constants/type-image.js +59 -0
  64. package/dist/constants/type.js +124 -0
  65. package/dist/context.js +33 -0
  66. package/dist/editor/index.css +0 -0
  67. package/dist/editor/index.js +36 -0
  68. package/dist/index.js +6 -0
  69. package/dist/intl.js +37 -0
  70. package/dist/locale/index.js +18 -0
  71. package/dist/locale/lang/de.js +141 -0
  72. package/dist/locale/lang/en.js +143 -0
  73. package/dist/locale/lang/es.js +141 -0
  74. package/dist/locale/lang/fr.js +141 -0
  75. package/dist/locale/lang/pt.js +141 -0
  76. package/dist/locale/lang/ru.js +141 -0
  77. package/dist/locale/lang/zh_CN.js +143 -0
  78. package/dist/model/area-group.js +41 -0
  79. package/dist/model/area.js +32 -0
  80. package/dist/model/bar-group.js +44 -0
  81. package/dist/model/bar-stack.js +41 -0
  82. package/dist/model/bar.js +38 -0
  83. package/dist/model/base-model.js +9 -0
  84. package/dist/model/basic-number-card.js +22 -0
  85. package/dist/model/chart.js +23 -0
  86. package/dist/model/combination.js +38 -0
  87. package/dist/model/compare-bar.js +39 -0
  88. package/dist/model/completeness-group.js +24 -0
  89. package/dist/model/completeness.js +18 -0
  90. package/dist/model/dashboard.js +16 -0
  91. package/dist/model/generic-model.js +224 -0
  92. package/dist/model/heat-map.js +23 -0
  93. package/dist/model/horizontal-bar.js +38 -0
  94. package/dist/model/horizontal-group-bar.js +43 -0
  95. package/dist/model/index.js +63 -0
  96. package/dist/model/line-group.js +44 -0
  97. package/dist/model/line.js +38 -0
  98. package/dist/model/map-bubble.js +27 -0
  99. package/dist/model/map.js +27 -0
  100. package/dist/model/mirror.js +26 -0
  101. package/dist/model/pie.js +26 -0
  102. package/dist/model/ring.js +26 -0
  103. package/dist/model/scatter.js +19 -0
  104. package/dist/model/stacked-horizontal-bar.js +32 -0
  105. package/dist/model/table.js +23 -0
  106. package/dist/model/tree-map.js +20 -0
  107. package/dist/model/trend.js +24 -0
  108. package/dist/model/user.js +15 -0
  109. package/dist/model/world-map-bubble.js +26 -0
  110. package/dist/model/world-map.js +26 -0
  111. package/dist/settings/advance-bar-settings/data-settings.js +143 -0
  112. package/dist/settings/advance-bar-settings/index.js +3 -0
  113. package/dist/settings/advance-bar-settings/style-settings.js +161 -0
  114. package/dist/settings/bar-settings/data-settings.js +162 -0
  115. package/dist/settings/bar-settings/index.js +3 -0
  116. package/dist/settings/bar-settings/style-settings.js +179 -0
  117. package/dist/settings/basic-number-card/data-settings.js +126 -0
  118. package/dist/settings/basic-number-card/index.js +3 -0
  119. package/dist/settings/basic-number-card/style-settings.js +42 -0
  120. package/dist/settings/combination-settings/data-settings.js +279 -0
  121. package/dist/settings/combination-settings/index.js +3 -0
  122. package/dist/settings/combination-settings/style-settings.js +174 -0
  123. package/dist/settings/dashboard-settings/data-settings.js +179 -0
  124. package/dist/settings/dashboard-settings/index.js +2 -0
  125. package/dist/settings/data-settings.js +73 -0
  126. package/dist/settings/horizontal-bar-settings/data-settings.js +55 -0
  127. package/dist/settings/horizontal-bar-settings/index.js +3 -0
  128. package/dist/settings/horizontal-bar-settings/style-settings.js +46 -0
  129. package/dist/settings/index.css +85 -0
  130. package/dist/settings/index.js +76 -0
  131. package/dist/settings/pie-settings/data-settings.js +146 -0
  132. package/dist/settings/pie-settings/index.js +3 -0
  133. package/dist/settings/pie-settings/style-settings.js +141 -0
  134. package/dist/settings/style-settings.js +118 -0
  135. package/dist/settings/table-settings/data-settings.js +549 -0
  136. package/dist/settings/table-settings/index.js +2 -0
  137. package/dist/settings/time-comparison-settings/data-settings.js +172 -0
  138. package/dist/settings/time-comparison-settings/index.js +3 -0
  139. package/dist/settings/time-comparison-settings/style-settings.js +213 -0
  140. package/dist/settings/widgets/basic-summary/index.css +12 -0
  141. package/dist/settings/widgets/basic-summary/index.js +176 -0
  142. package/dist/settings/widgets/chart-type/index.css +31 -0
  143. package/dist/settings/widgets/chart-type/index.js +59 -0
  144. package/dist/settings/widgets/common-data-settings.js +48 -0
  145. package/dist/settings/widgets/data-filter/index.css +17 -0
  146. package/dist/settings/widgets/data-filter/index.js +89 -0
  147. package/dist/settings/widgets/data-sort.js +44 -0
  148. package/dist/settings/widgets/date-summary-item.js +111 -0
  149. package/dist/settings/widgets/display-values-settings/index.css +13 -0
  150. package/dist/settings/widgets/display-values-settings/index.js +42 -0
  151. package/dist/settings/widgets/divider/index.css +4 -0
  152. package/dist/settings/widgets/divider/index.js +12 -0
  153. package/dist/settings/widgets/font-settings/font-size-settings.js +33 -0
  154. package/dist/settings/widgets/font-settings/font-weight-settings.js +44 -0
  155. package/dist/settings/widgets/font-settings/index.js +3 -0
  156. package/dist/settings/widgets/group-by.js +160 -0
  157. package/dist/settings/widgets/label-color.js +30 -0
  158. package/dist/settings/widgets/min-max-setting.js +52 -0
  159. package/dist/settings/widgets/mininum-slice-percent.js +63 -0
  160. package/dist/settings/widgets/numeric-summary-item.js +90 -0
  161. package/dist/settings/widgets/select-table/index.css +0 -0
  162. package/dist/settings/widgets/select-table/index.js +38 -0
  163. package/dist/settings/widgets/stack.js +50 -0
  164. package/dist/settings/widgets/summary-method-setting.js +66 -0
  165. package/dist/settings/widgets/summary-settings.js +411 -0
  166. package/dist/settings/widgets/switch/index.css +37 -0
  167. package/dist/settings/widgets/switch/index.js +24 -0
  168. package/dist/settings/widgets/text-horizontal-settings.js +25 -0
  169. package/dist/settings/widgets/time-picker.js +173 -0
  170. package/dist/settings/widgets/title-settings/index.js +60 -0
  171. package/dist/settings/widgets/title-settings/title-text.js +25 -0
  172. package/dist/settings/widgets/x-axios.js +0 -0
  173. package/dist/settings/widgets/y-axis-group-settings.js +438 -0
  174. package/dist/utils/cell-format-utils.js +42 -0
  175. package/dist/utils/chart-data-sql.js +606 -0
  176. package/dist/utils/chart-utils.js +1800 -0
  177. package/dist/utils/chart.js +6 -0
  178. package/dist/utils/collaborator-utils.js +39 -0
  179. package/dist/utils/column-2-sql-column.js +551 -0
  180. package/dist/utils/column-utils.js +208 -0
  181. package/dist/utils/custom-g2.js +612 -0
  182. package/dist/utils/date-translate.js +66 -0
  183. package/dist/utils/index.js +48 -0
  184. package/dist/utils/key-generator.js +13 -0
  185. package/dist/utils/object-utils.js +45 -0
  186. package/dist/utils/options-utils.js +60 -0
  187. package/dist/view/index.css +53 -0
  188. package/dist/view/index.js +189 -0
  189. package/dist/view/title/index.css +3 -0
  190. package/dist/view/title/index.js +46 -0
  191. package/dist/view/wrapper/area.js +150 -0
  192. package/dist/view/wrapper/bar-group.js +148 -0
  193. package/dist/view/wrapper/bar.js +138 -0
  194. package/dist/view/wrapper/basic-number-card.js +127 -0
  195. package/dist/view/wrapper/chart-component.js +261 -0
  196. package/dist/view/wrapper/combination.js +399 -0
  197. package/dist/view/wrapper/dashboard.js +164 -0
  198. package/dist/view/wrapper/horizontal-bar-group.js +149 -0
  199. package/dist/view/wrapper/horizontal-bar.js +140 -0
  200. package/dist/view/wrapper/horizontal-component.js +78 -0
  201. package/dist/view/wrapper/index.js +200 -0
  202. package/dist/view/wrapper/line-group.js +145 -0
  203. package/dist/view/wrapper/line.js +157 -0
  204. package/dist/view/wrapper/pie.js +185 -0
  205. package/dist/view/wrapper/ring.js +264 -0
  206. package/dist/view/wrapper/table/index.css +103 -0
  207. package/dist/view/wrapper/table/index.js +31 -0
  208. package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +144 -0
  209. package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +198 -0
  210. package/dist/view/wrapper/table/pivot-table-display-name.js +247 -0
  211. package/dist/view/wrapper/table/two-dimension-table.js +249 -0
  212. package/dist/view/wrapper/treemap.js +186 -0
  213. package/package.json +151 -0
@@ -0,0 +1,19 @@
1
+ import BaseModel from './base-model';
2
+ import { isBoolean } from '../utils';
3
+ import { CHART_TYPE } from '../constants';
4
+ class Scatter extends BaseModel {
5
+ constructor(options) {
6
+ super({
7
+ ...options,
8
+ type: CHART_TYPE.SCATTER
9
+ });
10
+ this.x_axis_column_key = options.x_axis_column_key;
11
+ this.y_axis_summary_column_key = options.y_axis_summary_column_key;
12
+ this.group_column = options.column_groupby_column_key;
13
+ this.x_axis_show_label = isBoolean(options.x_axis_show_label) ? options.x_axis_show_label : false;
14
+ this.x_axis_label_position = options.x_axis_label_position;
15
+ this.y_axis_show_label = isBoolean(options.y_axis_show_label) ? options.y_axis_show_label : false;
16
+ this.y_axis_label_position = options.y_axis_label_position;
17
+ }
18
+ }
19
+ export default Scatter;
@@ -0,0 +1,32 @@
1
+ import BaseModel from './base-model';
2
+ import { isBoolean } from '../utils';
3
+ import { CHART_TYPE } from '../constants';
4
+ class StackedHorizontalGroupBar extends BaseModel {
5
+ constructor(options) {
6
+ super({
7
+ ...options,
8
+ type: CHART_TYPE.STACKED_HORIZONTAL_BAR
9
+ });
10
+ this.vertical_axis_column_key = options.x_axis_column_key;
11
+ this.vertical_axis_date_granularity = options.x_axis_date_granularity;
12
+ this.vertical_axis_geolocation_granularity = options.x_axis_geolocation_granularity;
13
+ this.vertical_axis_include_empty = options.x_axis_include_empty_cells;
14
+ this.horizontal_axis_summary_type = options.y_axis_summary_type;
15
+ this.show_vertical_axis_label = isBoolean(options.x_axis_show_label) ? options.x_axis_show_label : false;
16
+ this.show_horizontal_axis_label = isBoolean(options.y_axis_show_label) ? options.y_axis_show_label : false;
17
+ this.vertical_axis_label_position = options.x_axis_label_position;
18
+ this.horizontal_axis_label_position = options.y_axis_label_position;
19
+ this.horizontal_axis_column_key = options.y_axis_summary_column_key;
20
+ this.horizontal_axis_summary_method = options.y_axis_summary_method;
21
+ this.horizontal_axis_label_color = options.y_axis_label_color;
22
+
23
+ // column-group
24
+ this.column_groupby_column_key = options.column_groupby_column_key;
25
+ this.column_groupby_date_granularity = options.column_groupby_date_granularity;
26
+ this.column_groupby_geolocation_granularity = options.column_groupby_geolocation_granularity;
27
+ this.column_groupby_multiple_numeric_column = options.column_groupby_multiple_numeric_column;
28
+ this.summary_columns = options.summary_columns;
29
+ this.label_font_size = options.label_font_size;
30
+ }
31
+ }
32
+ export default StackedHorizontalGroupBar;
@@ -0,0 +1,23 @@
1
+ import BaseModel from './base-model';
2
+ import { CHART_SUMMARY_TYPE, CHART_TYPE } from '../constants';
3
+ class Table extends BaseModel {
4
+ constructor(options) {
5
+ super({
6
+ ...options,
7
+ type: CHART_TYPE.TABLE
8
+ });
9
+ this.groupby_column_key = options.x_axis_column_key;
10
+ this.groupby_date_granularity = options.x_axis_date_granularity;
11
+ this.groupby_geolocation_granularity = options.x_axis_geolocation_granularity;
12
+ this.groupby_include_empty_cells = options.x_axis_include_empty_cells;
13
+ this.summary_column_key = options.y_axis_summary_column_key;
14
+ this.summary_method = options.y_axis_summary_method || CHART_SUMMARY_TYPE.SUM;
15
+ this.summary_type = options.y_axis_summary_type || CHART_SUMMARY_TYPE.COUNT;
16
+ this.column_groupby_multiple_numeric_column = options.column_groupby_multiple_numeric_column;
17
+ this.summary_columns = options.summary_columns;
18
+ this.column_groupby_column_key = options.column_groupby_column_key;
19
+ this.column_groupby_date_granularity = options.column_groupby_date_granularity;
20
+ this.column_groupby_geolocation_granularity = options.column_groupby_geolocation_granularity;
21
+ }
22
+ }
23
+ export default Table;
@@ -0,0 +1,20 @@
1
+ import BaseModel from './base-model';
2
+ import { CHART_SUMMARY_TYPE, CHART_TYPE } from '../constants';
3
+ class TreeMap extends BaseModel {
4
+ constructor(options) {
5
+ super({
6
+ ...options,
7
+ type: CHART_TYPE.TREE_MAP
8
+ });
9
+ this.groupby_column_key = options.x_axis_column_key;
10
+ this.groupby_date_granularity = options.x_axis_date_granularity;
11
+ this.groupby_geolocation_granularity = options.x_axis_geolocation_granularity;
12
+ this.groupby_include_empty_cells = options.x_axis_include_empty_cells;
13
+ this.summary_type = options.y_axis_summary_type || CHART_SUMMARY_TYPE.COUNT;
14
+ this.summary_method = options.y_axis_summary_method || CHART_SUMMARY_TYPE.SUM;
15
+ this.summary_column_key = options.y_axis_summary_column_key;
16
+ this.sort_type = options.sort_type;
17
+ this.minimum_slice_percent = options.minimum_slice_percent;
18
+ }
19
+ }
20
+ export default TreeMap;
@@ -0,0 +1,24 @@
1
+ import { getTableColumnByKey, isDateColumn } from 'dtable-utils';
2
+ import BaseModel from './base-model';
3
+ import { CHART_TYPE } from '../constants';
4
+ class Trend extends BaseModel {
5
+ constructor(options, table) {
6
+ super({
7
+ ...options,
8
+ type: CHART_TYPE.TREND
9
+ });
10
+ this.date_column_key = options.x_axis_column_key;
11
+ this.date_granularity = options.x_axis_date_granularity;
12
+ if (this.date_column_key) {
13
+ const column = getTableColumnByKey(table, this.date_column_key);
14
+ if (!column || !isDateColumn(column)) {
15
+ this.date_column_key = null;
16
+ this.date_granularity = null;
17
+ }
18
+ }
19
+ this.summary_type = options.y_axis_summary_type;
20
+ this.summary_column_key = options.y_axis_summary_column_key;
21
+ this.summary_method = options.y_axis_summary_method;
22
+ }
23
+ }
24
+ export default Trend;
@@ -0,0 +1,15 @@
1
+ class User {
2
+ constructor(obj) {
3
+ this.loaded = obj.loaded || false;
4
+ this.email = obj.email || '';
5
+ this.name = obj.name || '';
6
+ this.avatar_url = obj.avatar_url || '';
7
+ this.contact_email = obj.contact_email || null;
8
+ this.name_pinyin = obj.name_pinyin || '';
9
+ this.id = obj.id_in_org || '';
10
+ }
11
+ updateLoaded(loaded) {
12
+ this.loaded = loaded;
13
+ }
14
+ }
15
+ export default User;
@@ -0,0 +1,26 @@
1
+ import { getTableById, getTableColumnByKey } from 'dtable-utils';
2
+ import BaseModel from './base-model';
3
+ import { isStatisticWorldMapColumn } from '../utils';
4
+ import { CHART_TYPE } from '../constants';
5
+ class WorldMapBubble extends BaseModel {
6
+ constructor(options, tables) {
7
+ super({
8
+ ...options,
9
+ type: CHART_TYPE.WORLD_MAP_BUBBLE
10
+ });
11
+ this.column_key = options.x_axis_column_key;
12
+ if (this.column_key && this.table_id && tables) {
13
+ const table = getTableById(tables, this.table_id);
14
+ const column = getTableColumnByKey(table, this.column_key);
15
+ if (!isStatisticWorldMapColumn(column)) {
16
+ this.column_key = null;
17
+ }
18
+ }
19
+ this.summary_type = options.y_axis_summary_type;
20
+ this.summary_method = options.y_axis_summary_method;
21
+ this.summary_column_key = options.y_axis_summary_column_key;
22
+ this.legend_direction = options.legend_direction;
23
+ this.legend_size = options.legend_size;
24
+ }
25
+ }
26
+ export default WorldMapBubble;
@@ -0,0 +1,26 @@
1
+ import { getTableById, getTableColumnByKey } from 'dtable-utils';
2
+ import BaseModel from './base-model';
3
+ import { isStatisticWorldMapColumn } from '../utils';
4
+ import { CHART_TYPE } from '../constants';
5
+ class WorldMap extends BaseModel {
6
+ constructor(options, tables) {
7
+ super({
8
+ ...options,
9
+ type: CHART_TYPE.WORLD_MAP
10
+ });
11
+ this.column_key = options.x_axis_column_key;
12
+ if (this.column_key && this.table_id && tables) {
13
+ const table = getTableById(tables, this.table_id);
14
+ const column = getTableColumnByKey(table, this.column_key);
15
+ if (!isStatisticWorldMapColumn(column)) {
16
+ this.column_key = null;
17
+ }
18
+ }
19
+ this.summary_type = options.y_axis_summary_type;
20
+ this.summary_method = options.y_axis_summary_method;
21
+ this.summary_column_key = options.y_axis_summary_column_key;
22
+ this.legend_direction = options.legend_direction;
23
+ this.legend_size = options.legend_size;
24
+ }
25
+ }
26
+ export default WorldMap;
@@ -0,0 +1,143 @@
1
+ import React, { useCallback } from 'react';
2
+ import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
3
+ import CommonDataSettings from '../widgets/common-data-settings';
4
+ import Divider from '../widgets/divider';
5
+ import GroupBy from '../widgets/group-by';
6
+ import Switch from '../widgets/switch';
7
+ import YAxisGroupSettings from '../widgets/y-axis-group-settings';
8
+ import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
9
+ import { eventStopPropagation } from '../../utils';
10
+ import intl from '../../intl';
11
+ const DataSettings = _ref => {
12
+ let {
13
+ chart,
14
+ onChange,
15
+ tables,
16
+ xLabel,
17
+ yLabel
18
+ } = _ref;
19
+ const onXAxisColumnChange = useCallback(option => {
20
+ const {
21
+ config
22
+ } = chart;
23
+ const {
24
+ x_axis_column_key
25
+ } = config;
26
+ const column = option.value;
27
+ const {
28
+ key: newXAxisColumnKey,
29
+ type
30
+ } = column;
31
+ const validValue = newXAxisColumnKey === 'Groupby_null' ? null : newXAxisColumnKey;
32
+ if (x_axis_column_key === validValue) return;
33
+ let update = {
34
+ x_axis_column_key: validValue
35
+ };
36
+ if (!validValue) {
37
+ update['x_axis_date_granularity'] = null;
38
+ update['x_axis_geolocation_granularity'] = null;
39
+ } else {
40
+ if (DATE_COLUMN_OPTIONS.includes(type)) {
41
+ update['x_axis_date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
42
+ update['x_axis_geolocation_granularity'] = null;
43
+ } else if (type === CellType.GEOLOCATION) {
44
+ const {
45
+ geo_format
46
+ } = column.data || {};
47
+ if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE) {
48
+ update['x_axis_geolocation_granularity'] = GEOLOCATION_FORMAT_MAP.PROVINCE;
49
+ } else if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE_CITY) {
50
+ update['x_axis_geolocation_granularity'] = GEOLOCATION_FORMAT_CITY;
51
+ } else if (geo_format === GEOLOCATION_FORMAT_MAP.GEOLOCATION || !geo_format) {
52
+ update['x_axis_geolocation_granularity'] = 'district';
53
+ } else {
54
+ update['x_axis_geolocation_granularity'] = null;
55
+ }
56
+ update['x_axis_date_granularity'] = null;
57
+ }
58
+ }
59
+ onChange && onChange(update);
60
+ }, [chart, onChange]);
61
+ const onGroupbyDateGranularityChange = useCallback(option => {
62
+ const {
63
+ config
64
+ } = chart;
65
+ const {
66
+ x_axis_date_granularity
67
+ } = config;
68
+ const value = option.value;
69
+ if (value === x_axis_date_granularity) return;
70
+ onChange && onChange({
71
+ x_axis_date_granularity: value
72
+ });
73
+ }, [chart, onChange]);
74
+ const onGroupbyGeolocationGranularityChange = useCallback(option => {
75
+ const {
76
+ config
77
+ } = chart;
78
+ const {
79
+ x_axis_geolocation_granularity
80
+ } = config;
81
+ const value = option.value;
82
+ if (value === x_axis_geolocation_granularity) return;
83
+ onChange && onChange({
84
+ x_axis_geolocation_granularity: value
85
+ });
86
+ }, [chart, onChange]);
87
+ const onIncludeEmptyChange = useCallback(event => {
88
+ eventStopPropagation(event);
89
+ const {
90
+ config
91
+ } = chart;
92
+ const {
93
+ x_axis_include_empty_cells
94
+ } = config;
95
+ onChange && onChange({
96
+ x_axis_include_empty_cells: !x_axis_include_empty_cells
97
+ });
98
+ }, [chart, onChange]);
99
+ const {
100
+ config
101
+ } = chart;
102
+ const {
103
+ table_id,
104
+ x_axis_column_key,
105
+ x_axis_date_granularity,
106
+ x_axis_geolocation_granularity,
107
+ x_axis_include_empty_cells
108
+ } = config;
109
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CommonDataSettings, {
110
+ chart: chart,
111
+ tables: tables,
112
+ onChange: onChange
113
+ }), /*#__PURE__*/React.createElement(GroupBy, {
114
+ tables: tables,
115
+ className: "selected-x-axis",
116
+ label: intl.get(xLabel),
117
+ selectedTableId: table_id,
118
+ selectedColumnKey: x_axis_column_key,
119
+ selectedDateGranularity: x_axis_date_granularity,
120
+ selectedGeolocationGranularity: x_axis_geolocation_granularity,
121
+ onGroupByChange: onXAxisColumnChange,
122
+ onGroupbyDateGranularityChange: onGroupbyDateGranularityChange,
123
+ onGroupbyGeolocationGranularityChange: onGroupbyGeolocationGranularityChange
124
+ }), /*#__PURE__*/React.createElement(Switch, {
125
+ key: "x_axis_include_empty_cells",
126
+ checked: x_axis_include_empty_cells,
127
+ placeholder: intl.get('Include_empty'),
128
+ onChange: onIncludeEmptyChange
129
+ }), /*#__PURE__*/React.createElement(Divider, {
130
+ className: "mt-4"
131
+ }), /*#__PURE__*/React.createElement(YAxisGroupSettings, {
132
+ className: "selected-y-axis",
133
+ label: intl.get(yLabel),
134
+ chart: chart,
135
+ tables: tables,
136
+ onChange: onChange
137
+ }));
138
+ };
139
+ DataSettings.defaultProps = {
140
+ xLabel: 'X_axis',
141
+ yLabel: 'Y_axis'
142
+ };
143
+ export default DataSettings;
@@ -0,0 +1,3 @@
1
+ import AdvanceBarDataSettings from './data-settings';
2
+ import AdvanceBarStyleSettings from './style-settings';
3
+ export { AdvanceBarDataSettings, AdvanceBarStyleSettings };
@@ -0,0 +1,161 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import { Label, FormGroup } from 'reactstrap';
3
+ import DTableSelect from "dtable-ui-component/lib/DTableSelect";
4
+ import Switch from '../widgets/switch';
5
+ import Divider from '../widgets/divider';
6
+ import MinMaxSetting from '../widgets/min-max-setting';
7
+ import DisplayValuesSettings from '../widgets/display-values-settings';
8
+ import { eventStopPropagation } from '../../utils';
9
+ import { X_LABEL_POSITIONS, Y_LABEL_POSITIONS, LABEL_POSITION_TYPE_SHOW } from '../../constants';
10
+ import intl from '../../intl';
11
+ const StyleSettings = _ref => {
12
+ let {
13
+ chart,
14
+ xLabel,
15
+ yLabel,
16
+ onChange
17
+ } = _ref;
18
+ const xAxisLabelOptions = useMemo(() => {
19
+ return X_LABEL_POSITIONS.map(item => {
20
+ return {
21
+ value: item,
22
+ label: intl.get(LABEL_POSITION_TYPE_SHOW[item])
23
+ };
24
+ });
25
+ }, []);
26
+ const yAxisLabelOptions = useMemo(() => {
27
+ return Y_LABEL_POSITIONS.map(item => {
28
+ return {
29
+ value: item,
30
+ label: intl.get(LABEL_POSITION_TYPE_SHOW[item])
31
+ };
32
+ });
33
+ }, []);
34
+ const onAxisLabelShowChange = useCallback((event, labelKey) => {
35
+ eventStopPropagation(event);
36
+ const {
37
+ config
38
+ } = chart;
39
+ const value = config[labelKey];
40
+ onChange && onChange({
41
+ [labelKey]: !value
42
+ });
43
+ }, [chart, onChange]);
44
+ const onAxisLabelPositionChange = useCallback((option, positionKey) => {
45
+ const position = option.value;
46
+ const {
47
+ config
48
+ } = chart;
49
+ const oldValue = config[positionKey];
50
+ if (position === oldValue) return;
51
+ onChange && onChange({
52
+ [positionKey]: position
53
+ });
54
+ }, [chart, onChange]);
55
+ const onYAxisAutoRangeChange = useCallback(event => {
56
+ eventStopPropagation(event);
57
+ const {
58
+ config
59
+ } = chart;
60
+ const {
61
+ y_axis_auto_range
62
+ } = config;
63
+ onChange && onChange({
64
+ y_axis_auto_range: !y_axis_auto_range
65
+ });
66
+ }, [chart, onChange]);
67
+ const onYAxisMinChange = useCallback(min => {
68
+ const newMin = parseInt(min);
69
+ if (Number.isNaN(newMin)) return;
70
+ const {
71
+ config
72
+ } = chart;
73
+ const {
74
+ y_axis_min
75
+ } = config;
76
+ if (y_axis_min === newMin) return;
77
+ onChange && onChange({
78
+ y_axis_min: newMin
79
+ });
80
+ }, [chart, onChange]);
81
+ const onYAxisMaxChange = useCallback(max => {
82
+ const newMax = parseInt(max);
83
+ if (Number.isNaN(newMax)) return;
84
+ const {
85
+ config
86
+ } = chart;
87
+ const {
88
+ y_axis_max
89
+ } = config;
90
+ if (y_axis_max === newMax) return;
91
+ onChange && onChange({
92
+ y_axis_max: newMax
93
+ });
94
+ }, [chart, onChange]);
95
+ const onDisplayValueChange = useCallback(update => {
96
+ onChange(update);
97
+ }, [onChange]);
98
+ const {
99
+ config
100
+ } = chart;
101
+ const {
102
+ x_axis_show_label,
103
+ x_axis_label_position,
104
+ y_axis_show_label,
105
+ y_axis_label_position,
106
+ y_axis_auto_range = true,
107
+ y_axis_min,
108
+ y_axis_max,
109
+ y_axis_show_value,
110
+ label_font_size
111
+ } = config;
112
+ const xAxisLabelPosition = xAxisLabelOptions.find(option => option.value === x_axis_label_position) || xAxisLabelOptions[0];
113
+ const yAxisLabelPosition = yAxisLabelOptions.find(option => option.value === y_axis_label_position) || yAxisLabelOptions[0];
114
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
115
+ className: "sea-chart-parameter-item"
116
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get(xLabel)), /*#__PURE__*/React.createElement(Switch, {
117
+ key: "x_axis_show_label",
118
+ checked: x_axis_show_label || false,
119
+ placeholder: intl.get('Display_title'),
120
+ onChange: event => onAxisLabelShowChange(event, 'x_axis_show_label')
121
+ }), x_axis_show_label && /*#__PURE__*/React.createElement(DTableSelect, {
122
+ value: xAxisLabelPosition,
123
+ options: xAxisLabelOptions,
124
+ onChange: option => onAxisLabelPositionChange(option, 'x_axis_label_position')
125
+ })), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(FormGroup, {
126
+ className: "sea-chart-parameter-item"
127
+ }, /*#__PURE__*/React.createElement(Label, null, intl.get(yLabel)), /*#__PURE__*/React.createElement(Switch, {
128
+ key: "y_axis_show_label",
129
+ checked: y_axis_show_label || false,
130
+ placeholder: intl.get('Display_title'),
131
+ onChange: event => onAxisLabelShowChange(event, 'y_axis_show_label')
132
+ }), y_axis_show_label && /*#__PURE__*/React.createElement("div", {
133
+ className: "sea-chart-parameter-container"
134
+ }, /*#__PURE__*/React.createElement(DTableSelect, {
135
+ value: yAxisLabelPosition,
136
+ classNamePrefix: "chart-y-axis-label-position",
137
+ options: yAxisLabelOptions,
138
+ onChange: option => onAxisLabelPositionChange(option, 'y_axis_label_position')
139
+ })), /*#__PURE__*/React.createElement(Switch, {
140
+ key: "y_axis_auto_range",
141
+ checked: y_axis_auto_range,
142
+ placeholder: intl.get('Auto_range'),
143
+ onChange: onYAxisAutoRangeChange
144
+ }), !y_axis_auto_range && /*#__PURE__*/React.createElement(MinMaxSetting, {
145
+ min: y_axis_min,
146
+ max: y_axis_max,
147
+ onMinChange: onYAxisMinChange,
148
+ onMaxChange: onYAxisMaxChange
149
+ })), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(DisplayValuesSettings, {
150
+ isShowValueKey: "y_axis_show_value",
151
+ isShowValue: y_axis_show_value,
152
+ fontSizeKey: "label_font_size",
153
+ fontSize: label_font_size,
154
+ onChange: onDisplayValueChange
155
+ }));
156
+ };
157
+ StyleSettings.defaultProps = {
158
+ xLabel: 'X_axis',
159
+ yLabel: 'Y_axis'
160
+ };
161
+ export default StyleSettings;
@@ -0,0 +1,162 @@
1
+ import React, { useCallback } from 'react';
2
+ import { CellType, DATE_COLUMN_OPTIONS } from 'dtable-utils';
3
+ import CommonDataSettings from '../widgets/common-data-settings';
4
+ import Divider from '../widgets/divider';
5
+ import GroupBy from '../widgets/group-by';
6
+ import Switch from '../widgets/switch';
7
+ import BasicSummary from '../widgets/basic-summary';
8
+ import DataSort from '../widgets/data-sort';
9
+ import { eventStopPropagation } from '../../utils';
10
+ import { CHART_SUMMARY_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, CHART_SUMMARY_TYPES, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
11
+ import intl from '../../intl';
12
+ const DataSettings = _ref => {
13
+ let {
14
+ chart,
15
+ tables,
16
+ xLabel,
17
+ yLabel,
18
+ onChange
19
+ } = _ref;
20
+ const onXAxisColumnChange = useCallback(option => {
21
+ const {
22
+ config
23
+ } = chart;
24
+ const {
25
+ x_axis_column_key
26
+ } = config;
27
+ const column = option.value;
28
+ const {
29
+ key: newXAxisColumnKey,
30
+ type
31
+ } = column;
32
+ const validValue = newXAxisColumnKey === 'Groupby_null' ? null : newXAxisColumnKey;
33
+ if (x_axis_column_key === validValue) return;
34
+ let update = {
35
+ x_axis_column_key: validValue
36
+ };
37
+ if (!validValue) {
38
+ update['x_axis_date_granularity'] = null;
39
+ update['x_axis_geolocation_granularity'] = null;
40
+ } else {
41
+ if (DATE_COLUMN_OPTIONS.includes(type)) {
42
+ update['x_axis_date_granularity'] = CHART_SUMMARY_TYPE.MONTH;
43
+ update['x_axis_geolocation_granularity'] = null;
44
+ } else if (type === CellType.GEOLOCATION) {
45
+ const {
46
+ geo_format
47
+ } = column.data || {};
48
+ if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE) {
49
+ update['x_axis_geolocation_granularity'] = GEOLOCATION_FORMAT_MAP.PROVINCE;
50
+ } else if (geo_format === GEOLOCATION_FORMAT_MAP.PROVINCE_CITY) {
51
+ update['x_axis_geolocation_granularity'] = GEOLOCATION_FORMAT_CITY;
52
+ } else if (geo_format === GEOLOCATION_FORMAT_MAP.GEOLOCATION || !geo_format) {
53
+ update['x_axis_geolocation_granularity'] = 'district';
54
+ } else {
55
+ update['x_axis_geolocation_granularity'] = null;
56
+ }
57
+ update['x_axis_date_granularity'] = null;
58
+ }
59
+ }
60
+ onChange && onChange(update);
61
+ }, [chart, onChange]);
62
+ const onGroupbyDateGranularityChange = useCallback(option => {
63
+ const {
64
+ config
65
+ } = chart;
66
+ const {
67
+ x_axis_date_granularity
68
+ } = config;
69
+ const value = option.value;
70
+ if (value === x_axis_date_granularity) return;
71
+ onChange && onChange({
72
+ x_axis_date_granularity: value
73
+ });
74
+ }, [chart, onChange]);
75
+ const onGroupbyGeolocationGranularityChange = useCallback(option => {
76
+ const {
77
+ config
78
+ } = chart;
79
+ const {
80
+ x_axis_geolocation_granularity
81
+ } = config;
82
+ const value = option.value;
83
+ if (value === x_axis_geolocation_granularity) return;
84
+ onChange && onChange({
85
+ x_axis_geolocation_granularity: value
86
+ });
87
+ }, [chart, onChange]);
88
+ const onIncludeEmptyChange = useCallback(event => {
89
+ eventStopPropagation(event);
90
+ const {
91
+ config
92
+ } = chart;
93
+ const {
94
+ x_axis_include_empty_cells
95
+ } = config;
96
+ onChange && onChange({
97
+ x_axis_include_empty_cells: !x_axis_include_empty_cells
98
+ });
99
+ }, [chart, onChange]);
100
+ const renderDataSort = useCallback(() => {
101
+ const {
102
+ config
103
+ } = chart;
104
+ if (!SUPPORT_DATA_SORT_CHART_TYPES.includes(config.type)) return null;
105
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, {
106
+ className: "mt-4"
107
+ }), /*#__PURE__*/React.createElement(DataSort, {
108
+ chart: chart,
109
+ onChange: onChange
110
+ }));
111
+ }, [chart, onChange]);
112
+ const {
113
+ config
114
+ } = chart;
115
+ const {
116
+ table_id,
117
+ x_axis_column_key,
118
+ x_axis_date_granularity,
119
+ x_axis_geolocation_granularity,
120
+ x_axis_include_empty_cells
121
+ } = config;
122
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CommonDataSettings, {
123
+ chart: chart,
124
+ tables: tables,
125
+ onChange: onChange
126
+ }), /*#__PURE__*/React.createElement(GroupBy, {
127
+ tables: tables,
128
+ className: "selected-x-axis",
129
+ label: intl.get(xLabel),
130
+ selectedTableId: table_id,
131
+ selectedColumnKey: x_axis_column_key,
132
+ selectedDateGranularity: x_axis_date_granularity,
133
+ selectedGeolocationGranularity: x_axis_geolocation_granularity,
134
+ onGroupByChange: onXAxisColumnChange,
135
+ onGroupbyDateGranularityChange: onGroupbyDateGranularityChange,
136
+ onGroupbyGeolocationGranularityChange: onGroupbyGeolocationGranularityChange
137
+ }), /*#__PURE__*/React.createElement(Switch, {
138
+ key: "x_axis_include_empty_cells",
139
+ checked: x_axis_include_empty_cells,
140
+ placeholder: intl.get('Include_empty'),
141
+ onChange: onIncludeEmptyChange
142
+ }), /*#__PURE__*/React.createElement(Divider, {
143
+ className: "mt-4"
144
+ }), /*#__PURE__*/React.createElement(BasicSummary, {
145
+ className: "selected-y-axis",
146
+ label: intl.get(yLabel),
147
+ summaryTypeKey: 'y_axis_summary_type',
148
+ summaryMethodKey: 'y_axis_summary_method',
149
+ summaryColumnKey: 'y_axis_summary_column_key',
150
+ chart: chart,
151
+ selectedTableId: table_id,
152
+ tables: tables,
153
+ supportColumnTypes: [CellType.NUMBER],
154
+ summaryTypeOptions: CHART_SUMMARY_TYPES,
155
+ onChange: onChange
156
+ }), renderDataSort());
157
+ };
158
+ DataSettings.defaultProps = {
159
+ xLabel: 'X_axis',
160
+ yLabel: 'Y_axis'
161
+ };
162
+ export default DataSettings;
@@ -0,0 +1,3 @@
1
+ import BarDataSettings from './data-settings';
2
+ import BarStyleSettings from './style-settings';
3
+ export { BarDataSettings, BarStyleSettings };