dtable-statistic 4.0.7 → 4.0.9

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 (64) 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/model/ring.js +3 -2
  27. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +1 -2
  28. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  29. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +4 -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 +81 -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 +207 -231
  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 +22 -15
  53. package/es/stat-view/pivot-table/two-dimension-table.js +98 -31
  54. package/es/stat-view/ring-chart.js +24 -42
  55. package/es/stat-view/scatter-chart.js +4 -21
  56. package/es/stat-view/treemap-chart.js +3 -12
  57. package/es/stat-view/trend-chart.js +6 -17
  58. package/es/stat-view/world-map.js +39 -50
  59. package/es/tabs/tab.js +2 -1
  60. package/es/utils/common-utils.js +29 -12
  61. package/es/utils/sql-utils.js +10 -9
  62. package/es/utils/stat-utils.js +23 -15
  63. package/es/utils/trend-utils.js +1 -1
  64. 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 { DATA_SORT_TYPE, 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,45 @@ 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
- data = sortDataByGroupSum(originalData, sort_type);
50
- }
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
- });
48
+ var convertedSortType = sort_type;
49
+ if (sort_type === DATA_SORT_TYPE.ASCENDING) {
50
+ convertedSortType = DATA_SORT_TYPE.DESCENDING;
51
+ } else if (sort_type === DATA_SORT_TYPE.DESCENDING) {
52
+ convertedSortType = DATA_SORT_TYPE.ASCENDING;
53
+ }
54
+ data = sortDataByGroupSum(originalData, convertedSortType);
65
55
  }
66
56
  _this.chart.on('interval:click', function (e) {
67
57
  _this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
68
58
  });
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;
59
+ var currentTheme = getCurrentTheme(colorThemeName);
60
+ var isGroup = column_groupby_column_key || column_groupby_multiple_numeric_column;
61
+ var chartBarColor = '#2a67d1';
62
+ var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
82
63
  if (horizontal_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
83
64
  var table = getTableById(table_id);
84
65
  var summaryColumn = TableUtils.getTableColumnByKey(table, horizontal_axis_column_key) || {};
85
- columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
66
+ summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
86
67
  }
