dtable-statistic 4.2.2 → 4.3.0
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/api/dtable-db-api.js +31 -37
- package/es/calculator/base-calculator.js +49 -99
- package/es/calculator/basic-chart-calculator.js +335 -559
- package/es/calculator/combination-calculator.js +231 -299
- package/es/calculator/compare-bar-calculator.js +184 -281
- package/es/calculator/completeness-calculator.js +203 -288
- package/es/calculator/copy-value.js +18 -18
- package/es/calculator/dashboard-calculator.js +68 -137
- package/es/calculator/heat-map-calculator.js +139 -220
- package/es/calculator/horizontal-bar-calculator.js +64 -93
- package/es/calculator/index.js +53 -69
- package/es/calculator/map-calculator.js +98 -174
- package/es/calculator/mirror-calculator.js +137 -216
- package/es/calculator/number-card-calculator.js +58 -126
- package/es/calculator/pivot-table-calculator.js +750 -792
- package/es/calculator/scatter-calculator.js +72 -140
- package/es/calculator/thread-manager.js +48 -67
- package/es/calculator/trend-calculator.js +107 -191
- package/es/calculator/workers/basic-chart-calculator-worker.js +194 -165
- package/es/calculator/workers/calculator.worker.js +22 -6
- package/es/calculator/workers/card-calculator-worker.js +16 -14
- package/es/calculator/workers/combination-calculator-worker.js +128 -135
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +80 -96
- package/es/calculator/workers/completeness-calculator-worker.js +56 -49
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -22
- package/es/calculator/workers/mirror-calculator-worker.js +52 -52
- package/es/calculator/workers/pivot-table-calculator-worker.js +247 -230
- package/es/calculator/workers/scatter-calculator-worker.js +34 -32
- package/es/calculator/workers/trend-calculator-worker.js +33 -29
- package/es/calculator/world-map-calculator.js +120 -197
- package/es/components/common-add-tool.js +7 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +67 -77
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +57 -67
- package/es/components/dialog/color-theme-dialog.js +34 -47
- package/es/components/dialog/delete-confirmation-dialog.js +7 -5
- package/es/components/dialog/enlarged-chart-dialog.js +68 -81
- package/es/components/dialog/new-table-dialog.js +62 -80
- package/es/components/dialog/new-view-dialog.js +50 -62
- package/es/components/dialog/rename-view-dialog.js +49 -58
- package/es/components/dialog/statistic-record-dialog/index.js +233 -231
- package/es/components/dialog/statistic-types-dialog/index.js +40 -49
- package/es/components/dialog/table-select-dialog.js +61 -70
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +129 -142
- package/es/components/dtable-popover.js +62 -81
- package/es/components/dtable-search-input.js +89 -99
- package/es/components/dtable-select.js +55 -74
- package/es/components/icon.js +5 -3
- package/es/components/loading.js +1 -1
- package/es/components/modal-portal.js +15 -32
- package/es/components/popover/color-rules/color-rule.js +137 -141
- package/es/components/popover/color-rules/index.js +58 -66
- package/es/components/popover/color-rules/rule-filters/filter.js +124 -124
- package/es/components/popover/color-rules/rule-filters/index.js +50 -58
- package/es/components/popover/color-rules/rule-filters/number-input.js +42 -57
- package/es/components/popover/color-rules-popover.js +117 -121
- package/es/components/popover/color-selector-popover.js +60 -70
- package/es/components/seatable-radio/index.js +2 -2
- package/es/components/select/option-group.js +139 -157
- package/es/components/select/option.js +26 -40
- package/es/components/select/select.js +97 -112
- package/es/components/toast/alert.js +65 -80
- package/es/components/toast/index.js +1 -1
- package/es/components/toast/toast.js +76 -103
- package/es/components/toast/toastManager.js +57 -93
- package/es/components/toast/toaster.js +58 -56
- package/es/constants/color-rules.js +8 -5
- package/es/constants/dtable-select-style.js +44 -48
- package/es/constants/event-types.js +4 -4
- package/es/constants/index.js +328 -242
- package/es/constants/map.js +2 -2
- package/es/constants/model.js +20 -20
- package/es/constants/regions.js +1 -1
- package/es/constants/zIndexes.js +1 -1
- package/es/custom-g2.js +11 -11
- package/es/dashboard.js +343 -333
- package/es/desktop-dashboard.js +217 -224
- package/es/index.js +45 -58
- package/es/locale/index.js +3 -3
- package/es/locale/lang/de.js +1 -1
- package/es/locale/lang/en.js +7 -7
- package/es/locale/lang/fr.js +1 -1
- package/es/locale/lang/zh_CN.js +1 -1
- package/es/mobile-dashboard.js +76 -89
- package/es/model/bar-group.js +34 -44
- package/es/model/bar.js +26 -36
- package/es/model/base-model.js +11 -12
- package/es/model/basic-number-card.js +10 -20
- package/es/model/collaborators.js +10 -11
- package/es/model/combination.js +32 -42
- package/es/model/compare-bar.js +30 -40
- package/es/model/completeness-group.js +19 -29
- package/es/model/completeness.js +14 -24
- package/es/model/custom-bar.js +14 -24
- package/es/model/dashboard.js +9 -19
- package/es/model/generic-model.js +187 -197
- package/es/model/heat-map.js +16 -26
- package/es/model/horizontal-bar-group.js +32 -42
- package/es/model/horizontal-bar.js +26 -36
- package/es/model/index.js +31 -3
- package/es/model/map.js +20 -30
- package/es/model/mirror.js +15 -25
- package/es/model/pie.js +21 -31
- package/es/model/ring.js +23 -33
- package/es/model/scatter.js +11 -21
- package/es/model/statistic-dashboard.js +7 -8
- package/es/model/table.js +19 -29
- package/es/model/trend.js +15 -25
- package/es/model/world-map.js +17 -27
- package/es/service/chart-service.js +69 -65
- package/es/service/dashboard-service.js +421 -419
- package/es/service/map-json.js +112 -132
- package/es/stat-editor/chart-name-editor.js +44 -58
- package/es/stat-editor/index.js +59 -70
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +93 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +246 -248
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +127 -126
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +5 -3
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +78 -90
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +146 -150
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +88 -98
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +100 -118
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +161 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +58 -66
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +58 -60
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +152 -148
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +101 -105
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +81 -91
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +110 -122
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +101 -113
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +130 -120
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +88 -102
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +200 -194
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +98 -110
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +106 -118
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +212 -223
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +109 -119
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +329 -319
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +82 -90
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +58 -65
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +126 -116
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +201 -182
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +79 -79
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +196 -175
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +35 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +180 -147
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +31 -40
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +56 -67
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +60 -69
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +165 -158
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +61 -74
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +199 -193
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +25 -38
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +79 -86
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +138 -120
- package/es/stat-editor/stat-settings/map/map-level.js +31 -43
- package/es/stat-editor/stat-settings/map/map-province-city.js +82 -83
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +48 -50
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +96 -96
- package/es/stat-editor/stat-settings/public-setting/calender.js +69 -75
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +5 -3
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +36 -41
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +37 -41
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +25 -38
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +40 -52
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +90 -93
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +23 -36
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +39 -44
- package/es/stat-list/chart-preview.js +85 -98
- package/es/stat-list/index.js +170 -178
- package/es/stat-view/area-chart.js +282 -274
- package/es/stat-view/bar-chart.js +300 -292
- package/es/stat-view/base-chart.js +58 -52
- package/es/stat-view/basic-number-card.js +115 -168
- package/es/stat-view/combination-chart.js +298 -334
- package/es/stat-view/compare-chart.js +256 -254
- package/es/stat-view/completeness-chart.js +194 -206
- package/es/stat-view/custom-bar.js +221 -223
- package/es/stat-view/dashboard-chart.js +122 -180
- package/es/stat-view/heat-map.js +268 -294
- package/es/stat-view/horizontal-bar-chart.js +291 -281
- package/es/stat-view/index.js +136 -152
- package/es/stat-view/line-chart.js +267 -265
- package/es/stat-view/map.js +246 -246
- package/es/stat-view/mirror.js +141 -152
- package/es/stat-view/pie-chart.js +143 -156
- package/es/stat-view/pivot-table/index.js +113 -118
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +104 -102
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +116 -118
- package/es/stat-view/pivot-table/pivot-table-display-name.js +96 -95
- package/es/stat-view/pivot-table/two-dimension-table.js +238 -229
- package/es/stat-view/ring-chart.js +189 -200
- package/es/stat-view/scatter-chart.js +162 -213
- package/es/stat-view/treemap-chart.js +136 -200
- package/es/stat-view/trend-chart.js +137 -183
- package/es/stat-view/world-map.js +233 -243
- package/es/tabs/index.js +164 -169
- package/es/tabs/tab.js +101 -116
- package/es/utils/basic-chart-utils.js +7 -9
- package/es/utils/cell-format.js +48 -51
- package/es/utils/cell-value.js +1 -1
- package/es/utils/collaborator.js +15 -14
- package/es/utils/color-utils.js +48 -37
- package/es/utils/column-utils.js +47 -33
- package/es/utils/column.js +1 -1
- package/es/utils/common-utils.js +111 -117
- package/es/utils/date-format.js +17 -17
- package/es/utils/export-table-utils.js +507 -396
- package/es/utils/index.js +6 -6
- package/es/utils/map.js +30 -34
- package/es/utils/model.js +3 -5
- package/es/utils/object.js +4 -4
- package/es/utils/pivot-table.js +20 -20
- package/es/utils/row-utils.js +41 -33
- package/es/utils/search.js +18 -20
- package/es/utils/sql-utils.js +132 -98
- package/es/utils/stat-utils.js +303 -320
- package/es/utils/trend-utils.js +57 -67
- package/package.json +2 -2
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
import PropTypes from 'prop-types';
|
|
7
3
|
import intl from 'react-intl-universal';
|
|
@@ -11,7 +7,7 @@ import { Chart } from '../custom-g2';
|
|
|
11
7
|
import { getCurrentTheme } from '../utils/common-utils';
|
|
12
8
|
import { getChartGroups } from '../utils/basic-chart-utils';
|
|
13
9
|
import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_CONFIG_CHANGED, STATISTICS_COUNT_SHOW, SUMMARY_TYPE, TITLE_AMOUNT, USEABLE_COLOR_TYPES } from '../constants';
|
|
14
|
-
|
|
10
|
+
const propTypes = {
|
|
15
11
|
isPreview: PropTypes.bool,
|
|
16
12
|
isEdit: PropTypes.bool,
|
|
17
13
|
colorThemeName: PropTypes.string,
|
|
@@ -21,35 +17,34 @@ var propTypes = {
|
|
|
21
17
|
getTableById: PropTypes.func,
|
|
22
18
|
toggleStatisticRecordsDialog: PropTypes.func
|
|
23
19
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
_this.chart.on('element:click', function (e) {
|
|
20
|
+
class LineChart extends BaseChart {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
super(props);
|
|
23
|
+
this.drawChart = data => {
|
|
24
|
+
const {
|
|
25
|
+
getTableById,
|
|
26
|
+
statItem,
|
|
27
|
+
colorThemeName
|
|
28
|
+
} = this.props;
|
|
29
|
+
const {
|
|
30
|
+
table_id,
|
|
31
|
+
summary_type,
|
|
32
|
+
y_axis_column_key,
|
|
33
|
+
y_axis_summary_type,
|
|
34
|
+
summary_method,
|
|
35
|
+
y_axis_summary_method,
|
|
36
|
+
column_groupby_column_key,
|
|
37
|
+
column_groupby_multiple_numeric_column
|
|
38
|
+
} = statItem;
|
|
39
|
+
this.initChartHandler();
|
|
40
|
+
this.chart.on('element:click', e => {
|
|
46
41
|
if (e.data && e.data.data) {
|
|
47
|
-
|
|
42
|
+
this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
48
43
|
}
|
|
49
44
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
let summaryType = summary_type;
|
|
46
|
+
let summaryMethod = summary_method;
|
|
47
|
+
let summaryColumnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
53
48
|
if (!summaryType && y_axis_summary_type) {
|
|
54
49
|
summaryType = y_axis_summary_type;
|
|
55
50
|
}
|
|
@@ -57,64 +52,68 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
57
52
|
summaryMethod = y_axis_summary_method;
|
|
58
53
|
}
|
|
59
54
|
if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
const table = getTableById(table_id);
|
|
56
|
+
const summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
62
57
|
summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
63
58
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
const currentTheme = getCurrentTheme(colorThemeName);
|
|
60
|
+
const chartBarColor = currentTheme && currentTheme.colors[0] || '#2a67d1';
|
|
61
|
+
const isGroup = column_groupby_column_key || column_groupby_multiple_numeric_column;
|
|
67
62
|
if (isGroup) {
|
|
68
|
-
|
|
63
|
+
this.chart.scale('group_name', {
|
|
69
64
|
type: 'cat'
|
|
70
65
|
});
|
|
71
66
|
}
|
|
72
|
-
|
|
67
|
+
this.chart.data(data, {
|
|
73
68
|
'name': {
|
|
74
69
|
type: 'cat',
|
|
75
70
|
nice: false
|
|
76
71
|
}
|
|
77
72
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
const {
|
|
74
|
+
width
|
|
75
|
+
} = this.chart.coordinateBBox;
|
|
76
|
+
const chartData = isGroup ? getChartGroups(data) : data;
|
|
77
|
+
const ticks = this.getTicks(chartData, width);
|
|
78
|
+
const labelCount = this.getLabelCount(ticks, chartData);
|
|
82
79
|
if (ticks.length > 0) {
|
|
83
|
-
|
|
80
|
+
this.chart.scale('name', {
|
|
84
81
|
type: 'cat',
|
|
85
|
-
ticks
|
|
82
|
+
ticks
|
|
86
83
|
});
|
|
87
84
|
}
|
|
88
|
-
|
|
85
|
+
const themeColors = this.getThemeColors();
|
|
89
86
|
|
|
90
87
|
// set Coord type
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
this.chart.coordinate('rect');
|
|
89
|
+
this.handleAutoRange(data, summaryColumnData, summaryMethod);
|
|
93
90
|
if (isGroup) {
|
|
94
|
-
|
|
95
|
-
data
|
|
96
|
-
currentTheme
|
|
97
|
-
themeColors
|
|
91
|
+
this.drawLineGroup({
|
|
92
|
+
data,
|
|
93
|
+
currentTheme,
|
|
94
|
+
themeColors
|
|
98
95
|
});
|
|
99
96
|
} else {
|
|
100
|
-
|
|
101
|
-
summaryType
|
|
102
|
-
summaryMethod
|
|
103
|
-
chartBarColor
|
|
104
|
-
themeColors
|
|
97
|
+
this.drawLine({
|
|
98
|
+
summaryType,
|
|
99
|
+
summaryMethod,
|
|
100
|
+
chartBarColor,
|
|
101
|
+
themeColors
|
|
105
102
|
});
|
|
106
103
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
this.setTooltip();
|
|
105
|
+
this.setAxis(themeColors, labelCount);
|
|
106
|
+
this.setTheme();
|
|
107
|
+
this.setLegend(themeColors);
|
|
108
|
+
this.chart.render();
|
|
109
|
+
this.renderAxisLabel();
|
|
113
110
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
this.initChartHandler = () => {
|
|
112
|
+
const {
|
|
113
|
+
isPreview
|
|
114
|
+
} = this.props;
|
|
115
|
+
let config = {
|
|
116
|
+
container: this.container
|
|
118
117
|
};
|
|
119
118
|
if (isPreview) {
|
|
120
119
|
config.autoFit = true;
|
|
@@ -122,16 +121,17 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
122
121
|
config.height = 400;
|
|
123
122
|
config.width = 700;
|
|
124
123
|
}
|
|
125
|
-
|
|
124
|
+
this.chart = new Chart(config);
|
|
126
125
|
};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
y_axis_auto_range
|
|
130
|
-
y_axis_min
|
|
131
|
-
y_axis_max
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
126
|
+
this.handleAutoRange = (data, summaryColumnData, summaryMethod) => {
|
|
127
|
+
const {
|
|
128
|
+
y_axis_auto_range,
|
|
129
|
+
y_axis_min,
|
|
130
|
+
y_axis_max
|
|
131
|
+
} = this.props.statItem;
|
|
132
|
+
let valueScaleOptions = {
|
|
133
|
+
formatter: value => {
|
|
134
|
+
return this.getNumberDisplayString(value, summaryColumnData, summaryMethod);
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
|
|
@@ -147,80 +147,87 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
// set the filter rule
|
|
150
|
-
|
|
150
|
+
this.chart.filter('value', value => {
|
|
151
151
|
return value >= y_axis_min;
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
// filter the data
|
|
155
|
-
|
|
155
|
+
this.chart.filterData(data);
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
this.chart.scale({
|
|
158
158
|
value: valueScaleOptions
|
|
159
159
|
});
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
this.drawLine = _ref => {
|
|
162
|
+
let {
|
|
163
|
+
summaryType,
|
|
164
|
+
summaryMethod,
|
|
165
|
+
chartBarColor,
|
|
166
|
+
themeColors
|
|
167
|
+
} = _ref;
|
|
168
|
+
const {
|
|
169
|
+
display_data
|
|
170
|
+
} = this.props.statItem;
|
|
171
|
+
this.chart.line().position('name*value').color(chartBarColor).tooltip('name*formatted_value', (name, value) => {
|
|
168
172
|
return {
|
|
169
|
-
value
|
|
173
|
+
value,
|
|
170
174
|
name: summaryType === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summaryMethod])
|
|
171
175
|
};
|
|
172
176
|
});
|
|
173
|
-
|
|
177
|
+
this.chart.point().label(display_data ? 'value' : false, {
|
|
174
178
|
style: {
|
|
175
|
-
fontSize:
|
|
179
|
+
fontSize: this.getLabelFontSize(),
|
|
176
180
|
fill: themeColors.textColor
|
|
177
181
|
}
|
|
178
182
|
}).position('name*value').color(chartBarColor).shape('circle').size(3).style({
|
|
179
183
|
lineWidth: 1,
|
|
180
184
|
stroke: '#fff'
|
|
181
|
-
}).tooltip('name*formatted_value',
|
|
185
|
+
}).tooltip('name*formatted_value', (name, value) => {
|
|
182
186
|
return {
|
|
183
|
-
value
|
|
187
|
+
value,
|
|
184
188
|
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
185
189
|
title: summaryType === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[summaryMethod])
|
|
186
190
|
};
|
|
187
191
|
});
|
|
188
192
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
this.drawLineGroup = _ref2 => {
|
|
194
|
+
let {
|
|
195
|
+
data,
|
|
196
|
+
currentTheme,
|
|
197
|
+
themeColors
|
|
198
|
+
} = _ref2;
|
|
199
|
+
const {
|
|
200
|
+
display_data,
|
|
201
|
+
color_option
|
|
202
|
+
} = this.props.statItem;
|
|
203
|
+
let groupColorCallback = currentTheme && currentTheme.colors;
|
|
197
204
|
// when the 'Group by' column is a 'single-select' column,
|
|
198
205
|
// and the user chooses to use the colors from the column.
|
|
199
206
|
if (color_option === USEABLE_COLOR_TYPES[1]) {
|
|
200
|
-
|
|
201
|
-
data.forEach(
|
|
207
|
+
const groupColorMapping = {};
|
|
208
|
+
data.forEach(item => {
|
|
202
209
|
if (!groupColorMapping[item.group_name]) {
|
|
203
210
|
groupColorMapping[item.group_name] = item.color;
|
|
204
211
|
}
|
|
205
212
|
});
|
|
206
|
-
groupColorCallback =
|
|
213
|
+
groupColorCallback = group_name => {
|
|
207
214
|
return groupColorMapping[group_name];
|
|
208
215
|
};
|
|
209
216
|
}
|
|
210
|
-
|
|
217
|
+
this.chart.scale({
|
|
211
218
|
group_name: {
|
|
212
219
|
type: 'cat'
|
|
213
220
|
}
|
|
214
221
|
});
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
this.chart.line().position('name*value').color('group_name', groupColorCallback);
|
|
223
|
+
this.chart.point().label(display_data ? 'formatted_value' : false, {
|
|
217
224
|
style: {
|
|
218
|
-
fontSize:
|
|
225
|
+
fontSize: this.getLabelFontSize(),
|
|
219
226
|
fill: themeColors.textColor
|
|
220
227
|
}
|
|
221
|
-
}).position('name*value').size(3).color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name',
|
|
228
|
+
}).position('name*value').size(3).color('group_name', groupColorCallback).tooltip('name*formatted_value*group_name', (name, value, group_name) => {
|
|
222
229
|
return {
|
|
223
|
-
value
|
|
230
|
+
value,
|
|
224
231
|
title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
225
232
|
name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
|
|
226
233
|
};
|
|
@@ -229,20 +236,20 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
229
236
|
stroke: '#fff'
|
|
230
237
|
});
|
|
231
238
|
};
|
|
232
|
-
|
|
233
|
-
|
|
239
|
+
this.setTooltip = () => {
|
|
240
|
+
this.chart.tooltip({
|
|
234
241
|
showCrosshairs: true,
|
|
235
242
|
showTitle: true,
|
|
236
243
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
237
244
|
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
238
245
|
domStyles: {
|
|
239
|
-
'g2-tooltip':
|
|
240
|
-
'tooltip-item':
|
|
246
|
+
'g2-tooltip': this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
247
|
+
'tooltip-item': this.getDefaultChartStyleByKey('tooltip-item')
|
|
241
248
|
}
|
|
242
249
|
});
|
|
243
250
|
};
|
|
244
|
-
|
|
245
|
-
|
|
251
|
+
this.setAxis = (themeColors, labelCount) => {
|
|
252
|
+
this.chart.axis('name', {
|
|
246
253
|
line: {
|
|
247
254
|
style: themeColors.gridColor
|
|
248
255
|
},
|
|
@@ -253,10 +260,10 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
253
260
|
offset: 20,
|
|
254
261
|
autoRotate: true,
|
|
255
262
|
rotate: labelCount > 11 ? 0.3 : 0,
|
|
256
|
-
formatter:
|
|
263
|
+
formatter: this.labelFormatter
|
|
257
264
|
}
|
|
258
265
|
});
|
|
259
|
-
|
|
266
|
+
this.chart.axis('value', {
|
|
260
267
|
label: {
|
|
261
268
|
style: {
|
|
262
269
|
fill: themeColors.textColor
|
|
@@ -271,8 +278,8 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
271
278
|
}
|
|
272
279
|
});
|
|
273
280
|
};
|
|
274
|
-
|
|
275
|
-
|
|
281
|
+
this.setTheme = () => {
|
|
282
|
+
this.chart.theme({
|
|
276
283
|
geometries: {
|
|
277
284
|
point: {
|
|
278
285
|
circle: {
|
|
@@ -287,14 +294,14 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
287
294
|
}
|
|
288
295
|
});
|
|
289
296
|
};
|
|
290
|
-
|
|
291
|
-
|
|
297
|
+
this.setLegend = themeColors => {
|
|
298
|
+
this.chart.legend('group_name', {
|
|
292
299
|
position: 'bottom',
|
|
293
300
|
itemName: {
|
|
294
301
|
style: {
|
|
295
302
|
fill: themeColors.textColor
|
|
296
303
|
},
|
|
297
|
-
formatter:
|
|
304
|
+
formatter: name => {
|
|
298
305
|
return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
|
|
299
306
|
}
|
|
300
307
|
},
|
|
@@ -314,35 +321,37 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
314
321
|
}
|
|
315
322
|
});
|
|
316
323
|
};
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
getTableById
|
|
320
|
-
statItem
|
|
324
|
+
this.renderAxisLabel = newStatItem => {
|
|
325
|
+
let {
|
|
326
|
+
getTableById,
|
|
327
|
+
statItem
|
|
328
|
+
} = this.props;
|
|
321
329
|
if (newStatItem && newStatItem._id !== statItem._id) {
|
|
322
330
|
return;
|
|
323
331
|
}
|
|
324
|
-
if (!
|
|
332
|
+
if (!this.chart) return;
|
|
325
333
|
statItem = newStatItem || statItem;
|
|
326
|
-
|
|
327
|
-
table_id
|
|
328
|
-
x_axis_column_key
|
|
329
|
-
y_axis_column_key
|
|
330
|
-
show_y_axis_label
|
|
331
|
-
show_x_axis_label
|
|
332
|
-
y_axis_label_position
|
|
333
|
-
x_axis_label_position
|
|
334
|
-
y_axis_summary_type
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
334
|
+
const {
|
|
335
|
+
table_id,
|
|
336
|
+
x_axis_column_key,
|
|
337
|
+
y_axis_column_key,
|
|
338
|
+
show_y_axis_label,
|
|
339
|
+
show_x_axis_label,
|
|
340
|
+
y_axis_label_position,
|
|
341
|
+
x_axis_label_position,
|
|
342
|
+
y_axis_summary_type
|
|
343
|
+
} = statItem;
|
|
344
|
+
const table = getTableById(table_id);
|
|
345
|
+
const autoPadding = this.chart.autoPadding;
|
|
346
|
+
const textColor = this.getAxisLabelColor();
|
|
347
|
+
const xAxisID = "chart-x-axis-label_".concat(statItem._id);
|
|
348
|
+
const chartContainer = this.chart.getCanvas().get('container');
|
|
349
|
+
const xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
341
350
|
if (!xLabel && show_x_axis_label) {
|
|
342
|
-
|
|
351
|
+
const div = document.createElement('div');
|
|
343
352
|
div.id = xAxisID;
|
|
344
353
|
div.className = 'statistic-chart-axis-label';
|
|
345
|
-
|
|
354
|
+
const column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
346
355
|
div.innerHTML = "".concat(column ? column.name : '');
|
|
347
356
|
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
348
357
|
chartContainer.appendChild(div);
|
|
@@ -353,157 +362,150 @@ var LineChart = /*#__PURE__*/function (_BaseChart) {
|
|
|
353
362
|
if (xLabel && !show_x_axis_label) {
|
|
354
363
|
xLabel.parentNode.removeChild(xLabel);
|
|
355
364
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
365
|
+
const yAxisID = "chart-y-axis-label_".concat(statItem._id);
|
|
366
|
+
const yLabel = chartContainer.querySelector("#".concat(yAxisID));
|
|
367
|
+
let paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
|
|
359
368
|
if (!yLabel && show_y_axis_label) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
369
|
+
const div = document.createElement('div');
|
|
370
|
+
div.id = yAxisID;
|
|
371
|
+
div.className = 'statistic-chart-axis-label';
|
|
363
372
|
if (y_axis_summary_type === SUMMARY_TYPE.COUNT) {
|
|
364
|
-
|
|
373
|
+
div.innerHTML = intl.get(TITLE_AMOUNT);
|
|
365
374
|
} else {
|
|
366
|
-
|
|
367
|
-
|
|
375
|
+
const column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
376
|
+
div.innerHTML = column.name || '';
|
|
368
377
|
}
|
|
369
|
-
|
|
370
|
-
|
|
378
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
379
|
+
let textAlign = 'center';
|
|
371
380
|
if (y_axis_label_position === 'bottom') textAlign = 'left';
|
|
372
381
|
if (y_axis_label_position === 'top') textAlign = 'right';
|
|
373
|
-
|
|
374
|
-
chartContainer.appendChild(
|
|
382
|
+
div.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0px; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
383
|
+
chartContainer.appendChild(div);
|
|
375
384
|
}
|
|
376
385
|
if (yLabel && show_y_axis_label) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
if (y_axis_label_position === 'bottom')
|
|
380
|
-
if (y_axis_label_position === 'top')
|
|
381
|
-
yLabel.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(
|
|
386
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
387
|
+
let textAlign = 'center';
|
|
388
|
+
if (y_axis_label_position === 'bottom') textAlign = 'left';
|
|
389
|
+
if (y_axis_label_position === 'top') textAlign = 'right';
|
|
390
|
+
yLabel.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0px; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
382
391
|
}
|
|
383
392
|
if (yLabel && !show_y_axis_label) {
|
|
384
393
|
yLabel.parentNode.removeChild(yLabel);
|
|
385
394
|
}
|
|
386
395
|
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
396
|
+
this.destroyChart = () => {
|
|
397
|
+
this.chart.destroy();
|
|
398
|
+
this.chart = null;
|
|
390
399
|
};
|
|
391
|
-
|
|
400
|
+
this.state = {
|
|
392
401
|
isCalculatingData: true,
|
|
393
402
|
showResultDescription: true
|
|
394
403
|
};
|
|
395
|
-
|
|
396
|
-
|
|
404
|
+
this.calculateData = null;
|
|
405
|
+
}
|
|
406
|
+
componentDidMount() {
|
|
407
|
+
const {
|
|
408
|
+
statItem,
|
|
409
|
+
chartCalculator,
|
|
410
|
+
eventBus
|
|
411
|
+
} = this.props;
|
|
412
|
+
this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, newStatItem => {
|
|
413
|
+
this.renderAxisLabel(newStatItem);
|
|
414
|
+
});
|
|
415
|
+
if (this.container) {
|
|
416
|
+
chartCalculator.calculate(statItem).then(data => {
|
|
417
|
+
const showResultDescription = data.length > 0 ? false : true;
|
|
418
|
+
this.setState({
|
|
419
|
+
isCalculatingData: false,
|
|
420
|
+
showResultDescription
|
|
421
|
+
}, () => {
|
|
422
|
+
if (!showResultDescription) {
|
|
423
|
+
this.drawChart(data);
|
|
424
|
+
this.calculateData = data;
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
431
|
+
const {
|
|
432
|
+
colorThemeName
|
|
433
|
+
} = this.props;
|
|
434
|
+
if (this.canUpdate(this.props, nextProps)) {
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
if (nextProps.colorThemeName !== colorThemeName) {
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
return false;
|
|
397
444
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
445
|
+
componentDidUpdate(preProps, preState) {
|
|
446
|
+
const {
|
|
447
|
+
statItem,
|
|
448
|
+
chartCalculator
|
|
449
|
+
} = this.props;
|
|
450
|
+
const {
|
|
451
|
+
isCalculatingData
|
|
452
|
+
} = this.state;
|
|
453
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
454
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
455
|
+
this.setState({
|
|
456
|
+
isCalculatingData: true
|
|
408
457
|
});
|
|
409
458
|
if (this.container) {
|
|
410
|
-
chartCalculator.calculate(statItem).then(
|
|
411
|
-
|
|
412
|
-
|
|
459
|
+
chartCalculator.calculate(statItem).then(data => {
|
|
460
|
+
const showResultDescription = data.length > 0 ? false : true;
|
|
461
|
+
this.chart && this.destroyChart();
|
|
462
|
+
this.calculateData = data;
|
|
463
|
+
this.setState({
|
|
413
464
|
isCalculatingData: false,
|
|
414
|
-
showResultDescription
|
|
415
|
-
},
|
|
465
|
+
showResultDescription
|
|
466
|
+
}, () => {
|
|
416
467
|
if (!showResultDescription) {
|
|
417
|
-
|
|
418
|
-
|
|
468
|
+
this.drawChart(data);
|
|
469
|
+
if (this.props.isPreview) this.chart.forceFit();
|
|
419
470
|
}
|
|
420
471
|
});
|
|
421
472
|
});
|
|
422
473
|
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
return true;
|
|
430
|
-
}
|
|
431
|
-
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
432
|
-
return true;
|
|
433
|
-
}
|
|
434
|
-
if (nextProps.colorThemeName !== colorThemeName) {
|
|
435
|
-
return true;
|
|
436
|
-
}
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
}, {
|
|
440
|
-
key: "componentDidUpdate",
|
|
441
|
-
value: function componentDidUpdate(preProps, preState) {
|
|
442
|
-
var _this3 = this;
|
|
443
|
-
var _this$props4 = this.props,
|
|
444
|
-
statItem = _this$props4.statItem,
|
|
445
|
-
chartCalculator = _this$props4.chartCalculator;
|
|
446
|
-
var isCalculatingData = this.state.isCalculatingData;
|
|
447
|
-
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
448
|
-
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
449
|
-
this.setState({
|
|
450
|
-
isCalculatingData: true
|
|
451
|
-
});
|
|
452
|
-
if (this.container) {
|
|
453
|
-
chartCalculator.calculate(statItem).then(function (data) {
|
|
454
|
-
var showResultDescription = data.length > 0 ? false : true;
|
|
455
|
-
_this3.chart && _this3.destroyChart();
|
|
456
|
-
_this3.calculateData = data;
|
|
457
|
-
_this3.setState({
|
|
458
|
-
isCalculatingData: false,
|
|
459
|
-
showResultDescription: showResultDescription
|
|
460
|
-
}, function () {
|
|
461
|
-
if (!showResultDescription) {
|
|
462
|
-
_this3.drawChart(data);
|
|
463
|
-
if (_this3.props.isPreview) _this3.chart.forceFit();
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
} else {
|
|
469
|
-
if (!this.state.showResultDescription) {
|
|
470
|
-
this.chart && this.destroyChart();
|
|
471
|
-
this.drawChart(this.calculateData);
|
|
472
|
-
if (this.props.isPreview) {
|
|
473
|
-
this.chart.forceFit();
|
|
474
|
-
}
|
|
474
|
+
} else {
|
|
475
|
+
if (!this.state.showResultDescription) {
|
|
476
|
+
this.chart && this.destroyChart();
|
|
477
|
+
this.drawChart(this.calculateData);
|
|
478
|
+
if (this.props.isPreview) {
|
|
479
|
+
this.chart.forceFit();
|
|
475
480
|
}
|
|
476
481
|
}
|
|
477
482
|
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}]);
|
|
506
|
-
return LineChart;
|
|
507
|
-
}(BaseChart);
|
|
483
|
+
}
|
|
484
|
+
componentWillUnmount() {
|
|
485
|
+
this.container = null;
|
|
486
|
+
this.unsubscribeStyleChange();
|
|
487
|
+
}
|
|
488
|
+
render() {
|
|
489
|
+
const {
|
|
490
|
+
statItem
|
|
491
|
+
} = this.props;
|
|
492
|
+
const {
|
|
493
|
+
isCalculatingData,
|
|
494
|
+
showResultDescription
|
|
495
|
+
} = this.state;
|
|
496
|
+
const {
|
|
497
|
+
show_y_axis_label,
|
|
498
|
+
show_x_axis_label
|
|
499
|
+
} = statItem;
|
|
500
|
+
const style = {
|
|
501
|
+
padding: show_y_axis_label || show_x_axis_label ? 30 : 20
|
|
502
|
+
};
|
|
503
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
504
|
+
ref: ref => this.container = ref,
|
|
505
|
+
style: style,
|
|
506
|
+
className: "statistic-chart-container"
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
}
|
|
508
510
|
LineChart.propTypes = propTypes;
|
|
509
511
|
export default LineChart;
|