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.
- package/es/calculator/basic-chart-calculator.js +27 -18
- package/es/calculator/combination-calculator.js +34 -9
- package/es/calculator/compare-bar-calculator.js +37 -30
- package/es/calculator/heat-map-calculator.js +25 -14
- package/es/calculator/map-calculator.js +25 -14
- package/es/calculator/mirror-calculator.js +29 -14
- package/es/calculator/pivot-table-calculator.js +78 -51
- package/es/calculator/workers/basic-chart-calculator-worker.js +21 -6
- package/es/calculator/workers/combination-calculator-worker.js +20 -5
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -6
- package/es/calculator/workers/mirror-calculator-worker.js +15 -6
- package/es/calculator/workers/pivot-table-calculator-worker.js +87 -41
- package/es/calculator/world-map-calculator.js +25 -14
- package/es/components/dialog/enlarged-chart-dialog.js +2 -2
- package/es/components/dialog/statistic-record-dialog/index.js +71 -41
- package/es/constants/index.js +30 -29
- package/es/dashboard.js +57 -43
- package/es/desktop-dashboard.js +16 -51
- package/es/index.js +34 -2
- package/es/locale/lang/de.js +2 -0
- package/es/locale/lang/en.js +2 -0
- package/es/locale/lang/fr.js +2 -0
- package/es/locale/lang/zh_CN.js +2 -0
- package/es/mobile-dashboard.js +5 -5
- package/es/model/horizontal-bar-group.js +2 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +1 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +20 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +2 -8
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +23 -2
- package/es/stat-list/chart-preview.js +3 -4
- package/es/stat-list/index.js +10 -4
- package/es/stat-view/area-chart.js +177 -162
- package/es/stat-view/bar-chart.js +221 -222
- package/es/stat-view/base-chart.js +79 -7
- package/es/stat-view/basic-number-card.js +11 -19
- package/es/stat-view/combination-chart.js +100 -83
- package/es/stat-view/compare-chart.js +133 -144
- package/es/stat-view/completeness-chart.js +108 -102
- package/es/stat-view/custom-bar.js +79 -99
- package/es/stat-view/dashboard-chart.js +57 -57
- package/es/stat-view/heat-map.js +13 -32
- package/es/stat-view/horizontal-bar-chart.js +200 -230
- package/es/stat-view/index.js +2 -2
- package/es/stat-view/line-chart.js +162 -158
- package/es/stat-view/map.js +26 -40
- package/es/stat-view/mirror.js +88 -94
- package/es/stat-view/pie-chart.js +11 -39
- package/es/stat-view/pivot-table/index.js +4 -16
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +22 -15
- package/es/stat-view/ring-chart.js +24 -42
- package/es/stat-view/scatter-chart.js +4 -21
- package/es/stat-view/treemap-chart.js +3 -12
- package/es/stat-view/trend-chart.js +6 -17
- package/es/stat-view/world-map.js +39 -50
- package/es/tabs/tab.js +2 -1
- package/es/utils/common-utils.js +24 -6
- package/es/utils/sql-utils.js +10 -9
- package/es/utils/stat-utils.js +8 -5
- package/package.json +1 -1
|
@@ -5,18 +5,15 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import intl from 'react-intl-universal';
|
|
8
|
-
import { TableUtils
|
|
8
|
+
import { TableUtils } from 'dtable-store';
|
|
9
9
|
import BaseChart from './base-chart';
|
|
10
10
|
import { Chart } from '../custom-g2';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_CONFIG_CHANGED, NO_STATISTIC_RESULTS, STATISTICS_COUNT_SHOW, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE, TITLE_AMOUNT, USEABLE_COLOR_TYPES } from '../constants';
|
|
11
|
+
import { getCurrentTheme } from '../utils/common-utils';
|
|
12
|
+
import { getChartGroups } from '../utils/basic-chart-utils';
|
|
13
|
+
import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_CONFIG_CHANGED, STATISTICS_COUNT_SHOW, SUMMARY_TYPE, TITLE_AMOUNT, USEABLE_COLOR_TYPES } from '../constants';
|
|
15
14
|
var propTypes = {
|
|
16
15
|
isPreview: PropTypes.bool,
|
|
17
|
-
isEnlarge: PropTypes.bool,
|
|
18
16
|
isEdit: PropTypes.bool,
|
|
19
|
-
theme: PropTypes.string,
|
|
20
17
|
colorThemeName: PropTypes.string,
|
|
21
18
|
statItem: PropTypes.object,
|
|
22
19
|
chartCalculator: PropTypes.object,
|
|
@@ -34,29 +31,8 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
34
31
|
_this.drawChart = function (data) {
|
|
35
32
|
var _this$props = _this.props,
|
|
36
33
|
getTableById = _this$props.getTableById,
|
|
37
|
-
isPreview = _this$props.isPreview,
|
|
38
34
|
statItem = _this$props.statItem,
|
|
39
|
-
isEnlarge = _this$props.isEnlarge,
|
|
40
|
-
theme = _this$props.theme,
|
|
41
35
|
colorThemeName = _this$props.colorThemeName;
|
|
42
|
-
var currentTheme = getCurrentTheme(colorThemeName);
|
|
43
|
-
if (isPreview) {
|
|
44
|
-
_this.chart = new Chart({
|
|
45
|
-
container: _this.container,
|
|
46
|
-
autoFit: true
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
49
|
-
_this.chart = new Chart({
|
|
50
|
-
container: _this.container,
|
|
51
|
-
height: 400,
|
|
52
|
-
width: 700
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
_this.chart.on('element:click', function (e) {
|
|
56
|
-
if (e.data && e.data.data) {
|
|
57
|
-
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
36
|
var table_id = statItem.table_id,
|
|
61
37
|
summary_type = statItem.summary_type,
|
|
62
38
|
y_axis_column_key = statItem.y_axis_column_key,
|
|
@@ -64,20 +40,31 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
64
40
|
summary_method = statItem.summary_method,
|
|
65
41
|
y_axis_summary_method = statItem.y_axis_summary_method,
|
|
66
42
|
column_groupby_column_key = statItem.column_groupby_column_key,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
43
|
+
column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column;
|
|
44
|
+
_this.initChartHandler();
|
|
45
|
+
_this.chart.on('element:click', function (e) {
|
|
46
|
+
if (e.data && e.data.data) {
|
|
47
|
+
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
var summaryType = summary_type;
|
|
51
|
+
var summaryMethod = summary_method;
|
|
52
|
+
var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
53
|
+
if (!summaryType && y_axis_summary_type) {
|
|
54
|
+
summaryType = y_axis_summary_type;
|
|
55
|
+
}
|
|
56
|
+
if (!summaryMethod && y_axis_summary_method) {
|
|
57
|
+
summaryMethod = y_axis_summary_method;
|
|
75
58
|
}
|
|
76
|
-
if (
|
|
77
|
-
|
|
59
|
+
if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
60
|
+
var table = getTableById(table_id);
|
|
61
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
62
|
+
summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
78
63
|
}
|
|
64
|
+
var currentTheme = getCurrentTheme(colorThemeName);
|
|
79
65
|
var chartBarColor = currentTheme && currentTheme.colors[0] || '#2a67d1';
|
|
80
|
-
|
|
66
|
+
var isGroup = column_groupby_column_key || column_groupby_multiple_numeric_column;
|
|
67
|
+
if (isGroup) {
|
|
81
68
|
_this.chart.scale('group_name', {
|
|
82
69
|
type: 'cat'
|
|
83
70
|
});
|
|
@@ -89,133 +76,172 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
89
76
|
}
|
|
90
77
|
});
|
|
91
78
|
var width = _this.chart.coordinateBBox.width;
|
|
92
|
-
var chartData
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
} else {
|
|
97
|
-
chartData = data;
|
|
98
|
-
}
|
|
99
|
-
var labelCount = chartData.length;
|
|
100
|
-
if (Math.floor(width / labelCount) <= 20) {
|
|
101
|
-
var displayLabels = getChartDisplayLabels(width, 20, chartData);
|
|
102
|
-
labelCount = displayLabels.length;
|
|
79
|
+
var chartData = isGroup ? getChartGroups(data) : data;
|
|
80
|
+
var ticks = _this.getTicks(chartData, width);
|
|
81
|
+
var labelCount = _this.getLabelCount(ticks, chartData);
|
|
82
|
+
if (ticks.length > 0) {
|
|
103
83
|
_this.chart.scale('name', {
|
|
104
84
|
type: 'cat',
|
|
105
|
-
ticks:
|
|
85
|
+
ticks: ticks
|
|
106
86
|
});
|
|
107
87
|
}
|
|
108
|
-
|
|
109
|
-
var table = getTableById(table_id);
|
|
110
|
-
var summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
111
|
-
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
112
|
-
}
|
|
113
|
-
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
114
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
115
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
116
|
-
}
|
|
88
|
+
var themeColors = _this.getThemeColors();
|
|
117
89
|
|
|
118
90
|
// set Coord type
|
|
119
91
|
_this.chart.coordinate('rect');
|
|
92
|
+
_this.handleAutoRange(data, summaryColumnData, summaryMethod);
|
|
93
|
+
if (isGroup) {
|
|
94
|
+
_this.drawLineGroup({
|
|
95
|
+
data: data,
|
|
96
|
+
currentTheme: currentTheme,
|
|
97
|
+
themeColors: themeColors
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
_this.drawLine({
|
|
101
|
+
summaryType: summaryType,
|
|
102
|
+
summaryMethod: summaryMethod,
|
|
103
|
+
chartBarColor: chartBarColor,
|
|
104
|
+
themeColors: themeColors
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
_this.setTooltip();
|
|
108
|
+
_this.setAxis(themeColors, labelCount);
|
|
109
|
+
_this.setTheme();
|
|
110
|
+
_this.setLegend(themeColors);
|
|
111
|
+
_this.chart.render();
|
|
112
|
+
_this.renderAxisLabel();
|
|
113
|
+
};
|
|
114
|
+
_this.initChartHandler = function () {
|
|
115
|
+
var isPreview = _this.props.isPreview;
|
|
116
|
+
var config = {
|
|
117
|
+
container: _this.container
|
|
118
|
+
};
|
|
119
|
+
if (isPreview) {
|
|
120
|
+
config.autoFit = true;
|
|
121
|
+
} else {
|
|
122
|
+
config.height = 400;
|
|
123
|
+
config.width = 700;
|
|
124
|
+
}
|
|
125
|
+
_this.chart = new Chart(config);
|
|
126
|
+
};
|
|
127
|
+
_this.handleAutoRange = function (data, summaryColumnData, summaryMethod) {
|
|
128
|
+
var _this$props$statItem = _this.props.statItem,
|
|
129
|
+
y_axis_auto_range = _this$props$statItem.y_axis_auto_range,
|
|
130
|
+
y_axis_min = _this$props$statItem.y_axis_min,
|
|
131
|
+
y_axis_max = _this$props$statItem.y_axis_max;
|
|
120
132
|
var valueScaleOptions = {
|
|
121
133
|
formatter: function formatter(value) {
|
|
122
|
-
return getNumberDisplayString(value,
|
|
134
|
+
return _this.getNumberDisplayString(value, summaryColumnData, summaryMethod);
|
|
123
135
|
}
|
|
124
136
|
};
|
|
137
|
+
|
|
138
|
+
// eslint-disable-next-line
|
|
125
139
|
if (y_axis_auto_range == undefined || y_axis_auto_range) {
|
|
126
|
-
valueScaleOptions = Object.assign(
|
|
140
|
+
valueScaleOptions = Object.assign(valueScaleOptions, {
|
|
127
141
|
nice: true
|
|
128
142
|
});
|
|
129
143
|
} else {
|
|
130
|
-
valueScaleOptions = Object.assign(
|
|
144
|
+
valueScaleOptions = Object.assign(valueScaleOptions, {
|
|
131
145
|
min: y_axis_min,
|
|
132
146
|
max: y_axis_max
|
|
133
147
|
});
|
|
148
|
+
|
|
134
149
|
// set the filter rule
|
|
135
150
|
_this.chart.filter('value', function (value) {
|
|
136
151
|
return value >= y_axis_min;
|
|
137
152
|
});
|
|
153
|
+
|
|
138
154
|
// filter the data
|
|
139
155
|
_this.chart.filterData(data);
|
|
140
156
|
}
|
|
141
157
|
_this.chart.scale({
|
|
142
158
|
value: valueScaleOptions
|
|
143
159
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
};
|
|
161
|
+
_this.drawLine = function (_ref) {
|
|
162
|
+
var summaryType = _ref.summaryType,
|
|
163
|
+
summaryMethod = _ref.summaryMethod,
|
|
164
|
+
chartBarColor = _ref.chartBarColor,
|
|
165
|
+
themeColors = _ref.themeColors;
|
|
166
|
+
var display_data = _this.props.statItem.display_data;
|
|
167
|
+
_this.chart.line().position('name*value').color(chartBarColor).tooltip('name*formatted_value', function (name, value) {
|
|
168
|
+
return {
|
|
169
|
+
value: value,
|
|
170
|
+
name: summaryType === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summaryMethod])
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
_this.chart.point().label(display_data ? 'value' : false, {
|
|
174
|
+
style: {
|
|
175
|
+
fontSize: _this.getLabelFontSize(),
|
|
176
|
+
fill: themeColors.textColor
|
|
158
177
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
};
|
|
186
|
-
});
|
|
187
|
-
_this.chart.point().label(display_data ? 'value' : false, {
|
|
188
|
-
style: {
|
|
189
|
-
fontSize: _this.getLabelFontSize(),
|
|
190
|
-
fill: themeColors.textColor
|
|
178
|
+
}).position('name*value').color(chartBarColor).shape('circle').size(3).style({
|
|
179
|
+
lineWidth: 1,
|
|
180
|
+
stroke: '#fff'
|
|
181
|
+
}).tooltip('name*formatted_value', function (name, value) {
|
|
182
|
+
return {
|
|
183
|
+
value: value,
|
|
184
|
+
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
185
|
+
title: summaryType === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summaryMethod])
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
_this.drawLineGroup = function (_ref2) {
|
|
190
|
+
var data = _ref2.data,
|
|
191
|
+
currentTheme = _ref2.currentTheme,
|
|
192
|
+
themeColors = _ref2.themeColors;
|
|
193
|
+
var _this$props$statItem2 = _this.props.statItem,
|
|
194
|
+
display_data = _this$props$statItem2.display_data,
|
|
195
|
+
color_option = _this$props$statItem2.color_option;
|
|
196
|
+
var groupColorCallback = currentTheme && currentTheme.colors;
|
|
197
|
+
// when the 'Group by' column is a 'single-select' column,
|
|
198
|
+
// and the user chooses to use the colors from the column.
|
|
199
|
+
if (color_option === USEABLE_COLOR_TYPES[1]) {
|
|
200
|
+
var groupColorMapping = {};
|
|
201
|
+
data.forEach(function (item) {
|
|
202
|
+
if (!groupColorMapping[item.group_name]) {
|
|
203
|
+
groupColorMapping[item.group_name] = item.color;
|
|
191
204
|
}
|
|
192
|
-
}).position('name*value').color(chartBarColor).shape('circle').size(3).style({
|
|
193
|
-
lineWidth: 1,
|
|
194
|
-
stroke: '#fff'
|
|
195
|
-
}).tooltip('name*value', function (name, value) {
|
|
196
|
-
return {
|
|
197
|
-
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
198
|
-
value: getNumberDisplayString(value, columnData),
|
|
199
|
-
title: summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method])
|
|
200
|
-
};
|
|
201
205
|
});
|
|
206
|
+
groupColorCallback = function groupColorCallback(group_name) {
|
|
207
|
+
return groupColorMapping[group_name];
|
|
208
|
+
};
|
|
202
209
|
}
|
|
210
|
+
_this.chart.scale({
|
|
211
|
+
group_name: {
|
|
212
|
+
type: 'cat'
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
_this.chart.line().position('name*value').color('group_name', groupColorCallback);
|
|
216
|
+
_this.chart.point().label(display_data ? 'formatted_value' : false, {
|
|
217
|
+
style: {
|
|
218
|
+
fontSize: _this.getLabelFontSize(),
|
|
219
|
+
fill: themeColors.textColor
|
|
220
|
+
}
|
|
221
|
+
}).position('name*value').size(3).color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name', function (name, value, group_name) {
|
|
222
|
+
return {
|
|
223
|
+
value: value,
|
|
224
|
+
title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
225
|
+
name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
|
|
226
|
+
};
|
|
227
|
+
}).shape('circle').style({
|
|
228
|
+
lineWidth: 1,
|
|
229
|
+
stroke: '#fff'
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
_this.setTooltip = function () {
|
|
203
233
|
_this.chart.tooltip({
|
|
204
234
|
showCrosshairs: true,
|
|
205
235
|
showTitle: true,
|
|
206
236
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
207
237
|
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
208
238
|
domStyles: {
|
|
209
|
-
'g2-tooltip':
|
|
210
|
-
|
|
211
|
-
backgroundColor: '#fff',
|
|
212
|
-
padding: '10px'
|
|
213
|
-
},
|
|
214
|
-
'tooltip-item': {
|
|
215
|
-
marginTop: '5px'
|
|
216
|
-
}
|
|
239
|
+
'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
240
|
+
'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
|
|
217
241
|
}
|
|
218
242
|
});
|
|
243
|
+
};
|
|
244
|
+
_this.setAxis = function (themeColors, labelCount) {
|
|
219
245
|
_this.chart.axis('name', {
|
|
220
246
|
line: {
|
|
221
247
|
style: themeColors.gridColor
|
|
@@ -227,16 +253,7 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
227
253
|
offset: 20,
|
|
228
254
|
autoRotate: true,
|
|
229
255
|
rotate: labelCount > 11 ? 0.3 : 0,
|
|
230
|
-
formatter:
|
|
231
|
-
var label = name;
|
|
232
|
-
if (name.length > 10) {
|
|
233
|
-
label = "".concat(name.slice(0, 10), "...");
|
|
234
|
-
}
|
|
235
|
-
if (name === '' || name === 'undefined') {
|
|
236
|
-
label = intl.get(EMPTY_NAME);
|
|
237
|
-
}
|
|
238
|
-
return label;
|
|
239
|
-
}
|
|
256
|
+
formatter: _this.labelFormatter
|
|
240
257
|
}
|
|
241
258
|
});
|
|
242
259
|
_this.chart.axis('value', {
|
|
@@ -253,6 +270,8 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
253
270
|
}
|
|
254
271
|
}
|
|
255
272
|
});
|
|
273
|
+
};
|
|
274
|
+
_this.setTheme = function () {
|
|
256
275
|
_this.chart.theme({
|
|
257
276
|
geometries: {
|
|
258
277
|
point: {
|
|
@@ -267,6 +286,8 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
267
286
|
}
|
|
268
287
|
}
|
|
269
288
|
});
|
|
289
|
+
};
|
|
290
|
+
_this.setLegend = function (themeColors) {
|
|
270
291
|
_this.chart.legend('group_name', {
|
|
271
292
|
position: 'bottom',
|
|
272
293
|
itemName: {
|
|
@@ -292,16 +313,11 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
292
313
|
}
|
|
293
314
|
}
|
|
294
315
|
});
|
|
295
|
-
_this.chart.render();
|
|
296
|
-
_this.renderAxisLabel();
|
|
297
316
|
};
|
|
298
317
|
_this.renderAxisLabel = function (newStatItem) {
|
|
299
318
|
var _this$props2 = _this.props,
|
|
300
319
|
getTableById = _this$props2.getTableById,
|
|
301
|
-
statItem = _this$props2.statItem
|
|
302
|
-
isEnlarge = _this$props2.isEnlarge,
|
|
303
|
-
isPreview = _this$props2.isPreview,
|
|
304
|
-
theme = _this$props2.theme;
|
|
320
|
+
statItem = _this$props2.statItem;
|
|
305
321
|
if (newStatItem && newStatItem._id !== statItem._id) {
|
|
306
322
|
return;
|
|
307
323
|
}
|
|
@@ -318,10 +334,7 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
318
334
|
y_axis_summary_type = _statItem.y_axis_summary_type;
|
|
319
335
|
var table = getTableById(table_id);
|
|
320
336
|
var autoPadding = _this.chart.autoPadding;
|
|
321
|
-
var textColor =
|
|
322
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
323
|
-
textColor = '#ffffff';
|
|
324
|
-
}
|
|
337
|
+
var textColor = _this.getAxisLabelColor();
|
|
325
338
|
var xAxisID = "chart-x-axis-label_".concat(statItem._id);
|
|
326
339
|
var chartContainer = _this.chart.getCanvas().get('container');
|
|
327
340
|
var xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
@@ -375,11 +388,6 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
375
388
|
_this.chart.destroy();
|
|
376
389
|
_this.chart = null;
|
|
377
390
|
};
|
|
378
|
-
_this.getLabelFontSize = function () {
|
|
379
|
-
var statItem = _this.props.statItem;
|
|
380
|
-
var label_font_size = statItem.label_font_size;
|
|
381
|
-
return getLabelFontSize(label_font_size);
|
|
382
|
-
};
|
|
383
391
|
_this.state = {
|
|
384
392
|
isCalculatingData: true,
|
|
385
393
|
showResultDescription: true
|
|
@@ -486,13 +494,9 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
486
494
|
var style = {
|
|
487
495
|
padding: show_y_axis_label || show_x_axis_label ? 30 : 20
|
|
488
496
|
};
|
|
489
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
className: 'statistic-chart-text'
|
|
493
|
-
}, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
|
|
494
|
-
ref: function ref(_ref) {
|
|
495
|
-
return _this4.container = _ref;
|
|
497
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
498
|
+
ref: function ref(_ref3) {
|
|
499
|
+
return _this4.container = _ref3;
|
|
496
500
|
},
|
|
497
501
|
style: style,
|
|
498
502
|
className: "statistic-chart-container"
|
package/es/stat-view/map.js
CHANGED
|
@@ -5,11 +5,10 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import DataSet from '@antv/data-set/lib/index';
|
|
8
|
-
import { TableUtils
|
|
8
|
+
import { TableUtils } from 'dtable-store';
|
|
9
9
|
import BaseChart from './base-chart';
|
|
10
10
|
import { Chart } from '../custom-g2';
|
|
11
|
-
import {
|
|
12
|
-
import { COLOR_OPTIONS, DEFAULT_NUMBER_FORMAT_OBJECT, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE } from '../constants';
|
|
11
|
+
import { COLOR_OPTIONS, DEFAULT_NUMBER_FORMAT_OBJECT, SUMMARY_TYPE } from '../constants';
|
|
13
12
|
var WIDTH = 798;
|
|
14
13
|
var HEIGHT = 520;
|
|
15
14
|
var Map = /*#__PURE__*/function (_BaseChart) {
|
|
@@ -33,7 +32,8 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
33
32
|
if (matchFeature) {
|
|
34
33
|
statisticNewData.push({
|
|
35
34
|
name: matchFeature.properties.name,
|
|
36
|
-
value: item.value || 0
|
|
35
|
+
value: item.value || 0,
|
|
36
|
+
formatted_value: item.formatted_value
|
|
37
37
|
});
|
|
38
38
|
if (type === 'map_bubble') {
|
|
39
39
|
sum += item.value;
|
|
@@ -49,10 +49,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
49
49
|
_this.renderCommonMap = function (data) {
|
|
50
50
|
var _this$props = _this.props,
|
|
51
51
|
getTableById = _this$props.getTableById,
|
|
52
|
-
statItem = _this$props.statItem
|
|
53
|
-
theme = _this$props.theme,
|
|
54
|
-
isEnlarge = _this$props.isEnlarge,
|
|
55
|
-
isPreview = _this$props.isPreview;
|
|
52
|
+
statItem = _this$props.statItem;
|
|
56
53
|
var userDataView = _this.dataSet.getView('statisticViewModel').source(data).transform({
|
|
57
54
|
geoDataView: _this.dataSet.getView('mapDataModel'),
|
|
58
55
|
field: 'name',
|
|
@@ -63,6 +60,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
63
60
|
table_id = _this$props$statItem.table_id,
|
|
64
61
|
data_color = _this$props$statItem.data_color,
|
|
65
62
|
summary_type = _this$props$statItem.summary_type,
|
|
63
|
+
summary_method = _this$props$statItem.summary_method,
|
|
66
64
|
summary_column = _this$props$statItem.summary_column;
|
|
67
65
|
var currentColorOption = COLOR_OPTIONS.filter(function (item) {
|
|
68
66
|
return item.name == data_color;
|
|
@@ -88,17 +86,14 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
88
86
|
stroke: highlightedBorderColor
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
|
-
}).tooltip('name*
|
|
89
|
+
}).tooltip('name*formatted_value*color', function (name, value, color) {
|
|
92
90
|
return {
|
|
93
91
|
name: name,
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
color: color,
|
|
93
|
+
value: value
|
|
96
94
|
};
|
|
97
95
|
});
|
|
98
|
-
var themeColors =
|
|
99
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
100
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
101
|
-
}
|
|
96
|
+
var themeColors = _this.getThemeColors();
|
|
102
97
|
var legendDirection = statItem.legend_direction || 'vertical';
|
|
103
98
|
var size = statItem.legend_size || 1;
|
|
104
99
|
_this.chart.legend({
|
|
@@ -115,7 +110,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
115
110
|
},
|
|
116
111
|
align: legendDirection === 'vertical' ? 'right' : 'bottom',
|
|
117
112
|
formatter: function formatter(value) {
|
|
118
|
-
return getNumberDisplayString(value, columnData);
|
|
113
|
+
return _this.getNumberDisplayString(value, columnData, summary_method);
|
|
119
114
|
}
|
|
120
115
|
},
|
|
121
116
|
handler: {
|
|
@@ -150,9 +145,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
150
145
|
var _this$props2 = _this.props,
|
|
151
146
|
getTableById = _this$props2.getTableById,
|
|
152
147
|
statItem = _this$props2.statItem,
|
|
153
|
-
isPreview = _this$props2.isPreview
|
|
154
|
-
isEnlarge = _this$props2.isEnlarge,
|
|
155
|
-
theme = _this$props2.theme;
|
|
148
|
+
isPreview = _this$props2.isPreview;
|
|
156
149
|
var userDv = _this.dataSet.createView().source(data).transform({
|
|
157
150
|
geoDataView: _this.dataSet.getView('mapDataModel'),
|
|
158
151
|
field: 'name',
|
|
@@ -162,6 +155,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
162
155
|
var _this$props$statItem2 = _this.props.statItem,
|
|
163
156
|
table_id = _this$props$statItem2.table_id,
|
|
164
157
|
summary_type = _this$props$statItem2.summary_type,
|
|
158
|
+
summary_method = _this$props$statItem2.summary_method,
|
|
165
159
|
summary_column = _this$props$statItem2.summary_column;
|
|
166
160
|
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
167
161
|
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
@@ -178,11 +172,11 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
178
172
|
size = 60;
|
|
179
173
|
}
|
|
180
174
|
return size;
|
|
181
|
-
}).shape('circle').color(statItem.bubble_color || '#2a67d1').tooltip('name*
|
|
175
|
+
}).shape('circle').color(statItem.bubble_color || '#2a67d1').tooltip('name*formatted_value*color', function (name, value, color) {
|
|
182
176
|
return {
|
|
183
177
|
name: name,
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
color: color,
|
|
179
|
+
value: value
|
|
186
180
|
};
|
|
187
181
|
}).style({
|
|
188
182
|
fillOpacity: 0.6,
|
|
@@ -196,10 +190,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
196
190
|
}
|
|
197
191
|
}
|
|
198
192
|
});
|
|
199
|
-
var themeColors =
|
|
200
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
201
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
202
|
-
}
|
|
193
|
+
var themeColors = _this.getThemeColors();
|
|
203
194
|
var legendDirection = statItem.legend_direction || 'vertical';
|
|
204
195
|
var size = statItem.legend_size || 1;
|
|
205
196
|
_this.chart.legend({
|
|
@@ -215,7 +206,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
215
206
|
},
|
|
216
207
|
align: legendDirection === 'vertical' ? 'right' : 'bottom',
|
|
217
208
|
formatter: function formatter(value) {
|
|
218
|
-
return getNumberDisplayString(value, columnData);
|
|
209
|
+
return _this.getNumberDisplayString(value, columnData, summary_method);
|
|
219
210
|
}
|
|
220
211
|
},
|
|
221
212
|
handler: {
|
|
@@ -269,14 +260,8 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
269
260
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
270
261
|
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{name}<div><div class="tooltip-item">数量: {value}<div></div>',
|
|
271
262
|
domStyles: {
|
|
272
|
-
'g2-tooltip':
|
|
273
|
-
|
|
274
|
-
backgroundColor: '#fff',
|
|
275
|
-
padding: '10px'
|
|
276
|
-
},
|
|
277
|
-
'tooltip-item': {
|
|
278
|
-
marginTop: '5px'
|
|
279
|
-
}
|
|
263
|
+
'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
264
|
+
'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
|
|
280
265
|
}
|
|
281
266
|
});
|
|
282
267
|
_this.chart.scale({
|
|
@@ -332,6 +317,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
332
317
|
isDataLoaded: true
|
|
333
318
|
}, function () {
|
|
334
319
|
if (!data) return;
|
|
320
|
+
_this2.geoData = data;
|
|
335
321
|
_this2.initStatisticContext(data);
|
|
336
322
|
if (_this2.container) {
|
|
337
323
|
chartCalculator.calculate(statItem).then(function (data) {
|
|
@@ -371,6 +357,10 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
371
357
|
isCalculatingData: true
|
|
372
358
|
});
|
|
373
359
|
if (this.container) {
|
|
360
|
+
if (this.chart) {
|
|
361
|
+
this.chart.destroy();
|
|
362
|
+
this.initStatisticContext(this.geoData);
|
|
363
|
+
}
|
|
374
364
|
chartCalculator.calculate(statItem).then(function (statData) {
|
|
375
365
|
_this3.calculateData = statData;
|
|
376
366
|
_this3.setState({
|
|
@@ -404,9 +394,7 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
404
394
|
var _this$state = this.state,
|
|
405
395
|
isDataLoaded = _this$state.isDataLoaded,
|
|
406
396
|
isCalculatingData = _this$state.isCalculatingData;
|
|
407
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, (!isDataLoaded || isCalculatingData) && /*#__PURE__*/React.createElement("div", {
|
|
408
|
-
className: 'statistic-chart-loading-container'
|
|
409
|
-
}, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
|
|
397
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, (!isDataLoaded || isCalculatingData) && this.renderLoading(), /*#__PURE__*/React.createElement("div", {
|
|
410
398
|
ref: function ref(_ref) {
|
|
411
399
|
return _this4.container = _ref;
|
|
412
400
|
},
|
|
@@ -418,8 +406,6 @@ var Map = /*#__PURE__*/function (_BaseChart) {
|
|
|
418
406
|
}(BaseChart);
|
|
419
407
|
Map.propTypes = {
|
|
420
408
|
isPreview: PropTypes.bool,
|
|
421
|
-
isEnlarge: PropTypes.bool,
|
|
422
|
-
theme: PropTypes.string,
|
|
423
409
|
statItem: PropTypes.object,
|
|
424
410
|
chartCalculator: PropTypes.object,
|
|
425
411
|
getTableById: PropTypes.func,
|