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.
- 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/model/ring.js +3 -2
- 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/pivot-table-settings.js +4 -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 +81 -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 +207 -231
- 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/pivot-table/two-dimension-table.js +98 -31
- 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 +29 -12
- package/es/utils/sql-utils.js +10 -9
- package/es/utils/stat-utils.js +23 -15
- package/es/utils/trend-utils.js +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import React, { Component } from 'react';
|
|
|
6
6
|
import intl from 'react-intl-universal';
|
|
7
7
|
import Icon from '../../../../components/icon';
|
|
8
8
|
import StatisticTypesDialog from '../../../../components/dialog/statistic-types-dialog';
|
|
9
|
-
import { STATISTIC_TYPE_SHOW } from '../../../../constants';
|
|
9
|
+
import { STATISTIC_TYPE_SHOW, STAT_TYPE } from '../../../../constants';
|
|
10
10
|
import './index.css';
|
|
11
11
|
var TypeSettings = /*#__PURE__*/function (_Component) {
|
|
12
12
|
_inherits(TypeSettings, _Component);
|
|
@@ -25,6 +25,27 @@ var TypeSettings = /*#__PURE__*/function (_Component) {
|
|
|
25
25
|
isShowDialog: false
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
+
_this.getChartTypeName = function () {
|
|
29
|
+
var chartType = _this.props.chart.type;
|
|
30
|
+
switch (chartType) {
|
|
31
|
+
case STAT_TYPE.MAP:
|
|
32
|
+
{
|
|
33
|
+
return '中国地图';
|
|
34
|
+
}
|
|
35
|
+
case STAT_TYPE.MAP_BUBBLE:
|
|
36
|
+
{
|
|
37
|
+
return '中国地图(气泡图)';
|
|
38
|
+
}
|
|
39
|
+
case STAT_TYPE.WORLD_MAP_BUBBLE:
|
|
40
|
+
{
|
|
41
|
+
return "".concat(intl.get(STATISTIC_TYPE_SHOW[STAT_TYPE.WORLD_MAP]), "(").concat(intl.get('Bubble'), ")");
|
|
42
|
+
}
|
|
43
|
+
default:
|
|
44
|
+
{
|
|
45
|
+
return intl.get(STATISTIC_TYPE_SHOW[chartType]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
28
49
|
_this.state = {
|
|
29
50
|
isShowDialog: false
|
|
30
51
|
};
|
|
@@ -40,7 +61,7 @@ var TypeSettings = /*#__PURE__*/function (_Component) {
|
|
|
40
61
|
className: "statistic-chart-parameter-item"
|
|
41
62
|
}, /*#__PURE__*/React.createElement("label", null, intl.get('Chart_type')), /*#__PURE__*/React.createElement("div", {
|
|
42
63
|
className: "statistic-selected-type-container d-flex align-items-center"
|
|
43
|
-
}, /*#__PURE__*/React.createElement("span", null,
|
|
64
|
+
}, /*#__PURE__*/React.createElement("span", null, this.getChartTypeName()), /*#__PURE__*/React.createElement("div", {
|
|
44
65
|
className: "statistic-switch-type-container",
|
|
45
66
|
onClick: this.openTypesDialog
|
|
46
67
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
@@ -70,7 +69,7 @@ var ChartPreview = /*#__PURE__*/function (_Component) {
|
|
|
70
69
|
};
|
|
71
70
|
_this.renderChart = function (statItem) {
|
|
72
71
|
var _this$props = _this.props,
|
|
73
|
-
|
|
72
|
+
dtableChangedTime = _this$props.dtableChangedTime,
|
|
74
73
|
chartCalculator = _this$props.chartCalculator,
|
|
75
74
|
theme = _this$props.theme,
|
|
76
75
|
colorThemeName = _this$props.colorThemeName,
|
|
@@ -80,11 +79,11 @@ var ChartPreview = /*#__PURE__*/function (_Component) {
|
|
|
80
79
|
return _this.chartView = _ref;
|
|
81
80
|
},
|
|
82
81
|
isPreview: true,
|
|
83
|
-
|
|
82
|
+
dtableChangedTime: dtableChangedTime,
|
|
84
83
|
isEnlarge: false,
|
|
85
84
|
theme: theme,
|
|
86
85
|
colorThemeName: colorThemeName,
|
|
87
|
-
statItem:
|
|
86
|
+
statItem: statItem,
|
|
88
87
|
chartCalculator: chartCalculator,
|
|
89
88
|
eventBus: eventBus,
|
|
90
89
|
getTableById: _this.props.getTableById,
|
package/es/stat-list/index.js
CHANGED
|
@@ -24,6 +24,12 @@ var StatList = /*#__PURE__*/function (_Component) {
|
|
|
24
24
|
_this = _super.call(this, props);
|
|
25
25
|
_this.getStatItemsLayout = function (statItems) {
|
|
26
26
|
return Array.isArray(statItems) ? statItems.map(function (chart) {
|
|
27
|
+
// eslint-disable-next-line
|
|
28
|
+
if (chart.layout.y == null) {
|
|
29
|
+
return _objectSpread(_objectSpread({}, chart.layout), {}, {
|
|
30
|
+
y: Infinity
|
|
31
|
+
});
|
|
32
|
+
}
|
|
27
33
|
return chart.layout;
|
|
28
34
|
}) : [];
|
|
29
35
|
};
|
|
@@ -183,7 +189,7 @@ var StatList = /*#__PURE__*/function (_Component) {
|
|
|
183
189
|
var _this2 = this;
|
|
184
190
|
var _this$props = this.props,
|
|
185
191
|
isTableReadOnly = _this$props.isTableReadOnly,
|
|
186
|
-
|
|
192
|
+
dtableChangedTime = _this$props.dtableChangedTime,
|
|
187
193
|
theme = _this$props.theme,
|
|
188
194
|
colorThemeName = _this$props.colorThemeName,
|
|
189
195
|
statItems = _this$props.statItems,
|
|
@@ -219,10 +225,10 @@ var StatList = /*#__PURE__*/function (_Component) {
|
|
|
219
225
|
className: "statistic-chart-preview"
|
|
220
226
|
}, /*#__PURE__*/React.createElement(ChartPreview, {
|
|
221
227
|
isTableReadOnly: isTableReadOnly,
|
|
222
|
-
|
|
228
|
+
dtableChangedTime: dtableChangedTime,
|
|
223
229
|
theme: theme,
|
|
224
230
|
colorThemeName: colorThemeName,
|
|
225
|
-
statItem:
|
|
231
|
+
statItem: statItem,
|
|
226
232
|
chartCalculator: chartCalculator,
|
|
227
233
|
eventBus: eventBus,
|
|
228
234
|
getTableById: _this2.props.getTableById,
|
|
@@ -245,7 +251,7 @@ var StatList = /*#__PURE__*/function (_Component) {
|
|
|
245
251
|
toggleStatisticRecordsDialog: _this2.props.toggleStatisticRecordsDialog
|
|
246
252
|
}));
|
|
247
253
|
})), enlargedChart && /*#__PURE__*/React.createElement(EnlargeChartDialog, {
|
|
248
|
-
|
|
254
|
+
dtableChangedTime: dtableChangedTime,
|
|
249
255
|
colorThemeName: colorThemeName,
|
|
250
256
|
statItem: enlargedChart,
|
|
251
257
|
eventBus: eventBus,
|
|
@@ -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, TYPE_COLOR_USING } 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, TYPE_COLOR_USING } 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,
|
|
@@ -31,34 +28,12 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
31
28
|
var _this;
|
|
32
29
|
_classCallCheck(this, AreaChart);
|
|
33
30
|
_this = _super.call(this, props);
|
|
34
|
-
_this.getLabelFontSize = function () {
|
|
35
|
-
var statItem = _this.props.statItem;
|
|
36
|
-
var label_font_size = statItem.label_font_size;
|
|
37
|
-
return getLabelFontSize(label_font_size);
|
|
38
|
-
};
|
|
39
31
|
_this.drawChart = function (data) {
|
|
40
32
|
var _this$props = _this.props,
|
|
41
33
|
getTableById = _this$props.getTableById,
|
|
42
|
-
isPreview = _this$props.isPreview,
|
|
43
34
|
statItem = _this$props.statItem,
|
|
44
|
-
isEnlarge = _this$props.isEnlarge,
|
|
45
|
-
theme = _this$props.theme,
|
|
46
35
|
colorThemeName = _this$props.colorThemeName;
|
|
47
|
-
|
|
48
|
-
if (isPreview) {
|
|
49
|
-
_this.chart = new Chart({
|
|
50
|
-
container: _this.container,
|
|
51
|
-
autoFit: true,
|
|
52
|
-
appendPadding: [3, 0, 0, 0]
|
|
53
|
-
});
|
|
54
|
-
} else {
|
|
55
|
-
_this.chart = new Chart({
|
|
56
|
-
container: _this.container,
|
|
57
|
-
height: 400,
|
|
58
|
-
width: 700,
|
|
59
|
-
appendPadding: [3, 0, 0, 0]
|
|
60
|
-
});
|
|
61
|
-
}
|
|
36
|
+
_this.initChartHandler();
|
|
62
37
|
_this.chart.on('element:click', function (e) {
|
|
63
38
|
var areaElement = e.target.get('element');
|
|
64
39
|
var data = areaElement.data;
|
|
@@ -66,26 +41,23 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
66
41
|
_this.props.toggleStatisticRecordsDialog(data, statItem);
|
|
67
42
|
}
|
|
68
43
|
});
|
|
44
|
+
var currentTheme = getCurrentTheme(colorThemeName);
|
|
69
45
|
var table_id = statItem.table_id,
|
|
70
|
-
|
|
46
|
+
y_axis_summary_type = statItem.y_axis_summary_type,
|
|
71
47
|
y_axis_column_key = statItem.y_axis_column_key,
|
|
72
|
-
summary_method = statItem.y_axis_summary_method,
|
|
73
48
|
column_groupby_column_key = statItem.column_groupby_column_key,
|
|
74
|
-
display_data = statItem.display_data,
|
|
75
|
-
y_axis_auto_range = statItem.y_axis_auto_range,
|
|
76
|
-
y_axis_min = statItem.y_axis_min,
|
|
77
|
-
y_axis_max = statItem.y_axis_max,
|
|
78
49
|
column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column,
|
|
79
50
|
color_option = statItem.color_option;
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
if (
|
|
51
|
+
var isGroup = column_groupby_column_key || column_groupby_multiple_numeric_column;
|
|
52
|
+
var summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
53
|
+
if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
83
54
|
var table = getTableById(table_id);
|
|
84
55
|
var summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
85
|
-
|
|
56
|
+
summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
86
57
|
}
|
|
87
58
|
var groupColorMapping = null;
|
|
88
|
-
|
|
59
|
+
var chartBarColor = '#2a67d1';
|
|
60
|
+
if (isGroup) {
|
|
89
61
|
chartBarColor = currentTheme && currentTheme.colors;
|
|
90
62
|
if (color_option === TYPE_COLOR_USING.USE_COLUMN_COLORS) {
|
|
91
63
|
// when the 'Group by' column is a 'single-select' column,
|
|
@@ -105,8 +77,6 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
105
77
|
});
|
|
106
78
|
} else if (currentTheme && currentTheme.colors) {
|
|
107
79
|
chartBarColor = currentTheme.colors[0];
|
|
108
|
-
} else {
|
|
109
|
-
chartBarColor = '#2a67d1';
|
|
110
80
|
}
|
|
111
81
|
_this.chart.data(data, {
|
|
112
82
|
'name': {
|
|
@@ -114,131 +84,194 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
114
84
|
nice: false
|
|
115
85
|
}
|
|
116
86
|
});
|
|
87
|
+
var chartData = isGroup ? getChartGroups(data) : data;
|
|
117
88
|
var width = _this.chart.coordinateBBox.width;
|
|
118
|
-
var chartData;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
} else {
|
|
122
|
-
chartData = data;
|
|
123
|
-
}
|
|
124
|
-
var labelCount = chartData.length;
|
|
125
|
-
if (Math.floor(width / labelCount) <= 20) {
|
|
126
|
-
var displayLabels = getChartDisplayLabels(width, 20, chartData);
|
|
127
|
-
labelCount = displayLabels.length;
|
|
89
|
+
var ticks = _this.getTicks(chartData, width);
|
|
90
|
+
var labelCount = _this.getLabelCount(ticks, chartData);
|
|
91
|
+
if (ticks.length > 0) {
|
|
128
92
|
_this.chart.scale('name', {
|
|
129
93
|
type: 'cat',
|
|
130
|
-
ticks:
|
|
94
|
+
ticks: ticks
|
|
131
95
|
});
|
|
132
96
|
}
|
|
133
|
-
var themeColors =
|
|
134
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
135
|
-
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
136
|
-
}
|
|
97
|
+
var themeColors = _this.getThemeColors();
|
|
137
98
|
|
|
138
99
|
// set Coord type
|
|
139
100
|
_this.chart.coordinate('rect');
|
|
101
|
+
_this.handleAutoRange(data, summaryColumnData);
|
|
102
|
+
|
|
103
|
+
// draw line
|
|
104
|
+
if (isGroup) {
|
|
105
|
+
_this.drawLineGroup({
|
|
106
|
+
chartBarColor: chartBarColor,
|
|
107
|
+
themeColors: themeColors
|
|
108
|
+
});
|
|
109
|
+
} else {
|
|
110
|
+
_this.drawLine({
|
|
111
|
+
chartBarColor: chartBarColor,
|
|
112
|
+
themeColors: themeColors
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// draw area
|
|
117
|
+
if (isGroup) {
|
|
118
|
+
_this.drawAreaGroup({
|
|
119
|
+
chartBarColor: chartBarColor
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
_this.drawArea({
|
|
123
|
+
chartBarColor: chartBarColor
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
_this.setTooltip();
|
|
127
|
+
_this.setAxis(themeColors, labelCount);
|
|
128
|
+
_this.setTheme();
|
|
129
|
+
_this.setLegend(themeColors);
|
|
130
|
+
_this.chart.render();
|
|
131
|
+
_this.renderAxisLabel();
|
|
132
|
+
};
|
|
133
|
+
_this.initChartHandler = function () {
|
|
134
|
+
var isPreview = _this.props.isPreview;
|
|
135
|
+
var config = {
|
|
136
|
+
container: _this.container,
|
|
137
|
+
autoFit: true,
|
|
138
|
+
appendPadding: [3, 0, 0, 0]
|
|
139
|
+
};
|
|
140
|
+
if (!isPreview) {
|
|
141
|
+
config.height = 400;
|
|
142
|
+
config.width = 700;
|
|
143
|
+
}
|
|
144
|
+
_this.chart = new Chart(config);
|
|
145
|
+
};
|
|
146
|
+
_this.drawLine = function (_ref) {
|
|
147
|
+
var chartBarColor = _ref.chartBarColor,
|
|
148
|
+
themeColors = _ref.themeColors;
|
|
149
|
+
var _this$props$statItem = _this.props.statItem,
|
|
150
|
+
y_axis_summary_type = _this$props$statItem.y_axis_summary_type,
|
|
151
|
+
y_axis_summary_method = _this$props$statItem.y_axis_summary_method,
|
|
152
|
+
display_data = _this$props$statItem.display_data;
|
|
153
|
+
_this.chart.line().position('name*value').color(chartBarColor).tooltip('name*formatted_value', function (name, value) {
|
|
154
|
+
return {
|
|
155
|
+
value: value,
|
|
156
|
+
name: y_axis_summary_type === SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_summary_method])
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
_this.chart.point().label(display_data ? 'formatted_value' : false, {
|
|
160
|
+
style: {
|
|
161
|
+
fontSize: _this.getLabelFontSize(),
|
|
162
|
+
fill: themeColors.textColor
|
|
163
|
+
}
|
|
164
|
+
}).position('name*value').color(chartBarColor).shape('circle').size(3).style({
|
|
165
|
+
lineWidth: 1,
|
|
166
|
+
stroke: '#fff'
|
|
167
|
+
}).tooltip('name*formatted_value', function (name, value) {
|
|
168
|
+
return {
|
|
169
|
+
value: value,
|
|
170
|
+
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
171
|
+
title: y_axis_summary_type === SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_summary_method])
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
_this.drawLineGroup = function (_ref2) {
|
|
176
|
+
var chartBarColor = _ref2.chartBarColor,
|
|
177
|
+
themeColors = _ref2.themeColors;
|
|
178
|
+
var display_data = _this.props.statItem.display_data;
|
|
179
|
+
_this.chart.scale({
|
|
180
|
+
group_name: {
|
|
181
|
+
type: 'cat'
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
_this.chart.line().position('name*value').color('group_name', chartBarColor);
|
|
185
|
+
_this.chart.point().label(display_data ? 'formatted_value' : false, {
|
|
186
|
+
style: {
|
|
187
|
+
fontSize: _this.getLabelFontSize(),
|
|
188
|
+
fill: themeColors.textColor
|
|
189
|
+
}
|
|
190
|
+
}).position('name*value').size(3).color('group_name', chartBarColor).tooltip('name*formatted_value*group_name', function (name, value, group_name) {
|
|
191
|
+
return {
|
|
192
|
+
value: value,
|
|
193
|
+
title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
194
|
+
name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
|
|
195
|
+
};
|
|
196
|
+
}).shape('circle').style({
|
|
197
|
+
lineWidth: 1,
|
|
198
|
+
stroke: '#fff'
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
_this.drawArea = function (_ref3) {
|
|
202
|
+
var chartBarColor = _ref3.chartBarColor;
|
|
203
|
+
var _this$props$statItem2 = _this.props.statItem,
|
|
204
|
+
y_axis_summary_type = _this$props$statItem2.y_axis_summary_type,
|
|
205
|
+
y_axis_summary_method = _this$props$statItem2.y_axis_summary_method;
|
|
206
|
+
_this.chart.area().position('name*value').color(chartBarColor).tooltip('name*formatted_value', function (name, value) {
|
|
207
|
+
return {
|
|
208
|
+
value: value,
|
|
209
|
+
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
210
|
+
title: y_axis_summary_type === SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_summary_method])
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
_this.drawAreaGroup = function (_ref4) {
|
|
215
|
+
var chartBarColor = _ref4.chartBarColor;
|
|
216
|
+
var _this$props$statItem3 = _this.props.statItem,
|
|
217
|
+
y_axis_summary_type = _this$props$statItem3.y_axis_summary_type,
|
|
218
|
+
y_axis_summary_method = _this$props$statItem3.y_axis_summary_method;
|
|
219
|
+
_this.chart.area().position('name*value').color('group_name', chartBarColor).tooltip('name*formatted_value', function (name, value) {
|
|
220
|
+
return {
|
|
221
|
+
value: value,
|
|
222
|
+
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
223
|
+
title: y_axis_summary_type === SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_summary_method])
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
_this.handleAutoRange = function (data, summaryColumnData) {
|
|
228
|
+
var _this$props$statItem4 = _this.props.statItem,
|
|
229
|
+
y_axis_auto_range = _this$props$statItem4.y_axis_auto_range,
|
|
230
|
+
y_axis_min = _this$props$statItem4.y_axis_min,
|
|
231
|
+
y_axis_max = _this$props$statItem4.y_axis_max,
|
|
232
|
+
y_axis_summary_method = _this$props$statItem4.y_axis_summary_method;
|
|
140
233
|
var valueScaleOptions = {
|
|
141
234
|
formatter: function formatter(value) {
|
|
142
|
-
return getNumberDisplayString(value,
|
|
235
|
+
return _this.getNumberDisplayString(value, summaryColumnData, y_axis_summary_method);
|
|
143
236
|
}
|
|
144
237
|
};
|
|
238
|
+
|
|
239
|
+
// eslint-disable-next-line
|
|
145
240
|
if (y_axis_auto_range == undefined || y_axis_auto_range) {
|
|
146
|
-
valueScaleOptions = Object.assign(
|
|
241
|
+
valueScaleOptions = Object.assign(valueScaleOptions, {
|
|
147
242
|
nice: true
|
|
148
243
|
});
|
|
149
244
|
} else {
|
|
150
|
-
valueScaleOptions = Object.assign(
|
|
245
|
+
valueScaleOptions = Object.assign(valueScaleOptions, {
|
|
151
246
|
min: y_axis_min,
|
|
152
247
|
max: y_axis_max
|
|
153
248
|
});
|
|
249
|
+
|
|
154
250
|
// set the filter rule
|
|
155
251
|
_this.chart.filter('value', function (value) {
|
|
156
252
|
return value >= y_axis_min;
|
|
157
253
|
});
|
|
254
|
+
|
|
158
255
|
// filter the data
|
|
159
256
|
_this.chart.filterData(data);
|
|
160
257
|
}
|
|
161
258
|
_this.chart.scale({
|
|
162
259
|
value: valueScaleOptions
|
|
163
260
|
});
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
group_name: {
|
|
167
|
-
type: 'cat'
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
_this.chart.line().position('name*value').color('group_name', chartBarColor);
|
|
171
|
-
_this.chart.point().label(display_data ? 'value' : false, {
|
|
172
|
-
style: {
|
|
173
|
-
fontSize: _this.getLabelFontSize(),
|
|
174
|
-
fill: themeColors.textColor
|
|
175
|
-
}
|
|
176
|
-
}).position('name*value').size(3).color('group_name', chartBarColor).tooltip('name*value*group_name', function (name, value, group_name) {
|
|
177
|
-
return {
|
|
178
|
-
title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
179
|
-
value: getNumberDisplayString(value, columnData),
|
|
180
|
-
name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
|
|
181
|
-
};
|
|
182
|
-
}).shape('circle').style({
|
|
183
|
-
lineWidth: 1,
|
|
184
|
-
stroke: '#fff'
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
_this.chart.line().position('name*value').color(chartBarColor).tooltip('name*value', function (name, value) {
|
|
188
|
-
return {
|
|
189
|
-
name: summary_type === SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method]),
|
|
190
|
-
value: getNumberDisplayString(value, columnData)
|
|
191
|
-
};
|
|
192
|
-
});
|
|
193
|
-
_this.chart.point().label(display_data ? 'value' : false, {
|
|
194
|
-
style: {
|
|
195
|
-
fontSize: _this.getLabelFontSize(),
|
|
196
|
-
fill: themeColors.textColor
|
|
197
|
-
}
|
|
198
|
-
}).position('name*value').color(chartBarColor).shape('circle').size(3).style({
|
|
199
|
-
lineWidth: 1,
|
|
200
|
-
stroke: '#fff'
|
|
201
|
-
}).tooltip('name*value', function (name, value) {
|
|
202
|
-
return {
|
|
203
|
-
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
204
|
-
value: getNumberDisplayString(value, columnData),
|
|
205
|
-
title: summary_type === SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method])
|
|
206
|
-
};
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
if (column_groupby_column_key || column_groupby_multiple_numeric_column) {
|
|
210
|
-
_this.chart.area().position('name*value').color('group_name', chartBarColor).tooltip('name*value', function (name, value) {
|
|
211
|
-
return {
|
|
212
|
-
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
213
|
-
value: getNumberDisplayString(value, columnData),
|
|
214
|
-
title: summary_type === SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method])
|
|
215
|
-
};
|
|
216
|
-
});
|
|
217
|
-
} else {
|
|
218
|
-
_this.chart.area().position('name*value').color(chartBarColor).tooltip('name*value', function (name, value) {
|
|
219
|
-
return {
|
|
220
|
-
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
221
|
-
value: getNumberDisplayString(value, columnData),
|
|
222
|
-
title: summary_type === SUMMARY_TYPE.COUNT ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summary_method])
|
|
223
|
-
};
|
|
224
|
-
});
|
|
225
|
-
}
|
|
261
|
+
};
|
|
262
|
+
_this.setTooltip = function () {
|
|
226
263
|
_this.chart.tooltip({
|
|
227
264
|
showCrosshairs: true,
|
|
228
265
|
showTitle: true,
|
|
229
266
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
230
267
|
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
231
268
|
domStyles: {
|
|
232
|
-
'g2-tooltip':
|
|
233
|
-
|
|
234
|
-
backgroundColor: '#fff',
|
|
235
|
-
padding: '10px'
|
|
236
|
-
},
|
|
237
|
-
'tooltip-item': {
|
|
238
|
-
marginTop: '5px'
|
|
239
|
-
}
|
|
269
|
+
'g2-tooltip': _this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
270
|
+
'tooltip-item': _this.getDefaultChartStyleByKey('tooltip-item')
|
|
240
271
|
}
|
|
241
272
|
});
|
|
273
|
+
};
|
|
274
|
+
_this.setAxis = function (themeColors, labelCount) {
|
|
242
275
|
_this.chart.axis('name', {
|
|
243
276
|
line: {
|
|
244
277
|
style: themeColors.gridColor
|
|
@@ -250,16 +283,7 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
250
283
|
offset: 20,
|
|
251
284
|
autoRotate: true,
|
|
252
285
|
rotate: labelCount > 11 ? 0.3 : 0,
|
|
253
|
-
formatter:
|
|
254
|
-
var label = name;
|
|
255
|
-
if (name.length > 10) {
|
|
256
|
-
label = "".concat(name.slice(0, 10), "...");
|
|
257
|
-
}
|
|
258
|
-
if (name === '' || name === 'undefined') {
|
|
259
|
-
label = intl.get(EMPTY_NAME);
|
|
260
|
-
}
|
|
261
|
-
return label;
|
|
262
|
-
}
|
|
286
|
+
formatter: _this.labelFormatter
|
|
263
287
|
}
|
|
264
288
|
});
|
|
265
289
|
_this.chart.axis('value', {
|
|
@@ -276,6 +300,8 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
276
300
|
}
|
|
277
301
|
}
|
|
278
302
|
});
|
|
303
|
+
};
|
|
304
|
+
_this.setTheme = function () {
|
|
279
305
|
_this.chart.theme({
|
|
280
306
|
geometries: {
|
|
281
307
|
point: {
|
|
@@ -290,6 +316,8 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
290
316
|
}
|
|
291
317
|
}
|
|
292
318
|
});
|
|
319
|
+
};
|
|
320
|
+
_this.setLegend = function (themeColors) {
|
|
293
321
|
_this.chart.legend('group_name', {
|
|
294
322
|
position: 'bottom',
|
|
295
323
|
itemName: {
|
|
@@ -315,16 +343,11 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
315
343
|
}
|
|
316
344
|
}
|
|
317
345
|
});
|
|
318
|
-
_this.chart.render();
|
|
319
|
-
_this.renderAxisLabel();
|
|
320
346
|
};
|
|
321
347
|
_this.renderAxisLabel = function (newStatItem) {
|
|
322
348
|
var _this$props2 = _this.props,
|
|
323
349
|
getTableById = _this$props2.getTableById,
|
|
324
|
-
statItem = _this$props2.statItem
|
|
325
|
-
isEnlarge = _this$props2.isEnlarge,
|
|
326
|
-
isPreview = _this$props2.isPreview,
|
|
327
|
-
theme = _this$props2.theme;
|
|
350
|
+
statItem = _this$props2.statItem;
|
|
328
351
|
if (newStatItem && newStatItem._id !== statItem._id) {
|
|
329
352
|
return;
|
|
330
353
|
}
|
|
@@ -341,10 +364,7 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
341
364
|
y_axis_summary_type = _statItem.y_axis_summary_type;
|
|
342
365
|
var table = getTableById(table_id);
|
|
343
366
|
var autoPadding = _this.chart.autoPadding;
|
|
344
|
-
var textColor =
|
|
345
|
-
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
346
|
-
textColor = '#ffffff';
|
|
347
|
-
}
|
|
367
|
+
var textColor = _this.getAxisLabelColor();
|
|
348
368
|
var xAxisID = "chart-x-axis-label_".concat(statItem._id);
|
|
349
369
|
var chartContainer = _this.chart.getCanvas().get('container');
|
|
350
370
|
var xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
@@ -499,18 +519,13 @@ var AreaChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
499
519
|
showResultDescription = _this$state.showResultDescription;
|
|
500
520
|
var show_y_axis_label = statItem.show_y_axis_label,
|
|
501
521
|
show_x_axis_label = statItem.show_x_axis_label;
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
className: 'statistic-chart-text'
|
|
509
|
-
}, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
|
|
510
|
-
ref: function ref(_ref) {
|
|
511
|
-
return _this4.container = _ref;
|
|
522
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
523
|
+
ref: function ref(_ref5) {
|
|
524
|
+
return _this4.container = _ref5;
|
|
525
|
+
},
|
|
526
|
+
style: {
|
|
527
|
+
padding: show_y_axis_label || show_x_axis_label ? 30 : 20
|
|
512
528
|
},
|
|
513
|
-
style: style,
|
|
514
529
|
className: "statistic-chart-container"
|
|
515
530
|
}));
|
|
516
531
|
}
|