dtable-statistic 4.0.7 → 4.0.8

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 (60) hide show
  1. package/es/calculator/basic-chart-calculator.js +27 -18
  2. package/es/calculator/combination-calculator.js +34 -9
  3. package/es/calculator/compare-bar-calculator.js +37 -30
  4. package/es/calculator/heat-map-calculator.js +25 -14
  5. package/es/calculator/map-calculator.js +25 -14
  6. package/es/calculator/mirror-calculator.js +29 -14
  7. package/es/calculator/pivot-table-calculator.js +78 -51
  8. package/es/calculator/workers/basic-chart-calculator-worker.js +21 -6
  9. package/es/calculator/workers/combination-calculator-worker.js +20 -5
  10. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -6
  11. package/es/calculator/workers/mirror-calculator-worker.js +15 -6
  12. package/es/calculator/workers/pivot-table-calculator-worker.js +87 -41
  13. package/es/calculator/world-map-calculator.js +25 -14
  14. package/es/components/dialog/enlarged-chart-dialog.js +2 -2
  15. package/es/components/dialog/statistic-record-dialog/index.js +71 -41
  16. package/es/constants/index.js +30 -29
  17. package/es/dashboard.js +57 -43
  18. package/es/desktop-dashboard.js +16 -51
  19. package/es/index.js +34 -2
  20. package/es/locale/lang/de.js +2 -0
  21. package/es/locale/lang/en.js +2 -0
  22. package/es/locale/lang/fr.js +2 -0
  23. package/es/locale/lang/zh_CN.js +2 -0
  24. package/es/mobile-dashboard.js +5 -5
  25. package/es/model/horizontal-bar-group.js +2 -0
  26. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +1 -2
  27. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  28. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +20 -3
  29. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +2 -8
  30. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +23 -2
  31. package/es/stat-list/chart-preview.js +3 -4
  32. package/es/stat-list/index.js +10 -4
  33. package/es/stat-view/area-chart.js +177 -162
  34. package/es/stat-view/bar-chart.js +221 -222
  35. package/es/stat-view/base-chart.js +79 -7
  36. package/es/stat-view/basic-number-card.js +11 -19
  37. package/es/stat-view/combination-chart.js +100 -83
  38. package/es/stat-view/compare-chart.js +133 -144
  39. package/es/stat-view/completeness-chart.js +108 -102
  40. package/es/stat-view/custom-bar.js +79 -99
  41. package/es/stat-view/dashboard-chart.js +57 -57
  42. package/es/stat-view/heat-map.js +13 -32
  43. package/es/stat-view/horizontal-bar-chart.js +200 -230
  44. package/es/stat-view/index.js +2 -2
  45. package/es/stat-view/line-chart.js +162 -158
  46. package/es/stat-view/map.js +26 -40
  47. package/es/stat-view/mirror.js +88 -94
  48. package/es/stat-view/pie-chart.js +11 -39
  49. package/es/stat-view/pivot-table/index.js +4 -16
  50. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +22 -15
  51. package/es/stat-view/ring-chart.js +24 -42
  52. package/es/stat-view/scatter-chart.js +4 -21
  53. package/es/stat-view/treemap-chart.js +3 -12
  54. package/es/stat-view/trend-chart.js +6 -17
  55. package/es/stat-view/world-map.js +39 -50
  56. package/es/tabs/tab.js +2 -1
  57. package/es/utils/common-utils.js +24 -6
  58. package/es/utils/sql-utils.js +10 -9
  59. package/es/utils/stat-utils.js +8 -5
  60. package/package.json +1 -1
@@ -8,13 +8,9 @@ import React from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import BaseChart from './base-chart';
10
10
  import { Chart, registerShape } from '../custom-g2';
11
- import { Loading } from '../components';
12
11
  import { isMobile } from '../utils';
13
- import { STAT_ITEM_THEME_COLORS } from '../constants';
14
12
  var propTypes = {
15
13
  isPreview: PropTypes.bool,
16
- isEnlarge: PropTypes.bool,
17
- theme: PropTypes.string,
18
14
  statItem: PropTypes.object,
19
15
  chartCalculator: PropTypes.object
20
16
  };
