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,485 @@
|
|
|
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 { getCurrentTheme, getLabelFontSize } from '../utils/common-utils';
|
|
13
|
+
import { getChartDisplayLabels, getChartGroups } from '../utils/basic-chart-utils';
|
|
14
|
+
import { DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, STAT_ITEM_THEME_COLORS, SUMMARY_TYPE, LABEL_CONFIG_CHANGED, NO_STATISTIC_RESULTS, STATISTICS_COUNT_SHOW, TITLE_AMOUNT, TITLE_INCREASE } from '../constants';
|
|
15
|
+
var propTypes = {
|
|
16
|
+
isPreview: PropTypes.bool,
|
|
17
|
+
isEnlarge: PropTypes.bool,
|
|
18
|
+
isEdit: PropTypes.bool,
|
|
19
|
+
theme: PropTypes.string,
|
|
20
|
+
colorThemeName: PropTypes.string,
|
|
21
|
+
statItem: PropTypes.object,
|
|
22
|
+
chartCalculator: PropTypes.object,
|
|
23
|
+
eventBus: PropTypes.object,
|
|
24
|
+
getTableById: PropTypes.func,
|
|
25
|
+
toggleStatisticRecordsDialog: PropTypes.func
|
|
26
|
+
};
|
|
27
|
+
var CompareChart = /*#__PURE__*/function (_BaseChart) {
|
|
28
|
+
_inherits(CompareChart, _BaseChart);
|
|
29
|
+
var _super = _createSuper(CompareChart);
|
|
30
|
+
function CompareChart(props) {
|
|
31
|
+
var _this;
|
|
32
|
+
_classCallCheck(this, CompareChart);
|
|
33
|
+
_this = _super.call(this, props);
|
|
34
|
+
_this.drawChart = function (data) {
|
|
35
|
+
var _this$props = _this.props,
|
|
36
|
+
getTableById = _this$props.getTableById,
|
|
37
|
+
isPreview = _this$props.isPreview,
|
|
38
|
+
statItem = _this$props.statItem,
|
|
39
|
+
isEnlarge = _this$props.isEnlarge,
|
|
40
|
+
theme = _this$props.theme,
|
|
41
|
+
colorThemeName = _this$props.colorThemeName;
|
|
42
|
+
var display_data = statItem.display_data,
|
|
43
|
+
display_increase_percentage = statItem.display_increase_percentage;
|
|
44
|
+
var currentTheme = getCurrentTheme(colorThemeName);
|
|
45
|
+
if (isPreview) {
|
|
46
|
+
_this.chart = new Chart({
|
|
47
|
+
container: _this.container,
|
|
48
|
+
autoFit: true,
|
|
49
|
+
appendPadding: [display_data || display_increase_percentage ? 17 : 0, 0, 0, 0]
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
_this.chart = new Chart({
|
|
53
|
+
container: _this.container,
|
|
54
|
+
autoFit: true,
|
|
55
|
+
height: 400,
|
|
56
|
+
width: 700,
|
|
57
|
+
appendPadding: [display_data || display_increase_percentage ? 17 : 0, 0, 0, 0]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
_this.chart.on('interval:click', function (e) {
|
|
61
|
+
_this.props.toggleStatisticRecordsDialog(e.data.data, statItem);
|
|
62
|
+
});
|
|
63
|
+
var table_id = statItem.table_id,
|
|
64
|
+
y_axis_column_key = statItem.y_axis_column_key,
|
|
65
|
+
y_axis_summary_type = statItem.y_axis_summary_type,
|
|
66
|
+
y_axis_summary_method = statItem.y_axis_summary_method,
|
|
67
|
+
y_axis_auto_range = statItem.y_axis_auto_range,
|
|
68
|
+
y_axis_min = statItem.y_axis_min,
|
|
69
|
+
y_axis_max = statItem.y_axis_max,
|
|
70
|
+
display_increase = statItem.display_increase,
|
|
71
|
+
increase_line_color = statItem.increase_line_color;
|
|
72
|
+
var columnData = DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
73
|
+
if (y_axis_summary_type === SUMMARY_TYPE.ADVANCED) {
|
|
74
|
+
var table = getTableById(table_id);
|
|
75
|
+
var summaryColumn = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
76
|
+
columnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
|
|
77
|
+
}
|
|
78
|
+
_this.chart.data(data, {
|
|
79
|
+
'name': {
|
|
80
|
+
type: 'cat',
|
|
81
|
+
nice: false
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var width = _this.chart.coordinateBBox.width;
|
|
85
|
+
var chartData = getChartGroups(data);
|
|
86
|
+
var labelCount = chartData.length;
|
|
87
|
+
if (Math.floor(width / labelCount) <= 20) {
|
|
88
|
+
var displayLabels = getChartDisplayLabels(width, 20, chartData);
|
|
89
|
+
labelCount = displayLabels.length;
|
|
90
|
+
_this.chart.scale('name', {
|
|
91
|
+
ticks: displayLabels
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// set Coord type
|
|
96
|
+
_this.chart.coordinate('rect');
|
|
97
|
+
var valueScaleOptions = {
|
|
98
|
+
formatter: function formatter(value) {
|
|
99
|
+
return getNumberDisplayString(value, columnData);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
if (y_axis_auto_range == undefined || y_axis_auto_range) {
|
|
103
|
+
valueScaleOptions = Object.assign({}, valueScaleOptions, {
|
|
104
|
+
nice: true
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
valueScaleOptions = Object.assign({}, valueScaleOptions, {
|
|
108
|
+
min: y_axis_min,
|
|
109
|
+
max: y_axis_max
|
|
110
|
+
});
|
|
111
|
+
// set the filter rule
|
|
112
|
+
_this.chart.filter('value', function (value) {
|
|
113
|
+
return value >= y_axis_min;
|
|
114
|
+
});
|
|
115
|
+
// filter the data
|
|
116
|
+
_this.chart.filterData(data);
|
|
117
|
+
}
|
|
118
|
+
_this.chart.scale({
|
|
119
|
+
// Set the type of the name column so that g2 can draw correctly
|
|
120
|
+
name: {
|
|
121
|
+
type: 'cat'
|
|
122
|
+
},
|
|
123
|
+
value: valueScaleOptions
|
|
124
|
+
});
|
|
125
|
+
_this.chart.scale({
|
|
126
|
+
group_name: {
|
|
127
|
+
type: 'cat'
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
var themeColors = STAT_ITEM_THEME_COLORS.light;
|
|
131
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
132
|
+
themeColors = STAT_ITEM_THEME_COLORS.dark;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// bar chart
|
|
136
|
+
_this.chart.interval().label(display_data ? 'value' : false, {
|
|
137
|
+
formatter: function formatter(value) {
|
|
138
|
+
return getNumberDisplayString(value, columnData);
|
|
139
|
+
},
|
|
140
|
+
style: {
|
|
141
|
+
fontSize: _this.getLabelFontSize(),
|
|
142
|
+
fill: themeColors.textColor
|
|
143
|
+
}
|
|
144
|
+
}).position('name*value').color('group_name', currentTheme && currentTheme.colors).tooltip('name*value*raw_name', function (name, value, raw_name) {
|
|
145
|
+
var nameContent = !raw_name && typeof raw_name !== 'number' ? intl.get(EMPTY_NAME) : raw_name;
|
|
146
|
+
var titleContent = y_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(STATISTICS_COUNT_SHOW[y_axis_summary_method]);
|
|
147
|
+
return {
|
|
148
|
+
title: titleContent,
|
|
149
|
+
value: getNumberDisplayString(value, columnData),
|
|
150
|
+
name: nameContent
|
|
151
|
+
};
|
|
152
|
+
}).adjust('dodge').state({
|
|
153
|
+
active: {
|
|
154
|
+
style: {
|
|
155
|
+
stroke: null
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
_this.chart.tooltip({
|
|
160
|
+
showTitle: true,
|
|
161
|
+
showMarkers: false,
|
|
162
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
163
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
164
|
+
domStyles: {
|
|
165
|
+
'g2-tooltip': {
|
|
166
|
+
borderRadius: '2px',
|
|
167
|
+
backgroundColor: '#fff',
|
|
168
|
+
padding: '10px'
|
|
169
|
+
},
|
|
170
|
+
'tooltip-item': {
|
|
171
|
+
marginTop: '5px'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
if (display_increase) {
|
|
176
|
+
// line chart
|
|
177
|
+
_this.chart.line().position('name*increase_value').size(3).color(increase_line_color || '#fbd44a').shape('smooth').tooltip('name*increase_value', function (name, value) {
|
|
178
|
+
return {
|
|
179
|
+
title: intl.get(TITLE_INCREASE),
|
|
180
|
+
value: getNumberDisplayString(value, {
|
|
181
|
+
format: 'percent'
|
|
182
|
+
}),
|
|
183
|
+
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
_this.chart.point().label(display_increase_percentage ? 'increase_value' : false, function (value) {
|
|
187
|
+
return {
|
|
188
|
+
content: getNumberDisplayString(value, {
|
|
189
|
+
format: 'percent'
|
|
190
|
+
}),
|
|
191
|
+
style: {
|
|
192
|
+
fill: themeColors.textColor
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}).color(increase_line_color || '#fbd44a').position('name*increase_value').size(3).tooltip('name*increase_value', function (name, value) {
|
|
196
|
+
return {
|
|
197
|
+
title: intl.get(TITLE_INCREASE),
|
|
198
|
+
value: getNumberDisplayString(value, {
|
|
199
|
+
format: 'percent'
|
|
200
|
+
}),
|
|
201
|
+
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
_this.chart.axis('increase_value', {
|
|
205
|
+
label: null,
|
|
206
|
+
grid: null
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// set axis label and tooltip
|
|
210
|
+
_this.chart.axis('name', {
|
|
211
|
+
line: {
|
|
212
|
+
style: themeColors.gridColor
|
|
213
|
+
},
|
|
214
|
+
label: {
|
|
215
|
+
autoRotate: true,
|
|
216
|
+
style: {
|
|
217
|
+
fill: themeColors.textColor
|
|
218
|
+
},
|
|
219
|
+
formatter: function formatter(name) {
|
|
220
|
+
var label = name;
|
|
221
|
+
if (name.length > 10) {
|
|
222
|
+
label = "".concat(name.slice(0, 10), "...");
|
|
223
|
+
}
|
|
224
|
+
if (name === '' || name === 'undefined') {
|
|
225
|
+
label = intl.get(EMPTY_NAME);
|
|
226
|
+
}
|
|
227
|
+
return label;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
_this.chart.axis('value', {
|
|
232
|
+
label: {
|
|
233
|
+
style: {
|
|
234
|
+
fill: themeColors.textColor
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
grid: {
|
|
238
|
+
line: {
|
|
239
|
+
style: {
|
|
240
|
+
stroke: themeColors.gridColor
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
var legendPosition = 'bottom';
|
|
246
|
+
_this.chart.legend('group_name', {
|
|
247
|
+
position: legendPosition,
|
|
248
|
+
itemName: {
|
|
249
|
+
style: {
|
|
250
|
+
fill: themeColors.textColor
|
|
251
|
+
},
|
|
252
|
+
formatter: function formatter(name) {
|
|
253
|
+
return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
pageNavigator: {
|
|
257
|
+
text: {
|
|
258
|
+
style: {
|
|
259
|
+
fill: themeColors.textColor
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
marker: {
|
|
263
|
+
style: {
|
|
264
|
+
fill: themeColors.legendPageNavigatorMarkerColor,
|
|
265
|
+
inactiveFill: themeColors.legendPageNavigatorMarkerColor,
|
|
266
|
+
inactiveOpacity: 0.45
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
_this.chart.interaction('active-region');
|
|
272
|
+
_this.chart.removeInteraction('legend-filter');
|
|
273
|
+
_this.chart.render();
|
|
274
|
+
_this.renderAxisLabel();
|
|
275
|
+
};
|
|
276
|
+
_this.getLabelFontSize = function () {
|
|
277
|
+
var statItem = _this.props.statItem;
|
|
278
|
+
var label_font_size = statItem.label_font_size;
|
|
279
|
+
return getLabelFontSize(label_font_size);
|
|
280
|
+
};
|
|
281
|
+
_this.renderAxisLabel = function (newStatItem) {
|
|
282
|
+
var _this$props2 = _this.props,
|
|
283
|
+
getTableById = _this$props2.getTableById,
|
|
284
|
+
statItem = _this$props2.statItem;
|
|
285
|
+
if (newStatItem && newStatItem._id !== statItem._id) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (!_this.chart) return;
|
|
289
|
+
statItem = newStatItem || statItem;
|
|
290
|
+
var _this$props3 = _this.props,
|
|
291
|
+
isEnlarge = _this$props3.isEnlarge,
|
|
292
|
+
isPreview = _this$props3.isPreview,
|
|
293
|
+
theme = _this$props3.theme;
|
|
294
|
+
var _statItem = statItem,
|
|
295
|
+
table_id = _statItem.table_id,
|
|
296
|
+
x_axis_column_key = _statItem.x_axis_column_key,
|
|
297
|
+
y_axis_column_key = _statItem.y_axis_column_key,
|
|
298
|
+
show_y_axis_label = _statItem.show_y_axis_label,
|
|
299
|
+
show_x_axis_label = _statItem.show_x_axis_label,
|
|
300
|
+
y_axis_label_position = _statItem.y_axis_label_position,
|
|
301
|
+
x_axis_label_position = _statItem.x_axis_label_position,
|
|
302
|
+
y_axis_summary_type = _statItem.y_axis_summary_type;
|
|
303
|
+
var table = getTableById(table_id);
|
|
304
|
+
var autoPadding = _this.chart.autoPadding;
|
|
305
|
+
var textColor = '#999999';
|
|
306
|
+
if (theme === 'dark' && !isEnlarge && isPreview) {
|
|
307
|
+
textColor = '#ffffff';
|
|
308
|
+
}
|
|
309
|
+
var xAxisID = "chart-x-axis-label_".concat(statItem._id);
|
|
310
|
+
var chartContainer = _this.chart.getCanvas().get('container');
|
|
311
|
+
var xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
312
|
+
if (!xLabel && show_x_axis_label) {
|
|
313
|
+
var div = document.createElement('div');
|
|
314
|
+
div.id = xAxisID;
|
|
315
|
+
div.className = 'statistic-chart-axis-label';
|
|
316
|
+
var column = TableUtils.getTableColumnByKey(table, x_axis_column_key);
|
|
317
|
+
div.innerHTML = "".concat(column ? column.name : '');
|
|
318
|
+
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
319
|
+
chartContainer.appendChild(div);
|
|
320
|
+
}
|
|
321
|
+
if (xLabel && show_x_axis_label) {
|
|
322
|
+
xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; padding-left: ").concat(autoPadding.left, "px; text-align: ").concat(x_axis_label_position, "; bottom: -20px"));
|
|
323
|
+
}
|
|
324
|
+
if (xLabel && !show_x_axis_label) {
|
|
325
|
+
xLabel.parentNode.removeChild(xLabel);
|
|
326
|
+
}
|
|
327
|
+
var yAxisID = "chart-y-axis-label_".concat(statItem._id);
|
|
328
|
+
var yLabel = chartContainer.querySelector("#".concat(yAxisID));
|
|
329
|
+
var paddingLeft = autoPadding.bottom + (show_x_axis_label ? 10 : 0);
|
|
330
|
+
if (!yLabel && show_y_axis_label) {
|
|
331
|
+
var _div = document.createElement('div');
|
|
332
|
+
_div.id = yAxisID;
|
|
333
|
+
_div.className = 'statistic-chart-axis-label';
|
|
334
|
+
if (y_axis_summary_type === SUMMARY_TYPE.COUNT) {
|
|
335
|
+
_div.innerHTML = intl.get(TITLE_AMOUNT);
|
|
336
|
+
} else {
|
|
337
|
+
var _column = TableUtils.getTableColumnByKey(table, y_axis_column_key) || {};
|
|
338
|
+
_div.innerHTML = _column.name || '';
|
|
339
|
+
}
|
|
340
|
+
var containerHeight = chartContainer.offsetHeight;
|
|
341
|
+
var textAlign = 'center';
|
|
342
|
+
if (y_axis_label_position === 'bottom') textAlign = 'left';
|
|
343
|
+
if (y_axis_label_position === 'top') textAlign = 'right';
|
|
344
|
+
_div.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0px; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
345
|
+
chartContainer.appendChild(_div);
|
|
346
|
+
}
|
|
347
|
+
if (yLabel && show_y_axis_label) {
|
|
348
|
+
var _containerHeight = chartContainer.offsetHeight;
|
|
349
|
+
var _textAlign = 'center';
|
|
350
|
+
if (y_axis_label_position === 'bottom') _textAlign = 'left';
|
|
351
|
+
if (y_axis_label_position === 'top') _textAlign = 'right';
|
|
352
|
+
yLabel.setAttribute('style', "color:".concat(textColor, "; padding-right: ").concat(autoPadding.top, "px; padding-left: ").concat(paddingLeft, "px; position: absolute; width: ").concat(_containerHeight, "px; text-align: ").concat(_textAlign, "; top: 0; left: 0px; transform: translate(-").concat(_containerHeight / 2 + 12, "px, ").concat((_containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
353
|
+
}
|
|
354
|
+
if (yLabel && !show_y_axis_label) {
|
|
355
|
+
yLabel.parentNode.removeChild(yLabel);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
_this.destroyChart = function () {
|
|
359
|
+
_this.chart.destroy();
|
|
360
|
+
_this.chart = null;
|
|
361
|
+
};
|
|
362
|
+
_this.state = {
|
|
363
|
+
isCalculatingData: true,
|
|
364
|
+
showResultDescription: true
|
|
365
|
+
};
|
|
366
|
+
_this.calculateData = null;
|
|
367
|
+
return _this;
|
|
368
|
+
}
|
|
369
|
+
_createClass(CompareChart, [{
|
|
370
|
+
key: "componentDidMount",
|
|
371
|
+
value: function componentDidMount() {
|
|
372
|
+
var _this2 = this;
|
|
373
|
+
var _this$props4 = this.props,
|
|
374
|
+
statItem = _this$props4.statItem,
|
|
375
|
+
chartCalculator = _this$props4.chartCalculator,
|
|
376
|
+
eventBus = _this$props4.eventBus;
|
|
377
|
+
this.unsubscribeStyleChange = eventBus.subscribe(LABEL_CONFIG_CHANGED, function (newStatItem) {
|
|
378
|
+
_this2.renderAxisLabel(newStatItem);
|
|
379
|
+
});
|
|
380
|
+
if (this.container) {
|
|
381
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
382
|
+
var showResultDescription = data.length > 0 ? false : true;
|
|
383
|
+
_this2.setState({
|
|
384
|
+
isCalculatingData: false,
|
|
385
|
+
showResultDescription: showResultDescription
|
|
386
|
+
}, function () {
|
|
387
|
+
if (!showResultDescription) {
|
|
388
|
+
_this2.drawChart(data);
|
|
389
|
+
_this2.calculateData = data;
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}, {
|
|
396
|
+
key: "shouldComponentUpdate",
|
|
397
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
398
|
+
var colorThemeName = this.props.colorThemeName;
|
|
399
|
+
if (this.canUpdate(this.props, nextProps)) {
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
if (nextState.isCalculatingData !== this.state.isCalculatingData) {
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
if (nextProps.colorThemeName !== colorThemeName) {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
}, {
|
|
411
|
+
key: "componentDidUpdate",
|
|
412
|
+
value: function componentDidUpdate(preProps, preState) {
|
|
413
|
+
var _this3 = this;
|
|
414
|
+
var _this$props5 = this.props,
|
|
415
|
+
statItem = _this$props5.statItem,
|
|
416
|
+
chartCalculator = _this$props5.chartCalculator;
|
|
417
|
+
var isCalculatingData = this.state.isCalculatingData;
|
|
418
|
+
if (isCalculatingData !== preState.isCalculatingData) return;
|
|
419
|
+
if (this.shouldCalculateStatItem(preProps, this.props)) {
|
|
420
|
+
this.setState({
|
|
421
|
+
isCalculatingData: true
|
|
422
|
+
});
|
|
423
|
+
if (this.container) {
|
|
424
|
+
chartCalculator.calculate(statItem).then(function (data) {
|
|
425
|
+
var showResultDescription = data.length > 0 ? false : true;
|
|
426
|
+
_this3.chart && _this3.destroyChart();
|
|
427
|
+
_this3.calculateData = data;
|
|
428
|
+
_this3.setState({
|
|
429
|
+
isCalculatingData: false,
|
|
430
|
+
showResultDescription: showResultDescription
|
|
431
|
+
}, function () {
|
|
432
|
+
if (!showResultDescription) {
|
|
433
|
+
_this3.drawChart(data);
|
|
434
|
+
if (_this3.props.isPreview) {
|
|
435
|
+
_this3.chart.forceFit();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
} else {
|
|
442
|
+
if (!this.state.showResultDescription) {
|
|
443
|
+
this.chart && this.destroyChart();
|
|
444
|
+
this.drawChart(this.calculateData);
|
|
445
|
+
if (this.props.isPreview) {
|
|
446
|
+
this.chart.forceFit();
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}, {
|
|
452
|
+
key: "componentWillUnmount",
|
|
453
|
+
value: function componentWillUnmount() {
|
|
454
|
+
this.container = null;
|
|
455
|
+
this.unsubscribeStyleChange();
|
|
456
|
+
}
|
|
457
|
+
}, {
|
|
458
|
+
key: "render",
|
|
459
|
+
value: function render() {
|
|
460
|
+
var _this4 = this;
|
|
461
|
+
var statItem = this.props.statItem;
|
|
462
|
+
var _this$state = this.state,
|
|
463
|
+
isCalculatingData = _this$state.isCalculatingData,
|
|
464
|
+
showResultDescription = _this$state.showResultDescription;
|
|
465
|
+
var show_y_axis_label = statItem.show_y_axis_label,
|
|
466
|
+
show_x_axis_label = statItem.show_x_axis_label;
|
|
467
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isCalculatingData && /*#__PURE__*/React.createElement("div", {
|
|
468
|
+
className: 'statistic-chart-loading-container'
|
|
469
|
+
}, /*#__PURE__*/React.createElement(Loading, null)), showResultDescription && /*#__PURE__*/React.createElement("div", {
|
|
470
|
+
className: 'statistic-chart-text'
|
|
471
|
+
}, intl.get(NO_STATISTIC_RESULTS)), /*#__PURE__*/React.createElement("div", {
|
|
472
|
+
ref: function ref(_ref) {
|
|
473
|
+
return _this4.container = _ref;
|
|
474
|
+
},
|
|
475
|
+
style: {
|
|
476
|
+
padding: show_y_axis_label || show_x_axis_label ? 30 : 20
|
|
477
|
+
},
|
|
478
|
+
className: "statistic-chart-container"
|
|
479
|
+
}));
|
|
480
|
+
}
|
|
481
|
+
}]);
|
|
482
|
+
return CompareChart;
|
|
483
|
+
}(BaseChart);
|
|
484
|
+
CompareChart.propTypes = propTypes;
|
|
485
|
+
export default CompareChart;
|