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,443 @@
|
|
|
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 DataSet from '@antv/data-set/lib/index';
|
|
8
|
+
import intl from 'react-intl-universal';
|
|
9
|
+
import { TableUtils, getNumberDisplayString } from 'dtable-store';
|
|
10
|
+
import BaseChart from './base-chart';
|
|
11
|
+
import { Chart } from '../custom-g2';
|
|
12
|
+
import { Loading } from '../components';
|
|
13
|
+
import { COLOR_OPTIONS, DEFAULT_NUMBER_FORMAT_OBJECT, STAT_ITEM_THEME_COLORS, STAT_TYPE, SUMMARY_TYPE, TITLE_AMOUNT } from '../constants';
|
|
14
|
+
var WIDTH = 798;
|
|
15
|
+
var HEIGHT = 394;
|
|
16
|
+
var WorldMap = /*#__PURE__*/function (_BaseChart) {
|
|
17
|
+
_inherits(WorldMap, _BaseChart);
|
|
18
|
+
var _super = _createSuper(WorldMap);
|
|
19
|
+
function WorldMap(props) {
|
|
20
|
+
var _this;
|
|
21
|
+
_classCallCheck(this, WorldMap);
|
|
22
|
+
_this = _super.call(this, props);
|
|
23
|
+
_this.fixData = function (statisticData) {
|
|
24
|
+
if (!statisticData) return [];
|
|
25
|
+
var statisticNewData = [];
|
|
26
|
+
var sum = 0;
|
|
27
|
+
var statItem = _this.props.statItem;
|
|
28
|
+
var type = statItem.type;
|
|
29
|
+
statisticData.forEach(function (item, index) {
|
|
30
|
+
if (item && item.name) {
|
|
31
|
+
var nameType, name, name_cn;
|
|
32
|
+
if (_this.reg.test(item.name)) {
|
|
33
|
+
nameType = 'en';
|
|
34
|
+
name = item.name;
|
|
35
|
+
name_cn = _this.countryMap.get(name);
|
|
36
|
+
} else {
|
|
37
|
+
nameType = 'zh-cn';
|
|
38
|
+
name = _this.countryMap.get(item.name);
|
|
39
|
+
name_cn = item.name;
|
|
40
|
+
}
|
|
41
|
+
var value = item.value;
|
|
42
|
+
if (name_cn && name) {
|
|
43
|
+
statisticNewData.push({
|
|
44
|
+
name_cn: name_cn,
|
|
45
|
+
name: name,
|
|
46
|
+
nameType: nameType,
|
|
47
|
+
value: value || 0
|
|
48
|
+
});
|
|
49
|
+
if (type === STAT_TYPE.WORLD_MAP_BUBBLE) {
|
|
50
|
+
sum += item.value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
if (type === STAT_TYPE.WORLD_MAP_BUBBLE) {
|
|
56
|
+
statisticNewData.sum = sum;
|
|
57
|
+
}
|
|
58
|
+
return statisticNewData;
|
|
59
|
+
};
|
|
60
|
+
_this.renderCommonMap = function (data) {
|
|
61
|
+
var _this$props = _this.props,
|
|
62
|
+
getTableById = _this$props.getTableById,
|
|
63
|
+
statItem = _this$props.statItem,
|
|
64
|
+
theme = _this$props.theme,
|
|
65
|
+
isEnlarge = _this$props.isEnlarge,
|
|
66
|
+
isPreview = _this$props.isPreview;
|
|
67
|
+
var userDataView = _this.dataSet.getView('statisticViewModel').source(data).transform({
|
|
68
|
+
geoDataView: _this.dataSet.getView('mapDataModel'),
|
|
69
|
+
field: 'name',
|
|
70
|
+
type: 'geo.region',
|
|
71
|
+
as: ['longitude', 'latitude']
|
|
72
|
+
});
|
|
73
|
+
var _this$props$statItem = _this.props.statItem,
|
|
74
|
+
table_id = _this$props$statItem.table_id,
|
|
75
|
+
data_color = _this$props$statItem.data_color,
|
|
76
|
+
summary_type = _this$props$statItem.summary_type,
|
|
77
|
+
summary_column = _this$props$statItem.summary_column;
|
|
78
|
+
var currentColorOption = COLOR_OPTIONS.filter(function (item) {
|
|
79
|
+
return item.name == data_color;
|
|
80
|
+
})[0] || COLOR_OPTIONS[0];
|
|
81
|
+
var exampleColors = currentColorOption.exampleColors,
|
|
82
|
+
highlightedBorderColor = currentColorOption.highlightedBorderColor;
|
|
83
|
+
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
84
|
+
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
85
|
+
var table = getTableById(table_id);
|
|
86
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
|
|
87
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
88
|
+
}
|
|
89
|
+
_this.statisticView = _this.chart.createView();
|
|
90
|
+
_this.statisticView.data(userDataView.rows);
|
|
91
|
+
_this.statisticView.polygon().position('longitude*latitude').color('value', "".concat(exampleColors[0], "-").concat(exampleColors[4], "-").concat(exampleColors[8])).style({
|
|
92
|
+
lineWidth: 1,
|
|
93
|
+
stroke: '#bdbdbd',
|
|
94
|
+
strokeOpacity: 0.5
|
|
95
|
+
}).state({
|
|
96
|
+
active: {
|
|
97
|
+
style: {
|
|
98
|
+
lineWidth: 1,
|
|
99
|
+
stroke: highlightedBorderColor
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}).tooltip('name*value*color*nameType*name_cn', function (name, value, color, nameType, name_cn) {
|
|
103
|
+
return {
|
|
104
|
+
name: nameType === 'en' ? name : name_cn,
|
|
105
|
+
value: getNumberDisplayString(value, columnData),
|
|
106
|
+
color: color
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
110
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
111
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
112
|
+
}
|
|
113
|
+
var legendDirection = statItem.legend_direction || 'vertical';
|
|
114
|
+
var size = statItem.legend_size || 1;
|
|
115
|
+
_this.chart.legend({
|
|
116
|
+
layout: legendDirection,
|
|
117
|
+
position: legendDirection === 'vertical' ? 'left-bottom' : 'bottom-left',
|
|
118
|
+
rail: {
|
|
119
|
+
type: 'color',
|
|
120
|
+
defaultLength: 100 * size
|
|
121
|
+
},
|
|
122
|
+
label: {
|
|
123
|
+
spacing: 2,
|
|
124
|
+
style: {
|
|
125
|
+
fill: themeColors.textColor
|
|
126
|
+
},
|
|
127
|
+
align: legendDirection === 'vertical' ? 'right' : 'bottom',
|
|
128
|
+
formatter: function formatter(value) {
|
|
129
|
+
return getNumberDisplayString(value, columnData);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
handler: {
|
|
133
|
+
style: {
|
|
134
|
+
'opacity': 0
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
_this.statisticView.interaction('element-active');
|
|
139
|
+
_this.statisticView.render();
|
|
140
|
+
};
|
|
141
|
+
_this.renderBubbleMap = function (data) {
|
|
142
|
+
var _this$props2 = _this.props,
|
|
143
|
+
getTableById = _this$props2.getTableById,
|
|
144
|
+
statItem = _this$props2.statItem,
|
|
145
|
+
isPreview = _this$props2.isPreview,
|
|
146
|
+
isEnlarge = _this$props2.isEnlarge,
|
|
147
|
+
theme = _this$props2.theme;
|
|
148
|
+
var userDv = _this.dataSet.createView().source(data).transform({
|
|
149
|
+
geoDataView: _this.dataSet.getView('mapDataModel'),
|
|
150
|
+
field: 'name',
|
|
151
|
+
type: 'geo.centroid',
|
|
152
|
+
as: ['longitude', 'latitude']
|
|
153
|
+
});
|
|
154
|
+
var _this$props$statItem2 = _this.props.statItem,
|
|
155
|
+
table_id = _this$props$statItem2.table_id,
|
|
156
|
+
summary_type = _this$props$statItem2.summary_type,
|
|
157
|
+
summary_column = _this$props$statItem2.summary_column;
|
|
158
|
+
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
159
|
+
if (summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
160
|
+
var table = getTableById(table_id);
|
|
161
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column) || {};
|
|
162
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
163
|
+
}
|
|
164
|
+
_this.statisticView = _this.chart.createView();
|
|
165
|
+
_this.statisticView.data(userDv.rows);
|
|
166
|
+
_this.statisticView.point().position('longitude*latitude').size('value', function (value) {
|
|
167
|
+
var percent = value / data.sum;
|
|
168
|
+
var size = percent * 100;
|
|
169
|
+
if (isPreview && size > 60) {
|
|
170
|
+
size = 60;
|
|
171
|
+
}
|
|
172
|
+
return size;
|
|
173
|
+
}).shape('circle').color(statItem.bubble_color || '#2a67d1').tooltip('name*value*color', function (name, value, color) {
|
|
174
|
+
return {
|
|
175
|
+
name: name,
|
|
176
|
+
value: getNumberDisplayString(value, columnData),
|
|
177
|
+
color: color
|
|
178
|
+
};
|
|
179
|
+
}).style({
|
|
180
|
+
fillOpacity: 0.6,
|
|
181
|
+
stroke: statItem.bubble_color || '#2a67d1'
|
|
182
|
+
}).state({
|
|
183
|
+
active: {
|
|
184
|
+
style: {
|
|
185
|
+
lineWidth: 1,
|
|
186
|
+
stroke: statItem.bubble_color || '#2a67d1',
|
|
187
|
+
fillOpacity: 0.9
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
192
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
193
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
194
|
+
}
|
|
195
|
+
var legendDirection = statItem.legend_direction || 'vertical';
|
|
196
|
+
var size = statItem.legend_size || 1;
|
|
197
|
+
_this.chart.legend({
|
|
198
|
+
layout: legendDirection,
|
|
199
|
+
position: legendDirection === 'vertical' ? 'left-bottom' : 'bottom-left',
|
|
200
|
+
rail: {
|
|
201
|
+
type: 'size',
|
|
202
|
+
defaultLength: 100 * size
|
|
203
|
+
},
|
|
204
|
+
label: {
|
|
205
|
+
style: {
|
|
206
|
+
fill: themeColors.textColor
|
|
207
|
+
},
|
|
208
|
+
align: legendDirection === 'vertical' ? 'right' : 'bottom',
|
|
209
|
+
formatter: function formatter(value) {
|
|
210
|
+
return getNumberDisplayString(value, columnData);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
handler: {
|
|
214
|
+
style: {
|
|
215
|
+
'opacity': 0
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
_this.statisticView.interaction('element-active');
|
|
220
|
+
_this.statisticView.render();
|
|
221
|
+
};
|
|
222
|
+
_this.updateStatisticData = function (data) {
|
|
223
|
+
// re-render statistic data view;
|
|
224
|
+
if (_this.statisticView) {
|
|
225
|
+
_this.statisticView.destroy();
|
|
226
|
+
}
|
|
227
|
+
if (data.length === 0) {
|
|
228
|
+
_this.chart.legend(false);
|
|
229
|
+
_this.chart.render();
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
var statItem = _this.props.statItem;
|
|
233
|
+
var type = statItem.type;
|
|
234
|
+
if (!type.includes('bubble')) {
|
|
235
|
+
_this.renderCommonMap(data);
|
|
236
|
+
} else {
|
|
237
|
+
_this.renderBubbleMap(data);
|
|
238
|
+
}
|
|
239
|
+
_this.chart.render();
|
|
240
|
+
};
|
|
241
|
+
_this.getCanvasSize = function () {
|
|
242
|
+
var maxWidth = _this.container.clientWidth;
|
|
243
|
+
var maxHeight = _this.container.clientHeight;
|
|
244
|
+
var h = maxHeight;
|
|
245
|
+
var w = h * (WIDTH / HEIGHT);
|
|
246
|
+
if (w > maxWidth) {
|
|
247
|
+
w = maxWidth;
|
|
248
|
+
h = w * (HEIGHT / WIDTH);
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
w: w,
|
|
252
|
+
h: h
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
_this.initStatisticContext = function (geolocation) {
|
|
256
|
+
_this.countryMap = new Map();
|
|
257
|
+
geolocation.features.forEach(function (item) {
|
|
258
|
+
_this.countryMap.set(item.properties.name, item.properties.name_cn);
|
|
259
|
+
_this.countryMap.set(item.properties.name_cn, item.properties.name);
|
|
260
|
+
});
|
|
261
|
+
if (!_this.container) return;
|
|
262
|
+
// create chart
|
|
263
|
+
var canvasSize = _this.getCanvasSize();
|
|
264
|
+
_this.chart = new Chart({
|
|
265
|
+
container: _this.container,
|
|
266
|
+
width: canvasSize.w,
|
|
267
|
+
height: canvasSize.h,
|
|
268
|
+
padding: [20, 20]
|
|
269
|
+
});
|
|
270
|
+
_this.chart.on('element:click', function (e) {
|
|
271
|
+
var statItem = _this.props.statItem;
|
|
272
|
+
var data = e.data.data;
|
|
273
|
+
var lang = window.dtable ? window.dtable.lang : 'zh-cn';
|
|
274
|
+
var countryName = lang === 'zh-cn' ? data.name_cn : data.name;
|
|
275
|
+
var clickData = _this.calculateData.find(function (i) {
|
|
276
|
+
return i.name === countryName;
|
|
277
|
+
});
|
|
278
|
+
if (clickData) {
|
|
279
|
+
_this.props.toggleStatisticRecordsDialog(clickData, statItem);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
_this.chart.tooltip({
|
|
283
|
+
showTitle: false,
|
|
284
|
+
showMarkers: false,
|
|
285
|
+
shared: true,
|
|
286
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
287
|
+
itemTpl: "<div class=\"g2-tooltip-content\"><div class=\"tooltip-name\">{name}<div><div class=\"tooltip-item\">".concat(intl.get(TITLE_AMOUNT), " : {value}<div></div>"),
|
|
288
|
+
domStyles: {
|
|
289
|
+
'g2-tooltip': {
|
|
290
|
+
borderRadius: '2px',
|
|
291
|
+
backgroundColor: '#fff',
|
|
292
|
+
padding: '10px'
|
|
293
|
+
},
|
|
294
|
+
'tooltip-item': {
|
|
295
|
+
marginTop: '5px'
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
_this.chart.scale({
|
|
300
|
+
longitude: {
|
|
301
|
+
sync: true
|
|
302
|
+
},
|
|
303
|
+
latitude: {
|
|
304
|
+
sync: true
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
_this.chart.axis(false);
|
|
308
|
+
_this.dataSet = new DataSet();
|
|
309
|
+
|
|
310
|
+
// transform map data
|
|
311
|
+
var mapData = _this.dataSet.createView('mapDataModel').source(geolocation, {
|
|
312
|
+
type: 'GeoJSON'
|
|
313
|
+
});
|
|
314
|
+
var mapView = _this.chart.createView();
|
|
315
|
+
|
|
316
|
+
// draw background map
|
|
317
|
+
mapView.data(mapData.rows);
|
|
318
|
+
mapView.tooltip(false);
|
|
319
|
+
mapView.polygon().position('longitude*latitude').style({
|
|
320
|
+
fill: '#e2e2e2',
|
|
321
|
+
stroke: '#bdbdbd',
|
|
322
|
+
lineWidth: 1
|
|
323
|
+
});
|
|
324
|
+
_this.dataSet.createView('statisticViewModel');
|
|
325
|
+
mapView.render();
|
|
326
|
+
};
|
|
327
|
+
_this.getGeoLocationData = function () {
|
|
328
|
+
var mediaUrl = window.dtable.mediaUrl;
|
|
329
|
+
return fetch("".concat(mediaUrl, "dtable-statistic/geolocation/world.json")).catch(function (err) {});
|
|
330
|
+
};
|
|
331
|
+
_this.state = {
|
|
332
|
+
isDataLoaded: false,
|
|
333
|
+
isCalculatingData: true
|
|
334
|
+
};
|
|
335
|
+
_this.reg = /^([A-Za-z])/;
|
|
336
|
+
_this.calculateData = null;
|
|
337
|
+
_this.countryMap = null;
|
|
338
|
+
return _this;
|
|
339
|
+
}
|
|
340
|
+
_createClass(WorldMap, [{
|
|
341
|
+
key: "componentDidMount",
|
|
342
|
+
value: function componentDidMount() {
|
|
343
|
+
var _this2 = this;
|
|
344
|
+
var _this$props3 = this.props,
|
|
345
|
+
statItem = _this$props3.statItem,
|
|
346
|
+
chartCalculator = _this$props3.chartCalculator;
|
|
347
|
+
this.getGeoLocationData().then(function (res) {
|
|
348
|
+
return res && res.json();
|
|
349
|
+
}).then(function (data) {
|
|
350
|
+
_this2.setState({
|
|
351
|
+
isDataLoaded: true
|
|
352
|
+
});
|
|
353
|
+
if (!data) return;
|
|
354
|
+
_this2.initStatisticContext(data);
|
|
355
|
+
if (_this2.container) {
|
|
356
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
357
|
+
_this2.setState({
|
|
358
|
+
isCalculatingData: false
|
|
359
|
+
});
|
|
360
|
+
_this2.calculateData = data;
|
|
361
|
+
_this2.updateStatisticData(_this2.fixData(data));
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}, {
|
|
367
|
+
key: "shouldComponentUpdate",
|
|
368
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
369
|
+
if (this.canUpdate(this.props, nextProps) && nextState.isDataLoaded === this.state.isDataLoaded) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
}, {
|
|
378
|
+
key: "componentDidUpdate",
|
|
379
|
+
value: function componentDidUpdate(preProps, preState) {
|
|
380
|
+
var _this3 = this;
|
|
381
|
+
if (!this.chart || !this.dataSet) return;
|
|
382
|
+
var _this$props4 = this.props,
|
|
383
|
+
statItem = _this$props4.statItem,
|
|
384
|
+
chartCalculator = _this$props4.chartCalculator;
|
|
385
|
+
var isCalculatingData = this.state.isCalculatingData;
|
|
386
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
387
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
388
|
+
this.setState({
|
|
389
|
+
isCalculatingData: true
|
|
390
|
+
});
|
|
391
|
+
if (this.container) {
|
|
392
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
393
|
+
_this3.calculateData = data;
|
|
394
|
+
_this3.updateStatisticData(_this3.fixData(data));
|
|
395
|
+
if (_this3.props.isPreview) {
|
|
396
|
+
var canvasSize = _this3.getCanvasSize();
|
|
397
|
+
_this3.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
} else {
|
|
402
|
+
this.updateStatisticData(this.fixData(this.calculateData));
|
|
403
|
+
if (this.props.isPreview) {
|
|
404
|
+
var canvasSize = this.getCanvasSize();
|
|
405
|
+
this.chart.changeSize(canvasSize.w, canvasSize.h);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}, {
|
|
410
|
+
key: "componentWillUnmount",
|
|
411
|
+
value: function componentWillUnmount() {
|
|
412
|
+
this.container = null;
|
|
413
|
+
this.setState = function () {};
|
|
414
|
+
}
|
|
415
|
+
}, {
|
|
416
|
+
key: "render",
|
|
417
|
+
value: function render() {
|
|
418
|
+
var _this4 = this;
|
|
419
|
+
var _this$state = this.state,
|
|
420
|
+
isDataLoaded = _this$state.isDataLoaded,
|
|
421
|
+
isCalculatingData = _this$state.isCalculatingData;
|
|
422
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !isDataLoaded && isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
423
|
+
className: 'statistic-chart-loading-container'
|
|
424
|
+
}, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
|
|
425
|
+
ref: function ref(_ref) {
|
|
426
|
+
return _this4.container = _ref;
|
|
427
|
+
},
|
|
428
|
+
className: "statistic-chart-container d-flex justify-content-around align-items-center w-100 h-100"
|
|
429
|
+
}));
|
|
430
|
+
}
|
|
431
|
+
}]);
|
|
432
|
+
return WorldMap;
|
|
433
|
+
}(BaseChart);
|
|
434
|
+
WorldMap.propTypes = {
|
|
435
|
+
isPreview: PropTypes.bool,
|
|
436
|
+
isEnlarge: PropTypes.bool,
|
|
437
|
+
theme: PropTypes.string,
|
|
438
|
+
statItem: PropTypes.object,
|
|
439
|
+
chartCalculator: PropTypes.object,
|
|
440
|
+
getTableById: PropTypes.func,
|
|
441
|
+
toggleStatisticRecordsDialog: PropTypes.func
|
|
442
|
+
};
|
|
443
|
+
export default WorldMap;
|
package/es/tabs/index.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import React, { Component } from 'react';
|
|
7
|
+
import NewViewDialog from '../components/dialog/new-view-dialog';
|
|
8
|
+
import RenameViewDialog from '../components/dialog/rename-view-dialog';
|
|
9
|
+
import Tab from './tab';
|
|
10
|
+
import styles from './statistic-tabs.module.css';
|
|
11
|
+
var SCROLL_TYPE = {
|
|
12
|
+
PREV: 'prev',
|
|
13
|
+
NEXT: 'next'
|
|
14
|
+
};
|
|
15
|
+
var DashboardTabs = /*#__PURE__*/function (_Component) {
|
|
16
|
+
_inherits(DashboardTabs, _Component);
|
|
17
|
+
var _super = _createSuper(DashboardTabs);
|
|
18
|
+
function DashboardTabs(_props) {
|
|
19
|
+
var _this;
|
|
20
|
+
_classCallCheck(this, DashboardTabs);
|
|
21
|
+
_this = _super.call(this, _props);
|
|
22
|
+
_this.initSelectedViewScroll = function (props) {
|
|
23
|
+
if (_this.views.length === 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
var selectedDashboardIdx = props.selectedDashboardIdx;
|
|
27
|
+
var _this$views$selectedD = _this.views[selectedDashboardIdx].getBoundingClientRect(),
|
|
28
|
+
left = _this$views$selectedD.left;
|
|
29
|
+
var offsetWidth = _this.viewsTabsScroll.offsetWidth;
|
|
30
|
+
if (left > offsetWidth) {
|
|
31
|
+
_this.viewsTabsScroll.scrollLeft = left - offsetWidth;
|
|
32
|
+
} else {
|
|
33
|
+
_this.checkAvailableScrollType();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
_this.checkAvailableScrollType = function () {
|
|
37
|
+
var _this$state = _this.state,
|
|
38
|
+
canScrollPrev = _this$state.canScrollPrev,
|
|
39
|
+
canScrollNext = _this$state.canScrollNext;
|
|
40
|
+
var _this$viewsTabsScroll = _this.viewsTabsScroll,
|
|
41
|
+
offsetWidth = _this$viewsTabsScroll.offsetWidth,
|
|
42
|
+
scrollWidth = _this$viewsTabsScroll.scrollWidth,
|
|
43
|
+
scrollLeft = _this$viewsTabsScroll.scrollLeft;
|
|
44
|
+
var _canScrollPrev = false;
|
|
45
|
+
var _canScrollNext = false;
|
|
46
|
+
if (scrollLeft > 0) {
|
|
47
|
+
_canScrollPrev = true;
|
|
48
|
+
}
|
|
49
|
+
if (scrollLeft + offsetWidth < scrollWidth) {
|
|
50
|
+
_canScrollNext = true;
|
|
51
|
+
}
|
|
52
|
+
if (_canScrollPrev !== canScrollPrev || _canScrollNext !== canScrollNext) {
|
|
53
|
+
_this.setState({
|
|
54
|
+
canScrollPrev: _canScrollPrev,
|
|
55
|
+
canScrollNext: _canScrollNext
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
_this.onScrollWithControl = function (type) {
|
|
60
|
+
var _this$viewsTabsScroll2 = _this.viewsTabsScroll,
|
|
61
|
+
offsetWidth = _this$viewsTabsScroll2.offsetWidth,
|
|
62
|
+
scrollWidth = _this$viewsTabsScroll2.scrollWidth,
|
|
63
|
+
scrollLeft = _this$viewsTabsScroll2.scrollLeft;
|
|
64
|
+
var targetScrollLeft;
|
|
65
|
+
if (type === SCROLL_TYPE.PREV) {
|
|
66
|
+
if (scrollLeft === 0) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
targetScrollLeft = scrollLeft - offsetWidth;
|
|
70
|
+
targetScrollLeft = targetScrollLeft > 0 ? targetScrollLeft : 0;
|
|
71
|
+
}
|
|
72
|
+
if (type === SCROLL_TYPE.NEXT) {
|
|
73
|
+
if (scrollLeft + offsetWidth === scrollWidth) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
targetScrollLeft = scrollLeft + offsetWidth;
|
|
77
|
+
targetScrollLeft = targetScrollLeft > scrollWidth - offsetWidth ? scrollWidth - offsetWidth : targetScrollLeft;
|
|
78
|
+
}
|
|
79
|
+
if (_this.state.canViewsScroll) {
|
|
80
|
+
_this.setState({
|
|
81
|
+
canViewsScroll: false
|
|
82
|
+
});
|
|
83
|
+
var timer = null;
|
|
84
|
+
timer = setInterval(function () {
|
|
85
|
+
var step = (targetScrollLeft - scrollLeft) / 10;
|
|
86
|
+
step = step > 0 ? Math.ceil(step) : Math.floor(step);
|
|
87
|
+
_this.viewsTabsScroll.scrollLeft = _this.viewsTabsScroll.scrollLeft + step;
|
|
88
|
+
if (Math.abs(targetScrollLeft - _this.viewsTabsScroll.scrollLeft) <= Math.abs(step)) {
|
|
89
|
+
_this.viewsTabsScroll.scrollLeft = targetScrollLeft;
|
|
90
|
+
clearInterval(timer);
|
|
91
|
+
_this.setState({
|
|
92
|
+
canViewsScroll: true
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}, 15);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
_this.setViewItem = function (idx, viewItem) {
|
|
99
|
+
_this.views[idx] = viewItem;
|
|
100
|
+
};
|
|
101
|
+
_this.selectDashboard = function (index, event) {
|
|
102
|
+
event.stopPropagation();
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
var selectedDashboardIdx = _this.props.selectedDashboardIdx;
|
|
105
|
+
if (index === selectedDashboardIdx) return;
|
|
106
|
+
_this.props.selectDashboard(index);
|
|
107
|
+
};
|
|
108
|
+
_this.onViewsScroll = function () {
|
|
109
|
+
_this.checkAvailableScrollType();
|
|
110
|
+
};
|
|
111
|
+
_this.setViewsTabsScroll = function () {
|
|
112
|
+
if (!_this.viewsTabsScroll) return;
|
|
113
|
+
var _this$viewsTabsScroll3 = _this.viewsTabsScroll,
|
|
114
|
+
offsetWidth = _this$viewsTabsScroll3.offsetWidth,
|
|
115
|
+
scrollWidth = _this$viewsTabsScroll3.scrollWidth;
|
|
116
|
+
if (scrollWidth > offsetWidth) {
|
|
117
|
+
_this.viewsTabsScroll.scrollLeft = scrollWidth - offsetWidth;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
_this.onNewViewToggle = function () {
|
|
121
|
+
if (_this.props.isMobile) return;
|
|
122
|
+
_this.setState({
|
|
123
|
+
isShowNewViewDialog: !_this.state.isShowNewViewDialog
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
_this.onNewViewCancel = function () {
|
|
127
|
+
_this.setState({
|
|
128
|
+
isShowNewViewDialog: false
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
_this.onToggleRenameView = function () {
|
|
132
|
+
if (_this.props.isMobile) return;
|
|
133
|
+
_this.setState({
|
|
134
|
+
isShowRenameViewDialog: !_this.state.isShowRenameViewDialog
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
_this.hideRenameViewDialog = function () {
|
|
138
|
+
_this.setState({
|
|
139
|
+
isShowRenameViewDialog: false
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
_this.onAddDashboard = function (viewName) {
|
|
143
|
+
_this.props.addDashboard(viewName, function () {
|
|
144
|
+
_this.setViewsTabsScroll();
|
|
145
|
+
});
|
|
146
|
+
_this.onNewViewToggle();
|
|
147
|
+
};
|
|
148
|
+
_this.renderTabs = function () {
|
|
149
|
+
var _this$props = _this.props,
|
|
150
|
+
statistics = _this$props.statistics,
|
|
151
|
+
selectedDashboardIdx = _this$props.selectedDashboardIdx,
|
|
152
|
+
theme = _this$props.theme;
|
|
153
|
+
if (!statistics) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
var canDelete = statistics.length > 1;
|
|
157
|
+
return statistics.map(function (item, index) {
|
|
158
|
+
return /*#__PURE__*/React.createElement(Tab, {
|
|
159
|
+
key: "statistic-view-".concat(index),
|
|
160
|
+
item: item,
|
|
161
|
+
theme: theme,
|
|
162
|
+
canDelete: canDelete,
|
|
163
|
+
selectedDashboardIdx: selectedDashboardIdx,
|
|
164
|
+
selected: index === selectedDashboardIdx,
|
|
165
|
+
setViewItem: function setViewItem(ref) {
|
|
166
|
+
return _this.setViewItem(index, ref);
|
|
167
|
+
},
|
|
168
|
+
onSelectDashboard: _this.selectDashboard.bind(_assertThisInitialized(_this), index),
|
|
169
|
+
onToggleRenameView: _this.onToggleRenameView,
|
|
170
|
+
onDeleteDashboard: _this.props.deleteDashboard.bind(_assertThisInitialized(_this), index),
|
|
171
|
+
onMoveDashboard: _this.props.moveDashboard
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
_this.state = {
|
|
176
|
+
isShowNewViewDialog: false,
|
|
177
|
+
isShowRenameViewDialog: false,
|
|
178
|
+
canScrollPrev: false,
|
|
179
|
+
canScrollNext: false,
|
|
180
|
+
canViewsScroll: true
|
|
181
|
+
};
|
|
182
|
+
_this.views = [];
|
|
183
|
+
return _this;
|
|
184
|
+
}
|
|
185
|
+
_createClass(DashboardTabs, [{
|
|
186
|
+
key: "componentDidMount",
|
|
187
|
+
value: function componentDidMount() {
|
|
188
|
+
this.initSelectedViewScroll(this.props);
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "componentDidUpdate",
|
|
192
|
+
value: function componentDidUpdate(prevProps) {
|
|
193
|
+
var statistics = this.props.statistics;
|
|
194
|
+
if (!prevProps.statistics && statistics !== prevProps.statistics) {
|
|
195
|
+
this.initSelectedViewScroll(this.props);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "render",
|
|
200
|
+
value: function render() {
|
|
201
|
+
var _this2 = this;
|
|
202
|
+
var _this$state2 = this.state,
|
|
203
|
+
isShowNewViewDialog = _this$state2.isShowNewViewDialog,
|
|
204
|
+
isShowRenameViewDialog = _this$state2.isShowRenameViewDialog,
|
|
205
|
+
canScrollPrev = _this$state2.canScrollPrev,
|
|
206
|
+
canScrollNext = _this$state2.canScrollNext;
|
|
207
|
+
var _this$props2 = this.props,
|
|
208
|
+
isMobile = _this$props2.isMobile,
|
|
209
|
+
statistics = _this$props2.statistics,
|
|
210
|
+
selectedDashboardIdx = _this$props2.selectedDashboardIdx;
|
|
211
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
212
|
+
className: styles['tabs-container']
|
|
213
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
214
|
+
className: "".concat(styles['views-tabs-scroll'], " d-flex pr-1"),
|
|
215
|
+
ref: function ref(_ref) {
|
|
216
|
+
return _this2.viewsTabsScroll = _ref;
|
|
217
|
+
},
|
|
218
|
+
onScroll: this.onViewsScroll
|
|
219
|
+
}, this.renderTabs()), (canScrollPrev || canScrollNext) && !isMobile && /*#__PURE__*/React.createElement("div", {
|
|
220
|
+
className: styles['views-scroll-control']
|
|
221
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
222
|
+
className: "".concat(styles['scroll-control-btn'], " ").concat(styles['scroll-prev'], " ").concat(canScrollPrev && styles['scroll-active']),
|
|
223
|
+
onClick: this.onScrollWithControl.bind(this, SCROLL_TYPE.PREV)
|
|
224
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
225
|
+
className: "dtable-font dtable-icon-left-slide ".concat(styles['btn-scroll-icon'])
|
|
226
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
227
|
+
className: "".concat(styles['scroll-control-btn'], " ").concat(styles['scroll-next'], " ").concat(canScrollNext && styles['scroll-active']),
|
|
228
|
+
onClick: this.onScrollWithControl.bind(this, SCROLL_TYPE.NEXT)
|
|
229
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
230
|
+
className: "dtable-font dtable-icon-right-slide ".concat(styles['btn-scroll-icon'])
|
|
231
|
+
}))), !isMobile && /*#__PURE__*/React.createElement("div", {
|
|
232
|
+
className: styles['btn-add-view'],
|
|
233
|
+
key: 'btn-add-view',
|
|
234
|
+
onClick: this.onNewViewToggle
|
|
235
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
236
|
+
className: "".concat(styles['add-map-view-icon'], " dtable-font dtable-icon-add-table")
|
|
237
|
+
})), isShowNewViewDialog && /*#__PURE__*/React.createElement(NewViewDialog, {
|
|
238
|
+
onNewViewConfirm: this.onAddDashboard,
|
|
239
|
+
onNewViewCancel: this.onNewViewCancel
|
|
240
|
+
}), isShowRenameViewDialog && /*#__PURE__*/React.createElement(RenameViewDialog, {
|
|
241
|
+
viewName: statistics[selectedDashboardIdx].name,
|
|
242
|
+
onRenameDashboard: this.props.renameDashboard,
|
|
243
|
+
hideRenameViewDialog: this.hideRenameViewDialog
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
}]);
|
|
247
|
+
return DashboardTabs;
|
|
248
|
+
}(Component);
|
|
249
|
+
DashboardTabs.defaultProps = {
|
|
250
|
+
isMobile: false
|
|
251
|
+
};
|
|
252
|
+
export default DashboardTabs;
|