87
- if (column_groupby_column_key || column_groupby_multiple_numeric_column) {
68
+ if (isGroup) {
88
69
  chartBarColor = 'group_name';
89
70
  _this.chart.scale('group_name', {
90
71
  type: 'cat'
91
72
  });
92
73
  } else if (currentTheme && currentTheme.colors) {
93
74
  chartBarColor = currentTheme.colors[0];
94
- } else {
95
- chartBarColor = '#2a67d1';
96
75
  }
97
76
  _this.chart.data(data, {
98
77
  'name': {
@@ -100,42 +79,72 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
100
79
  nice: false
101
80
  }
102
81
  });
103
- var themeColors = STAT_ITEM_THEME_COLORS.light;
104
- if (theme === 'dark' && !isEnlarge && isPreview) {
105
- themeColors = STAT_ITEM_THEME_COLORS.dark;
106
- }
82
+ var themeColors = _this.getThemeColors();
107
83
  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;
84
+ var chartData = isGroup ? getChartGroups(data) : data;
85
+ var ticks = _this.getTicks(chartData, width);
86
+ if (ticks.length > 0) {
118
87
  _this.chart.scale('name', {
119
- ticks: displayLabels
88
+ ticks: ticks
120
89
  });
121
90
  }
122
91
 
123
92
  // set Coord type
124
93
  _this.chart.coordinate('rect');
125
-
94
+ _this.handleAutoRange(data, summaryColumnData);
95
+ if (isGroup) {
96
+ _this.drawBarGroup({
97
+ data: data,
98
+ themeColors: themeColors,
99
+ currentTheme: currentTheme,
100
+ summaryColumnData: summaryColumnData
101
+ });
102
+ } else {
103
+ _this.drawBar({
104
+ themeColors: themeColors,
105
+ chartBarColor: chartBarColor
106
+ });
107
+ }
108
+ _this.setTooltip();
109
+ _this.setAxis(themeColors);
110
+ _this.setLegend(themeColors);
111
+ _this.chart.interaction('active-region');
112
+ _this.chart.coordinate().transpose();
113
+ _this.chart.render();
114
+ _this.renderAxisLabel();
115
+ };
116
+ _this.initChartHandler = function () {
117
+ var isPreview = _this.props.isPreview;
118
+ var config = {
119
+ container: _this.container,
120
+ autoFit: true,
121
+ appendPadding: [0, 30, 0, 0]
122
+ };
123
+ if (!isPreview) {
124
+ config.height = 400;
125
+ config.width = 700;
126
+ }
127
+ _this.chart = new Chart(config);
128
+ };
129
+ _this.handleAutoRange = function (data, summaryColumnData) {
126
130
  // set scale options for 'value'
131
+ var _this$props$statItem = _this.props.statItem,
132
+ horizontal_axis_summary_method = _this$props$statItem.horizontal_axis_summary_method,
133
+ h_axis_auto_range = _this$props$statItem.h_axis_auto_range,
134
+ h_axis_min = _this$props$statItem.h_axis_min,
135
+ h_axis_max = _this$props$statItem.h_axis_max;
127
136
  var valueScaleOptions = {
128
137
  formatter: function formatter(value) {
129
- return getNumberDisplayString(value, columnData);
138
+ return _this.getNumberDisplayString(value, summaryColumnData, horizontal_axis_summary_method);
130
139
  }
131
140
  };
132
141
  if (h_axis_auto_range == undefined || h_axis_auto_range) {
133
- valueScaleOptions = Object.assign({}, valueScaleOptions, {
142
+ valueScaleOptions = Object.assign(valueScaleOptions, {
134
143
  // Automatically adjust the maximum and minimum values
135
144
  nice: true
136
145
  });
137
146
  } else {
138
- valueScaleOptions = Object.assign({}, valueScaleOptions, {
147
+ valueScaleOptions = Object.assign(valueScaleOptions, {
139
148
  min: h_axis_min,
140
149
  max: h_axis_max
141
150
  });
@@ -153,157 +162,150 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
153
162
  },
154
163
  value: valueScaleOptions
155
164
  });
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
- },
165
+ };
166
+ _this.drawBar = function (_ref) {
167
+ var themeColors = _ref.themeColors,
168
+ chartBarColor = _ref.chartBarColor;
169
+ var statItem = _this.props.statItem;
170
+ var horizontal_axis_summary_type = statItem.horizontal_axis_summary_type,
171
+ horizontal_axis_summary_method = statItem.horizontal_axis_summary_method,
172
+ display_data = statItem.display_data,
173
+ color_option = statItem.color_option,
174
+ horizontal_axis_label_color_rules = statItem.horizontal_axis_label_color_rules;
175
+ var colorRules = color_option === TYPE_COLOR_USING.USE_RULES && horizontal_axis_label_color_rules && getConvertedColorRules(horizontal_axis_label_color_rules);
176
+ _this.chart.interval().label(display_data ? 'formatted_value' : false, {
177
+ offset: 5,
178
+ position: function position() {
179
+ return 'right';
180
+ },
181
+ style: {
182
+ fontSize: _this.getLabelFontSize(),
183
+ fill: themeColors.textColor
184
+ }
185
+ }).position('name*value').tooltip('name*formatted_value', function (name, value) {
186
+ return {
187
+ value: value,
188
+ title: horizontal_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[horizontal_axis_summary_method]),
189
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
190
+ };
191
+ }).state({
192
+ active: {
167
193
  style: {
168
- fontSize: _this.getLabelFontSize(),
169
- fill: themeColors.textColor
194
+ stroke: null
170
195
  }
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
196
  }
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
- }
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
- }
197
+ }).style('value', function (value) {
198
+ var color = getLabelColor({
199
+ chart: statItem,
200
+ colorRules: colorRules,
201
+ value: value
249
202
  });
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) {
203
+ if (color) {
262
204
  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
205
+ fill: color
266
206
  };
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
207
+ }
208
+ return {
209
+ fill: chartBarColor
210
+ };
211
+ });
212
+ };
213
+ _this.drawBarGroup = function (_ref2) {
214
+ var data = _ref2.data,
215
+ themeColors = _ref2.themeColors,
216
+ currentTheme = _ref2.currentTheme,
217
+ summaryColumnData = _ref2.summaryColumnData;
218
+ var statItem = _this.props.statItem;
219
+ var horizontal_axis_summary_method = statItem.horizontal_axis_summary_method,
220
+ display_data = statItem.display_data,
221
+ color_option = statItem.color_option;
222
+ _this.chart.scale({
223
+ group_name: {
224
+ type: 'cat'
225
+ }
226
+ });
227
+ var labelCfg = {
228
+ style: {
229
+ fontSize: _this.getLabelFontSize(),
230
+ fill: themeColors.textColor
231
+ }
232
+ };
233
+ var displayData = display_data;
234
+ if (statItem.type == STAT_TYPE.STACKED_HORIZONTAL_BAR) {
235
+ var display_each_block_data = statItem.display_each_block_data;
236
+ displayData = display_each_block_data;
237
+ if (displayData) {
238
+ labelCfg.position = 'middle';
239
+ }
240
+
241
+ // get the total value of each stack
242
+ var dv = new DataSet.DataView().source(data);
243
+ dv.transform({
244
+ type: 'aggregate',
245
+ fields: ['value'],
246
+ operations: ['sum'],
247
+ as: ['value_sum'],
248
+ groupBy: ['name']
249
+ });
250
+ if (display_data) {
251
+ dv.rows.forEach(function (item) {
252
+ _this.chart.annotation().text({
253
+ content: _this.getNumberDisplayString(item.value_sum, summaryColumnData, horizontal_axis_summary_method),
254
+ position: {
255
+ name: item.name,
256
+ value: item.value_sum
257
+ },
258
+ offsetY: 0,
259
+ offsetX: 5
260
+ });
278
261
  });
279
- if (color) {
280
- return {
281
- fill: color
282
- };
262
+ }
263
+ }
264
+ var groupColorCallback = currentTheme && currentTheme.colors;
265
+ // when the 'Group by' column is a 'single-select' column,
266
+ // and the user chooses to use the colors from the column.
267
+ if (color_option === USEABLE_COLOR_TYPES[1]) {
268
+ var groupColorMapping = {};
269
+ data.forEach(function (item) {
270
+ if (!groupColorMapping[item.group_name]) {
271
+ groupColorMapping[item.group_name] = item.color;
283
272
  }
284
- return {
285
- fill: chartBarColor
286
- };
287
273
  });
274
+ groupColorCallback = function groupColorCallback(group_name) {
275
+ return groupColorMapping[group_name];
276
+ };
288
277
  }
278
+ _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) {
279
+ return {
280
+ value: value,
281
+ title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
282
+ name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
283
+ };
284
+ }).adjust([{
285
+ reverseOrder: true,
286
+ // for 'stack'. It only work for 'stack'.
287
+ type: statItem.type == STAT_TYPE.STACKED_HORIZONTAL_BAR ? 'stack' : 'dodge'
288
+ }]).state({
289
+ active: {
290
+ style: {
291
+ stroke: null
292
+ }
293
+ }
294
+ });
295
+ };
296
+ _this.setTooltip = function () {
289
297
  _this.chart.tooltip({
290
298
  showTitle: true,
291
299
  showMarkers: false,
292
300
  containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
293
301
  itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
294
302
  domStyles: {
295
- 'g2-tooltip': {
296
- borderRadius: '2px',
297
- backgroundColor: '#fff',
298
- padding: '10px'
299
- },
300
- 'tooltip-item': {
301
- marginTop: '5px'
302
- }
303
+ 'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
304
+ 'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
303
305
  }
304
306
  });
305
-
306
- // set axis label and tooltip
307
+ };
308
+ _this.setAxis = function (themeColors) {
307
309
  _this.chart.axis('name', {
308
310
  label: {
309
311
  style: {
@@ -313,16 +315,7 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
313
315
  style: themeColors.gridColor
314
316
  },
315
317
  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
- }
318
+ formatter: _this.labelFormatter
326
319
  }
327
320
  });
