dtable-statistic 4.0.2-test-2
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/README.md +3 -0
- package/es/api/dtable-db-api.js +43 -0
- package/es/assets/css/color-picker.css +53 -0
- package/es/assets/css/color-rules-popover.css +144 -0
- package/es/assets/css/color-theme-dialog.css +40 -0
- package/es/assets/css/dashboard.css +562 -0
- package/es/assets/css/dialog.css +415 -0
- package/es/assets/css/mobile-dashboard.module.css +91 -0
- package/es/assets/css/slider.css +77 -0
- package/es/assets/css/statistic-chart.module.css +11 -0
- package/es/assets/css/statistic-custom-title.module.css +3 -0
- package/es/assets/css/statistic-custom.module.css +4 -0
- package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
- package/es/assets/css/statistic-time-picker.module.css +21 -0
- package/es/assets/css/theme.css +61 -0
- package/es/assets/images/icon.png +0 -0
- package/es/calculator/base-calculator.js +111 -0
- package/es/calculator/basic-chart-calculator.js +571 -0
- package/es/calculator/combination-calculator.js +296 -0
- package/es/calculator/compare-bar-calculator.js +291 -0
- package/es/calculator/completeness-calculator.js +307 -0
- package/es/calculator/copy-value.js +47 -0
- package/es/calculator/dashboard-calculator.js +146 -0
- package/es/calculator/heat-map-calculator.js +225 -0
- package/es/calculator/horizontal-bar-calculator.js +100 -0
- package/es/calculator/index.js +88 -0
- package/es/calculator/map-calculator.js +169 -0
- package/es/calculator/mirror-calculator.js +217 -0
- package/es/calculator/number-card-calculator.js +135 -0
- package/es/calculator/pivot-table-calculator.js +810 -0
- package/es/calculator/scatter-calculator.js +150 -0
- package/es/calculator/thread-manager.js +70 -0
- package/es/calculator/trend-calculator.js +204 -0
- package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
- package/es/calculator/workers/calculator.worker.js +22 -0
- package/es/calculator/workers/card-calculator-worker.js +28 -0
- package/es/calculator/workers/combination-calculator-worker.js +257 -0
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
- package/es/calculator/workers/completeness-calculator-worker.js +153 -0
- package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
- package/es/calculator/workers/mirror-calculator-worker.js +132 -0
- package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
- package/es/calculator/workers/scatter-calculator-worker.js +67 -0
- package/es/calculator/workers/trend-calculator-worker.js +93 -0
- package/es/calculator/world-map-calculator.js +193 -0
- package/es/components/common-add-tool.js +19 -0
- package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
- package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
- package/es/components/dialog/color-theme-dialog.js +71 -0
- package/es/components/dialog/enlarged-chart-dialog.js +73 -0
- package/es/components/dialog/new-table-dialog.js +113 -0
- package/es/components/dialog/new-view-dialog.js +87 -0
- package/es/components/dialog/rename-view-dialog.js +87 -0
- package/es/components/dialog/statistic-record-dialog/index.css +114 -0
- package/es/components/dialog/statistic-record-dialog/index.js +174 -0
- package/es/components/dialog/table-select-dialog.js +93 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
- package/es/components/dtable-popover.js +109 -0
- package/es/components/dtable-search-input.js +137 -0
- package/es/components/dtable-select.js +104 -0
- package/es/components/index.js +11 -0
- package/es/components/loading.js +8 -0
- package/es/components/modal-portal.js +36 -0
- package/es/components/popover/color-rules/color-rule.js +179 -0
- package/es/components/popover/color-rules/index.js +87 -0
- package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
- package/es/components/popover/color-rules/rule-filters/index.css +214 -0
- package/es/components/popover/color-rules/rule-filters/index.js +97 -0
- package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
- package/es/components/popover/color-rules-popover.js +213 -0
- package/es/components/popover/color-selector-popover.js +85 -0
- package/es/components/seatable-radio/index.css +51 -0
- package/es/components/seatable-radio/index.js +28 -0
- package/es/components/select/index.js +2 -0
- package/es/components/select/option-group.css +104 -0
- package/es/components/select/option-group.js +225 -0
- package/es/components/select/option.js +51 -0
- package/es/components/select/select.css +211 -0
- package/es/components/select/select.js +157 -0
- package/es/components/toast/alert.js +130 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +164 -0
- package/es/components/toast/toastManager.js +150 -0
- package/es/components/toast/toaster.js +64 -0
- package/es/constants/color-rules.js +8 -0
- package/es/constants/dtable-select-style.js +61 -0
- package/es/constants/event-types.js +1 -0
- package/es/constants/index.js +501 -0
- package/es/constants/key-codes.js +102 -0
- package/es/constants/zIndexes.js +1 -0
- package/es/custom-g2.js +614 -0
- package/es/dashboard.js +408 -0
- package/es/desktop-dashboard.js +299 -0
- package/es/index.js +33 -0
- package/es/locale/index.js +17 -0
- package/es/locale/lang/de.js +237 -0
- package/es/locale/lang/en.js +237 -0
- package/es/locale/lang/fr.js +237 -0
- package/es/locale/lang/zh_CN.js +237 -0
- package/es/mobile-dashboard.js +103 -0
- package/es/model/collaborators.js +11 -0
- package/es/model/stat-item.js +340 -0
- package/es/model/statistic-dashboard.js +8 -0
- package/es/service/chart-service.js +192 -0
- package/es/service/dashboard-service.js +415 -0
- package/es/stat-editor/chart-name-editor.js +75 -0
- package/es/stat-editor/index.js +74 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
- package/es/stat-list/chart-preview.js +139 -0
- package/es/stat-list/index.js +275 -0
- package/es/stat-view/area-chart.js +521 -0
- package/es/stat-view/bar-chart.js +568 -0
- package/es/stat-view/base-chart.js +44 -0
- package/es/stat-view/basic-number-card.js +255 -0
- package/es/stat-view/combination-chart.js +558 -0
- package/es/stat-view/compare-chart.js +485 -0
- package/es/stat-view/completeness-chart.js +389 -0
- package/es/stat-view/custom-bar.js +433 -0
- package/es/stat-view/dashboard-chart.js +317 -0
- package/es/stat-view/heat-map.js +501 -0
- package/es/stat-view/horizontal-bar-chart.js +569 -0
- package/es/stat-view/index.js +183 -0
- package/es/stat-view/line-chart.js +505 -0
- package/es/stat-view/map.js +428 -0
- package/es/stat-view/mirror.js +285 -0
- package/es/stat-view/pie-chart.js +326 -0
- package/es/stat-view/pivot-table/index.js +206 -0
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
- package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
- package/es/stat-view/ring-chart.js +416 -0
- package/es/stat-view/scatter-chart.js +367 -0
- package/es/stat-view/treemap-chart.js +318 -0
- package/es/stat-view/trend-chart.js +299 -0
- package/es/stat-view/world-map.js +443 -0
- package/es/tabs/index.js +252 -0
- package/es/tabs/statistic-tabs.module.css +154 -0
- package/es/tabs/tab.js +167 -0
- package/es/utils/basic-chart-utils.js +24 -0
- package/es/utils/cell-format.js +110 -0
- package/es/utils/cell-value.js +27 -0
- package/es/utils/collaborator.js +31 -0
- package/es/utils/color-utils.js +112 -0
- package/es/utils/column-utils.js +18 -0
- package/es/utils/column.js +13 -0
- package/es/utils/common-utils.js +303 -0
- package/es/utils/date-format.js +65 -0
- package/es/utils/export-table-utils.js +632 -0
- package/es/utils/index.js +26 -0
- package/es/utils/object.js +26 -0
- package/es/utils/row-utils.js +115 -0
- package/es/utils/search.js +67 -0
- package/es/utils/sql-utils.js +293 -0
- package/es/utils/stat-utils.js +353 -0
- package/es/utils/trend-utils.js +136 -0
- package/index.js +1 -0
- package/package.json +188 -0
|
@@ -0,0 +1,326 @@
|
|
|
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
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import intl from 'react-intl-universal';
|
|
8
|
+
import { TableUtils, getNumberDisplayString } from 'dtable-store';
|
|
9
|
+
import BaseChart from './base-chart';
|
|
10
|
+
import { Chart } from '../custom-g2';
|
|
11
|
+
import { Loading } from '../components';
|
|
12
|
+
import { formatPieChartData, getCurrentTheme, getLabelFontSize } from '../utils/common-utils';
|
|
13
|
+
import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, LABEL_FORMATS, LABEL_POSITIONS, NO_STATISTIC_RESULTS, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE } from '../constants';
|
|
14
|
+
import chartStyles from '../assets/css/statistic-chart.module.css';
|
|
15
|
+
var propTypes = {
|
|
16
|
+
isPreview: PropTypes.bool,
|
|
17
|
+
isEnlarge: PropTypes.bool,
|
|
18
|
+
theme: PropTypes.string,
|
|
19
|
+
colorThemeName: PropTypes.string,
|
|
20
|
+
statItem: PropTypes.object,
|
|
21
|
+
chartCalculator: PropTypes.object,
|
|
22
|
+
getTableById: PropTypes.func,
|
|
23
|
+
toggleStatisticRecordsDialog: PropTypes.func
|
|
24
|
+
};
|
|
25
|
+
var PieChart = /*#__PURE__*/function (_BaseChart) {
|
|
26
|
+
_inherits(PieChart, _BaseChart);
|
|
27
|
+
var _super = _createSuper(PieChart);
|
|
28
|
+
function PieChart(props) {
|
|
29
|
+
var _this;
|
|
30
|
+
_classCallCheck(this, PieChart);
|
|
31
|
+
_this = _super.call(this, props);
|
|
32
|
+
_this.drawChart = function (data) {
|
|
33
|
+
var isPreview = _this.props.isPreview;
|
|
34
|
+
if (isPreview) {
|
|
35
|
+
_this.chart = new Chart({
|
|
36
|
+
container: _this.container,
|
|
37
|
+
autoFit: true,
|
|
38
|
+
padding: [20, 0]
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
_this.chart = new Chart({
|
|
42
|
+
container: _this.container,
|
|
43
|
+
autoFit: true,
|
|
44
|
+
height: 400,
|
|
45
|
+
width: 700
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
_this.drawPieChart(data, !isPreview);
|
|
49
|
+
_this.chart.render();
|
|
50
|
+
};
|
|
51
|
+
_this.drawPieChart = function (data, isCreating) {
|
|
52
|
+
if (data.length === 0) return;
|
|
53
|
+
var _this$props = _this.props,
|
|
54
|
+
getTableById = _this$props.getTableById,
|
|
55
|
+
theme = _this$props.theme,
|
|
56
|
+
isEnlarge = _this$props.isEnlarge,
|
|
57
|
+
isPreview = _this$props.isPreview,
|
|
58
|
+
statItem = _this$props.statItem,
|
|
59
|
+
colorThemeName = _this$props.colorThemeName;
|
|
60
|
+
_this.chart.coordinate('theta', {
|
|
61
|
+
radius: isCreating ? 0.75 : 0.95
|
|
62
|
+
});
|
|
63
|
+
var summary_type = statItem.summary_type,
|
|
64
|
+
summary_column_key = statItem.summary_column_key,
|
|
65
|
+
table_id = statItem.table_id,
|
|
66
|
+
show_legend = statItem.show_legend,
|
|
67
|
+
show_percent = statItem.show_percent,
|
|
68
|
+
display_label = statItem.display_label,
|
|
69
|
+
label_position = statItem.label_position;
|
|
70
|
+
var currentTheme = getCurrentTheme(colorThemeName);
|
|
71
|
+
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
72
|
+
var table = getTableById(table_id);
|
|
73
|
+
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
74
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key) || {};
|
|
75
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
76
|
+
}
|
|
77
|
+
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
78
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
79
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
80
|
+
}
|
|
81
|
+
var newData = formatPieChartData(data, statItem, table, currentTheme);
|
|
82
|
+
_this.chart.data(newData, {
|
|
83
|
+
'name': {
|
|
84
|
+
type: 'cat',
|
|
85
|
+
nice: false
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
_this.chart.on('element:click', function (e) {
|
|
89
|
+
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
90
|
+
});
|
|
91
|
+
var colorSet = newData.colorSet;
|
|
92
|
+
if (show_legend) {
|
|
93
|
+
_this.chart.legend('name', {
|
|
94
|
+
position: 'right',
|
|
95
|
+
custom: true,
|
|
96
|
+
itemName: {
|
|
97
|
+
style: {
|
|
98
|
+
fill: themeColors.textColor
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
items: newData.map(function (obj, index) {
|
|
102
|
+
var sIndex = String(index);
|
|
103
|
+
var colorIndex = sIndex.charAt(sIndex.length - 1);
|
|
104
|
+
var name = obj.name;
|
|
105
|
+
if (!obj.name && typeof obj.name !== 'number') {
|
|
106
|
+
name = intl.get(EMPTY_NAME);
|
|
107
|
+
} else if (obj.name === 'Others') {
|
|
108
|
+
name = intl.get('Others');
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
name: name,
|
|
112
|
+
value: obj.value,
|
|
113
|
+
marker: {
|
|
114
|
+
symbol: 'circle',
|
|
115
|
+
style: {
|
|
116
|
+
r: 5,
|
|
117
|
+
fill: colorSet[colorIndex]
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
_this.chart.legend(false);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Do not automatically adjust the maximum and minimum values in pie chart
|
|
128
|
+
_this.chart.scale({
|
|
129
|
+
value: {
|
|
130
|
+
nice: false
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
_this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('value*percent', function (value, percent) {
|
|
134
|
+
var displayedValue = getNumberDisplayString(value, columnData);
|
|
135
|
+
return {
|
|
136
|
+
content: _this.getLabel(displayedValue, percent)
|
|
137
|
+
};
|
|
138
|
+
}, {
|
|
139
|
+
offset: !label_position || label_position == LABEL_POSITIONS[0] ? isCreating ? -10 : -2 : undefined,
|
|
140
|
+
style: {
|
|
141
|
+
fill: themeColors.labelColor,
|
|
142
|
+
fontSize: _this.getLabelFontSize(),
|
|
143
|
+
shadowBlur: 2,
|
|
144
|
+
shadowColor: 'rgba(0, 0, 0, .45)'
|
|
145
|
+
}
|
|
146
|
+
}).tooltip('name*value*percent', function (name, value, percent) {
|
|
147
|
+
var title = name;
|
|
148
|
+
if (!name || name === 'undefined') {
|
|
149
|
+
title = intl.get(EMPTY_NAME);
|
|
150
|
+
} else if (name === 'Others') {
|
|
151
|
+
title = intl.get('Others');
|
|
152
|
+
}
|
|
153
|
+
var displayedValue = getNumberDisplayString(value, columnData);
|
|
154
|
+
return show_percent || display_label ? {
|
|
155
|
+
name: title,
|
|
156
|
+
value: _this.getLabel(displayedValue, percent)
|
|
157
|
+
} : {
|
|
158
|
+
name: title,
|
|
159
|
+
value: displayedValue
|
|
160
|
+
};
|
|
161
|
+
}).state({
|
|
162
|
+
active: {
|
|
163
|
+
style: {
|
|
164
|
+
fillOpacity: 0.7,
|
|
165
|
+
border: 'none',
|
|
166
|
+
stroke: 0
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
_this.chart.tooltip({
|
|
171
|
+
showTitle: false,
|
|
172
|
+
showMarkers: false,
|
|
173
|
+
itemTpl: '<div class="g2-tooltip-list-item"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</div>'
|
|
174
|
+
});
|
|
175
|
+
_this.chart.interaction('element-active');
|
|
176
|
+
};
|
|
177
|
+
_this.getLabel = function (value, percent) {
|
|
178
|
+
var _this$props$statItem = _this.props.statItem,
|
|
179
|
+
show_percent = _this$props$statItem.show_percent,
|
|
180
|
+
display_label = _this$props$statItem.display_label,
|
|
181
|
+
label_format = _this$props$statItem.label_format;
|
|
182
|
+
var content;
|
|
183
|
+
if (show_percent) {
|
|
184
|
+
content = percent;
|
|
185
|
+
return content;
|
|
186
|
+
} else {
|
|
187
|
+
if (!display_label) {
|
|
188
|
+
content = '';
|
|
189
|
+
return content;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
switch (label_format) {
|
|
193
|
+
case LABEL_FORMATS[0]:
|
|
194
|
+
content = percent;
|
|
195
|
+
break;
|
|
196
|
+
case LABEL_FORMATS[1]:
|
|
197
|
+
content = value;
|
|
198
|
+
break;
|
|
199
|
+
case LABEL_FORMATS[2]:
|
|
200
|
+
content = "".concat(value, " (").concat(percent, ")");
|
|
201
|
+
break;
|
|
202
|
+
default:
|
|
203
|
+
content = percent;
|
|
204
|
+
}
|
|
205
|
+
return content;
|
|
206
|
+
};
|
|
207
|
+
_this.destroyChart = function () {
|
|
208
|
+
_this.chart.destroy();
|
|
209
|
+
_this.chart = null;
|
|
210
|
+
};
|
|
211
|
+
_this.getLabelFontSize = function () {
|
|
212
|
+
var statItem = _this.props.statItem;
|
|
213
|
+
var label_font_size = statItem.label_font_size;
|
|
214
|
+
return getLabelFontSize(label_font_size);
|
|
215
|
+
};
|
|
216
|
+
_this.state = {
|
|
217
|
+
isCalculatingData: true,
|
|
218
|
+
showResultDescription: true
|
|
219
|
+
};
|
|
220
|
+
_this.calculateData = null;
|
|
221
|
+
return _this;
|
|
222
|
+
}
|
|
223
|
+
_createClass(PieChart, [{
|
|
224
|
+
key: "componentDidMount",
|
|
225
|
+
value: function componentDidMount() {
|
|
226
|
+
var _this2 = this;
|
|
227
|
+
var _this$props2 = this.props,
|
|
228
|
+
statItem = _this$props2.statItem,
|
|
229
|
+
chartCalculator = _this$props2.chartCalculator;
|
|
230
|
+
if (this.container) {
|
|
231
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
232
|
+
var showResultDescription = data.length > 0 ? false : true;
|
|
233
|
+
_this2.setState({
|
|
234
|
+
isCalculatingData: false,
|
|
235
|
+
showResultDescription: showResultDescription
|
|
236
|
+
}, function () {
|
|
237
|
+
if (!showResultDescription) {
|
|
238
|
+
_this2.drawChart(data);
|
|
239
|
+
_this2.calculateData = data;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}, {
|
|
246
|
+
key: "shouldComponentUpdate",
|
|
247
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
248
|
+
var colorThemeName = this.props.colorThemeName;
|
|
249
|
+
if (this.canUpdate(this.props, nextProps)) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
if (nextProps.colorThemeName !== colorThemeName) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
key: "componentDidUpdate",
|
|
262
|
+
value: function componentDidUpdate(preProps, preState) {
|
|
263
|
+
var _this3 = this;
|
|
264
|
+
var _this$props3 = this.props,
|
|
265
|
+
statItem = _this$props3.statItem,
|
|
266
|
+
chartCalculator = _this$props3.chartCalculator;
|
|
267
|
+
var isCalculatingData = this.state.isCalculatingData;
|
|
268
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
269
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
270
|
+
this.setState({
|
|
271
|
+
isCalculatingData: true
|
|
272
|
+
});
|
|
273
|
+
if (this.container) {
|
|
274
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
275
|
+
var showResultDescription = data.length > 0 ? false : true;
|
|
276
|
+
_this3.chart && _this3.destroyChart();
|
|
277
|
+
_this3.calculateData = data;
|
|
278
|
+
_this3.setState({
|
|
279
|
+
isCalculatingData: false,
|
|
280
|
+
showResultDescription: showResultDescription
|
|
281
|
+
}, function () {
|
|
282
|
+
if (!showResultDescription) {
|
|
283
|
+
_this3.drawChart(data);
|
|
284
|
+
if (_this3.props.isPreview) _this3.chart.forceFit();
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
if (!this.state.showResultDescription) {
|
|
291
|
+
this.chart && this.destroyChart();
|
|
292
|
+
this.drawChart(this.calculateData);
|
|
293
|
+
if (this.props.isPreview) {
|
|
294
|
+
this.chart.forceFit();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}, {
|
|
300
|
+
key: "componentWillUnmount",
|
|
301
|
+
value: function componentWillUnmount() {
|
|
302
|
+
this.container = null;
|
|
303
|
+
}
|
|
304
|
+
}, {
|
|
305
|
+
key: "render",
|
|
306
|
+
value: function render() {
|
|
307
|
+
var _this4 = this;
|
|
308
|
+
var _this$state = this.state,
|
|
309
|
+
isCalculatingData = _this$state.isCalculatingData,
|
|
310
|
+
showResultDescription = _this$state.showResultDescription;
|
|
311
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
312
|
+
className: 'statistic-chart-loading-container'
|
|
313
|
+
}, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
|
|
314
|
+
className: 'statistic-chart-text'
|
|
315
|
+
}, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
|
|
316
|
+
ref: function ref(_ref) {
|
|
317
|
+
return _this4.container = _ref;
|
|
318
|
+
},
|
|
319
|
+
className: "".concat(chartStyles['statistic-pie-chart-container'], " statistic-chart-container")
|
|
320
|
+
}));
|
|
321
|
+
}
|
|
322
|
+
}]);
|
|
323
|
+
return PieChart;
|
|
324
|
+
}(BaseChart);
|
|
325
|
+
PieChart.propTypes = propTypes;
|
|
326
|
+
export default PieChart;
|
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import intl from 'react-intl-universal';
|
|
8
|
+
import { getDateDisplayString, getNumberDisplayString, TableUtils } from 'dtable-store';
|
|
9
|
+
import BaseChart from '../base-chart';
|
|
10
|
+
import OneDimensionTableNoNumericColumns from './one-dimension-table-no-numeric-columns';
|
|
11
|
+
import TwoDimensionTable from './two-dimension-table';
|
|
12
|
+
import OneDimensionTableWithNumericColumns from './one-dimension-table-with-numeric-columns';
|
|
13
|
+
import { Loading } from '../../components';
|
|
14
|
+
import { TIME_COLUMN_LIST, STAT_ITEM_THEME_COLORS, DEFAULT_NUMBER_FORMAT_OBJECT, SUMMARY_TYPE, NO_STATISTIC_RESULTS, TOO_MANY_STATISTIC_ENTRIES } from '../../constants';
|
|
15
|
+
import styles from './statistic-pivot-table.module.css';
|
|
16
|
+
var PivotTable = /*#__PURE__*/function (_BaseChart) {
|
|
17
|
+
_inherits(PivotTable, _BaseChart);
|
|
18
|
+
var _super = _createSuper(PivotTable);
|
|
19
|
+
function PivotTable(props) {
|
|
20
|
+
var _this;
|
|
21
|
+
_classCallCheck(this, PivotTable);
|
|
22
|
+
_this = _super.call(this, props);
|
|
23
|
+
_this.isValidValue = function (value) {
|
|
24
|
+
if (value === 0) return true;
|
|
25
|
+
return Boolean(value);
|
|
26
|
+
};
|
|
27
|
+
_this.renderPivotTable = function () {
|
|
28
|
+
var _this$props = _this.props,
|
|
29
|
+
statItem = _this$props.statItem,
|
|
30
|
+
isPreview = _this$props.isPreview,
|
|
31
|
+
theme = _this$props.theme,
|
|
32
|
+
isEnlarge = _this$props.isEnlarge,
|
|
33
|
+
getTableById = _this$props.getTableById;
|
|
34
|
+
var statData = _this.state.statData;
|
|
35
|
+
if (!Object.keys(statData).length > 0) return '';
|
|
36
|
+
var pivot_columns = statData.pivot_columns;
|
|
37
|
+
var column_groupby_column_key = statItem.column_groupby_column_key;
|
|
38
|
+
var themeColors = '#212529';
|
|
39
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
40
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(pivot_columns) && pivot_columns.length > 100) {
|
|
43
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
className: 'statistic-chart-text'
|
|
45
|
+
}, intl.get(TOO_MANY_STATISTIC_ENTRIES));
|
|
46
|
+
}
|
|
47
|
+
if (column_groupby_column_key) {
|
|
48
|
+
return /*#__PURE__*/React.createElement(TwoDimensionTable, {
|
|
49
|
+
pivotResult: _this.state.statData,
|
|
50
|
+
statItem: statItem,
|
|
51
|
+
isPreview: isPreview,
|
|
52
|
+
textColor: themeColors.textColor,
|
|
53
|
+
getTableById: getTableById,
|
|
54
|
+
isValidValue: _this.isValidValue,
|
|
55
|
+
getSummaryValueDisplayString: _this.getSummaryValueDisplayString,
|
|
56
|
+
toggleStatisticRecordsDialog: _this.props.toggleStatisticRecordsDialog
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (pivot_columns.length < 2) {
|
|
60
|
+
return /*#__PURE__*/React.createElement(OneDimensionTableNoNumericColumns, {
|
|
61
|
+
pivotResult: _this.state.statData,
|
|
62
|
+
statItem: statItem,
|
|
63
|
+
isPreview: isPreview,
|
|
64
|
+
textColor: themeColors.textColor,
|
|
65
|
+
getTableById: getTableById,
|
|
66
|
+
isValidValue: _this.isValidValue,
|
|
67
|
+
getSummaryValueDisplayString: _this.getSummaryValueDisplayString,
|
|
68
|
+
toggleStatisticRecordsDialog: _this.props.toggleStatisticRecordsDialog
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/React.createElement(OneDimensionTableWithNumericColumns, {
|
|
72
|
+
getSummaryValueDisplayString: _this.getSummaryValueDisplayString,
|
|
73
|
+
pivotResult: _this.state.statData,
|
|
74
|
+
statItem: statItem,
|
|
75
|
+
isPreview: isPreview,
|
|
76
|
+
textColor: themeColors.textColor,
|
|
77
|
+
getTableById: getTableById,
|
|
78
|
+
isValidValue: _this.isValidValue,
|
|
79
|
+
toggleStatisticRecordsDialog: _this.props.toggleStatisticRecordsDialog
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
_this.getSummaryValueDisplayString = function (summaryColumn, summaryValue) {
|
|
83
|
+
var summaryMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : SUMMARY_TYPE.COUNT;
|
|
84
|
+
if (!summaryColumn || !summaryColumn.type) return summaryValue;
|
|
85
|
+
if (!summaryValue && summaryValue !== 0) return summaryValue;
|
|
86
|
+
if (summaryMethod.toUpperCase() === 'DISTINCT_VALUES') return summaryValue;
|
|
87
|
+
var data = summaryColumn.data;
|
|
88
|
+
if (TIME_COLUMN_LIST.includes(summaryColumn.type)) {
|
|
89
|
+
if (typeof summaryValue !== 'string') return summaryValue;
|
|
90
|
+
// The date returned by db carries T and Z, so that there is a time difference in data formatting
|
|
91
|
+
var _ref = data || {},
|
|
92
|
+
format = _ref.format;
|
|
93
|
+
return getDateDisplayString(summaryValue.replace(/[T|Z]/g, ' '), format);
|
|
94
|
+
}
|
|
95
|
+
if (typeof summaryValue !== 'number') return summaryValue;
|
|
96
|
+
return getNumberDisplayString(summaryValue, data || DEFAULT_NUMBER_FORMAT_OBJECT);
|
|
97
|
+
};
|
|
98
|
+
_this.getStatData = function () {
|
|
99
|
+
var _this$props2 = _this.props,
|
|
100
|
+
getTableById = _this$props2.getTableById,
|
|
101
|
+
statItem = _this$props2.statItem;
|
|
102
|
+
var table_id = statItem.table_id,
|
|
103
|
+
groupby_column_key = statItem.groupby_column_key,
|
|
104
|
+
column_groupby_column_key = statItem.column_groupby_column_key,
|
|
105
|
+
summary_column_key = statItem.summary_column_key;
|
|
106
|
+
var table = getTableById(table_id);
|
|
107
|
+
var groupbyColumn = groupby_column_key && TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
108
|
+
var columnGroupbyColumn = column_groupby_column_key && TableUtils.getTableColumnByKey(table, column_groupby_column_key);
|
|
109
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key) || {};
|
|
110
|
+
return {
|
|
111
|
+
pivotResult: _this.state.statData,
|
|
112
|
+
statisticTableColumns: table.columns,
|
|
113
|
+
groupbyColumn: groupbyColumn,
|
|
114
|
+
columnGroupbyColumn: columnGroupbyColumn,
|
|
115
|
+
summaryColumn: summaryColumn
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
_this.state = {
|
|
119
|
+
isCalculatingData: true,
|
|
120
|
+
showResultDescription: true,
|
|
121
|
+
statData: null
|
|
122
|
+
};
|
|
123
|
+
_this.calculateData = null;
|
|
124
|
+
return _this;
|
|
125
|
+
}
|
|
126
|
+
_createClass(PivotTable, [{
|
|
127
|
+
key: "componentDidMount",
|
|
128
|
+
value: function componentDidMount() {
|
|
129
|
+
var _this2 = this;
|
|
130
|
+
var _this$props3 = this.props,
|
|
131
|
+
statItem = _this$props3.statItem,
|
|
132
|
+
chartCalculator = _this$props3.chartCalculator;
|
|
133
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
134
|
+
var showResultDescription = Object.keys(data).length > 0 ? false : true;
|
|
135
|
+
_this2.setState({
|
|
136
|
+
isCalculatingData: false,
|
|
137
|
+
showResultDescription: showResultDescription,
|
|
138
|
+
statData: data
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "shouldComponentUpdate",
|
|
144
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
145
|
+
if (this.canUpdate(this.props, nextProps) || nextState.isCalculatingData !== this.state.isCalculatingData || nextState.showResultDescription !== this.state.showResultDescription) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
152
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
153
|
+
var _this3 = this;
|
|
154
|
+
var nextStatItem = nextProps.statItem,
|
|
155
|
+
chartCalculator = nextProps.chartCalculator;
|
|
156
|
+
if (this.shouldCalculateStatItem(this.props, nextProps)) {
|
|
157
|
+
this.setState({
|
|
158
|
+
isCalculatingData: true
|
|
159
|
+
}, function () {
|
|
160
|
+
chartCalculator.calculate(nextStatItem).then(function (data) {
|
|
161
|
+
var showResultDescription = Object.keys(data).length > 0 ? false : true;
|
|
162
|
+
_this3.setState({
|
|
163
|
+
statData: data,
|
|
164
|
+
isCalculatingData: false,
|
|
165
|
+
showResultDescription: showResultDescription
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "render",
|
|
173
|
+
value: function render() {
|
|
174
|
+
var _this4 = this;
|
|
175
|
+
var isEdit = this.props.isEdit;
|
|
176
|
+
var _this$state = this.state,
|
|
177
|
+
isCalculatingData = _this$state.isCalculatingData,
|
|
178
|
+
showResultDescription = _this$state.showResultDescription;
|
|
179
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData ? /*#__PURE__*/React.createElement("div", {
|
|
180
|
+
className: 'statistic-chart-loading-container'
|
|
181
|
+
}, /*#__PURE__*/React.createElement(Loading, null)) : /*#__PURE__*/React.createElement("div", {
|
|
182
|
+
ref: function ref(_ref2) {
|
|
183
|
+
return _this4.container = _ref2;
|
|
184
|
+
},
|
|
185
|
+
style: isEdit ? {
|
|
186
|
+
padding: '15px 30px'
|
|
187
|
+
} : null,
|
|
188
|
+
className: "statistic-chart-container ".concat(styles['pivot-table-container'])
|
|
189
|
+
}, this.renderPivotTable()), showResultDescription && /*#__PURE__*/React.createElement("div", {
|
|
190
|
+
className: 'statistic-chart-text'
|
|
191
|
+
}, intl.get(NO_STATISTIC_RESULTS)));
|
|
192
|
+
}
|
|
193
|
+
}]);
|
|
194
|
+
return PivotTable;
|
|
195
|
+
}(BaseChart);
|
|
196
|
+
PivotTable.propTypes = {
|
|
197
|
+
isPreview: PropTypes.bool,
|
|
198
|
+
isEnlarge: PropTypes.bool,
|
|
199
|
+
isEdit: PropTypes.bool,
|
|
200
|
+
theme: PropTypes.string,
|
|
201
|
+
statItem: PropTypes.object,
|
|
202
|
+
chartCalculator: PropTypes.object,
|
|
203
|
+
getTableById: PropTypes.func,
|
|
204
|
+
toggleStatisticRecordsDialog: PropTypes.func
|
|
205
|
+
};
|
|
206
|
+
export default PivotTable;
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
import React, { PureComponent } from 'react';
|
|
6
|
+
import intl from 'react-intl-universal';
|
|
7
|
+
import { TableUtils, Views } from 'dtable-store';
|
|
8
|
+
import { isMobile } from '../../utils';
|
|
9
|
+
import { EMPTY_NAME, TITLE_TOTAL } from '../../constants';
|
|
10
|
+
import styles from './statistic-pivot-table.module.css';
|
|
11
|
+
var OneDimensionTableNoNumericColumns = /*#__PURE__*/function (_PureComponent) {
|
|
12
|
+
_inherits(OneDimensionTableNoNumericColumns, _PureComponent);
|
|
13
|
+
var _super = _createSuper(OneDimensionTableNoNumericColumns);
|
|
14
|
+
function OneDimensionTableNoNumericColumns() {
|
|
15
|
+
var _this;
|
|
16
|
+
_classCallCheck(this, OneDimensionTableNoNumericColumns);
|
|
17
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
args[_key] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
21
|
+
_this.toggleRecords = function (cell) {
|
|
22
|
+
if (isMobile) return;
|
|
23
|
+
_this.props.toggleStatisticRecordsDialog(cell, _this.props.statItem);
|
|
24
|
+
};
|
|
25
|
+
_this.onClickTotals = function (recordsList) {
|
|
26
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
27
|
+
isCurrentView = _ref.isCurrentView;
|
|
28
|
+
if (isMobile) return;
|
|
29
|
+
var _this$props = _this.props,
|
|
30
|
+
getTableById = _this$props.getTableById,
|
|
31
|
+
statItem = _this$props.statItem;
|
|
32
|
+
var rows = [];
|
|
33
|
+
var table_id = statItem.table_id,
|
|
34
|
+
view_id = statItem.view_id;
|
|
35
|
+
var table = getTableById(table_id);
|
|
36
|
+
var view = Views.getViewById(table.views, view_id);
|
|
37
|
+
if (!Views.isArchiveView(view)) {
|
|
38
|
+
rows = recordsList.flat();
|
|
39
|
+
}
|
|
40
|
+
_this.props.toggleStatisticRecordsDialog({
|
|
41
|
+
rows: rows
|
|
42
|
+
}, _this.props.statItem, {
|
|
43
|
+
isCurrentView: isCurrentView
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
_this.renderHeader = function (_ref2) {
|
|
47
|
+
var table = _ref2.table;
|
|
48
|
+
var statItem = _this.props.statItem;
|
|
49
|
+
var groupby_column_key = statItem.groupby_column_key,
|
|
50
|
+
_statItem$display_tot = statItem.display_total,
|
|
51
|
+
display_total = _statItem$display_tot === void 0 ? true : _statItem$display_tot;
|
|
52
|
+
var groupByColumn = TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
53
|
+
var _ref3 = groupByColumn || {},
|
|
54
|
+
groupName = _ref3.name;
|
|
55
|
+
return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
56
|
+
className: "pivot-table-header"
|
|
57
|
+
}, /*#__PURE__*/React.createElement("div", null, groupName)), display_total && /*#__PURE__*/React.createElement("th", {
|
|
58
|
+
className: 'pivot-table-header'
|
|
59
|
+
}, /*#__PURE__*/React.createElement("div", null, intl.get(TITLE_TOTAL)))));
|
|
60
|
+
};
|
|
61
|
+
_this.renderRows = function (_ref4) {
|
|
62
|
+
var table = _ref4.table;
|
|
63
|
+
var _this$props2 = _this.props,
|
|
64
|
+
pivotResult = _this$props2.pivotResult,
|
|
65
|
+
statItem = _this$props2.statItem,
|
|
66
|
+
getSummaryValueDisplayString = _this$props2.getSummaryValueDisplayString;
|
|
67
|
+
var pivot_rows = pivotResult.pivot_rows,
|
|
68
|
+
pivot_columns_total = pivotResult.pivot_columns_total;
|
|
69
|
+
var summary_column_key = statItem.summary_column_key,
|
|
70
|
+
summary_method = statItem.summary_method,
|
|
71
|
+
_statItem$display_tot2 = statItem.display_total,
|
|
72
|
+
display_total = _statItem$display_tot2 === void 0 ? true : _statItem$display_tot2;
|
|
73
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key) || {};
|
|
74
|
+
var columnTotal = getSummaryValueDisplayString(summaryColumn, pivot_columns_total['total'], summary_method);
|
|
75
|
+
var isValidTColumnTotal = _this.props.isValidValue(columnTotal);
|
|
76
|
+
var pivotColumnCells = [];
|
|
77
|
+
return /*#__PURE__*/React.createElement("tbody", null, pivot_rows.map(function (rowItem, rowIdx) {
|
|
78
|
+
var name = rowItem.name,
|
|
79
|
+
total = rowItem.total,
|
|
80
|
+
rows = rowItem.rows;
|
|
81
|
+
var totalDisplayValue = getSummaryValueDisplayString(summaryColumn, total.total, summary_method);
|
|
82
|
+
var isValidTotalDisplayValue = _this.props.isValidValue(totalDisplayValue);
|
|
83
|
+
pivotColumnCells[rowIdx] = rows;
|
|
84
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
85
|
+
key: 'table-row-' + rowIdx
|
|
86
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
87
|
+
className: 'pivot-row-name'
|
|
88
|
+
}, /*#__PURE__*/React.createElement("div", null, !name || name === 0 ? intl.get(EMPTY_NAME) : name)), display_total && /*#__PURE__*/React.createElement("td", {
|
|
89
|
+
className: "".concat(styles['pivot-cell'], " ").concat(isValidTotalDisplayValue ? '' : styles['pivot-empty-cell']),
|
|
90
|
+
title: isValidTotalDisplayValue ? totalDisplayValue : '',
|
|
91
|
+
onClick: function onClick() {
|
|
92
|
+
return _this.toggleRecords(rowItem);
|
|
93
|
+
}
|
|
94
|
+
}, isValidTotalDisplayValue ? /*#__PURE__*/React.createElement("div", null, totalDisplayValue) : /*#__PURE__*/React.createElement("i", null)));
|
|
95
|
+
}), display_total && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
96
|
+
className: 'pivot-column-total'
|
|
97
|
+
}, /*#__PURE__*/React.createElement("div", null, intl.get(TITLE_TOTAL))), /*#__PURE__*/React.createElement("td", {
|
|
98
|
+
className: "".concat(styles['pivot-cell'], " pivot-table-total ").concat(isValidTColumnTotal ? '' : styles['pivot-empty-cell']),
|
|
99
|
+
onClick: function onClick() {
|
|
100
|
+
return _this.onClickTotals(pivotColumnCells, {
|
|
101
|
+
isCurrentView: true
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
title: isValidTColumnTotal ? columnTotal : ''
|
|
105
|
+
}, isValidTColumnTotal ? /*#__PURE__*/React.createElement("div", null, columnTotal) : /*#__PURE__*/React.createElement("i", null))));
|
|
106
|
+
};
|
|
107
|
+
return _this;
|
|
108
|
+
}
|
|
109
|
+
_createClass(OneDimensionTableNoNumericColumns, [{
|
|
110
|
+
key: "render",
|
|
111
|
+
value: function render() {
|
|
112
|
+
var _this$props3 = this.props,
|
|
113
|
+
isPreview = _this$props3.isPreview,
|
|
114
|
+
textColor = _this$props3.textColor,
|
|
115
|
+
statItem = _this$props3.statItem,
|
|
116
|
+
getTableById = _this$props3.getTableById;
|
|
117
|
+
var table_id = statItem.table_id;
|
|
118
|
+
var table = getTableById(table_id);
|
|
119
|
+
return /*#__PURE__*/React.createElement("table", {
|
|
120
|
+
style: {
|
|
121
|
+
color: textColor
|
|
122
|
+
},
|
|
123
|
+
className: "".concat(isPreview ? styles['preview-pivot-table'] : styles['large-pivot-table'], " ").concat(styles['pivot-table'])
|
|
124
|
+
}, this.renderHeader({
|
|
125
|
+
table: table
|
|
126
|
+
}), this.renderRows({
|
|
127
|
+
table: table
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
}]);
|
|
131
|
+
return OneDimensionTableNoNumericColumns;
|
|
132
|
+
}(PureComponent);
|
|
133
|
+
export default OneDimensionTableNoNumericColumns;
|