dtable-statistic 4.0.4 → 4.0.6

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 (74) hide show
  1. package/es/assets/icons/switch-icon.svg +17 -0
  2. package/es/calculator/workers/basic-chart-calculator-worker.js +1 -1
  3. package/es/components/dialog/chart-addition-edit-dialog.js +1 -0
  4. package/es/components/dialog/chart-addition-widgets/chart-selector.js +2 -1
  5. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +9 -0
  6. package/es/components/dialog/statistic-types-dialog/index.css +14 -0
  7. package/es/components/dialog/statistic-types-dialog/index.js +63 -0
  8. package/es/components/icon.js +12 -0
  9. package/es/constants/index.js +17 -6
  10. package/es/constants/model.js +20 -0
  11. package/es/dashboard.js +47 -9
  12. package/es/desktop-dashboard.js +3 -2
  13. package/es/locale/lang/de.js +3 -1
  14. package/es/locale/lang/en.js +3 -1
  15. package/es/locale/lang/fr.js +3 -1
  16. package/es/locale/lang/zh_CN.js +3 -1
  17. package/es/model/bar-group.js +60 -0
  18. package/es/model/bar.js +49 -0
  19. package/es/model/base-model.js +12 -0
  20. package/es/model/basic-number-card.js +27 -0
  21. package/es/model/combination.js +50 -0
  22. package/es/model/compare-bar.js +58 -0
  23. package/es/model/completeness-group.js +33 -0
  24. package/es/model/completeness.js +27 -0
  25. package/es/model/custom-bar.js +27 -0
  26. package/es/model/dashboard.js +22 -0
  27. package/es/model/generic-model.js +219 -0
  28. package/es/model/heat-map.js +35 -0
  29. package/es/model/horizontal-bar-group.js +55 -0
  30. package/es/model/horizontal-bar.js +49 -0
  31. package/es/model/index.js +26 -0
  32. package/es/model/map.js +37 -0
  33. package/es/model/mirror.js +35 -0
  34. package/es/model/pie.js +40 -0
  35. package/es/model/ring.js +41 -0
  36. package/es/model/scatter.js +24 -0
  37. package/es/model/table.js +34 -0
  38. package/es/model/trend.js +34 -0
  39. package/es/model/world-map.js +36 -0
  40. package/es/service/chart-service.js +47 -169
  41. package/es/service/dashboard-service.js +6 -5
  42. package/es/stat-editor/index.js +2 -0
  43. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +1 -0
  44. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +1 -0
  45. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +1 -0
  46. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +4 -3
  47. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +9 -10
  48. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +7 -31
  49. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +4 -3
  50. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +4 -3
  51. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +5 -29
  52. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +1 -0
  53. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -0
  54. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +1 -0
  55. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +1 -0
  56. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +1 -0
  57. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +1 -0
  58. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +10 -0
  59. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +1 -0
  60. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +1 -0
  61. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +1 -0
  62. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +1 -0
  63. package/es/stat-editor/stat-settings/public-setting/base-settings.js +22 -1
  64. package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +29 -0
  65. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +58 -0
  66. package/es/stat-view/pie-chart.js +2 -2
  67. package/es/stat-view/ring-chart.js +2 -2
  68. package/es/utils/column-utils.js +69 -2
  69. package/es/utils/common-utils.js +3 -0
  70. package/es/utils/model.js +13 -0
  71. package/es/utils/row-utils.js +1 -0
  72. package/es/utils/stat-utils.js +4 -0
  73. package/package.json +1 -1
  74. package/es/model/stat-item.js +0 -340
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">
5
+ <style type="text/css">
6
+ .st0{fill:#949494;}
7
+ </style>
8
+ <title>switch</title>
9
+ <g id="switch">
10
+ <g id="batch-replacement" transform="translate(1.000000, 3.000000)">
11
+ <path id="形状" class="st0" d="M9.1,11.7V8.9h12.8c1.4,0,2.5,1.2,3,2.3c0.4-0.6,0.7-1.8,0.7-2.7c0-2.1-1.7-4.5-3.8-4.5H9.1V0.7
12
+ c0-0.5-0.5-0.9-1-0.5L0.2,5.7c-0.3,0.2-0.3,0.8,0,1.1l7.8,5.6C8.6,12.6,9.1,12.3,9.1,11.7z M29.8,20.2l-7.8-5.6
13
+ c-0.4-0.3-1,0-1,0.5v3.2H8.1c-1.4,0-2.4-1.4-3.1-2.6c-0.4,0.6-0.8,2-0.8,2.9c0,2.1,1.7,4.3,3.8,4.3h12.8v3.2c0,0.5,0.5,0.9,1,0.5
14
+ l7.8-5.6C30.1,21,30.1,20.5,29.8,20.2L29.8,20.2z"/>
15
+ </g>
16
+ </g>
17
+ </svg>
@@ -179,7 +179,7 @@ function updateBasicChartRows(results, index, name, row, yAxisType) {
179
179
  }
180
180
  function groupChartRows(results, name, row, isColumnGroupbyColumnDataAsAnArray, groupName, include_empty, yAxisType) {
181
181
  if (isColumnGroupbyColumnDataAsAnArray) {
182
- if (groupName.length === 0) {
182
+ if (!groupName || groupName.length === 0) {
183
183
  updateGroupingChartRows(results, name, null, row, yAxisType);
184
184
  } else {
185
185
  groupName.forEach(function (v) {
@@ -76,6 +76,7 @@ var ChartAdditionEditDialog = /*#__PURE__*/function (_Component) {
76
76
  getTables: this.props.getTables,
77
77
  getViews: this.props.getViews,
78
78
  getTableById: getTableById,
79
+ getConvertedChart: this.props.getConvertedChart,
79
80
  modifyChartName: this.modifyChartName,
80
81
  modifyChart: this.modifyChart,
81
82
  toggleStatisticRecordsDialog: this.props.toggleStatisticRecordsDialog
@@ -209,6 +209,7 @@ var ChartSelector = /*#__PURE__*/function (_React$Component) {
209
209
  key: "render",
210
210
  value: function render() {
211
211
  var _this2 = this;
212
+ var selectedType = this.props.selectedType;
212
213
  var currentCatIndex = this.state.currentCatIndex;
213
214
  return /*#__PURE__*/React.createElement("div", {
214
215
  className: "".concat(styles['statistic-types-container'], " d-flex flex-column h-100")
@@ -242,7 +243,7 @@ var ChartSelector = /*#__PURE__*/function (_React$Component) {
242
243
  return /*#__PURE__*/React.createElement("div", {
243
244
  key: index,
244
245
  onClick: _this2.props.addEditingChart.bind(_this2, chart.type),
245
- className: "".concat(styles['statistic-type-item'], " ").concat(chart.hide ? 'd-none' : '')
246
+ className: "".concat(styles['statistic-type-item'], " ").concat(selectedType === chart.type ? styles['statistic-type-item-selected'] : '', " ").concat(chart.hide ? 'd-none' : '')
246
247
  }, /*#__PURE__*/React.createElement("p", {
247
248
  className: "".concat(styles['statistic-type-description'])
248
249
  }, chart.title), /*#__PURE__*/React.createElement("div", {
@@ -52,6 +52,15 @@
52
52
  margin: 20px 17px 0 0;
53
53
  }
54
54
 
55
+ .statistic-type-item:hover {
56
+ border-color: #FFBF7F;
57
+ }
58
+
59
+ .statistic-type-item-selected,
60
+ .statistic-type-item-selected:hover {
61
+ border-color: #FF8000;
62
+ }
63
+
55
64
  .statistic-type-description {
56
65
  font-weight: 500;
57
66
  font-size: 14px;
@@ -0,0 +1,14 @@
1
+ .statistic-types-dialog {
2
+ max-width: 1102px;
3
+ width: 1102px;
4
+ height: calc(100% - 56px);
5
+ }
6
+
7
+ .statistic-types-dialog .modal-content {
8
+ height: 100%;
9
+ }
10
+
11
+ .statistic-types-dialog .statistic-types-body {
12
+ padding: 0;
13
+ overflow: hidden;
14
+ }
@@ -0,0 +1,63 @@
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 intl from 'react-intl-universal';
7
+ import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
8
+ import ChartSelector from '../chart-addition-widgets/chart-selector';
9
+ import './index.css';
10
+ var StatisticTypesDialog = /*#__PURE__*/function (_Component) {
11
+ _inherits(StatisticTypesDialog, _Component);
12
+ var _super = _createSuper(StatisticTypesDialog);
13
+ function StatisticTypesDialog(props) {
14
+ var _this;
15
+ _classCallCheck(this, StatisticTypesDialog);
16
+ _this = _super.call(this, props);
17
+ _this.onToggle = function () {
18
+ _this.props.onToggle();
19
+ };
20
+ _this.onSelectStatisticType = function (type) {
21
+ if (type === _this.state.selectedType) return;
22
+ _this.setState({
23
+ selectedType: type
24
+ });
25
+ };
26
+ _this.onSubmit = function () {
27
+ var selectedType = _this.state.selectedType;
28
+ _this.props.onChange(selectedType);
29
+ _this.onToggle();
30
+ };
31
+ _this.state = {
32
+ selectedType: props.type
33
+ };
34
+ return _this;
35
+ }
36
+ _createClass(StatisticTypesDialog, [{
37
+ key: "render",
38
+ value: function render() {
39
+ var selectedType = this.state.selectedType;
40
+ return /*#__PURE__*/React.createElement(Modal, {
41
+ isOpen: true,
42
+ toggle: this.onToggle,
43
+ className: "statistic-types-dialog",
44
+ zIndex: 1048
45
+ }, /*#__PURE__*/React.createElement(ModalHeader, {
46
+ toggle: this.onToggle
47
+ }, intl.get('Edit_type')), /*#__PURE__*/React.createElement(ModalBody, {
48
+ className: "statistic-types-body"
49
+ }, /*#__PURE__*/React.createElement(ChartSelector, {
50
+ selectedType: selectedType,
51
+ addEditingChart: this.onSelectStatisticType
52
+ })), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
53
+ color: "secondary",
54
+ onClick: this.onToggle
55
+ }, intl.get('Cancel')), /*#__PURE__*/React.createElement(Button, {
56
+ color: "primary",
57
+ onClick: this.onSubmit
58
+ }, intl.get('Submit'))));
59
+ }
60
+ }]);
61
+ return StatisticTypesDialog;
62
+ }(Component);
63
+ export default StatisticTypesDialog;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ function Icon(props) {
3
+ var className = props.className,
4
+ symbol = props.symbol;
5
+ var iconClass = "multicolor-icon multicolor-icon-".concat(symbol, " ").concat(className || '');
6
+ return /*#__PURE__*/React.createElement("svg", {
7
+ className: iconClass
8
+ }, /*#__PURE__*/React.createElement("use", {
9
+ xlinkHref: "#".concat(symbol)
10
+ }));
11
+ }
12
+ export default Icon;
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- var _INIT_STAT_ITEM, _MULTIPLE_CELL_VALUE_, _DATA_SORT_TYPE_LABEL, _TYPE_DISPLAY_COLOR_U;
2
+ var _INIT_STAT_ITEM, _MULTIPLE_CELL_VALUE_, _DATA_SORT_TYPE_LABEL, _TYPE_DISPLAY_COLOR_U, _STATISTIC_TYPE_SHOW;
3
3
  import { CellType } from 'dtable-store';
4
4
  import KeyCodes from './key-codes';
5
5
  import { MenuSelectStyle, UserSelectStyle } from './dtable-select-style';
@@ -92,7 +92,8 @@ export var SUMMARY_METHOD_MAP = {
92
92
  Max: 'Max',
93
93
  Min: 'Min',
94
94
  Mean: 'Mean',
95
- Distinct_values: 'Distinct_values'
95
+ Distinct_values: 'Distinct_values',
96
+ Row_count: 'Row_count'
96
97
  };
97
98
  export var SUMMARY_METHOD = [SUMMARY_METHOD_MAP.Sum, SUMMARY_METHOD_MAP.Max, SUMMARY_METHOD_MAP.Min, SUMMARY_METHOD_MAP.Mean, SUMMARY_METHOD_MAP.Distinct_values];
98
99
  export var MONTH_MIRROR = {
@@ -117,6 +118,7 @@ export var GEOLOCATION_GRANULARITY = {
117
118
  CITY: 'city',
118
119
  DISTRICT: 'district'
119
120
  };
121
+ export var GEOLOCATION_GRANULARITY_LIST = [GEOLOCATION_GRANULARITY.PROVINCE, GEOLOCATION_GRANULARITY.CITY, GEOLOCATION_GRANULARITY.DISTRICT];
120
122
  export var DATE_GRANULARITY = {
121
123
  DAY: 'day',
122
124
  WEEK: 'week',
@@ -124,6 +126,7 @@ export var DATE_GRANULARITY = {
124
126
  QUARTER: 'quarter',
125
127
  YEAR: 'year'
126
128
  };
129
+ export var DATE_GRANULARITY_LIST = [DATE_GRANULARITY.DAY, DATE_GRANULARITY.WEEK, DATE_GRANULARITY.MONTH, DATE_GRANULARITY.QUARTER, DATE_GRANULARITY.YEAR];
127
130
  export var LABEL_COLORS = ['#2a67d1', '#4ecccb', '#59cb74', '#fbd44a', '#f4667c', '#9860e5', '#9f8cf1', '#dc82d2', '#eaa775', '#addf84', '#85e0be', '#89d2ea'];
128
131
  export var GROUPBY_TYPE = {
129
132
  ROW: 'row',
@@ -248,7 +251,7 @@ export var INIT_STAT_ITEM = (_INIT_STAT_ITEM = {}, _defineProperty(_INIT_STAT_IT
248
251
  show_y_axis_label: false
249
252
  }), _defineProperty(_INIT_STAT_ITEM, STAT_TYPE.BASIC_NUMBER_CARD, {
250
253
  numeric_column: null,
251
- summary_method: 'Row_count'
254
+ summary_method: SUMMARY_METHOD_MAP.Row_count
252
255
  }), _defineProperty(_INIT_STAT_ITEM, STAT_TYPE.COMBINATION_CHART, {
253
256
  x_axis_column_key: null,
254
257
  x_axis_geolocation_granularity: null,
@@ -283,9 +286,9 @@ export var INIT_STAT_ITEM = (_INIT_STAT_ITEM = {}, _defineProperty(_INIT_STAT_IT
283
286
  target_column: null
284
287
  }), _defineProperty(_INIT_STAT_ITEM, STAT_TYPE.DASHBOARD, {
285
288
  target_value_column: null,
286
- target_value_column_summary_method: 'Row_count',
289
+ target_value_column_summary_method: SUMMARY_METHOD_MAP.Row_count,
287
290
  total_value_column: null,
288
- total_value_column_summary_method: 'Row_count'
291
+ total_value_column_summary_method: SUMMARY_METHOD_MAP.Row_count
289
292
  }), _defineProperty(_INIT_STAT_ITEM, STAT_TYPE.GROUP_COMPLETENESS_CHART, {
290
293
  completed_column: null,
291
294
  target_column: null,
@@ -466,6 +469,13 @@ export var LABEL_FORMATS_MAP = {
466
469
  Percent: 'Percent',
467
470
  Value_percent: 'Numeric_value_and_percent'
468
471
  };
472
+ export var LABEL_POSITION = {
473
+ TOP: 'top',
474
+ RIGHT: 'right',
475
+ BOTTOM: 'bottom',
476
+ LEFT: 'left',
477
+ CENTER: 'center'
478
+ };
469
479
 
470
480
  // label positions for pie, ring charts
471
481
  export var LABEL_POSITIONS = ['inside', 'outside'];
@@ -498,4 +508,5 @@ export var DEFAULT_GRID_DISTANCE = 4;
498
508
  export var LEGEND_DIRECTION_MAP = {
499
509
  VERTICAL: 'vertical'
500
510
  };
501
- export var Y_AXIS_TYPE_PREFIX = '__y_axis__';
511
+ export var Y_AXIS_TYPE_PREFIX = '__y_axis__';
512
+ export var STATISTIC_TYPE_SHOW = (_STATISTIC_TYPE_SHOW = {}, _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BAR, 'Basic_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BAR_GROUP, 'Grouped_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BAR_STACK, 'Stacked_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.COMPARE_BAR, 'Time_comparison_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.CUSTOM_BAR, 'Custom_histogram'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.HORIZONTAL_BAR, 'Basic_bar_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.HORIZONTAL_GROUP_BAR, 'Grouped_bar_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.STACKED_HORIZONTAL_BAR, 'Stacked_bar_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.COMPLETENESS_CHART, 'Completeness_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.GROUP_COMPLETENESS_CHART, 'Grouped_completeness_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.LINE, 'Basic_line_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.GROUP_LINE, 'Grouped_line_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.AREA_CHART, 'Area_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.AREA_GROUP_CHART, 'Grouped_area_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.PIE, 'Basic_pie_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.RING, 'Ring_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.SCATTER, 'Scatter_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.COMBINATION_CHART, 'Combination_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.MAP, '中国地图'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.MAP_BUBBLE, '中国地图(气泡图)'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.WORLD_MAP, 'World_map'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.WORLD_MAP_BUBBLE, 'World_map_bubble'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.HEAT_MAP, 'Heat_map'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.MIRROR, 'Mirror_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.BASIC_NUMBER_CARD, 'Basic_number_card'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.TREND_CHART, 'Trend_chart'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.DASHBOARD, 'Gauge'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.TREEMAP, 'Treemap'), _defineProperty(_STATISTIC_TYPE_SHOW, STAT_TYPE.PIVOT_TABLE, 'Pivot_table'), _STATISTIC_TYPE_SHOW);
@@ -0,0 +1,20 @@
1
+ export var X_GROUPBY_KEYS = ['x_axis_column_key', 'groupby_column_key', 'vertical_axis_column_key', 'date_column', 'time_column', 'column', 'geo_column', 'x_axis_column', 'numeric_column', 'name_column'];
2
+ export var X_GEO_GRANULARITY_KEYS = ['x_axis_geolocation_granularity', 'groupby_geolocation_granularity', 'vertical_geolocation_granularity', 'geolocation_granularity'];
3
+ export var X_DATE_GRANULARITY_KEYS = ['x_axis_date_granularity', 'groupby_date_granularity', 'vertical_date_granularity', 'date_granularity'];
4
+ export var X_INCLUDE_EMPTY_KEYS = ['x_axis_include_empty', 'groupby_include_empty_cells', 'vertical_axis_include_empty'];
5
+ export var X_SHOW_AXIS_LABEL = ['show_x_axis_label', 'show_vertical_axis_label'];
6
+ export var X_LABEL_POSITION_KEYS = ['x_axis_label_position', 'vertical_axis_label_position'];
7
+ export var Y_SUMMARY_BY_KEYS = ['y_axis_column_key', 'y_axis_column', 'y_axis_summary_column', 'summary_column_key', 'horizontal_axis_column_key'];
8
+ export var Y_SUMMARY_METHOD_KEYS = ['y_axis_summary_method', 'horizontal_axis_summary_method', 'summary_method'];
9
+ export var Y_SUMMARY_TYPE_KEYS = ['y_axis_summary_type', 'horizontal_axis_summary_type', 'summary_type'];
10
+ export var Y_LABEL_COLOR_KEYS = ['y_axis_label_color', 'horizontal_axis_label_color'];
11
+ export var Y_LABEL_COLOR_RULES_KEYS = ['y_axis_label_color_rules', 'horizontal_axis_label_color_rules'];
12
+ export var Y_SHOW_AXIS_LABEL_KEYS = ['show_y_axis_label', 'show_horizontal_axis_label'];
13
+ export var Y_LABEL_POSITION_KEYS = ['y_axis_label_position', 'horizontal_axis_label_position'];
14
+ export var Y_AUTO_RANGE_KEYS = ['y_axis_auto_range', 'h_axis_auto_range'];
15
+ export var Y_AUTO_RANGE_MIN_KEYS = ['y_axis_min', 'h_axis_min'];
16
+ export var Y_AUTO_RANGE_MAX_KEYS = ['y_axis_max', 'h_axis_max'];
17
+ export var COLUMN_GROUPBY_KEYS = ['column_groupby_column_key', 'group_column'];
18
+ export var COLUMN_DATE_GRANULARITY_KEYS = ['column_groupby_date_granularity', 'date_granularity'];
19
+ export var COLUMN_GEO_GRANULARITY_KEYS = ['column_groupby_geolocation_granularity', 'geolocation_granularity'];
20
+ export var LABEL_FRONT_SIZE_KEYS = ['label_font_size', 'annotation_font_size'];
package/es/dashboard.js CHANGED
@@ -8,8 +8,8 @@ import React, { Component } from 'react';
8
8
  import intl from 'react-intl-universal';
9
9
  import { TableUtils, Views } from 'dtable-store';
10
10
  import StatisticDashBoard from './model/statistic-dashboard';
11
- import StatItem from './model/stat-item';
12
11
  import DashBoardService from './service/dashboard-service';
12
+ import ChartService from './service/chart-service';
13
13
  import DesktopDashboard from './desktop-dashboard';
14
14
  import MobileDashboard from './mobile-dashboard';
15
15
  import ThreadManager from './calculator/thread-manager';
@@ -28,6 +28,17 @@ var DashBoard = /*#__PURE__*/function (_Component) {
28
28
  var _this;
29
29
  _classCallCheck(this, DashBoard);
30
30
  _this = _super.call(this, props);
31
+ _this.loadSvg = function () {
32
+ var importAll = function importAll(requireContext) {
33
+ requireContext.keys().forEach(requireContext);
34
+ };
35
+ try {
36
+ importAll(require.context('./assets/icons', true, /\.svg$/));
37
+ } catch (error) {
38
+ // eslint-disable-next-line no-console
39
+ console.log(error);
40
+ }
41
+ };
31
42
  _this.onDTableDataChange = function (value) {
32
43
  _this.clearCalculations();
33
44
  var _this$initDashboard = _this.initDashboard({
@@ -62,6 +73,7 @@ var DashBoard = /*#__PURE__*/function (_Component) {
62
73
  value: value,
63
74
  defaultDashboardName: _this.defaultDashboardName,
64
75
  chartCalculator: _this.chartCalculator,
76
+ chartService: _this.chartService,
65
77
  updateStatistics: _this.props.updateStatistics,
66
78
  deletePluginSettings: _this.props.deletePluginSettings
67
79
  });
@@ -126,6 +138,28 @@ var DashBoard = /*#__PURE__*/function (_Component) {
126
138
  if (!activeViewId) return selectedTable.views[0];
127
139
  return Views.getViewById(selectedTable.views, activeViewId);
128
140
  };
141
+ _this.getInitChart = function (_ref2) {
142
+ var chartType = _ref2.chartType,
143
+ dashboard = _ref2.dashboard,
144
+ activeTable = _ref2.activeTable,
145
+ activeView = _ref2.activeView;
146
+ return _this.chartService.getInitChart({
147
+ type: chartType,
148
+ dashboard: dashboard,
149
+ activeTable: activeTable,
150
+ activeView: activeView
151
+ });
152
+ };
153
+ _this.getConvertedChart = function (_ref3) {
154
+ var originalStatistic = _ref3.originalStatistic,
155
+ targetStatisticType = _ref3.targetStatisticType,
156
+ activeTable = _ref3.activeTable;
157
+ return _this.chartService.getConvertedChart({
158
+ originalStatistic: originalStatistic,
159
+ targetStatisticType: targetStatisticType,
160
+ activeTable: activeTable
161
+ });
162
+ };
129
163
  _this.selectDashboard = function (selectedDashboardIdx) {
130
164
  _this.isInitDashboard = true;
131
165
  _this.setSelectedDashboardIdx(selectedDashboardIdx);
@@ -244,14 +278,11 @@ var DashBoard = /*#__PURE__*/function (_Component) {
244
278
  var fromChart = dashboard && dashboard.stat_items.find(function (chart) {
245
279
  return chart._id === chartId;
246
280
  });
247
- if (!fromChart) {
248
- return;
249
- }
250
- var newChartId = generatorUniqueId(dashboard.stat_items);
251
- var newChart = new StatItem(Object.assign({}, fromChart, {
252
- _id: newChartId,
253
- name: fromChart.name + '(copy)'
254
- }));
281
+ if (!fromChart) return;
282
+ var newChart = _this.chartService.getCopiedChart({
283
+ dashboard: dashboard,
284
+ originalStatItem: fromChart
285
+ });
255
286
  _this.addChart(newChart);
256
287
  };
257
288
  _this.deleteChart = function (chartId) {
@@ -320,7 +351,11 @@ var DashBoard = /*#__PURE__*/function (_Component) {
320
351
  return permission === 'r' || permission.slice(0, 2) === 'c-';
321
352
  };
322
353
  var _value = props.value;
354
+ var defaultChartTitle = intl.get('Untitled');
323
355
  _this.defaultDashboardName = intl.get('Default_dashboard');
356
+ _this.chartService = new ChartService({
357
+ defaultChartTitle: defaultChartTitle
358
+ });
324
359
  _this.statisticThreadManager = new ThreadManager((navigator.hardwareConcurrency || 4) - 1);
325
360
  var _this$initDashboard2 = _this.initDashboard({
326
361
  value: _value
@@ -333,6 +368,7 @@ var DashBoard = /*#__PURE__*/function (_Component) {
333
368
  refresh: false
334
369
  };
335
370
  _this.isInitDashboard = true;
371
+ _this.loadSvg();
336
372
  return _this;
337
373
  }
338
374
  _createClass(DashBoard, [{
@@ -395,6 +431,8 @@ var DashBoard = /*#__PURE__*/function (_Component) {
395
431
  getTableById: this.getTableById,
396
432
  getTables: this.getTables,
397
433
  getViews: this.getViews,
434
+ getInitChart: this.getInitChart,
435
+ getConvertedChart: this.getConvertedChart,
398
436
  copyChart: this.copyChart,
399
437
  deleteChart: this.deleteChart,
400
438
  modifyDashboardLayout: this.modifyDashboardLayout,
@@ -142,8 +142,8 @@ var DesktopDashboard = /*#__PURE__*/function (_Component) {
142
142
  var dashboard = statistics[selectedDashboardIdx];
143
143
  var activeTable = _this.props.getActiveTable();
144
144
  var activeView = _this.props.getActiveView();
145
- return _this.charService.generateChart({
146
- type: chartType,
145
+ return _this.props.getInitChart({
146
+ chartType: chartType,
147
147
  dashboard: dashboard,
148
148
  activeTable: activeTable,
149
149
  activeView: activeView
@@ -277,6 +277,7 @@ var DesktopDashboard = /*#__PURE__*/function (_Component) {
277
277
  getTableById: this.props.getTableById,
278
278
  generateChart: this.generateChart,
279
279
  hideChartAdditionDialog: this.onToggleChartAddition,
280
+ getConvertedChart: this.props.getConvertedChart,
280
281
  addChart: this.props.addChart,
281
282
  modifyChart: this.props.modifyChart,
282
283
  toggleStatisticRecordsDialog: this.toggleStatisticRecordsDialog
@@ -232,6 +232,8 @@ var de = {
232
232
  'Display_total': 'Gesamtwert anzeigen',
233
233
  'Line_color': 'Linienfarbe',
234
234
  'Stack': 'Stapel',
235
- 'Add_new_stack': 'Neuen Stapel hinzufügen'
235
+ 'Add_new_stack': 'Neuen Stapel hinzufügen',
236
+ 'Chart_type': 'Chart type',
237
+ 'Edit_type': 'Edit type'
236
238
  };
237
239
  export default de;
@@ -232,6 +232,8 @@ var en = {
232
232
  'Display_total': 'Display total',
233
233
  'Line_color': 'Line color',
234
234
  'Stack': 'Stack',
235
- 'Add_new_stack': 'Add new stack'
235
+ 'Add_new_stack': 'Add new stack',
236
+ 'Chart_type': 'Chart type',
237
+ 'Edit_type': 'Edit type'
236
238
  };
237
239
  export default en;
@@ -232,6 +232,8 @@ var fr = {
232
232
  'Display_total': 'Afficher le total',
233
233
  'Line_color': 'Couleur de courbe',
234
234
  'Stack': 'Pile',
235
- 'Add_new_stack': 'Ajouter une nouvelle pile'
235
+ 'Add_new_stack': 'Ajouter une nouvelle pile',
236
+ 'Chart_type': 'Chart type',
237
+ 'Edit_type': 'Edit type'
236
238
  };
237
239
  export default fr;
@@ -232,6 +232,8 @@ var zh_CN = {
232
232
  'Display_total': '显示总计',
233
233
  'Line_color': '线条颜色',
234
234
  'Stack': '堆叠',
235
- 'Add_new_stack': '添加新的堆叠'
235
+ 'Add_new_stack': '添加新的堆叠',
236
+ 'Chart_type': '图表类型',
237
+ 'Edit_type': '编辑类型'
236
238
  };
237
239
  export default zh_CN;
@@ -0,0 +1,60 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import BaseModel from './base-model';
5
+ import { isBoolean } from '../utils/common-utils';
6
+ import { STAT_TYPE, SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../constants';
7
+ var BarGroup = /*#__PURE__*/function (_BaseModel) {
8
+ _inherits(BarGroup, _BaseModel);
9
+ var _super = _createSuper(BarGroup);
10
+ function BarGroup(object) {
11
+ var _this;
12
+ _classCallCheck(this, BarGroup);
13
+ _this = _super.call(this, object);
14
+
15
+ // x data
16
+ _this.x_axis_column_key = object.x_axis_column_key;
17
+ _this.x_axis_date_granularity = object.x_axis_date_granularity;
18
+ _this.x_axis_geolocation_granularity = object.x_axis_geolocation_granularity;
19
+ _this.x_axis_include_empty = object.x_axis_include_empty;
20
+
21
+ // x style
22
+ _this.show_x_axis_label = isBoolean(object.show_x_axis_label) ? object.show_x_axis_label : false;
23
+ _this.x_axis_label_position = object.x_axis_label_position;
24
+
25
+ // y data
26
+ _this.y_axis_summary_type = object.y_axis_summary_type || SUMMARY_TYPE.COUNT;
27
+ _this.y_axis_column_key = object.y_axis_column_key;
28
+ _this.y_axis_summary_method = object.y_axis_summary_method;
29
+ if (_this.y_axis_summary_method === SUMMARY_METHOD_MAP.Row_count) {
30
+ _this.y_axis_summary_method = SUMMARY_METHOD_MAP.Max;
31
+ }
32
+
33
+ // y style
34
+ _this.y_axis_label_position = isBoolean(object.y_axis_label_position) ? object.y_axis_label_position : false;
35
+ _this.show_y_axis_label = object.show_y_axis_label;
36
+ _this.y_axis_label_color = object.y_axis_label_color;
37
+ _this.y_axis_use_stack = object.y_axis_use_stack;
38
+ if (_this.type === STAT_TYPE.BAR_STACK) {
39
+ _this.y_axis_use_stack = true;
40
+ }
41
+ _this.y_axis_auto_range = object.y_axis_auto_range;
42
+ _this.y_axis_max = object.y_axis_max;
43
+ _this.y_axis_min = object.y_axis_min;
44
+
45
+ // group
46
+ _this.column_groupby_column_key = object.column_groupby_column_key;
47
+ _this.column_groupby_date_granularity = object.column_groupby_date_granularity;
48
+ _this.column_groupby_geolocation_granularity = object.column_groupby_geolocation_granularity;
49
+ _this.column_groupby_multiple_numeric_column = object.column_groupby_multiple_numeric_column;
50
+ _this.column_groupby_numeric_columns = object.column_groupby_numeric_columns;
51
+ _this.display_each_block_data = object.display_each_block_data;
52
+ _this.title_name = object.title_name;
53
+ _this.label_font_size = object.label_font_size;
54
+ _this.display_data = object.display_data;
55
+ _this.sort_type = object.sort_type;
56
+ return _this;
57
+ }
58
+ return BarGroup;
59
+ }(BaseModel);
60
+ export { BarGroup as default };
@@ -0,0 +1,49 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import BaseModel from './base-model';
5
+ import { isBoolean } from '../utils/common-utils';
6
+ import { SUMMARY_METHOD_MAP, SUMMARY_TYPE } from '../constants';
7
+ var Bar = /*#__PURE__*/function (_BaseModel) {
8
+ _inherits(Bar, _BaseModel);
9
+ var _super = _createSuper(Bar);
10
+ function Bar(object) {
11
+ var _this;
12
+ _classCallCheck(this, Bar);
13
+ _this = _super.call(this, object);
14
+
15
+ // x data
16
+ _this.x_axis_column_key = object.x_axis_column_key;
17
+ _this.x_axis_date_granularity = object.x_axis_date_granularity;
18
+ _this.x_axis_geolocation_granularity = object.x_axis_geolocation_granularity;
19
+ _this.x_axis_include_empty = object.x_axis_include_empty;
20
+
21
+ // x style
22
+ _this.show_x_axis_label = isBoolean(object.show_x_axis_label) ? object.show_x_axis_label : false;
23
+ _this.x_axis_label_position = object.x_axis_label_position;
24
+
25
+ // y data
26
+ _this.y_axis_summary_type = object.y_axis_summary_type || SUMMARY_TYPE.COUNT;
27
+ _this.y_axis_column_key = object.y_axis_column_key;
28
+ _this.y_axis_summary_method = object.y_axis_summary_method;
29
+ if (_this.y_axis_summary_method === SUMMARY_METHOD_MAP.Row_count) {
30
+ _this.y_axis_summary_method = SUMMARY_METHOD_MAP.Max;
31
+ }
32
+
33
+ // y style
34
+ _this.color_option = object.color_option;
35
+ _this.y_axis_label_color = object.y_axis_label_color;
36
+ _this.y_axis_label_color_rules = object.y_axis_label_color_rules;
37
+ _this.show_y_axis_label = isBoolean(object.show_y_axis_label) ? object.show_y_axis_label : false;
38
+ _this.y_axis_label_position = object.y_axis_label_position;
39
+ _this.y_axis_auto_range = object.y_axis_auto_range;
40
+ _this.y_axis_min = object.y_axis_min;
41
+ _this.y_axis_max = object.y_axis_max;
42
+ _this.sort_type = object.sort_type;
43
+ _this.label_font_size = object.label_font_size;
44
+ _this.display_data = object.display_data;
45
+ return _this;
46
+ }
47
+ return Bar;
48
+ }(BaseModel);
49
+ export { Bar as default };
@@ -0,0 +1,12 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ var BaseModel = function BaseModel(object) {
3
+ _classCallCheck(this, BaseModel);
4
+ this._id = object._id || null;
5
+ this.name = object.name || null;
6
+ this.type = object.type || null;
7
+ this.table_id = object.table_id || null;
8
+ this.view_id = object.view_id || null;
9
+ this.layout = object.layout;
10
+ this.chart_color_theme = object.chart_color_theme || 'theme0';
11
+ };
12
+ export { BaseModel as default };
@@ -0,0 +1,27 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import { isNumericColumn, TableUtils } from 'dtable-store';
5
+ import BaseModel from './base-model';
6
+ import { SUMMARY_METHOD_MAP } from '../constants';
7
+ var BasicNumberCard = /*#__PURE__*/function (_BaseModel) {
8
+ _inherits(BasicNumberCard, _BaseModel);
9
+ var _super = _createSuper(BasicNumberCard);
10
+ function BasicNumberCard(object, table) {
11
+ var _this;
12
+ _classCallCheck(this, BasicNumberCard);
13
+ _this = _super.call(this, object);
14
+ _this.name = null;
15
+ _this.numeric_column = object.x_axis_column_key;
16
+ if (_this.numeric_column) {
17
+ var column = TableUtils.getTableColumnByKey(table, _this.numeric_column);
18
+ if (!isNumericColumn(column)) {
19
+ _this.numeric_column = null;
20
+ }
21
+ }
22
+ _this.summary_method = object.y_axis_summary_method || SUMMARY_METHOD_MAP.Row_count;
23
+ return _this;
24
+ }
25
+ return BasicNumberCard;
26
+ }(BaseModel);
27
+ export { BasicNumberCard as default };
@@ -0,0 +1,50 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
3
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
4
+ import BaseModel from './base-model';
5
+ import { isBoolean } from '../utils/common-utils';
6
+ import { LABEL_COLORS, STATISTICS_COUNT_TYPE } from '../constants';
7
+ var Combination = /*#__PURE__*/function (_BaseModel) {
8
+ _inherits(Combination, _BaseModel);
9
+ var _super = _createSuper(Combination);
10
+ function Combination(object) {
11
+ var _this;
12
+ _classCallCheck(this, Combination);
13
+ _this = _super.call(this, object);
14
+
15
+ // x data
16
+ _this.x_axis_column_key = object.x_axis_column_key;
17
+ _this.x_axis_geolocation_granularity = object.x_axis_geolocation_granularity;
18
+ _this.x_axis_date_granularity = object.x_axis_date_granularity;
19
+ _this.x_axis_include_empty = object.x_axis_include_empty;
20
+
21
+ // y left/right data/style
22
+ _this.y_axis_left_summary_type = object.y_axis_left_summary_type || STATISTICS_COUNT_TYPE.COUNT;
23
+ _this.y_axis_right_summary_type = object.y_axis_right_summary_type || STATISTICS_COUNT_TYPE.COUNT;
24
+ _this.y_axis_left_summary_method = object.y_axis_left_summary_method;
25
+ _this.y_axis_right_summary_method = object.y_axis_right_summary_method;
26
+ _this.y_axis_left_summary_column = object.y_axis_left__summary_column;
27
+ _this.y_axis_right_summary_column = object.y_axis_right_summary_column;
28
+ _this.y_axis_left_group_by_multiple_numeric_column = isBoolean(object.y_axis_left_group_by_multiple_numeric_column) ? object.y_axis_left_group_by_multiple_numeric_column : false;
29
+ _this.y_axis_left_group_by_numeric_columns = object.y_axis_left_group_by_numeric_columns;
30
+ _this.y_axis_left_color = object.y_axis_left_color || LABEL_COLORS[0];
31
+ _this.y_axis_right_color = object.y_axis_right_color || LABEL_COLORS[1];
32
+ _this.show_x_axis_label = object.show_x_axis_label;
33
+ _this.x_axis_label_position = object.x_axis_label_position;
34
+ _this.show_y_axis_left_label = isBoolean(object.show_y_axis_left_label) ? object.show_y_axis_left_label : false;
35
+ _this.show_y_axis_right_label = isBoolean(object.show_y_axis_right_label) ? object.show_y_axis_right_label : false;
36
+ _this.y_axis_left_label_position = object.y_axis_left_label_position;
37
+ _this.y_axis_right_label_position = object.y_axis_right_label_position;
38
+ _this.y_axis_auto_range_left = object.y_axis_auto_range_left;
39
+ _this.y_axis_min_left = object.y_axis_min_left;
40
+ _this.y_axis_max_left = object.y_axis_max_left;
41
+ _this.y_axis_auto_range_right = object.y_axis_auto_range_right;
42
+ _this.y_axis_min_right = object.y_axis_min_right;
43
+ _this.y_axis_max_right = object.y_axis_max_right;
44
+ _this.display_data = object.display_data;
45
+ _this.label_font_size = object.label_font_size;
46
+ return _this;
47
+ }
48
+ return Combination;
49
+ }(BaseModel);
50
+ export { Combination as default };