328
321
  _this.chart.axis('value', {
@@ -339,6 +332,8 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
339
332
  }
340
333
  }
341
334
  });
335
+ };
336
+ _this.setLegend = function (themeColors) {
342
337
  var legendPosition = 'bottom';
343
338
  _this.chart.legend('group_name', {
344
339
  position: legendPosition,
@@ -351,18 +346,11 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
351
346
  }
352
347
  }
353
348
  });
354
- _this.chart.interaction('active-region');
355
- _this.chart.coordinate().transpose();
356
- _this.chart.render();
357
- _this.renderAxisLabel();
358
349
  };
359
350
  _this.renderAxisLabel = function (newStatItem) {
360
351
  var _this$props2 = _this.props,
361
352
  getTableById = _this$props2.getTableById,
362
- statItem = _this$props2.statItem,
363
- isEnlarge = _this$props2.isEnlarge,
364
- isPreview = _this$props2.isPreview,
365
- theme = _this$props2.theme;
353
+ statItem = _this$props2.statItem;
366
354
  if (newStatItem && newStatItem._id !== statItem._id) {
367
355
  return;
368
356
  }
@@ -383,10 +371,7 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
383
371
  title_name = _statItem$title_name === void 0 ? '' : _statItem$title_name;
384
372
  var table = getTableById(table_id);
385
373
  var autoPadding = _this.chart.autoPadding;
386
- var textColor = '#999999';
387
- if (theme === 'dark' && !isEnlarge && isPreview) {
388
- textColor = '#ffffff';
389
- }
374
+ var textColor = _this.getAxisLabelColor();
390
375
  var chartContainer = _this.chart.getCanvas().get('container');
391
376
  var horizontalAxisID = "chart-horizontal-axis-label_".concat(statItem._id);
392
377
  var horizontalLabel = chartContainer.querySelector("#".concat(horizontalAxisID));
@@ -442,11 +427,6 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
442
427
  _this.chart.destroy();
443
428
  _this.chart = null;
444
429
  };
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
430
  _this.state = {
451
431
  isCalculatingData: true,
452
432
  showResultDescription: true
@@ -548,13 +528,9 @@ var HorizontalBarChart = /*#__PURE__*/function (_BaseChart) {
548
528
  showResultDescription = _this$state.showResultDescription;
549
529
  var show_horizontal_axis_label = statItem.show_horizontal_axis_label,
550
530
  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;
531
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
532
+ ref: function ref(_ref3) {
533
+ return _this4.container = _ref3;
558
534
  },
559
535
  style: {
560
536
  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,