sea-chart 0.0.1 → 0.0.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 +117 -1
- package/dist/api/index.js +101 -0
- package/{lib → dist}/components/collaborator/index.js +8 -6
- package/{lib → dist}/components/icon/index.css +1 -1
- package/{lib → dist}/components/icon/index.js +7 -5
- package/dist/components/index.js +8 -0
- package/{lib → dist}/components/loading/index.js +4 -2
- package/dist/components/number-input/index.js +31 -0
- package/{lib → dist}/components/pixel-editor/index.css +4 -4
- package/{lib → dist}/components/pixel-editor/index.js +11 -15
- package/{lib → dist}/components/select-group/index.css +10 -10
- package/dist/components/select-group/index.js +52 -0
- package/dist/components/types-dialog/index.css +97 -0
- package/dist/components/types-dialog/index.js +117 -0
- package/{lib → dist}/constants/geolocation.js +3 -3
- package/dist/constants/index.js +184 -0
- package/{lib → dist}/constants/model.js +25 -5
- package/dist/constants/style.js +15 -0
- package/dist/constants/type-image.js +59 -0
- package/dist/constants/type.js +124 -0
- package/dist/context.js +83 -0
- package/dist/editor/index.js +41 -0
- package/dist/index.js +9 -0
- package/dist/intl.js +37 -0
- package/dist/locale/index.js +18 -0
- package/{lib → dist}/locale/lang/de.js +1 -1
- package/{lib → dist}/locale/lang/en.js +1 -1
- package/{lib → dist}/locale/lang/es.js +1 -1
- package/{lib → dist}/locale/lang/fr.js +1 -1
- package/{lib → dist}/locale/lang/pt.js +1 -1
- package/{lib → dist}/locale/lang/ru.js +1 -1
- package/{lib → dist}/locale/lang/zh_CN.js +1 -1
- package/dist/model/area-group.js +41 -0
- package/dist/model/area.js +32 -0
- package/dist/model/bar-group.js +44 -0
- package/dist/model/bar-stack.js +41 -0
- package/dist/model/bar.js +38 -0
- package/dist/model/base-model.js +9 -0
- package/dist/model/basic-number-card.js +22 -0
- package/dist/model/chart.js +23 -0
- package/dist/model/combination.js +38 -0
- package/dist/model/compare-bar.js +39 -0
- package/dist/model/completeness-group.js +24 -0
- package/dist/model/completeness.js +18 -0
- package/dist/model/dashboard.js +16 -0
- package/dist/model/generic-model.js +224 -0
- package/dist/model/heat-map.js +23 -0
- package/dist/model/horizontal-bar.js +38 -0
- package/dist/model/horizontal-group-bar.js +43 -0
- package/dist/model/index.js +63 -0
- package/dist/model/line-group.js +44 -0
- package/dist/model/line.js +38 -0
- package/dist/model/map-bubble.js +27 -0
- package/dist/model/map.js +27 -0
- package/dist/model/mirror.js +26 -0
- package/dist/model/pie.js +26 -0
- package/dist/model/ring.js +26 -0
- package/dist/model/scatter.js +19 -0
- package/dist/model/stacked-horizontal-bar.js +32 -0
- package/dist/model/table.js +23 -0
- package/dist/model/tree-map.js +20 -0
- package/dist/model/trend.js +24 -0
- package/dist/model/user.js +15 -0
- package/dist/model/world-map-bubble.js +26 -0
- package/dist/model/world-map.js +26 -0
- package/{lib/components → dist}/settings/advance-bar-settings/data-settings.js +68 -45
- package/dist/settings/advance-bar-settings/style-settings.js +161 -0
- package/{lib/components → dist}/settings/bar-settings/data-settings.js +76 -51
- package/dist/settings/bar-settings/style-settings.js +179 -0
- package/dist/settings/basic-number-card/data-settings.js +126 -0
- package/dist/settings/basic-number-card/style-settings.js +42 -0
- package/dist/settings/combination-settings/data-settings.js +279 -0
- package/dist/settings/combination-settings/style-settings.js +174 -0
- package/dist/settings/dashboard-settings/data-settings.js +179 -0
- package/{lib/components → dist}/settings/data-settings.js +28 -22
- package/dist/settings/horizontal-bar-settings/data-settings.js +55 -0
- package/dist/settings/horizontal-bar-settings/style-settings.js +46 -0
- package/dist/settings/index.css +85 -0
- package/dist/settings/index.js +76 -0
- package/{lib/components → dist}/settings/pie-settings/data-settings.js +67 -44
- package/{lib/components → dist}/settings/pie-settings/style-settings.js +67 -49
- package/dist/settings/style-settings.js +118 -0
- package/{lib/components → dist}/settings/table-settings/data-settings.js +269 -208
- package/{lib/components → dist}/settings/time-comparison-settings/data-settings.js +82 -67
- package/dist/settings/time-comparison-settings/style-settings.js +213 -0
- package/dist/settings/widgets/basic-summary/index.css +12 -0
- package/dist/settings/widgets/basic-summary/index.js +176 -0
- package/{lib/components/settings/widgets/statistic-type → dist/settings/widgets/chart-type}/index.css +5 -5
- package/dist/settings/widgets/chart-type/index.js +59 -0
- package/{lib/components → dist}/settings/widgets/common-data-settings.js +24 -18
- package/dist/settings/widgets/data-filter/index.css +17 -0
- package/{lib/components → dist}/settings/widgets/data-filter/index.js +51 -37
- package/dist/settings/widgets/data-sort.js +44 -0
- package/dist/settings/widgets/date-summary-item.js +111 -0
- package/dist/settings/widgets/display-values-settings/index.css +13 -0
- package/{lib/components → dist}/settings/widgets/display-values-settings/index.js +19 -14
- package/{lib/components → dist}/settings/widgets/divider/index.css +1 -1
- package/dist/settings/widgets/divider/index.js +12 -0
- package/{lib/components → dist}/settings/widgets/font-settings/font-size-settings.js +14 -12
- package/{lib/components → dist}/settings/widgets/font-settings/font-weight-settings.js +14 -16
- package/dist/settings/widgets/group-by.js +160 -0
- package/{lib/components → dist}/settings/widgets/label-color.js +10 -10
- package/dist/settings/widgets/min-max-setting.js +52 -0
- package/dist/settings/widgets/mininum-slice-percent.js +63 -0
- package/dist/settings/widgets/numeric-summary-item.js +90 -0
- package/dist/settings/widgets/select-table/index.js +38 -0
- package/dist/settings/widgets/stack.js +50 -0
- package/dist/settings/widgets/summary-method-setting.js +66 -0
- package/dist/settings/widgets/summary-settings.js +411 -0
- package/dist/settings/widgets/switch/index.css +37 -0
- package/{lib/components → dist}/settings/widgets/switch/index.js +11 -8
- package/{lib/components → dist}/settings/widgets/text-horizontal-settings.js +12 -10
- package/dist/settings/widgets/time-picker.js +174 -0
- package/{lib/components → dist}/settings/widgets/title-settings/index.js +15 -13
- package/dist/settings/widgets/title-settings/title-text.js +25 -0
- package/dist/settings/widgets/x-axios.js +0 -0
- package/dist/settings/widgets/y-axis-group-settings.js +438 -0
- package/dist/utils/cell-format-utils.js +42 -0
- package/dist/utils/chart-data-sql.js +606 -0
- package/dist/utils/chart-utils.js +1803 -0
- package/dist/utils/chart.js +6 -0
- package/dist/utils/collaborator-manager.js +24 -0
- package/dist/utils/collaborator-utils.js +40 -0
- package/dist/utils/column-2-sql-column.js +551 -0
- package/dist/utils/column-utils.js +208 -0
- package/{lib → dist}/utils/custom-g2.js +11 -11
- package/{lib → dist}/utils/date-translate.js +11 -11
- package/dist/utils/index.js +48 -0
- package/dist/utils/key-generator.js +13 -0
- package/dist/utils/object-utils.js +45 -0
- package/{lib → dist}/utils/options-utils.js +17 -18
- package/dist/view/index.css +53 -0
- package/dist/view/index.js +169 -0
- package/{lib/layout → dist/view}/title/index.css +1 -1
- package/dist/view/title/index.js +46 -0
- package/dist/view/wrapper/area.js +150 -0
- package/dist/view/wrapper/bar-group.js +148 -0
- package/dist/view/wrapper/bar.js +138 -0
- package/dist/view/wrapper/basic-number-card.js +127 -0
- package/dist/view/wrapper/chart-component.js +261 -0
- package/dist/view/wrapper/combination.js +399 -0
- package/dist/view/wrapper/dashboard.js +164 -0
- package/dist/view/wrapper/horizontal-bar-group.js +149 -0
- package/dist/view/wrapper/horizontal-bar.js +140 -0
- package/dist/view/wrapper/horizontal-component.js +78 -0
- package/{lib/components/formatter → dist/view/wrapper}/index.js +90 -71
- package/dist/view/wrapper/line-group.js +145 -0
- package/dist/view/wrapper/line.js +157 -0
- package/dist/view/wrapper/pie.js +185 -0
- package/dist/view/wrapper/ring.js +264 -0
- package/{lib/components/formatter → dist/view/wrapper}/table/index.css +18 -18
- package/dist/view/wrapper/table/index.js +31 -0
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +144 -0
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +198 -0
- package/dist/view/wrapper/table/pivot-table-display-name.js +248 -0
- package/dist/view/wrapper/table/two-dimension-table.js +249 -0
- package/dist/view/wrapper/treemap.js +186 -0
- package/package.json +91 -100
- package/lib/components/formatter/area.js +0 -162
- package/lib/components/formatter/bar-group.js +0 -160
- package/lib/components/formatter/bar.js +0 -150
- package/lib/components/formatter/basic-number-card.js +0 -138
- package/lib/components/formatter/chart-component.js +0 -266
- package/lib/components/formatter/combination.js +0 -407
- package/lib/components/formatter/dashboard.js +0 -182
- package/lib/components/formatter/horizontal-bar-group.js +0 -161
- package/lib/components/formatter/horizontal-bar.js +0 -152
- package/lib/components/formatter/horizontal-component.js +0 -91
- package/lib/components/formatter/line-group.js +0 -157
- package/lib/components/formatter/line.js +0 -170
- package/lib/components/formatter/pie.js +0 -201
- package/lib/components/formatter/ring.js +0 -277
- package/lib/components/formatter/table/index.js +0 -42
- package/lib/components/formatter/table/one-dimension-table-no-numeric-columns.js +0 -145
- package/lib/components/formatter/table/one-dimension-table-with-numeric-columns.js +0 -193
- package/lib/components/formatter/table/pivot-table-display-name.js +0 -249
- package/lib/components/formatter/table/two-dimension-table.js +0 -241
- package/lib/components/formatter/treemap.js +0 -213
- package/lib/components/index.js +0 -5
- package/lib/components/number-input/index.js +0 -31
- package/lib/components/select-group/index.js +0 -63
- package/lib/components/settings/advance-bar-settings/style-settings.js +0 -149
- package/lib/components/settings/bar-settings/style-settings.js +0 -163
- package/lib/components/settings/basic-number-card/data-settings.js +0 -121
- package/lib/components/settings/basic-number-card/style-settings.js +0 -42
- package/lib/components/settings/combination-settings/data-settings.js +0 -256
- package/lib/components/settings/combination-settings/style-settings.js +0 -183
- package/lib/components/settings/dashboard-settings/data-settings.js +0 -167
- package/lib/components/settings/horizontal-bar-settings/data-settings.js +0 -45
- package/lib/components/settings/horizontal-bar-settings/style-settings.js +0 -38
- package/lib/components/settings/index.css +0 -73
- package/lib/components/settings/index.js +0 -74
- package/lib/components/settings/style-settings.js +0 -100
- package/lib/components/settings/time-comparison-settings/style-settings.js +0 -191
- package/lib/components/settings/widgets/basic-summary/index.css +0 -12
- package/lib/components/settings/widgets/basic-summary/index.js +0 -173
- package/lib/components/settings/widgets/data-filter/index.css +0 -17
- package/lib/components/settings/widgets/data-sort.js +0 -38
- package/lib/components/settings/widgets/date-summary-item.js +0 -126
- package/lib/components/settings/widgets/display-values-settings/index.css +0 -13
- package/lib/components/settings/widgets/divider/index.js +0 -10
- package/lib/components/settings/widgets/group-by.js +0 -168
- package/lib/components/settings/widgets/min-max-setting.js +0 -64
- package/lib/components/settings/widgets/mininum-slice-percent.js +0 -72
- package/lib/components/settings/widgets/numeric-summary-item.js +0 -109
- package/lib/components/settings/widgets/select-table/index.js +0 -49
- package/lib/components/settings/widgets/stack.js +0 -58
- package/lib/components/settings/widgets/statistic-type/index.js +0 -54
- package/lib/components/settings/widgets/summary-method-setting.js +0 -80
- package/lib/components/settings/widgets/summary-settings.js +0 -394
- package/lib/components/settings/widgets/switch/index.css +0 -37
- package/lib/components/settings/widgets/time-picker.js +0 -182
- package/lib/components/settings/widgets/title-settings/title-text.js +0 -31
- package/lib/components/settings/widgets/y-axis-group-settings.js +0 -399
- package/lib/components/types-dialog/index.css +0 -97
- package/lib/components/types-dialog/index.js +0 -127
- package/lib/constants/index.js +0 -164
- package/lib/constants/style.js +0 -13
- package/lib/constants/type-image.js +0 -32
- package/lib/constants/type.js +0 -97
- package/lib/context.js +0 -49
- package/lib/index.js +0 -6
- package/lib/intl.js +0 -37
- package/lib/layout/index.js +0 -4
- package/lib/layout/statistic/index.css +0 -53
- package/lib/layout/statistic/index.js +0 -190
- package/lib/layout/title/index.js +0 -41
- package/lib/locale/index.js +0 -11
- package/lib/model/area-group.js +0 -51
- package/lib/model/area.js +0 -42
- package/lib/model/bar-group.js +0 -54
- package/lib/model/bar-stack.js +0 -51
- package/lib/model/bar.js +0 -48
- package/lib/model/base-model.js +0 -11
- package/lib/model/basic-number-card.js +0 -32
- package/lib/model/combination.js +0 -48
- package/lib/model/compare-bar.js +0 -49
- package/lib/model/completeness-group.js +0 -34
- package/lib/model/completeness.js +0 -28
- package/lib/model/dashboard.js +0 -26
- package/lib/model/generic-model.js +0 -235
- package/lib/model/heat-map.js +0 -33
- package/lib/model/horizontal-bar.js +0 -48
- package/lib/model/horizontal-group-bar.js +0 -53
- package/lib/model/index.js +0 -36
- package/lib/model/line-group.js +0 -54
- package/lib/model/line.js +0 -48
- package/lib/model/map-bubble.js +0 -37
- package/lib/model/map.js +0 -37
- package/lib/model/mirror.js +0 -36
- package/lib/model/pie.js +0 -36
- package/lib/model/ring.js +0 -36
- package/lib/model/scatter.js +0 -29
- package/lib/model/stacked-horizontal-bar.js +0 -42
- package/lib/model/statistic.js +0 -22
- package/lib/model/table.js +0 -33
- package/lib/model/tree-map.js +0 -30
- package/lib/model/trend.js +0 -34
- package/lib/model/user.js +0 -22
- package/lib/model/world-map-bubble.js +0 -36
- package/lib/model/world-map.js +0 -36
- package/lib/utils/cell-format-utils.js +0 -41
- package/lib/utils/chart.js +0 -6
- package/lib/utils/collaborator-utils.js +0 -40
- package/lib/utils/column-utils.js +0 -247
- package/lib/utils/data-filter/filter-item-utils.js +0 -80
- package/lib/utils/data-filter/filters-utils.js +0 -406
- package/lib/utils/data-filter/index.js +0 -3
- package/lib/utils/index.js +0 -50
- package/lib/utils/key-generator.js +0 -13
- package/lib/utils/object-utils.js +0 -61
- package/lib/utils/statistic-column-2-sql-column-utils.js +0 -499
- package/lib/utils/statistic-utils.js +0 -1685
- /package/{lib → dist}/assets/icons/area-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/bar-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/card.svg +0 -0
- /package/{lib → dist}/assets/icons/combination-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/dtable-logo.svg +0 -0
- /package/{lib → dist}/assets/icons/facet-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/gauge.svg +0 -0
- /package/{lib → dist}/assets/icons/heat-map.svg +0 -0
- /package/{lib → dist}/assets/icons/histogram.svg +0 -0
- /package/{lib → dist}/assets/icons/line-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/map.svg +0 -0
- /package/{lib → dist}/assets/icons/pie-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/rectangular-tree-diagram.svg +0 -0
- /package/{lib → dist}/assets/icons/scatter-chart.svg +0 -0
- /package/{lib → dist}/assets/icons/type-change.svg +0 -0
- /package/{lib → dist}/assets/img/area-chart.png +0 -0
- /package/{lib → dist}/assets/img/area-group-chart.png +0 -0
- /package/{lib → dist}/assets/img/bar-group.png +0 -0
- /package/{lib → dist}/assets/img/bar-stack.png +0 -0
- /package/{lib → dist}/assets/img/bar.png +0 -0
- /package/{lib → dist}/assets/img/combination-chart.png +0 -0
- /package/{lib → dist}/assets/img/compared-chart.png +0 -0
- /package/{lib → dist}/assets/img/completeness-chart.png +0 -0
- /package/{lib → dist}/assets/img/custom-bar.png +0 -0
- /package/{lib → dist}/assets/img/dashboard-chart.png +0 -0
- /package/{lib → dist}/assets/img/group-completeness-chart.png +0 -0
- /package/{lib → dist}/assets/img/group_line.png +0 -0
- /package/{lib → dist}/assets/img/heat-map.png +0 -0
- /package/{lib → dist}/assets/img/horizontal-bar.png +0 -0
- /package/{lib → dist}/assets/img/horizontal-group-bar.png +0 -0
- /package/{lib → dist}/assets/img/line.png +0 -0
- /package/{lib → dist}/assets/img/map-bubble.png +0 -0
- /package/{lib → dist}/assets/img/map.png +0 -0
- /package/{lib → dist}/assets/img/mirror.png +0 -0
- /package/{lib → dist}/assets/img/number-card.png +0 -0
- /package/{lib → dist}/assets/img/pie.png +0 -0
- /package/{lib → dist}/assets/img/pivot-table.png +0 -0
- /package/{lib → dist}/assets/img/ring.png +0 -0
- /package/{lib → dist}/assets/img/scatter.png +0 -0
- /package/{lib → dist}/assets/img/stacked-horizontal-bar.png +0 -0
- /package/{lib → dist}/assets/img/treemap.png +0 -0
- /package/{lib → dist}/assets/img/trend-chart.png +0 -0
- /package/{lib → dist}/assets/img/world-map-bubble.png +0 -0
- /package/{lib → dist}/assets/img/world-map.png +0 -0
- /package/{lib → dist}/components/loading/index.css +0 -0
- /package/{lib/components/settings/widgets/select-table → dist/editor}/index.css +0 -0
- /package/{lib/components → dist}/settings/advance-bar-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/bar-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/basic-number-card/index.js +0 -0
- /package/{lib/components → dist}/settings/combination-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/dashboard-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/horizontal-bar-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/pie-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/table-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/time-comparison-settings/index.js +0 -0
- /package/{lib/components → dist}/settings/widgets/font-settings/index.js +0 -0
- /package/{lib/components/settings/widgets/x-axios.js → dist/settings/widgets/select-table/index.css} +0 -0
|
@@ -1,277 +0,0 @@
|
|
|
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 { STATISTIC_LABEL_POSITIONS, STATISTIC_LABEL_FORMATS } from '../../constants';
|
|
8
|
-
import { StatisticsUtils } from '../../utils';
|
|
9
|
-
import ChartComponent from './chart-component';
|
|
10
|
-
import intl from '../../intl';
|
|
11
|
-
var Ring = /*#__PURE__*/function (_ChartComponent) {
|
|
12
|
-
_inherits(Ring, _ChartComponent);
|
|
13
|
-
var _super = _createSuper(Ring);
|
|
14
|
-
function Ring(props) {
|
|
15
|
-
var _this;
|
|
16
|
-
_classCallCheck(this, Ring);
|
|
17
|
-
_this = _super.call(this, props);
|
|
18
|
-
_this.createChart = function () {
|
|
19
|
-
var canvasStyle = _this.props.canvasStyle;
|
|
20
|
-
_this.initChart(_this.container, canvasStyle, 0);
|
|
21
|
-
};
|
|
22
|
-
_this.destroyChart = function () {
|
|
23
|
-
_this.chart.destroy();
|
|
24
|
-
_this.chart = null;
|
|
25
|
-
};
|
|
26
|
-
_this.clearChart = function () {
|
|
27
|
-
_this.chart.annotation().clear(true);
|
|
28
|
-
_this.chart.clear(true);
|
|
29
|
-
};
|
|
30
|
-
_this.drawChart = function () {
|
|
31
|
-
var _this$props = _this.props,
|
|
32
|
-
data = _this$props.result,
|
|
33
|
-
statistic = _this$props.statistic,
|
|
34
|
-
tables = _this$props.tables,
|
|
35
|
-
summaryColumn = _this$props.summaryColumn;
|
|
36
|
-
if (data.length === 0) return;
|
|
37
|
-
_this.sum = data.total;
|
|
38
|
-
_this.chart.coordinate('theta', {
|
|
39
|
-
radius: 0.95,
|
|
40
|
-
innerRadius: 0.7
|
|
41
|
-
});
|
|
42
|
-
var _statistic$config = statistic.config,
|
|
43
|
-
show_legend = _statistic$config.show_legend,
|
|
44
|
-
display_label = _statistic$config.display_label,
|
|
45
|
-
label_position = _statistic$config.label_position,
|
|
46
|
-
label_font_size = _statistic$config.label_font_size,
|
|
47
|
-
summary_method = _statistic$config.summary_method;
|
|
48
|
-
var _StatisticsUtils$form = StatisticsUtils.formatPieChartData(data, statistic, tables),
|
|
49
|
-
newData = _StatisticsUtils$form.data,
|
|
50
|
-
colorSet = _StatisticsUtils$form.colorSet,
|
|
51
|
-
total = _StatisticsUtils$form.total;
|
|
52
|
-
if (!Array.isArray(newData)) return;
|
|
53
|
-
_this.sum = total;
|
|
54
|
-
_this.loadData(newData);
|
|
55
|
-
_this.chart.on('interval:click', function (e) {
|
|
56
|
-
_this.props.toggleRecords(e.data.data);
|
|
57
|
-
});
|
|
58
|
-
if (show_legend) {
|
|
59
|
-
_this.chart.legend('name', {
|
|
60
|
-
position: 'right',
|
|
61
|
-
custom: true,
|
|
62
|
-
itemName: {
|
|
63
|
-
style: {
|
|
64
|
-
fill: '#6e6e6e'
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
items: newData.map(function (obj, index) {
|
|
68
|
-
var name = obj.name;
|
|
69
|
-
if (!obj.name && typeof obj.name !== 'number') {
|
|
70
|
-
name = intl.get('Empty');
|
|
71
|
-
} else if (obj.name === '_Others') {
|
|
72
|
-
name = intl.get('Others');
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
name: name,
|
|
76
|
-
value: obj.value,
|
|
77
|
-
marker: {
|
|
78
|
-
symbol: 'circle',
|
|
79
|
-
style: {
|
|
80
|
-
r: 5,
|
|
81
|
-
fill: colorSet[index]
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
})
|
|
86
|
-
});
|
|
87
|
-
} else {
|
|
88
|
-
_this.chart.legend(false);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Do not automatically adjust the maximum and minimum values in pie chart
|
|
92
|
-
_this.chart.scale({
|
|
93
|
-
value: {
|
|
94
|
-
nice: false
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
_this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('value*percent', function (value, percent) {
|
|
98
|
-
var displayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
99
|
-
return {
|
|
100
|
-
content: _this.getLabel(displayValue, percent)
|
|
101
|
-
};
|
|
102
|
-
}, {
|
|
103
|
-
offset: !label_position || label_position === STATISTIC_LABEL_POSITIONS[0] ? -2 : undefined,
|
|
104
|
-
style: {
|
|
105
|
-
fill: '#000000',
|
|
106
|
-
fontSize: StatisticsUtils.getLabelFontSize(label_font_size),
|
|
107
|
-
shadowBlur: 2,
|
|
108
|
-
shadowColor: 'rgba(0, 0, 0, .45)'
|
|
109
|
-
}
|
|
110
|
-
}).tooltip('name*value*percent', function (name, value, percent) {
|
|
111
|
-
var title = name;
|
|
112
|
-
if (!name || name === 'undefined') {
|
|
113
|
-
title = intl.get('Empty');
|
|
114
|
-
} else if (name === '_Others') {
|
|
115
|
-
title = intl.get('Others');
|
|
116
|
-
}
|
|
117
|
-
var displayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
118
|
-
return {
|
|
119
|
-
name: title,
|
|
120
|
-
value: display_label ? _this.getLabel(displayValue, percent) : displayValue
|
|
121
|
-
};
|
|
122
|
-
}).state({
|
|
123
|
-
active: {
|
|
124
|
-
style: {
|
|
125
|
-
fillOpacity: 0.7,
|
|
126
|
-
border: 'none',
|
|
127
|
-
stroke: 0
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
_this.chart.tooltip({
|
|
132
|
-
showTitle: false,
|
|
133
|
-
showMarkers: false,
|
|
134
|
-
itemTpl: '<div class="g2-tooltip-list-item"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</div>'
|
|
135
|
-
});
|
|
136
|
-
_this.chart.interaction('statistic-active');
|
|
137
|
-
_this.setAnnotation({
|
|
138
|
-
name: intl.get('Total'),
|
|
139
|
-
value: StatisticsUtils.getSummaryValueDisplayString(summaryColumn, _this.sum, summary_method)
|
|
140
|
-
}, '#000000');
|
|
141
|
-
_this.chart.on('interval:mouseenter', function (evt) {
|
|
142
|
-
return _this.onEnterRingChart(evt, '#000000', {
|
|
143
|
-
summaryColumn: summaryColumn,
|
|
144
|
-
summaryMethod: summary_method
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
_this.chart.on('interval:mouseleave', function (evt) {
|
|
148
|
-
return _this.onLeaveRingChart(evt, '#000000', {
|
|
149
|
-
summaryColumn: summaryColumn,
|
|
150
|
-
summaryMethod: summary_method
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
_this.chart.render();
|
|
154
|
-
};
|
|
155
|
-
_this.getLabel = function (value, percent) {
|
|
156
|
-
var _this$props$statistic = _this.props.statistic.config,
|
|
157
|
-
display_label = _this$props$statistic.display_label,
|
|
158
|
-
label_format = _this$props$statistic.label_format;
|
|
159
|
-
if (!display_label) {
|
|
160
|
-
return '';
|
|
161
|
-
}
|
|
162
|
-
switch (label_format) {
|
|
163
|
-
case STATISTIC_LABEL_FORMATS[0]:
|
|
164
|
-
return percent;
|
|
165
|
-
case STATISTIC_LABEL_FORMATS[1]:
|
|
166
|
-
return value;
|
|
167
|
-
case STATISTIC_LABEL_FORMATS[2]:
|
|
168
|
-
return "".concat(value, " (").concat(percent, ")");
|
|
169
|
-
default:
|
|
170
|
-
return percent;
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
_this.setAnnotation = function (content, fontColor) {
|
|
174
|
-
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
175
|
-
summaryColumn = _ref.summaryColumn,
|
|
176
|
-
summaryMethod = _ref.summaryMethod;
|
|
177
|
-
var name = content.name;
|
|
178
|
-
if (!name || name === 'undefined') {
|
|
179
|
-
name = intl.get('Empty');
|
|
180
|
-
} else if (name === '_Others') {
|
|
181
|
-
name = intl.get('Others');
|
|
182
|
-
}
|
|
183
|
-
_this.chart.annotation().text({
|
|
184
|
-
content: name,
|
|
185
|
-
position: ['50%', '50%'],
|
|
186
|
-
style: {
|
|
187
|
-
fontSize: 12,
|
|
188
|
-
fill: fontColor,
|
|
189
|
-
fontWeight: '300',
|
|
190
|
-
textAlign: 'center'
|
|
191
|
-
},
|
|
192
|
-
offsetY: -20
|
|
193
|
-
}).text({
|
|
194
|
-
position: ['50%', '50%'],
|
|
195
|
-
content: summaryColumn ? StatisticsUtils.getSummaryValueDisplayString(summaryColumn, content.value, summaryMethod) : content.value,
|
|
196
|
-
style: {
|
|
197
|
-
fontSize: 20,
|
|
198
|
-
fill: fontColor,
|
|
199
|
-
textAlign: 'center'
|
|
200
|
-
},
|
|
201
|
-
offsetY: 20
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
_this.onEnterRingChart = function (ev, color, _ref2) {
|
|
205
|
-
var summaryColumn = _ref2.summaryColumn,
|
|
206
|
-
summaryMethod = _ref2.summaryMethod;
|
|
207
|
-
var item = ev.data.data;
|
|
208
|
-
_this.chart.annotation().clear(true);
|
|
209
|
-
_this.setAnnotation(item, color, {
|
|
210
|
-
summaryColumn: summaryColumn,
|
|
211
|
-
summaryMethod: summaryMethod
|
|
212
|
-
});
|
|
213
|
-
_this.chart.render(true);
|
|
214
|
-
};
|
|
215
|
-
_this.onLeaveRingChart = function (ev, color, _ref3) {
|
|
216
|
-
var summaryColumn = _ref3.summaryColumn,
|
|
217
|
-
summaryMethod = _ref3.summaryMethod;
|
|
218
|
-
_this.chart.annotation().clear(true);
|
|
219
|
-
_this.setAnnotation({
|
|
220
|
-
name: intl.get('Total'),
|
|
221
|
-
value: _this.sum
|
|
222
|
-
}, color, {
|
|
223
|
-
summaryColumn: summaryColumn,
|
|
224
|
-
summaryMethod: summaryMethod
|
|
225
|
-
});
|
|
226
|
-
_this.chart.render(true);
|
|
227
|
-
};
|
|
228
|
-
_this.sum = 0;
|
|
229
|
-
_this.chart = null;
|
|
230
|
-
return _this;
|
|
231
|
-
}
|
|
232
|
-
_createClass(Ring, [{
|
|
233
|
-
key: "componentDidMount",
|
|
234
|
-
value: function componentDidMount() {
|
|
235
|
-
this.createChart();
|
|
236
|
-
this.drawChart();
|
|
237
|
-
}
|
|
238
|
-
}, {
|
|
239
|
-
key: "componentDidUpdate",
|
|
240
|
-
value: function componentDidUpdate(prevProps) {
|
|
241
|
-
if (StatisticsUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
242
|
-
this.chart && this.destroyChart();
|
|
243
|
-
this.sum = 0;
|
|
244
|
-
this.createChart();
|
|
245
|
-
this.drawChart();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}, {
|
|
249
|
-
key: "componentWillUnmount",
|
|
250
|
-
value: function componentWillUnmount() {
|
|
251
|
-
this.chart && this.destroyChart();
|
|
252
|
-
}
|
|
253
|
-
}, {
|
|
254
|
-
key: "render",
|
|
255
|
-
value: function render() {
|
|
256
|
-
var _this2 = this;
|
|
257
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
258
|
-
className: "seastatistic-container w-100",
|
|
259
|
-
ref: function ref(_ref4) {
|
|
260
|
-
return _this2.container = _ref4;
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}]);
|
|
265
|
-
return Ring;
|
|
266
|
-
}(ChartComponent);
|
|
267
|
-
Ring.propTypes = {
|
|
268
|
-
canvasStyle: PropTypes.object,
|
|
269
|
-
statistic: PropTypes.object,
|
|
270
|
-
groupbyColumn: PropTypes.object,
|
|
271
|
-
columnGroupbyColumn: PropTypes.object,
|
|
272
|
-
summaryColumn: PropTypes.object,
|
|
273
|
-
result: PropTypes.array,
|
|
274
|
-
tables: PropTypes.array,
|
|
275
|
-
toggleRecords: PropTypes.func
|
|
276
|
-
};
|
|
277
|
-
export default Ring;
|
|
@@ -1,42 +0,0 @@
|
|
|
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 TwoDimensionTable from './two-dimension-table';
|
|
7
|
-
import OneDimensionTableNoNumericColumns from './one-dimension-table-no-numeric-columns';
|
|
8
|
-
import OneDimensionTableWithNumericColumns from './one-dimension-table-with-numeric-columns';
|
|
9
|
-
import intl from '../../../intl';
|
|
10
|
-
import './index.css';
|
|
11
|
-
var Table = /*#__PURE__*/function (_PureComponent) {
|
|
12
|
-
_inherits(Table, _PureComponent);
|
|
13
|
-
var _super = _createSuper(Table);
|
|
14
|
-
function Table() {
|
|
15
|
-
_classCallCheck(this, Table);
|
|
16
|
-
return _super.apply(this, arguments);
|
|
17
|
-
}
|
|
18
|
-
_createClass(Table, [{
|
|
19
|
-
key: "render",
|
|
20
|
-
value: function render() {
|
|
21
|
-
var _this$props = this.props,
|
|
22
|
-
groupbyColumn = _this$props.groupbyColumn,
|
|
23
|
-
columnGroupbyColumn = _this$props.columnGroupbyColumn,
|
|
24
|
-
result = _this$props.result;
|
|
25
|
-
var pivot_columns = result.pivot_columns;
|
|
26
|
-
if (!groupbyColumn) return '';
|
|
27
|
-
if (Array.isArray(pivot_columns) && pivot_columns.length > 100) {
|
|
28
|
-
return /*#__PURE__*/React.createElement("div", null, intl.get('There_are_too_many_statistics_entries_to_display'));
|
|
29
|
-
}
|
|
30
|
-
if (columnGroupbyColumn) {
|
|
31
|
-
return /*#__PURE__*/React.createElement(TwoDimensionTable, this.props);
|
|
32
|
-
}
|
|
33
|
-
if (!Array.isArray(pivot_columns)) return null;
|
|
34
|
-
if (pivot_columns.length < 2) {
|
|
35
|
-
return /*#__PURE__*/React.createElement(OneDimensionTableNoNumericColumns, this.props);
|
|
36
|
-
}
|
|
37
|
-
return /*#__PURE__*/React.createElement(OneDimensionTableWithNumericColumns, this.props);
|
|
38
|
-
}
|
|
39
|
-
}]);
|
|
40
|
-
return Table;
|
|
41
|
-
}(PureComponent);
|
|
42
|
-
export default Table;
|
|
@@ -1,145 +0,0 @@
|
|
|
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 classnames from 'classnames';
|
|
7
|
-
import PivotTableDisplayName from './pivot-table-display-name';
|
|
8
|
-
import { StatisticsUtils, ObjectUtils } from '../../../utils';
|
|
9
|
-
import intl from '../../../intl';
|
|
10
|
-
var OneDimensionTableNoNumericColumns = /*#__PURE__*/function (_PureComponent) {
|
|
11
|
-
_inherits(OneDimensionTableNoNumericColumns, _PureComponent);
|
|
12
|
-
var _super = _createSuper(OneDimensionTableNoNumericColumns);
|
|
13
|
-
function OneDimensionTableNoNumericColumns() {
|
|
14
|
-
var _this;
|
|
15
|
-
_classCallCheck(this, OneDimensionTableNoNumericColumns);
|
|
16
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17
|
-
args[_key] = arguments[_key];
|
|
18
|
-
}
|
|
19
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
20
|
-
_this.renderHeader = function () {
|
|
21
|
-
var _this$props = _this.props,
|
|
22
|
-
groupbyColumn = _this$props.groupbyColumn,
|
|
23
|
-
selectedCell = _this$props.selectedCell;
|
|
24
|
-
var groupName = groupbyColumn.name;
|
|
25
|
-
var _ref = selectedCell || {},
|
|
26
|
-
selectRowIdx = _ref.rowIdx,
|
|
27
|
-
selectedCellIdx = _ref.cellIdx;
|
|
28
|
-
var isSelectedTotalCellBottom = selectRowIdx === 0 && selectedCellIdx === 0;
|
|
29
|
-
return /*#__PURE__*/React.createElement("thead", {
|
|
30
|
-
className: "seatable-table-header-sm"
|
|
31
|
-
}, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
32
|
-
className: "pivot-table-header"
|
|
33
|
-
}, groupName), /*#__PURE__*/React.createElement("th", {
|
|
34
|
-
className: classnames('pivot-table-header', {
|
|
35
|
-
'selected-pivot-cell-top': isSelectedTotalCellBottom
|
|
36
|
-
})
|
|
37
|
-
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total')))));
|
|
38
|
-
};
|
|
39
|
-
_this.toggleRecords = function (cell, selectedCell) {
|
|
40
|
-
if (window.isMobile) return;
|
|
41
|
-
var _ref2 = _this.props.selectedCell || {},
|
|
42
|
-
selectedRowIdx = _ref2.rowIdx,
|
|
43
|
-
selectedCellIdx = _ref2.cellIdx;
|
|
44
|
-
var rowIdx = selectedCell.rowIdx,
|
|
45
|
-
cellIdx = selectedCell.cellIdx;
|
|
46
|
-
if (rowIdx === selectedRowIdx && selectedCellIdx === cellIdx) return;
|
|
47
|
-
_this.props.toggleRecords(cell, selectedCell);
|
|
48
|
-
};
|
|
49
|
-
_this.onClickTotals = function (recordsList, selectedCell) {
|
|
50
|
-
if (window.isMobile) return;
|
|
51
|
-
var rows = recordsList.flat();
|
|
52
|
-
var total = rows.length;
|
|
53
|
-
_this.toggleRecords({
|
|
54
|
-
rows: rows,
|
|
55
|
-
total: total
|
|
56
|
-
}, selectedCell);
|
|
57
|
-
};
|
|
58
|
-
_this.renderRows = function () {
|
|
59
|
-
var _this$props2 = _this.props,
|
|
60
|
-
result = _this$props2.result,
|
|
61
|
-
groupbyColumn = _this$props2.groupbyColumn,
|
|
62
|
-
selectedCell = _this$props2.selectedCell,
|
|
63
|
-
summaryColumn = _this$props2.summaryColumn;
|
|
64
|
-
var pivot_rows = result.pivot_rows,
|
|
65
|
-
pivot_columns_total = result.pivot_columns_total;
|
|
66
|
-
var _ref3 = selectedCell || {},
|
|
67
|
-
selectRowIdx = _ref3.rowIdx,
|
|
68
|
-
selectedCellIdx = _ref3.cellIdx;
|
|
69
|
-
var pivotRowsLen = Array.isArray(pivot_rows) ? pivot_rows.length : 0;
|
|
70
|
-
var pivotColumnCells = [];
|
|
71
|
-
var isSelectRowTotalCellRight = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
|
|
72
|
-
var isSelectTotal = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
|
|
73
|
-
// eslint-disable-next-line
|
|
74
|
-
var total = ObjectUtils.hasOwnProperty(pivot_columns_total, 'total') ? pivot_columns_total['total'] : 0;
|
|
75
|
-
var summaryDisplayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, total);
|
|
76
|
-
var isValidSummaryDisplayValue = StatisticsUtils.isValidValue(summaryDisplayValue);
|
|
77
|
-
return /*#__PURE__*/React.createElement("tbody", null, pivotRowsLen > 0 && pivot_rows.map(function (rowItem, rowIdx) {
|
|
78
|
-
var name = rowItem.name,
|
|
79
|
-
total = rowItem.total,
|
|
80
|
-
rows = rowItem.rows;
|
|
81
|
-
var isSelectedRowNameRight = selectRowIdx === rowIdx && selectedCellIdx === 0;
|
|
82
|
-
// let pivotRowCells = [];
|
|
83
|
-
var isSelectedTotalCell = selectRowIdx === rowIdx && selectedCellIdx === 0;
|
|
84
|
-
var isSelectedTotalCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === 0;
|
|
85
|
-
var isSelectedTotalCellLeft = selectRowIdx === rowIdx && selectedCellIdx === 0;
|
|
86
|
-
pivotColumnCells[rowIdx] = rows;
|
|
87
|
-
var totalDisplayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, total.total);
|
|
88
|
-
var isValidTotalDisplayValue = StatisticsUtils.isValidValue(totalDisplayValue);
|
|
89
|
-
return /*#__PURE__*/React.createElement("tr", {
|
|
90
|
-
key: 'table-row-' + rowIdx
|
|
91
|
-
}, /*#__PURE__*/React.createElement("td", {
|
|
92
|
-
className: classnames('pivot-row-name', {
|
|
93
|
-
'selected-pivot-cell-left': isSelectedRowNameRight
|
|
94
|
-
})
|
|
95
|
-
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
96
|
-
value: name,
|
|
97
|
-
column: groupbyColumn
|
|
98
|
-
})), /*#__PURE__*/React.createElement("td", {
|
|
99
|
-
className: classnames('pivot-cell', {
|
|
100
|
-
'pivot-empty-cell': !isValidTotalDisplayValue,
|
|
101
|
-
'selected-pivot-cell': isSelectedTotalCell,
|
|
102
|
-
'selected-pivot-cell-top': isSelectedTotalCellTop,
|
|
103
|
-
'selected-pivot-cell-left': isSelectedTotalCellLeft
|
|
104
|
-
})
|
|
105
|
-
// onClick={() => this.toggleRecords({rows: Array.isArray(rows) && rows.length > 0 ? rows : pivotRowCells, total: total}, {rowIdx, cellIdx: 0})}
|
|
106
|
-
,
|
|
107
|
-
total: totalDisplayValue
|
|
108
|
-
}, isValidTotalDisplayValue ? totalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
109
|
-
className: classnames({
|
|
110
|
-
'selected-pivot-cell-border': isSelectedTotalCell
|
|
111
|
-
})
|
|
112
|
-
})));
|
|
113
|
-
}), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
114
|
-
className: classnames('pivot-column-total', {
|
|
115
|
-
'selected-pivot-cell-left': isSelectRowTotalCellRight
|
|
116
|
-
})
|
|
117
|
-
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total'))), /*#__PURE__*/React.createElement("td", {
|
|
118
|
-
className: classnames('pivot-cell pivot-table-total', {
|
|
119
|
-
'pivot-empty-cell': !isValidSummaryDisplayValue,
|
|
120
|
-
'selected-pivot-cell': isSelectTotal
|
|
121
|
-
})
|
|
122
|
-
// onClick={() => this.onClickTotals(pivotColumnCells, {rowIdx: pivot_rows.length, cellIdx: 0})}
|
|
123
|
-
,
|
|
124
|
-
title: isValidSummaryDisplayValue ? summaryDisplayValue : ''
|
|
125
|
-
}, isValidSummaryDisplayValue ? summaryDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
126
|
-
className: classnames({
|
|
127
|
-
'selected-pivot-cell-border': isSelectTotal
|
|
128
|
-
})
|
|
129
|
-
}))));
|
|
130
|
-
};
|
|
131
|
-
return _this;
|
|
132
|
-
}
|
|
133
|
-
_createClass(OneDimensionTableNoNumericColumns, [{
|
|
134
|
-
key: "render",
|
|
135
|
-
value: function render() {
|
|
136
|
-
var groupbyColumn = this.props.groupbyColumn;
|
|
137
|
-
if (!groupbyColumn) return '';
|
|
138
|
-
return /*#__PURE__*/React.createElement("table", {
|
|
139
|
-
className: "seastatistic-pivot-table"
|
|
140
|
-
}, this.renderHeader(), this.renderRows());
|
|
141
|
-
}
|
|
142
|
-
}]);
|
|
143
|
-
return OneDimensionTableNoNumericColumns;
|
|
144
|
-
}(PureComponent);
|
|
145
|
-
export default OneDimensionTableNoNumericColumns;
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
-
import React, { PureComponent } from 'react';
|
|
7
|
-
import classnames from 'classnames';
|
|
8
|
-
import PivotTableDisplayName from './pivot-table-display-name';
|
|
9
|
-
import { StatisticsUtils } from '../../../utils';
|
|
10
|
-
import intl from '../../../intl';
|
|
11
|
-
var OneDimensionTableWithNumericColumns = /*#__PURE__*/function (_PureComponent) {
|
|
12
|
-
_inherits(OneDimensionTableWithNumericColumns, _PureComponent);
|
|
13
|
-
var _super = _createSuper(OneDimensionTableWithNumericColumns);
|
|
14
|
-
function OneDimensionTableWithNumericColumns(_props) {
|
|
15
|
-
var _this;
|
|
16
|
-
_classCallCheck(this, OneDimensionTableWithNumericColumns);
|
|
17
|
-
_this = _super.call(this, _props);
|
|
18
|
-
_this.init = function (props) {
|
|
19
|
-
var summaryColumns = props.summaryColumns;
|
|
20
|
-
_this.summaryColumnsMethodMap = {};
|
|
21
|
-
if (Array.isArray(summaryColumns) && summaryColumns.length > 0) {
|
|
22
|
-
summaryColumns.forEach(function (item) {
|
|
23
|
-
var column_key = item.column_key,
|
|
24
|
-
summary_method = item.summary_method;
|
|
25
|
-
_this.summaryColumnsMethodMap[column_key] = summary_method;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
_this.renderHeader = function () {
|
|
30
|
-
var _this$props = _this.props,
|
|
31
|
-
result = _this$props.result,
|
|
32
|
-
groupbyColumn = _this$props.groupbyColumn,
|
|
33
|
-
columnGroupbyColumn = _this$props.columnGroupbyColumn,
|
|
34
|
-
selectedCell = _this$props.selectedCell,
|
|
35
|
-
statisticTableColumns = _this$props.statisticTableColumns;
|
|
36
|
-
var groupName = groupbyColumn.name;
|
|
37
|
-
var _ref = columnGroupbyColumn || {},
|
|
38
|
-
rowGroupName = _ref.name;
|
|
39
|
-
var pivot_columns = result.pivot_columns;
|
|
40
|
-
var _ref2 = selectedCell || {},
|
|
41
|
-
selectRowIdx = _ref2.rowIdx,
|
|
42
|
-
selectedCellIdx = _ref2.cellIdx;
|
|
43
|
-
return /*#__PURE__*/React.createElement("thead", {
|
|
44
|
-
className: "seatable-table-header-sm"
|
|
45
|
-
}, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
46
|
-
className: "pivot-table-header"
|
|
47
|
-
}, !rowGroupName && groupName), Array.isArray(pivot_columns) && pivot_columns.map(function (item, index) {
|
|
48
|
-
var key = item.key;
|
|
49
|
-
var column = statisticTableColumns.find(function (column) {
|
|
50
|
-
return column.key === key;
|
|
51
|
-
});
|
|
52
|
-
var isSelectedHeaderBottom = selectRowIdx === 0 && selectedCellIdx === index;
|
|
53
|
-
return /*#__PURE__*/React.createElement("th", {
|
|
54
|
-
className: classnames('pivot-table-header', {
|
|
55
|
-
'selected-pivot-cell-top': isSelectedHeaderBottom
|
|
56
|
-
}),
|
|
57
|
-
key: "pivot-column-".concat(index)
|
|
58
|
-
}, /*#__PURE__*/React.createElement("div", null, column.name));
|
|
59
|
-
})));
|
|
60
|
-
};
|
|
61
|
-
_this.toggleRecords = function (cell, selectedCell) {
|
|
62
|
-
if (window.isMobile) return;
|
|
63
|
-
var _ref3 = _this.props.selectedCell || {},
|
|
64
|
-
selectedRowIdx = _ref3.rowIdx,
|
|
65
|
-
selectedCellIdx = _ref3.cellIdx;
|
|
66
|
-
var rowIdx = selectedCell.rowIdx,
|
|
67
|
-
cellIdx = selectedCell.cellIdx;
|
|
68
|
-
if (rowIdx === selectedRowIdx && selectedCellIdx === cellIdx) return;
|
|
69
|
-
_this.props.toggleRecords(cell, selectedCell);
|
|
70
|
-
};
|
|
71
|
-
_this.onClickTotals = function (recordsList, selectedCell) {
|
|
72
|
-
if (window.isMobile) return;
|
|
73
|
-
var rows = recordsList.flat();
|
|
74
|
-
var total = rows.length;
|
|
75
|
-
_this.toggleRecords({
|
|
76
|
-
rows: rows,
|
|
77
|
-
total: total
|
|
78
|
-
}, selectedCell);
|
|
79
|
-
};
|
|
80
|
-
_this.renderRows = function () {
|
|
81
|
-
var _this$props2 = _this.props,
|
|
82
|
-
result = _this$props2.result,
|
|
83
|
-
groupbyColumn = _this$props2.groupbyColumn,
|
|
84
|
-
selectedCell = _this$props2.selectedCell,
|
|
85
|
-
statisticTableColumns = _this$props2.statisticTableColumns;
|
|
86
|
-
var pivot_rows = result.pivot_rows,
|
|
87
|
-
pivot_columns = result.pivot_columns,
|
|
88
|
-
pivot_columns_total = result.pivot_columns_total;
|
|
89
|
-
var _ref4 = selectedCell || {},
|
|
90
|
-
selectRowIdx = _ref4.rowIdx,
|
|
91
|
-
selectedCellIdx = _ref4.cellIdx;
|
|
92
|
-
var pivotRowsLen = Array.isArray(pivot_rows) ? pivot_rows.length : 0;
|
|
93
|
-
var pivotColumnCells = [];
|
|
94
|
-
var isSelectRowTotalCellRight = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
|
|
95
|
-
return /*#__PURE__*/React.createElement("tbody", null, pivotRowsLen > 0 && pivot_rows.map(function (rowItem, rowIdx) {
|
|
96
|
-
var name = rowItem.name,
|
|
97
|
-
total = rowItem.total,
|
|
98
|
-
rows = rowItem.rows;
|
|
99
|
-
var isSelectedRowNameRight = selectRowIdx === rowIdx && selectedCellIdx === 0;
|
|
100
|
-
if (!Array.isArray(pivot_columns)) {
|
|
101
|
-
pivotColumnCells[rowIdx] = rowItem.rows || [];
|
|
102
|
-
}
|
|
103
|
-
return /*#__PURE__*/React.createElement("tr", {
|
|
104
|
-
key: 'table-row' + rowIdx
|
|
105
|
-
}, /*#__PURE__*/React.createElement("td", {
|
|
106
|
-
className: classnames('pivot-row-name', {
|
|
107
|
-
'selected-pivot-cell-left': isSelectedRowNameRight
|
|
108
|
-
})
|
|
109
|
-
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
110
|
-
value: name,
|
|
111
|
-
column: groupbyColumn
|
|
112
|
-
})), Array.isArray(pivot_columns) && pivot_columns.map(function (columnMap, cellIdx) {
|
|
113
|
-
var isSelectedCell = selectRowIdx === rowIdx && selectedCellIdx === cellIdx;
|
|
114
|
-
var isSelectedCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cellIdx;
|
|
115
|
-
var isSelectedCellLeft = selectRowIdx === rowIdx && selectedCellIdx - 1 === cellIdx;
|
|
116
|
-
var key = columnMap.key;
|
|
117
|
-
var column = statisticTableColumns.find(function (item) {
|
|
118
|
-
return item.key === key;
|
|
119
|
-
});
|
|
120
|
-
var displayValue = StatisticsUtils.getSummaryValueDisplayString(column, total[key], _this.summaryColumnsMethodMap[key]);
|
|
121
|
-
var isValidDisplayValue = StatisticsUtils.isValidValue(displayValue);
|
|
122
|
-
if (Array.isArray(rows) && rows.length > 0) {
|
|
123
|
-
if (pivotColumnCells[cellIdx]) {
|
|
124
|
-
var _pivotColumnCells$cel;
|
|
125
|
-
(_pivotColumnCells$cel = pivotColumnCells[cellIdx]).push.apply(_pivotColumnCells$cel, _toConsumableArray(rows));
|
|
126
|
-
} else {
|
|
127
|
-
pivotColumnCells[cellIdx] = _toConsumableArray(rows);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
131
|
-
className: classnames('pivot-cell', {
|
|
132
|
-
'pivot-empty-cell': !isValidDisplayValue,
|
|
133
|
-
'selected-pivot-cell': isSelectedCell,
|
|
134
|
-
'selected-pivot-cell-top': isSelectedCellTop,
|
|
135
|
-
'selected-pivot-cell-left': isSelectedCellLeft
|
|
136
|
-
}),
|
|
137
|
-
key: "table-cell-".concat(cellIdx)
|
|
138
|
-
// onClick={() => this.toggleRecords({rows, total: total[key]}, {rowIdx, cellIdx})}
|
|
139
|
-
,
|
|
140
|
-
title: isValidDisplayValue ? displayValue : ''
|
|
141
|
-
}, isValidDisplayValue ? displayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
142
|
-
className: classnames({
|
|
143
|
-
'selected-pivot-cell-border': isSelectedCell
|
|
144
|
-
})
|
|
145
|
-
}));
|
|
146
|
-
}));
|
|
147
|
-
}), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
148
|
-
className: classnames('pivot-column-total', {
|
|
149
|
-
'selected-pivot-cell-left': isSelectRowTotalCellRight
|
|
150
|
-
})
|
|
151
|
-
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total'))), Array.isArray(pivot_columns) && pivot_columns.map(function (c, index) {
|
|
152
|
-
// const pivotColumnCell = pivotColumnCells[index];
|
|
153
|
-
var pivotColumnTotal = pivot_columns_total[c.key];
|
|
154
|
-
var column = statisticTableColumns.find(function (column) {
|
|
155
|
-
return column.key === c.key;
|
|
156
|
-
});
|
|
157
|
-
var totalDisplayValue = StatisticsUtils.getSummaryValueDisplayString(column, pivotColumnTotal, _this.summaryColumnsMethodMap[c.key]);
|
|
158
|
-
var isValidTotalDisplayValue = StatisticsUtils.isValidValue(totalDisplayValue);
|
|
159
|
-
var isSelectRowTotalCell = selectRowIdx === pivot_rows.length && selectedCellIdx === index;
|
|
160
|
-
var isSelectRowTotalCellLeft = selectRowIdx === pivot_rows.length && selectedCellIdx - 1 === index;
|
|
161
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
162
|
-
className: classnames('pivot-cell', {
|
|
163
|
-
'pivot-empty-cell': !isValidTotalDisplayValue,
|
|
164
|
-
'selected-pivot-cell': isSelectRowTotalCell,
|
|
165
|
-
'selected-pivot-cell-left': isSelectRowTotalCellLeft
|
|
166
|
-
}),
|
|
167
|
-
key: "total-cell-".concat(index)
|
|
168
|
-
// onClick={() => this.toggleRecords({ rows: pivotColumnCell, total: pivot_columns_total[c.key] }, {rowIdx: pivot_rows.length, cellIdx: index})}
|
|
169
|
-
,
|
|
170
|
-
title: totalDisplayValue
|
|
171
|
-
}, isValidTotalDisplayValue ? totalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
172
|
-
className: classnames({
|
|
173
|
-
'selected-pivot-cell-border': isSelectRowTotalCell
|
|
174
|
-
})
|
|
175
|
-
}));
|
|
176
|
-
})));
|
|
177
|
-
};
|
|
178
|
-
_this.init(_props);
|
|
179
|
-
return _this;
|
|
180
|
-
}
|
|
181
|
-
_createClass(OneDimensionTableWithNumericColumns, [{
|
|
182
|
-
key: "render",
|
|
183
|
-
value: function render() {
|
|
184
|
-
var groupbyColumn = this.props.groupbyColumn;
|
|
185
|
-
if (!groupbyColumn) return '';
|
|
186
|
-
return /*#__PURE__*/React.createElement("table", {
|
|
187
|
-
className: "seastatistic-pivot-table"
|
|
188
|
-
}, this.renderHeader(), this.renderRows());
|
|
189
|
-
}
|
|
190
|
-
}]);
|
|
191
|
-
return OneDimensionTableWithNumericColumns;
|
|
192
|
-
}(PureComponent);
|
|
193
|
-
export default OneDimensionTableWithNumericColumns;
|