@@ -136,26 +132,52 @@ var DashboardChart = /*#__PURE__*/function (_BaseChart) {
136
132
  };
137
133
  };
138
134
  _this.drawChart = function (value) {
139
- var _this$props3 = _this.props,
140
- isPreview = _this$props3.isPreview,
141
- statItem = _this$props3.statItem,
142
- theme = _this$props3.theme,
143
- isEnlarge = _this$props3.isEnlarge;
135
+ _this.initChartHandler();
136
+ _this.registerShape();
137
+ var number = value > 1 ? 10 : value * 10;
138
+ var data = [{
139
+ value: number
140
+ }];
141
+ _this.chart.data(data);
142
+ _this.chart.scale('value', {
143
+ min: 0,
144
+ max: 10,
145
+ tickInterval: 1
146
+ });
147
+ _this.chart.coordinate('polar', {
148
+ startAngle: -9 / 8 * Math.PI,
149
+ endAngle: 1 / 8 * Math.PI,
150
+ radius: 0.75
151
+ });
152
+ _this.setAxis();
153
+ _this.chart.legend(false);
154
+ _this.chart.point().position('value*1').shape('pointer').color('#1890FF').animate({
155
+ appear: {
156
+ animation: 'fade-in'
157
+ }
158
+ });
159
+ _this.setAnnotationArc(data);
160
+ _this.setAnnotationText(value);
161
+ _this.chart.render();
162
+ _this.container.title = "".concat(data[0].value * 10, " %");
163
+ };
164
+ _this.initChartHandler = function () {
165
+ var isPreview = _this.props.isPreview;
166
+ var config = {
167
+ container: _this.container
168
+ };
144
169
  if (isPreview) {
145
170
  var canvasSize = _this.getCanvasSize();
146
- _this.chart = new Chart({
147
- container: _this.container,
148
- width: canvasSize.w,
149
- height: canvasSize.h,
150
- padding: [0, 0, 25, 0]
151
- });
171
+ config.width = canvasSize.w;
172
+ config.height = canvasSize.h;
173
+ config.padding = [0, 0, 25, 0];
152
174
  } else {
153
- _this.chart = new Chart({
154
- container: _this.container,
155
- width: WIDTH,
156
- height: HEIGHT
157
- });
175
+ config.width = WIDTH;
176
+ config.height = HEIGHT;
158
177
  }
178
+ _this.chart = new Chart(config);
179
+ };
180
+ _this.registerShape = function () {
159
181
  registerShape('point', 'pointer', {
160
182
  draw: function draw(cfg, container) {
161
183
  var group = container.addGroup();
@@ -187,24 +209,10 @@ var DashboardChart = /*#__PURE__*/function (_BaseChart) {
187
209
  return group;
188
210
  }
189
211
  });
190
- var number = value > 1 ? 10 : value * 10;
191
- var data = [{
192
- value: number
193
- }];
194
- var chart = _this.chart;
195
- chart.data(data);
196
- chart.scale('value', {
197
- min: 0,
198
- max: 10,
199
- tickInterval: 1
200
- });
201
- chart.coordinate('polar', {
202
- startAngle: -9 / 8 * Math.PI,
203
- endAngle: 1 / 8 * Math.PI,
204
- radius: 0.75
205
- });
206
- chart.axis('1', false);
207
- chart.axis('value', {
212
+ };
213
+ _this.setAxis = function () {
214
+ _this.chart.axis('1', false);
215
+ _this.chart.axis('value', {
208
216
  line: null,
209
217
  label: {
210
218
  offset: -36,
@@ -223,13 +231,9 @@ var DashboardChart = /*#__PURE__*/function (_BaseChart) {
223
231
  },
224
232
  grid: null
225
233
  });
226
- chart.legend(false);
227
- chart.point().position('value*1').shape('pointer').color('#1890FF').animate({
228
- appear: {
229
- animation: 'fade-in'
230
- }
231
- });
232
- chart.annotation().arc({
234
+ };
235
+ _this.setAnnotationArc = function (data) {
236
+ _this.chart.annotation().arc({
233
237
  top: false,
234
238
  start: [0, 1],
235
239
  end: [10, 1],
@@ -239,7 +243,7 @@ var DashboardChart = /*#__PURE__*/function (_BaseChart) {
239
243
  lineDash: null
240
244
  }
241
245
  });
242
- chart.annotation().arc({
246
+ _this.chart.annotation().arc({
243
247
  start: [0, 1],
244
248
  end: [data[0].value, 1],
245
249
  style: {
@@ -248,7 +252,10 @@ var DashboardChart = /*#__PURE__*/function (_BaseChart) {
248
252
  lineDash: null
249
253
  }
250
254
  });
251
- chart.annotation().text({
255
+ };
256
+ _this.setAnnotationText = function (value) {
257
+ var statItem = _this.props.statItem;
258
+ _this.chart.annotation().text({
252
259
  position: ['50%', '85%'],
253
260
  content: statItem.name,
254
261
  style: {
@@ -262,11 +269,8 @@ var DashboardChart = /*#__PURE__*/function (_BaseChart) {
262
269
  if (shownDotPos > -1 && shownDotPos < "".concat(shownValue).length - 2) {
263
270
  shownValue = shownValue.toFixed(1);
264
271
  }
265
- var themeColors = STAT_ITEM_THEME_COLORS.light;
266
- if (theme === 'dark' && !isEnlarge && isPreview) {
267
- themeColors = STAT_ITEM_THEME_COLORS.dark;
268
- }
269
- chart.annotation().text({
272
+ var themeColors = _this.getThemeColors();
273
+ _this.chart.annotation().text({
270
274
  position: ['50%', '90%'],
271
275
  content: "".concat(shownValue, " %"),
272
276
  style: {
@@ -276,8 +280,6 @@ var DashboardChart = /*#__PURE__*/function (_BaseChart) {
276
280
  },
277
281
  offsetY: 15
278
282
  });
279
- chart.render();
280
- _this.container.title = "".concat(data[0].value * 10, " %");
281
283
  };
282
284
  _this.state = {
283
285
  isCalculatingData: true
@@ -301,9 +303,7 @@ var DashboardChart = /*#__PURE__*/function (_BaseChart) {
301
303
  value: function render() {
302
304
  var _this2 = this;
303
305
  var isCalculatingData = this.state.isCalculatingData;
304
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
305
- className: 'statistic-chart-loading-container'
306
- }, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
306
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
307
307
  ref: function ref(_ref3) {
308
308
  return _this2.container = _ref3;
309
309
  },
@@ -8,12 +8,11 @@ import PropTypes from 'prop-types';
8
8
  import dayjs from 'dayjs';
9
9
  import weekOfYear from 'dayjs/plugin/weekOfYear';
10
10
  import intl from 'react-intl-universal';
11
- import { TableUtils, getNumberDisplayString } from 'dtable-store';
11
+ import { TableUtils } from 'dtable-store';
12
12
  import BaseChart from './base-chart';
13
13
  import { Chart, registerShape, getRectWithCornerRadius } from '../custom-g2';
14
- import { Loading } from '../components';
15
14
  import { isShapeEqual } from '../utils/common-utils';
16
- import { COLOR_OPTIONS, DEFAULT_GRID_DISTANCE, DEFAULT_GRID_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, FILL_BORDER_COLOR_MAP, MONTH_MIRROR, NO_STATISTIC_RESULTS, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
15
+ import { COLOR_OPTIONS, DEFAULT_GRID_DISTANCE, DEFAULT_GRID_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, FILL_BORDER_COLOR_MAP, MONTH_MIRROR, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
17
16
  import styles from '../assets/css/statistic-custom.module.css';
18
17
  dayjs.extend(weekOfYear);
19
18
  var HeatMap = /*#__PURE__*/function (_BaseChart) {
@@ -23,6 +22,10 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
23
22
  var _this;
24
23
  _classCallCheck(this, HeatMap);
25
24
  _this = _super.call(this, props);
25
+ _this.destroyChart = function () {
26
+ _this.chart.destroy();
27
+ _this.chart = null;
28
+ };
26
29
  _this.transformData = function (statData) {
27
30
  var data = {};
28
31
  var yearFirstDate = dayjs(statData[0].name);
@@ -79,9 +82,6 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
79
82
  _this.maxValue = 0;
80
83
  var _this$props = _this.props,
81
84
  getTableById = _this$props.getTableById,
82
- isPreview = _this$props.isPreview,
83
- isEnlarge = _this$props.isEnlarge,
84
- theme = _this$props.theme,
85
85
  statItem = _this$props.statItem;
86
86
  var currentColorOption = COLOR_OPTIONS.filter(function (item) {
87
87
  return item.name == statItem.data_color;
@@ -126,26 +126,18 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
126
126
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
127
127
  itemTpl: "<div class=\"g2-tooltip-content\"><div style=\"width: max-content; text-align: left;\" class=\"tooltip-name\">{date}<div><div style=\"word-break: keep-all;\" class=\"tooltip-item\">".concat(intl.get(TITLE_AMOUNT), " : {value}<div></div>"),
128
128
  domStyles: {
129
- 'g2-tooltip': {
130
- borderRadius: '2px',
131
- backgroundColor: '#fff',
132
- padding: '10px'
133
- },
134
- 'tooltip-item': {
135
- marginTop: '5px'
136
- }
129
+ 'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
130
+ 'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
137
131
  }
138
132
  });
139
133
  _this.chart.axis(false);
140
134
  _this.chart.data(statData.data);
141
- var themeColors = STAT_ITEM_THEME_COLORS.light;
142
- if (theme === 'dark' && !isEnlarge && isPreview) {
143
- themeColors = STAT_ITEM_THEME_COLORS.dark;
144
- }
135
+ var themeColors = _this.getThemeColors();
145
136
  var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
146
137
  var table_id = statItem.table_id,
147
138
  summary_type = statItem.summary_type,
148
- summary_column = statItem.summary_column;
139
+ summary_column = statItem.summary_column,
140
+ summary_method = statItem.summary_method;
149
141
  if (summary_type === SUMMARY_TYPE.ADVANCED) {
150
142
  var table = getTableById(table_id);
151
143
  var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
@@ -228,7 +220,7 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
228
220
  }).shape('boundary-polygon').label(false).tooltip('date*value', function (date, value) {
229
221
  return {
230
222
  date: date,
231
- value: getNumberDisplayString(value, columnData)
223
+ value: _this.getNumberDisplayString(value, columnData, summary_method)
232
224
  };
233
225
  });
234
226
  gridView.coordinate().reflect('y');
@@ -261,10 +253,6 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
261
253
  context.font = font;
262
254
  return Math.ceil(context.measureText(text).width);
263
255
  };
264
- _this.destroyChart = function () {
265
- _this.chart.destroy();
266
- _this.chart = null;
267
- };
268
256
  dayjs.locale('en');
269
257
  _this.state = {
270
258
  isCalculatingData: true,
@@ -469,11 +457,7 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
469
457
  var _this$state = this.state,
470
458
  isCalculatingData = _this$state.isCalculatingData,
471
459
  showResultDescription = _this$state.showResultDescription;
472
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
473
- className: 'statistic-chart-loading-container'
474
- }, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
475
- className: 'statistic-chart-text'
476
- }, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
460
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
477
461
  style: {
478
462
  overflow: 'auto',
479
463
  height: '100%',
@@ -490,9 +474,6 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
490
474
  return HeatMap;
491
475
  }(BaseChart);
492
476
  HeatMap.propTypes = {
493
- isPreview: PropTypes.bool,
494
- isEnlarge: PropTypes.bool,
495
- theme: PropTypes.string,
496
477
  statItem: PropTypes.object,
497
478
  chartCalculator: PropTypes.object,
498
479
  getTableById: PropTypes.func,