dtable-statistic 4.0.6 → 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 (67) hide show
  1. package/es/assets/css/dashboard.css +22 -0
  2. package/es/calculator/basic-chart-calculator.js +27 -18
  3. package/es/calculator/combination-calculator.js +34 -9
  4. package/es/calculator/compare-bar-calculator.js +37 -30
  5. package/es/calculator/heat-map-calculator.js +25 -14
  6. package/es/calculator/map-calculator.js +25 -14
  7. package/es/calculator/mirror-calculator.js +29 -14
  8. package/es/calculator/pivot-table-calculator.js +132 -76
  9. package/es/calculator/workers/basic-chart-calculator-worker.js +21 -6
  10. package/es/calculator/workers/combination-calculator-worker.js +20 -5
  11. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -6
  12. package/es/calculator/workers/mirror-calculator-worker.js +15 -6
  13. package/es/calculator/workers/pivot-table-calculator-worker.js +97 -44
  14. package/es/calculator/world-map-calculator.js +25 -14
  15. package/es/components/dialog/enlarged-chart-dialog.js +2 -2
  16. package/es/components/dialog/statistic-record-dialog/index.css +2 -0
  17. package/es/components/dialog/statistic-record-dialog/index.js +80 -52
  18. package/es/constants/index.js +30 -29
  19. package/es/dashboard.js +57 -43
  20. package/es/desktop-dashboard.js +21 -56
  21. package/es/index.js +34 -2
  22. package/es/locale/lang/de.js +7 -3
  23. package/es/locale/lang/en.js +5 -1
  24. package/es/locale/lang/fr.js +7 -3
  25. package/es/locale/lang/zh_CN.js +5 -1
  26. package/es/mobile-dashboard.js +5 -5
  27. package/es/model/horizontal-bar-group.js +2 -0
  28. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +1 -2
  29. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  30. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +20 -3
  31. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +2 -8
  32. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +23 -2
  33. package/es/stat-list/chart-preview.js +3 -4
  34. package/es/stat-list/index.js +10 -4
  35. package/es/stat-view/area-chart.js +177 -162
  36. package/es/stat-view/bar-chart.js +221 -222
  37. package/es/stat-view/base-chart.js +79 -7
  38. package/es/stat-view/basic-number-card.js +11 -19
  39. package/es/stat-view/combination-chart.js +100 -83
  40. package/es/stat-view/compare-chart.js +133 -144
  41. package/es/stat-view/completeness-chart.js +108 -102
  42. package/es/stat-view/custom-bar.js +79 -99
  43. package/es/stat-view/dashboard-chart.js +57 -57
  44. package/es/stat-view/heat-map.js +13 -32
  45. package/es/stat-view/horizontal-bar-chart.js +200 -230
  46. package/es/stat-view/index.js +2 -2
  47. package/es/stat-view/line-chart.js +162 -158
  48. package/es/stat-view/map.js +26 -40
  49. package/es/stat-view/mirror.js +88 -94
  50. package/es/stat-view/pie-chart.js +11 -39
  51. package/es/stat-view/pivot-table/index.js +4 -16
  52. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +36 -23
  53. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +11 -5
  54. package/es/stat-view/pivot-table/pivot-table-display-name.js +206 -0
  55. package/es/stat-view/pivot-table/two-dimension-table.js +104 -60
  56. package/es/stat-view/ring-chart.js +24 -42
  57. package/es/stat-view/scatter-chart.js +4 -21
  58. package/es/stat-view/treemap-chart.js +3 -12
  59. package/es/stat-view/trend-chart.js +6 -17
  60. package/es/stat-view/world-map.js +39 -50
  61. package/es/tabs/tab.js +2 -1
  62. package/es/utils/collaborator.js +9 -0
  63. package/es/utils/common-utils.js +24 -6
  64. package/es/utils/index.js +1 -1
  65. package/es/utils/sql-utils.js +10 -9
  66. package/es/utils/stat-utils.js +8 -5
  67. package/package.json +1 -1
