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
package/es/stat-view/heat-map.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
1
|
import React from 'react';
|
|
7
2
|
import PropTypes from 'prop-types';
|
|
8
3
|
import dayjs from 'dayjs';
|
|
@@ -15,61 +10,57 @@ import { isShapeEqual } from '../utils/common-utils';
|
|
|
15
10
|
import { COLOR_OPTIONS, DEFAULT_GRID_DISTANCE, DEFAULT_GRID_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, FILL_BORDER_COLOR_MAP, MONTH_MIRROR, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
|
|
16
11
|
import styles from '../assets/css/statistic-custom.module.css';
|
|
17
12
|
dayjs.extend(weekOfYear);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
_this = _super.call(this, props);
|
|
25
|
-
_this.destroyChart = function () {
|
|
26
|
-
_this.chart.destroy();
|
|
27
|
-
_this.chart = null;
|
|
13
|
+
class HeatMap extends BaseChart {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.destroyChart = () => {
|
|
17
|
+
this.chart.destroy();
|
|
18
|
+
this.chart = null;
|
|
28
19
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
statData.forEach(
|
|
20
|
+
this.transformData = statData => {
|
|
21
|
+
let data = {};
|
|
22
|
+
let yearFirstDate = dayjs(statData[0].name);
|
|
23
|
+
this.firstDate = yearFirstDate.year() + '-01-01';
|
|
24
|
+
statData.forEach(item => {
|
|
34
25
|
data[item.name] = data[item.name] ? data[item.name] + item.value : item.value;
|
|
35
26
|
});
|
|
36
27
|
return data;
|
|
37
28
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
this.generateBackgroundGridData = statData => {
|
|
30
|
+
let momentDate = dayjs(this.firstDate);
|
|
31
|
+
const year = momentDate.year();
|
|
32
|
+
const gridData = [];
|
|
33
|
+
const isLeapYear = year % 4 > 0 ? false : true;
|
|
34
|
+
let yearDayCount = 365;
|
|
44
35
|
if (isLeapYear) {
|
|
45
36
|
yearDayCount = 366;
|
|
46
37
|
}
|
|
47
|
-
for (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
for (let i = 0; i < yearDayCount; i++) {
|
|
39
|
+
const day = momentDate.day();
|
|
40
|
+
let week = momentDate.week() - 1;
|
|
41
|
+
const month = momentDate.month();
|
|
51
42
|
if (week === 0 && month === 11) {
|
|
52
43
|
week = 52;
|
|
53
44
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
const yearDate = momentDate.format('YYYY-MM-DD');
|
|
46
|
+
const value = statData[yearDate] || 0;
|
|
47
|
+
this.maxValue = Math.max(this.maxValue, value);
|
|
57
48
|
gridData.push({
|
|
58
49
|
date: yearDate,
|
|
59
50
|
value: statData[yearDate],
|
|
60
|
-
day
|
|
61
|
-
week
|
|
62
|
-
month
|
|
51
|
+
day,
|
|
52
|
+
week,
|
|
53
|
+
month
|
|
63
54
|
});
|
|
64
55
|
momentDate = momentDate.add(1, 'days');
|
|
65
56
|
}
|
|
66
57
|
return gridData;
|
|
67
58
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
this.getLabel = val => {
|
|
60
|
+
const currentDate = dayjs(this.firstDate).add(val * 7, 'days');
|
|
61
|
+
let month = currentDate.month();
|
|
62
|
+
let monthDate = currentDate.date();
|
|
63
|
+
let isFirst = monthDate <= 7 || false;
|
|
73
64
|
|
|
74
65
|
// if the week is the first week of a month
|
|
75
66
|
// mark it to axis
|
|
@@ -78,16 +69,17 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
78
69
|
}
|
|
79
70
|
return '';
|
|
80
71
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
getTableById
|
|
85
|
-
statItem
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
this.drawChart = statData => {
|
|
73
|
+
this.maxValue = 0;
|
|
74
|
+
const {
|
|
75
|
+
getTableById,
|
|
76
|
+
statItem
|
|
77
|
+
} = this.props;
|
|
78
|
+
const currentColorOption = COLOR_OPTIONS.filter(item => item.name == statItem.data_color)[0] || COLOR_OPTIONS[0];
|
|
79
|
+
const {
|
|
80
|
+
exampleColors
|
|
81
|
+
} = currentColorOption;
|
|
82
|
+
const count = statData.years.length;
|
|
91
83
|
/**
|
|
92
84
|
* 114: 12 * 7 + 6 * 4 + 8(mistake)
|
|
93
85
|
* 30: the bottom padding of one calendar
|
|
@@ -96,29 +88,29 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
96
88
|
* 15: the spacing of calendar
|
|
97
89
|
*/
|
|
98
90
|
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
let {
|
|
92
|
+
grid_size,
|
|
93
|
+
grid_distance
|
|
94
|
+
} = statItem;
|
|
101
95
|
grid_size = grid_size || DEFAULT_GRID_SIZE;
|
|
102
96
|
grid_distance = grid_distance || DEFAULT_GRID_DISTANCE;
|
|
103
97
|
// height for 1 year
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
container:
|
|
98
|
+
const yearHeight = grid_size * 7 + grid_distance * 6 + 8;
|
|
99
|
+
const chartHeight = (yearHeight + 30) * count + 30 + (count - 1) * 15;
|
|
100
|
+
this.chart = new Chart({
|
|
101
|
+
container: this.container,
|
|
108
102
|
autoFit: false,
|
|
109
103
|
height: chartHeight,
|
|
110
104
|
width: grid_size * 53 + grid_distance * 52 + 75,
|
|
111
105
|
// 75: left padding + right padding
|
|
112
106
|
padding: [30, 30, 0, 45]
|
|
113
107
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
_this.props.toggleStatisticRecordsDialog(data, statItem);
|
|
108
|
+
this.chart.on('element:click', e => {
|
|
109
|
+
const clickDate = e.data.data.date;
|
|
110
|
+
const data = statData.data.find(i => i.name === clickDate);
|
|
111
|
+
this.props.toggleStatisticRecordsDialog(data, statItem);
|
|
120
112
|
});
|
|
121
|
-
|
|
113
|
+
this.chart.tooltip({
|
|
122
114
|
title: 'date',
|
|
123
115
|
showMarkers: false,
|
|
124
116
|
showTitle: false,
|
|
@@ -126,24 +118,26 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
126
118
|
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
127
119
|
itemTpl: "<div class=\"g2-tooltip-content\"><div style=\"width: max-content; text-align: left;\" class=\"tooltip-name\">{date}<div><div style=\"word-break: keep-all;\" class=\"tooltip-item\">".concat(intl.get(TITLE_AMOUNT), " : {value}<div></div>"),
|
|
128
120
|
domStyles: {
|
|
129
|
-
'g2-tooltip':
|
|
130
|
-
'tooltip-item':
|
|
121
|
+
'g2-tooltip': this.getDefaultChartStyleByKey('g2-tooltip'),
|
|
122
|
+
'tooltip-item': this.getDefaultChartStyleByKey('tooltip-item')
|
|
131
123
|
}
|
|
132
124
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
125
|
+
this.chart.axis(false);
|
|
126
|
+
this.chart.data(statData.data);
|
|
127
|
+
const themeColors = this.getThemeColors();
|
|
128
|
+
let columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
129
|
+
const {
|
|
130
|
+
table_id,
|
|
131
|
+
summary_type,
|
|
132
|
+
summary_column,
|
|
133
|
+
summary_method
|
|
134
|
+
} = statItem;
|
|
141
135
|
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
const table = getTableById(table_id);
|
|
137
|
+
const summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
|
|
144
138
|
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
145
139
|
}
|
|
146
|
-
|
|
140
|
+
this.chart.facet('list', {
|
|
147
141
|
fields: ['year'],
|
|
148
142
|
cols: 1,
|
|
149
143
|
showTitle: true,
|
|
@@ -158,10 +152,10 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
158
152
|
},
|
|
159
153
|
padding: [0, 0, 15, 0],
|
|
160
154
|
spacing: [0, 15],
|
|
161
|
-
eachView:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
155
|
+
eachView: (view, facet) => {
|
|
156
|
+
let groupStatData = this.transformData(facet.data);
|
|
157
|
+
const gridData = this.generateBackgroundGridData(groupStatData);
|
|
158
|
+
const gridView = view.createView();
|
|
165
159
|
gridView.axis('week', {
|
|
166
160
|
position: 'top',
|
|
167
161
|
tickLine: null,
|
|
@@ -176,8 +170,8 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
176
170
|
fontSize: 12,
|
|
177
171
|
fill: themeColors.textColor
|
|
178
172
|
},
|
|
179
|
-
formatter:
|
|
180
|
-
return
|
|
173
|
+
formatter: (val, label, index) => {
|
|
174
|
+
return this.getLabel(val);
|
|
181
175
|
}
|
|
182
176
|
},
|
|
183
177
|
grid: null
|
|
@@ -208,25 +202,25 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
208
202
|
}
|
|
209
203
|
});
|
|
210
204
|
gridView.data(gridData);
|
|
211
|
-
gridView.polygon().position('week*day*date').color('value',
|
|
205
|
+
gridView.polygon().position('week*day*date').color('value', value => {
|
|
212
206
|
if (!value || value <= 0) {
|
|
213
207
|
return '#EBEDF0';
|
|
214
208
|
}
|
|
215
|
-
if (value ===
|
|
216
|
-
return exampleColors[Math.floor(value / (
|
|
209
|
+
if (value === this.maxValue) return exampleColors[8];
|
|
210
|
+
return exampleColors[Math.floor(value / (this.maxValue / 9))];
|
|
217
211
|
}).customInfo({
|
|
218
|
-
grid_size
|
|
219
|
-
grid_distance
|
|
220
|
-
}).shape('boundary-polygon').label(false).tooltip('date*value',
|
|
212
|
+
grid_size,
|
|
213
|
+
grid_distance
|
|
214
|
+
}).shape('boundary-polygon').label(false).tooltip('date*value', (date, value) => {
|
|
221
215
|
return {
|
|
222
|
-
date
|
|
223
|
-
value:
|
|
216
|
+
date,
|
|
217
|
+
value: this.getNumberDisplayString(value, columnData, summary_method)
|
|
224
218
|
};
|
|
225
219
|
});
|
|
226
220
|
gridView.coordinate().reflect('y');
|
|
227
221
|
}
|
|
228
222
|
});
|
|
229
|
-
|
|
223
|
+
this.chart.legend('value', {
|
|
230
224
|
position: 'top-left',
|
|
231
225
|
layout: 'horizontal',
|
|
232
226
|
offsetY: -6,
|
|
@@ -238,241 +232,221 @@ var HeatMap = /*#__PURE__*/function (_BaseChart) {
|
|
|
238
232
|
fill: themeColors.textColor
|
|
239
233
|
}
|
|
240
234
|
},
|
|
241
|
-
items:
|
|
235
|
+
items: this.getLegendItems(exampleColors)
|
|
242
236
|
});
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
this.chart.removeInteraction('legend-filter');
|
|
238
|
+
this.chart.render();
|
|
245
239
|
};
|
|
246
240
|
// get text width in canvas
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
241
|
+
this.getTextWidthInCanvas = text => {
|
|
242
|
+
let canvas = document.createElement('canvas');
|
|
243
|
+
const context = canvas.getContext('2d');
|
|
244
|
+
let font = context.font;
|
|
245
|
+
const fontStyle = font.slice(font.indexOf('px'));
|
|
252
246
|
font = 'bold ' + 12 + fontStyle;
|
|
253
247
|
context.font = font;
|
|
254
248
|
return Math.ceil(context.measureText(text).width);
|
|
255
249
|
};
|
|
256
250
|
dayjs.locale('en');
|
|
257
|
-
|
|
251
|
+
this.state = {
|
|
258
252
|
isCalculatingData: true,
|
|
259
253
|
showResultDescription: true
|
|
260
254
|
};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return _this;
|
|
255
|
+
this.calculateData = null;
|
|
256
|
+
this.maxValue = 0;
|
|
264
257
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
attrs
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
});
|
|
308
|
-
return group;
|
|
309
|
-
}
|
|
258
|
+
componentDidMount() {
|
|
259
|
+
const {
|
|
260
|
+
statItem,
|
|
261
|
+
chartCalculator
|
|
262
|
+
} = this.props;
|
|
263
|
+
registerShape('polygon', 'boundary-polygon', {
|
|
264
|
+
draw(cfg, container) {
|
|
265
|
+
if (cfg && cfg.points && cfg.points.length > 0) {
|
|
266
|
+
const group = container.addGroup();
|
|
267
|
+
let attrs = {
|
|
268
|
+
fill: cfg.color,
|
|
269
|
+
lineWidth: 1,
|
|
270
|
+
stroke: FILL_BORDER_COLOR_MAP[cfg.color]
|
|
271
|
+
};
|
|
272
|
+
const {
|
|
273
|
+
points,
|
|
274
|
+
customInfo
|
|
275
|
+
} = cfg;
|
|
276
|
+
const {
|
|
277
|
+
grid_size,
|
|
278
|
+
grid_distance
|
|
279
|
+
} = customInfo;
|
|
280
|
+
const distance = grid_distance / 2;
|
|
281
|
+
const offset = grid_size - 1;
|
|
282
|
+
const parsedPoint = this.parsePoints(points);
|
|
283
|
+
let [p0, p1, p2, p3] = parsedPoint;
|
|
284
|
+
p0.y = p0.y + distance;
|
|
285
|
+
p1.x = p0.x;
|
|
286
|
+
p1.y = p0.y + offset;
|
|
287
|
+
p2.x = p0.x + offset;
|
|
288
|
+
p2.y = p1.y;
|
|
289
|
+
p3.x = p0.x + offset;
|
|
290
|
+
p3.y = p0.y;
|
|
291
|
+
// get cell path that has radius, the cell radius is 2;
|
|
292
|
+
const path = getRectWithCornerRadius(parsedPoint, this.coordinate, 2);
|
|
293
|
+
attrs.path = path;
|
|
294
|
+
group.addShape('path', {
|
|
295
|
+
attrs,
|
|
296
|
+
capture: cfg.data.value > 0,
|
|
297
|
+
visible: true
|
|
298
|
+
});
|
|
299
|
+
return group;
|
|
310
300
|
}
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
if (this.container) {
|
|
304
|
+
chartCalculator.calculate(statItem).then(data => {
|
|
305
|
+
const showResultDescription = data.years && data.years.length > 0 ? false : true;
|
|
306
|
+
this.calculateData = data;
|
|
307
|
+
this.setState({
|
|
308
|
+
isCalculatingData: false,
|
|
309
|
+
showResultDescription
|
|
310
|
+
}, () => {
|
|
311
|
+
if (!showResultDescription) {
|
|
312
|
+
this.drawChart(data);
|
|
313
|
+
this.calculateData = data;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
320
|
+
const {
|
|
321
|
+
statItem
|
|
322
|
+
} = this.props;
|
|
323
|
+
if (this.canUpdate(this.props, nextProps)) {
|
|
324
|
+
if (!isShapeEqual(nextProps.statItem.layout, statItem.layout)) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
componentDidUpdate(preProps, preState) {
|
|
335
|
+
const {
|
|
336
|
+
statItem,
|
|
337
|
+
chartCalculator
|
|
338
|
+
} = this.props;
|
|
339
|
+
const {
|
|
340
|
+
isCalculatingData
|
|
341
|
+
} = this.state;
|
|
342
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
343
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
344
|
+
this.setState({
|
|
345
|
+
isCalculatingData: true
|
|
311
346
|
});
|
|
312
347
|
if (this.container) {
|
|
313
|
-
chartCalculator.calculate(statItem).then(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
348
|
+
chartCalculator.calculate(statItem).then(data => {
|
|
349
|
+
const showResultDescription = data.years && data.years.length > 0 ? false : true;
|
|
350
|
+
this.chart && this.destroyChart();
|
|
351
|
+
this.calculateData = data;
|
|
352
|
+
this.setState({
|
|
317
353
|
isCalculatingData: false,
|
|
318
|
-
showResultDescription
|
|
319
|
-
},
|
|
354
|
+
showResultDescription
|
|
355
|
+
}, () => {
|
|
320
356
|
if (!showResultDescription) {
|
|
321
|
-
|
|
322
|
-
_this2.calculateData = data;
|
|
357
|
+
this.drawChart(data);
|
|
323
358
|
}
|
|
324
359
|
});
|
|
325
360
|
});
|
|
326
361
|
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
var statItem = this.props.statItem;
|
|
332
|
-
if (this.canUpdate(this.props, nextProps)) {
|
|
333
|
-
if (!isShapeEqual(nextProps.statItem.layout, statItem.layout)) {
|
|
334
|
-
return false;
|
|
335
|
-
}
|
|
336
|
-
return true;
|
|
337
|
-
}
|
|
338
|
-
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
339
|
-
return true;
|
|
362
|
+
} else {
|
|
363
|
+
if (!this.state.showResultDescription) {
|
|
364
|
+
this.chart && this.destroyChart();
|
|
365
|
+
this.drawChart(this.calculateData);
|
|
340
366
|
}
|
|
341
|
-
return false;
|
|
342
367
|
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
this.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
_this3.calculateData = data;
|
|
361
|
-
_this3.setState({
|
|
362
|
-
isCalculatingData: false,
|
|
363
|
-
showResultDescription: showResultDescription
|
|
364
|
-
}, function () {
|
|
365
|
-
if (!showResultDescription) {
|
|
366
|
-
_this3.drawChart(data);
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
} else {
|
|
372
|
-
if (!this.state.showResultDescription) {
|
|
373
|
-
this.chart && this.destroyChart();
|
|
374
|
-
this.drawChart(this.calculateData);
|
|
368
|
+
}
|
|
369
|
+
componentWillUnmount() {
|
|
370
|
+
this.container = null;
|
|
371
|
+
}
|
|
372
|
+
getLegendItems(colors) {
|
|
373
|
+
const text = intl.get('Less');
|
|
374
|
+
const textWidth = this.getTextWidthInCanvas(text);
|
|
375
|
+
const items = [{
|
|
376
|
+
name: text,
|
|
377
|
+
marker: {
|
|
378
|
+
symbol: (x, y, r) => this.getLegendItemPath(x, y, r, 0, textWidth),
|
|
379
|
+
spacing: 0,
|
|
380
|
+
style: {
|
|
381
|
+
fill: '#E1E3E6',
|
|
382
|
+
lineWidth: 1,
|
|
383
|
+
stroke: '#EBEDF0',
|
|
384
|
+
r: 5
|
|
375
385
|
}
|
|
376
386
|
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
value: function componentWillUnmount() {
|
|
381
|
-
this.container = null;
|
|
382
|
-
}
|
|
383
|
-
}, {
|
|
384
|
-
key: "getLegendItems",
|
|
385
|
-
value: function getLegendItems(colors) {
|
|
386
|
-
var _this4 = this;
|
|
387
|
-
var text = intl.get('Less');
|
|
388
|
-
var textWidth = this.getTextWidthInCanvas(text);
|
|
389
|
-
var items = [{
|
|
390
|
-
name: text,
|
|
387
|
+
}];
|
|
388
|
+
colors.forEach((color, index) => {
|
|
389
|
+
items.push({
|
|
391
390
|
marker: {
|
|
392
|
-
symbol:
|
|
393
|
-
|
|
394
|
-
},
|
|
395
|
-
spacing: 0,
|
|
391
|
+
symbol: (x, y, r) => this.getLegendItemPath(x, y, r, index + 1, textWidth),
|
|
392
|
+
spacing: 2,
|
|
396
393
|
style: {
|
|
397
|
-
fill:
|
|
394
|
+
fill: color,
|
|
398
395
|
lineWidth: 1,
|
|
399
|
-
stroke:
|
|
396
|
+
stroke: FILL_BORDER_COLOR_MAP[color],
|
|
400
397
|
r: 5
|
|
401
398
|
}
|
|
402
399
|
}
|
|
403
|
-
}];
|
|
404
|
-
colors.forEach(function (color, index) {
|
|
405
|
-
items.push({
|
|
406
|
-
marker: {
|
|
407
|
-
symbol: function symbol(x, y, r) {
|
|
408
|
-
return _this4.getLegendItemPath(x, y, r, index + 1, textWidth);
|
|
409
|
-
},
|
|
410
|
-
spacing: 2,
|
|
411
|
-
style: {
|
|
412
|
-
fill: color,
|
|
413
|
-
lineWidth: 1,
|
|
414
|
-
stroke: FILL_BORDER_COLOR_MAP[color],
|
|
415
|
-
r: 5
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
400
|
});
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
p0.x = p0.x + 18;
|
|
437
|
-
}
|
|
438
|
-
var p1 = {
|
|
439
|
-
x: p0.x,
|
|
440
|
-
y: p0.y - 12
|
|
441
|
-
};
|
|
442
|
-
var p2 = {
|
|
443
|
-
x: p0.x + 12,
|
|
444
|
-
y: p0.y - 12
|
|
445
|
-
};
|
|
446
|
-
var p3 = {
|
|
447
|
-
x: p0.x + 12,
|
|
448
|
-
y: p0.y
|
|
449
|
-
};
|
|
450
|
-
var path = getRectWithCornerRadius([p0, p1, p2, p3], this.chart.coordinateInstance, 2);
|
|
451
|
-
return path;
|
|
452
|
-
}
|
|
453
|
-
}, {
|
|
454
|
-
key: "render",
|
|
455
|
-
value: function render() {
|
|
456
|
-
var _this5 = this;
|
|
457
|
-
var _this$state = this.state,
|
|
458
|
-
isCalculatingData = _this$state.isCalculatingData,
|
|
459
|
-
showResultDescription = _this$state.showResultDescription;
|
|
460
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
461
|
-
style: {
|
|
462
|
-
overflow: 'auto',
|
|
463
|
-
height: '100%',
|
|
464
|
-
display: 'flex',
|
|
465
|
-
padding: 15
|
|
466
|
-
},
|
|
467
|
-
ref: function ref(_ref) {
|
|
468
|
-
return _this5.container = _ref;
|
|
469
|
-
},
|
|
470
|
-
className: "".concat(styles['statistic-heatmap-container'], " statistic-chart-container")
|
|
471
|
-
}));
|
|
401
|
+
});
|
|
402
|
+
items[9].name = intl.get('More');
|
|
403
|
+
items[9].marker.spacing = 22;
|
|
404
|
+
return items;
|
|
405
|
+
}
|
|
406
|
+
getLegendItemPath(x, y, r, index, textWidth) {
|
|
407
|
+
// x, y represents the coordinates of the center point of the legend item marker
|
|
408
|
+
let p0 = {
|
|
409
|
+
x: x - 6,
|
|
410
|
+
y: y + 6
|
|
411
|
+
};
|
|
412
|
+
// translate the lengend marker to right to make the first legend item text to left of the marker
|
|
413
|
+
if (index === 0) {
|
|
414
|
+
p0.x = p0.x + textWidth + 16;
|
|
415
|
+
} else {
|
|
416
|
+
p0.x = p0.x + 18;
|
|
472
417
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
418
|
+
const p1 = {
|
|
419
|
+
x: p0.x,
|
|
420
|
+
y: p0.y - 12
|
|
421
|
+
};
|
|
422
|
+
const p2 = {
|
|
423
|
+
x: p0.x + 12,
|
|
424
|
+
y: p0.y - 12
|
|
425
|
+
};
|
|
426
|
+
const p3 = {
|
|
427
|
+
x: p0.x + 12,
|
|
428
|
+
y: p0.y
|
|
429
|
+
};
|
|
430
|
+
const path = getRectWithCornerRadius([p0, p1, p2, p3], this.chart.coordinateInstance, 2);
|
|
431
|
+
return path;
|
|
432
|
+
}
|
|
433
|
+
render() {
|
|
434
|
+
const {
|
|
435
|
+
isCalculatingData,
|
|
436
|
+
showResultDescription
|
|
437
|
+
} = this.state;
|
|
438
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && this.renderLoading(), showResultDescription && this.renderEmpty(), /*#__PURE__*/React.createElement("div", {
|
|
439
|
+
style: {
|
|
440
|
+
overflow: 'auto',
|
|
441
|
+
height: '100%',
|
|
442
|
+
display: 'flex',
|
|
443
|
+
padding: 15
|
|
444
|
+
},
|
|
445
|
+
ref: ref => this.container = ref,
|
|
446
|
+
className: "".concat(styles['statistic-heatmap-container'], " statistic-chart-container")
|
|
447
|
+
}));
|
|
448
|
+
}
|
|
449
|
+
}
|
|
476
450
|
HeatMap.propTypes = {
|
|
477
451
|
statItem: PropTypes.object,
|
|
478
452
|
chartCalculator: PropTypes.object,
|