@@ -6,19 +6,16 @@ import React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import DataSet from '@antv/data-set';
8
8
  import intl from 'react-intl-universal';
9
- import { TableUtils, getNumberDisplayString } from 'dtable-store';
9
+ import { TableUtils } from 'dtable-store';
10
10
  import BaseChart from './base-chart';
11
11
  import { Chart } from '../custom-g2';
12
- import { Loading } from '../components';
13
- import { getCurrentTheme, getLabelFontSize, sortDataByGroupSum } from '../utils/common-utils';
14
- import { getChartDisplayLabels, getChartGroups } from '../utils/basic-chart-utils';
12
+ import { getCurrentTheme, sortDataByGroupSum } from '../utils/common-utils';
13
+ import { getChartGroups } from '../utils/basic-chart-utils';
15
14
  import { getConvertedColorRules, getLabelColor } from '../utils/color-utils';
16
- import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_CONFIG_CHANGED, NO_STATISTIC_RESULTS, STATISTICS_COUNT_SHOW, STAT_ITEM_THEME_COLORS, STAT_TYPE, SUMMARY_TYPE, TITLE_AMOUNT, TYPE_COLOR_USING, USEABLE_COLOR_TYPES } from '../constants';
15
+ import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_CONFIG_CHANGED, STATISTICS_COUNT_SHOW, STAT_TYPE, SUMMARY_TYPE, TITLE_AMOUNT, TYPE_COLOR_USING, USEABLE_COLOR_TYPES } from '../constants';
17
16
  var propTypes = {
18
17
  isPreview: PropTypes.bool,
19
- isEnlarge: PropTypes.bool,
20
18
  isEdit: PropTypes.bool,
21
- theme: PropTypes.string,
22
19
  colorThemeName: PropTypes.string,
23
20
  statItem: PropTypes.object,
24
21
  chartCalculator: PropTypes.object,
@@ -36,63 +33,39 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
36
33
  _this.drawChart = function (originalData) {
37
34
  var _this$props = _this.props,
38
35
  getTableById = _this$props.getTableById,
39
- isPreview = _this$props.isPreview,
40
36
  statItem = _this$props.statItem,
41
- isEnlarge = _this$props.isEnlarge,
42
- theme = _this$props.theme,
43
37
  colorThemeName = _this$props.colorThemeName;
44
- var currentTheme = getCurrentTheme(colorThemeName);
45
- var type = statItem.type,
38
+ var table_id = statItem.table_id,
39
+ horizontal_axis_column_key = statItem.horizontal_axis_column_key,
40
+ horizontal_axis_summary_type = statItem.horizontal_axis_summary_type,
41
+ column_groupby_column_key = statItem.column_groupby_column_key,
42
+ column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column,
43
+ type = statItem.type,
46
44
  sort_type = statItem.sort_type;
45
+ _this.initChartHandler();
47
46
  var data = originalData;
48
47
  if (type == STAT_TYPE.STACKED_HORIZONTAL_BAR && sort_type) {
49
48
  data = sortDataByGroupSum(originalData, sort_type);
50
49
  }
51
- if (isPreview) {
52
- _this.chart = new Chart({
53
- container: _this.container,
54
- autoFit: true,
55
- appendPadding: [0, 30, 0, 0]
56
- });
57
- } else {
58
- _this.chart = new Chart({
59
- container: _this.container,
60
- autoFit: true,
61
- height: 400,
62
- width: 700,
63
- appendPadding: [0, 30, 0, 0]
64
- });
65
- }
66
50
  _this.chart.on('interval:click', function (e) {
67
51
  _this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
68
52
  });
69
- var table_id = statItem.table_id,
70
- horizontal_axis_column_key = statItem.horizontal_axis_column_key,
71
- horizontal_axis_summary_type = statItem.horizontal_axis_summary_type,
72
- horizontal_axis_summary_method = statItem.horizontal_axis_summary_method,
73
- column_groupby_column_key = statItem.column_groupby_column_key,
74
- display_data = statItem.display_data,
75
- column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column,
76
- h_axis_auto_range = statItem.h_axis_auto_range,
77
- h_axis_min = statItem.h_axis_min,
78
- h_axis_max = statItem.h_axis_max,
79
- color_option = statItem.color_option;
80
- var chartBarColor,
81
- columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
53
+ var currentTheme = getCurrentTheme(colorThemeName);
54
+ var isGroup = column_groupby_column_key || column_groupby_multiple_numeric_column;
55
+ var chartBarColor = '#2a67d1';
56
+ var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
82
57
  if (horizontal_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
83
58
  var table = getTableById(table_id);
84
59
  var summaryColumn = TableUtils.getTableColumnByKey(table, horizontal_axis_column_key) || {};
85
- columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
60
+ summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
86
61
  }
87
- if (column_groupby_column_key || column_groupby_multiple_numeric_column) {
62
+ if (isGroup) {
88
63
  chartBarColor = 'group_name';
89
64
  _this.chart.scale('group_name', {
90
65
  type: 'cat'
91
66
  });
92
67
  } else if (currentTheme && currentTheme.colors) {
93
68
  chartBarColor = currentTheme.colors[0];
94
- } else {
95
- chartBarColor = '#2a67d1';
96
69
  }
97
70
  _this.chart.data(data, {
98
71
  'name': {
@@ -100,42 +73,72 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
100
73
  nice: false
101
74
  }
102
75
  });
103
- var themeColors = STAT_ITEM_THEME_COLORS.light;
104
- if (theme === 'dark' && !isEnlarge && isPreview) {
105
- themeColors = STAT_ITEM_THEME_COLORS.dark;
106
- }
76
+ var themeColors = _this.getThemeColors();
107
77
  var width = _this.chart.coordinateBBox.width;
108
- var chartData;
109
- if (column_groupby_column_key || column_groupby_multiple_numeric_column) {
110
- chartData = getChartGroups(data);
111
- } else {
112
- chartData = data;
113
- }
114
- var labelCount = chartData.length;
115
- if (Math.floor(width / labelCount) <= 20) {
116
- var displayLabels = getChartDisplayLabels(width, 20, chartData);
117
- labelCount = displayLabels.length;
78
+ var chartData = isGroup ? getChartGroups(data) : data;
79
+ var ticks = _this.getTicks(chartData, width);
80
+ if (ticks.length > 0) {
118
81
  _this.chart.scale('name', {
119
- ticks: displayLabels
82
+ ticks: ticks
120
83
  });
121
84
  }
122
85
 
123
86
  // set Coord type
124
87
  _this.chart.coordinate('rect');
125
-
88
+ _this.handleAutoRange(data, summaryColumnData);
89
+ if (isGroup) {
90
+ _this.drawBarGroup({
91
+ data: data,
92
+ themeColors: themeColors,
93
+ currentTheme: currentTheme,
94
+ summaryColumnData: summaryColumnData
95
+ });
96
+ } else {
97
+ _this.drawBar({
98
+ themeColors: themeColors,
99
+ chartBarColor: chartBarColor
100
+ });
101
+ }
102
+ _this.setTooltip();
103
+ _this.setAxis(themeColors);
104
+ _this.setLegend(themeColors);
105
+ _this.chart.interaction('active-region');
106
+ _this.chart.coordinate().transpose();
107
+ _this.chart.render();
108
+ _this.renderAxisLabel();
109
+ };
110
+ _this.initChartHandler = function () {
111
+ var isPreview = _this.props.isPreview;
112
+ var config = {
113
+ container: _this.container,
114
+ autoFit: true,
115
+ appendPadding: [0, 30, 0, 0]
116
+ };
117
+ if (!isPreview) {
118
+ config.height = 400;
119
+ config.width = 700;
120
+ }
121
+ _this.chart = new Chart(config);
122
+ };
123
+ _this.handleAutoRange = function (data, summaryColumnData) {
126
124
  // set scale options for 'value'
125
+ var _this$props$statItem = _this.props.statItem,
126
+ horizontal_axis_summary_method = _this$props$statItem.horizontal_axis_summary_method,
127
+ h_axis_auto_range = _this$props$statItem.h_axis_auto_range,
128
+ h_axis_min = _this$props$statItem.h_axis_min,
129
+ h_axis_max = _this$props$statItem.h_axis_max;
127
130
  var valueScaleOptions = {
128
131
  formatter: function formatter(value) {
129
- return getNumberDisplayString(value, columnData);
132
+ return _this.getNumberDisplayString(value, summaryColumnData, horizontal_axis_summary_method);
130
133
  }
131
134
  };
132
135
  if (h_axis_auto_range == undefined || h_axis_auto_range) {
133
- valueScaleOptions = Object.assign({}, valueScaleOptions, {
136
+ valueScaleOptions = Object.assign(valueScaleOptions, {
134
137
  // Automatically adjust the maximum and minimum values
135
138
  nice: true
136
139
  });
137
140
  } else {
138
- valueScaleOptions = Object.assign({}, valueScaleOptions, {
141
+ valueScaleOptions = Object.assign(valueScaleOptions, {
139
142
  min: h_axis_min,
140
143
  max: h_axis_max
141
144
  });
@@ -153,157 +156,150 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
153
156
  },
154
157
  value: valueScaleOptions
155
158
  });
156
- if (column_groupby_column_key || column_groupby_multiple_numeric_column) {
157
- _this.chart.scale({
158
- group_name: {
159
- type: 'cat'
160
- }
161
- });
162
- var labelCfg = {
163
- offset: 5,
164
- position: function position() {
165
- return 'right';
166
- },
159
+ };
160
+ _this.drawBar = function (_ref) {
161
+ var themeColors = _ref.themeColors,
162
+ chartBarColor = _ref.chartBarColor;
163
+ var statItem = _this.props.statItem;
164
+ var horizontal_axis_summary_type = statItem.horizontal_axis_summary_type,
165
+ horizontal_axis_summary_method = statItem.horizontal_axis_summary_method,
166
+ display_data = statItem.display_data,
167
+ color_option = statItem.color_option,
168
+ horizontal_axis_label_color_rules = statItem.horizontal_axis_label_color_rules;
169
+ var colorRules = color_option === TYPE_COLOR_USING.USE_RULES && horizontal_axis_label_color_rules && getConvertedColorRules(horizontal_axis_label_color_rules);
170
+ _this.chart.interval().label(display_data ? 'formatted_value' : false, {
171
+ offset: 5,
172
+ position: function position() {
173
+ return 'right';
174
+ },
175
+ style: {
176
+ fontSize: _this.getLabelFontSize(),
177
+ fill: themeColors.textColor
178
+ }
179
+ }).position('name*value').tooltip('name*formatted_value', function (name, value) {
180
+ return {
181
+ value: value,
182
+ title: horizontal_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[horizontal_axis_summary_method]),
183
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
184
+ };
185
+ }).state({
186
+ active: {
167
187
  style: {
168
- fontSize: _this.getLabelFontSize(),
169
- fill: themeColors.textColor
188
+ stroke: null
170
189
  }
171
- };
172
- if (statItem.type == STAT_TYPE.STACKED_HORIZONTAL_BAR) {
173
- // get the total value of each stack
174
- var dv = new DataSet.DataView().source(data);
175
- dv.transform({
176
- type: 'aggregate',
177
- fields: ['value'],
178
- operations: ['sum'],
179
- as: ['value_sum'],
180
- groupBy: ['name']
181
- });
182
- var groupNames = [];
183
- data.forEach(function (item) {
184
- if (groupNames.indexOf(item.group_name) == -1) {
185
- groupNames.push(item.group_name);
186
- }
187
- });
188
- labelCfg.content = function (dataItem, mappingData, index) {
189
- var name = dataItem.name,
190
- group_name = dataItem.group_name;
191
- var targetData = dv.rows.filter(function (item) {
192
- return item.name == name;
193
- });
194
- // make the value displayed in the same precision with the column
195
- var valueSum = getNumberDisplayString(targetData[0].value_sum, columnData);
196
- var groupedItems = data.filter(function (item) {
197
- return item.name == name;
198
- });
199
- if (groupedItems.length == 1) {
200
- return valueSum;
201
- }
202
- var filteredGroupNameIndexes = groupedItems.map(function (item) {
203
- return groupNames.indexOf(item.group_name);
204
- }).filter(function (item) {
205
- return item > -1;
206
- });
207
- if (filteredGroupNameIndexes.length == 0) {
208
- return valueSum;
209
- }
210
- filteredGroupNameIndexes.sort(function (a, b) {
211
- return a - b;
212
- });
213
- if (group_name == groupNames[filteredGroupNameIndexes[0]]) {
214
- return valueSum;
215
- }
216
- return null;
217
- };
218
- }
219
- var groupColorCallback = currentTheme && currentTheme.colors;
220
- // when the 'Group by' column is a 'single-select' column,
221
- // and the user chooses to use the colors from the column.
222
- if (color_option === USEABLE_COLOR_TYPES[1]) {
223
- var groupColorMapping = {};
224
- data.forEach(function (item) {
225
- if (!groupColorMapping[item.group_name]) {
226
- groupColorMapping[item.group_name] = item.color;
227
- }
228
- });
229
- groupColorCallback = function groupColorCallback(group_name) {
230
- return groupColorMapping[group_name];
231
- };
232
190
  }
233
- _this.chart.interval().label(display_data ? 'value' : false, labelCfg).position('name*value').color('group_name', groupColorCallback).tooltip('name*value*group_name', function (name, value, group_name) {
234
- return {
235
- title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
236
- value: getNumberDisplayString(value, columnData),
237
- name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
238
- };
239
- }).adjust([{
240
- reverseOrder: true,
241
- // for 'stack'. It only work for 'stack'.
242
- type: statItem.type == STAT_TYPE.STACKED_HORIZONTAL_BAR ? 'stack' : 'dodge'
243
- }]).state({
244
- active: {
245
- style: {
246
- stroke: null
247
- }
248
- }
191
+ }).style('value', function (value) {
192
+ var color = getLabelColor({
193
+ chart: statItem,
194
+ colorRules: colorRules,
195
+ value: value
249
196
  });
250
- } else {
251
- var colorRules = statItem.color_option === TYPE_COLOR_USING.USE_RULES && statItem.horizontal_axis_label_color_rules && getConvertedColorRules(statItem.horizontal_axis_label_color_rules);
252
- _this.chart.interval().label(display_data ? 'value' : false, {
253
- offset: 5,
254
- position: function position() {
255
- return 'right';
256
- },
257
- style: {
258
- fontSize: _this.getLabelFontSize(),
259
- fill: themeColors.textColor
260
- }
261
- }).position('name*value').tooltip('name*value', function (name, value) {
197
+ if (color) {
262
198
  return {
263
- title: horizontal_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[horizontal_axis_summary_method]),
264
- value: getNumberDisplayString(value, columnData),
265
- name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
199
+ fill: color
266
200
  };
267
- }).state({
268
- active: {
269
- style: {
270
- stroke: null
271
- }
272
- }
273
- }).style('value', function (value) {
274
- var color = getLabelColor({
275
- chart: statItem,
276
- colorRules: colorRules,
277
- value: value
201
+ }
202
+ return {
203
+ fill: chartBarColor
204
+ };
205
+ });
206
+ };
207
+ _this.drawBarGroup = function (_ref2) {
208
+ var data = _ref2.data,
209
+ themeColors = _ref2.themeColors,
210
+ currentTheme = _ref2.currentTheme,
211
+ summaryColumnData = _ref2.summaryColumnData;
212
+ var statItem = _this.props.statItem;
213
+ var horizontal_axis_summary_method = statItem.horizontal_axis_summary_method,
214
+ display_data = statItem.display_data,
215
+ color_option = statItem.color_option;
216
+ _this.chart.scale({
217
+ group_name: {
218
+ type: 'cat'
219
+ }
220
+ });
221
+ var labelCfg = {
222
+ style: {
223
+ fontSize: _this.getLabelFontSize(),
224
+ fill: themeColors.textColor
225
+ }
226
+ };
227
+ var displayData = display_data;
228
+ if (statItem.type == STAT_TYPE.STACKED_HORIZONTAL_BAR) {
229
+ var display_each_block_data = statItem.display_each_block_data;
230
+ displayData = display_each_block_data;
231
+ if (displayData) {
232
+ labelCfg.position = 'middle';
233
+ }
234
+
235
+ // get the total value of each stack
236
+ var dv = new DataSet.DataView().source(data);
237
+ dv.transform({
238
+ type: 'aggregate',
239
+ fields: ['value'],
240
+ operations: ['sum'],
241
+ as: ['value_sum'],
242
+ groupBy: ['name']
243
+ });
244
+ if (display_data) {
245
+ dv.rows.forEach(function (item) {
246
+ _this.chart.annotation().text({
247
+ content: _this.getNumberDisplayString(item.value_sum, summaryColumnData, horizontal_axis_summary_method),
248
+ position: {
249
+ name: item.name,
250
+ value: item.value_sum
251
+ },
252
+ offsetY: 0,
253
+ offsetX: 5
254
+ });
278
255
  });
279
- if (color) {
280
- return {
281
- fill: color
282
- };
256
+ }
257
+ }
258
+ var groupColorCallback = currentTheme && currentTheme.colors;
259
+ // when the 'Group by' column is a 'single-select' column,
260
+ // and the user chooses to use the colors from the column.
261
+ if (color_option === USEABLE_COLOR_TYPES[1]) {
262
+ var groupColorMapping = {};
263
+ data.forEach(function (item) {
264
+ if (!groupColorMapping[item.group_name]) {
265
+ groupColorMapping[item.group_name] = item.color;
283
266
  }
284
- return {
285
- fill: chartBarColor
286
- };
287
267
  });
268
+ groupColorCallback = function groupColorCallback(group_name) {
269
+ return groupColorMapping[group_name];
270
+ };
288
271
  }
272
+ _this.chart.interval().label(displayData ? 'formatted_value' : false, labelCfg).position('name*value').color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name', function (name, value, group_name) {
273
+ return {
274
+ value: value,
275
+ title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
276
+ name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
277
+ };
278
+ }).adjust([{
279
+ reverseOrder: true,
280
+ // for 'stack'. It only work for 'stack'.
281
+ type: statItem.type == STAT_TYPE.STACKED_HORIZONTAL_BAR ? 'stack' : 'dodge'
282
+ }]).state({
283
+ active: {
284
+ style: {
285
+ stroke: null
286
+ }
287
+ }
288
+ });
289
+ };
290
+ _this.setTooltip = function () {
289
291
  _this.chart.tooltip({
290
292
  showTitle: true,
291
293
  showMarkers: false,
292
294
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
293
295
  itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
294
296
  domStyles: {
295
- 'g2-tooltip': {
296
- borderRadius: '2px',
297
- backgroundColor: '#fff',
298
- padding: '10px'
299
- },
300
- 'tooltip-item': {
301
- marginTop: '5px'
302
- }
297
+ 'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
298
+ 'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
303
299
  }
304
300
  });
305
-
306
- // set axis label and tooltip
301
+ };
302
+ _this.setAxis = function (themeColors) {
307
303
  _this.chart.axis('name', {
308
304
  label: {
309
305
  style: {
@@ -313,16 +309,7 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
313
309
  style: themeColors.gridColor
314
310
  },
315
311
  autoRotate: true,
316
- formatter: function formatter(name) {
317
- var label = name;
318
- if (name.length > 10) {
319
- label = "".concat(name.slice(0, 10), "...");
320
- }
321
- if (name === '' || name === 'undefined') {
322
- label = intl.get(EMPTY_NAME);
323
- }
324
- return label;
325
- }
312
+ formatter: _this.labelFormatter
326
313
  }
327
314
  });
328
315
  _this.chart.axis('value', {
@@ -339,6 +326,8 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
339
326
  }
340
327
  }
341
328
  });
329
+ };
330
+ _this.setLegend = function (themeColors) {
342
331
  var legendPosition = 'bottom';
343
332
  _this.chart.legend('group_name', {
344
333
  position: legendPosition,
@@ -351,18 +340,11 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
351
340
  }
352
341
  }
353
342
  });
354
- _this.chart.interaction('active-region');
355
- _this.chart.coordinate().transpose();
356
- _this.chart.render();
357
- _this.renderAxisLabel();
358
343
  };
359
344
  _this.renderAxisLabel = function (newStatItem) {
360
345
  var _this$props2 = _this.props,
361
346
  getTableById = _this$props2.getTableById,
362
- statItem = _this$props2.statItem,
363
- isEnlarge = _this$props2.isEnlarge,
364
- isPreview = _this$props2.isPreview,
365
- theme = _this$props2.theme;
347
+ statItem = _this$props2.statItem;
366
348
  if (newStatItem && newStatItem._id !== statItem._id) {
367
349
  return;
368
350
  }
@@ -383,10 +365,7 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
383
365
  title_name = _statItem$title_name === void 0 ? '' : _statItem$title_name;
384
366
  var table = getTableById(table_id);
385
367
  var autoPadding = _this.chart.autoPadding;
386
- var textColor = '#999999';
387
- if (theme === 'dark' && !isEnlarge && isPreview) {
388
- textColor = '#ffffff';
389
- }
368
+ var textColor = _this.getAxisLabelColor();
390
369
  var chartContainer = _this.chart.getCanvas().get('container');
391
370
  var horizontalAxisID = "chart-horizontal-axis-label_".concat(statItem._id);
392
371
  var horizontalLabel = chartContainer.querySelector("#".concat(horizontalAxisID));
@@ -442,11 +421,6 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
442
421
  _this.chart.destroy();
443
422
  _this.chart = null;
444
423
  };
445
- _this.getLabelFontSize = function () {
446
- var statItem = _this.props.statItem;
447
- var label_font_size = statItem.label_font_size;
448
- return getLabelFontSize(label_font_size);
449
- };
450
424
  _this.state = {
451
425
  isCalculatingData: true,
452
426
  showResultDescription: true
@@ -548,13 +522,9 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
548
522
  showResultDescription = _this$state.showResultDescription;
549
523
  var show_horizontal_axis_label = statItem.show_horizontal_axis_label,
550
524
  show_vertical_axis_label = statItem.show_vertical_axis_label;
551
- return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
552
- className: 'statistic-chart-loading-container'
553
- }, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
554
- className: 'statistic-chart-text'
555
- }, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
556
- ref: function ref(_ref) {
557
- return _this4.container = _ref;
525
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
526
+ ref: function ref(_ref3) {
527
+ return _this4.container = _ref3;
558
528
  },
559
529
  style: {
560
530
  padding: show_vertical_axis_label || show_horizontal_axis_label ? 30 : 20
@@ -48,7 +48,7 @@ var StatView = /*#__PURE__*/function (_React$Component) {
48
48
  isPreview = _this$props.isPreview,
49
49
  isEnlarge = _this$props.isEnlarge,
50
50
  isEdit = _this$props.isEdit,
51
- refresh = _this$props.refresh,
51
+ dtableChangedTime = _this$props.dtableChangedTime,
52
52
  theme = _this$props.theme,
53
53
  colorThemeName = _this$props.colorThemeName,
54
54
  statItem = _this$props.statItem,
@@ -60,7 +60,7 @@ var StatView = /*#__PURE__*/function (_React$Component) {
60
60
  isPreview: isPreview,
61
61
  isEnlarge: isEnlarge,
62
62
  isEdit: isEdit,
63
- refresh: refresh,
63
+ dtableChangedTime: dtableChangedTime,
64
64
  theme: theme,
65
65
  colorThemeName: colorThemeName,
66
66
  statItem: statItem,