sea-chart 1.1.64 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +13 -6
- package/dist/assets/css/sea-chart-d3-tooltip.css +64 -0
- package/dist/components/cell-factory/FormatterConfig.js +62 -55
- package/dist/components/cell-factory/SimpleCellFormatter.js +11 -4
- package/dist/components/cell-factory/SingleSelectOption.js +18 -11
- package/dist/components/cell-factory/cell-editor-factory.js +12 -5
- package/dist/components/cell-factory/cell-formatter-factory.js +11 -4
- package/dist/components/cell-factory/link-content.js +35 -27
- package/dist/components/chart-color-selector/color-selector.js +18 -11
- package/dist/components/collaborator/index.js +14 -7
- package/dist/components/color-picker/index.js +18 -11
- package/dist/components/color-popover/color-rules/color-rule.js +33 -25
- package/dist/components/color-popover/color-rules/index.js +14 -6
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +34 -27
- package/dist/components/color-popover/color-rules/rule-filters/index.js +25 -17
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +17 -9
- package/dist/components/color-popover/color-rules-popover.js +33 -25
- package/dist/components/color-popover/color-selector-popover.js +18 -10
- package/dist/components/color-setting/color-group-selector.js +20 -12
- package/dist/components/common-add-tool/index.js +13 -6
- package/dist/components/data-process-setter/data-setting-header.js +14 -7
- package/dist/components/data-process-setter/hide-column-setter.js +19 -12
- package/dist/components/data-process-setter/index.js +27 -4
- package/dist/components/data-process-setter/sort-setter.js +24 -16
- package/dist/components/draggable/Draggable.js +13 -7
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +48 -40
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +18 -10
- package/dist/components/drill-down-settings/index.js +18 -11
- package/dist/components/dtable-popover/index.js +20 -13
- package/dist/components/dtable-search-input/index.js +21 -13
- package/dist/components/font-settings/index.js +22 -14
- package/dist/components/goal-line-setting/goal-setting-item.js +14 -6
- package/dist/components/goal-line-setting/index.js +19 -12
- package/dist/components/highlighter/highlighter.js +14 -7
- package/dist/components/icon/index.js +12 -5
- package/dist/components/index.js +48 -7
- package/dist/components/loading/index.js +13 -6
- package/dist/components/number-input/index.js +11 -4
- package/dist/components/pixel-editor/index.js +23 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +14 -7
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +35 -27
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +18 -9
- package/dist/components/popover/sort-popover/sort-popover.js +65 -55
- package/dist/components/resize-handle/ResizeHandle.js +13 -6
- package/dist/components/row-card/row-card-header-cell.js +22 -15
- package/dist/components/row-card/row-card-header.js +21 -14
- package/dist/components/row-card/row-card-item.js +41 -33
- package/dist/components/row-card/row-card.js +23 -15
- package/dist/components/statistic-record-dialog/index.js +63 -55
- package/dist/components/types-dialog/index.js +63 -55
- package/dist/components/types-dialog/use-force-update.js +10 -4
- package/dist/constants/color-rules.js +14 -8
- package/dist/constants/common-constants.js +14 -8
- package/dist/constants/error.js +8 -2
- package/dist/constants/geolocation.js +15 -9
- package/dist/constants/index.js +271 -142
- package/dist/constants/key-codes.js +2 -0
- package/dist/constants/model.js +9 -3
- package/dist/constants/regions.js +8 -3
- package/dist/constants/style.js +12 -6
- package/dist/constants/table.js +7 -1
- package/dist/constants/type-image.js +39 -33
- package/dist/constants/type.js +9 -3
- package/dist/context.js +19 -12
- package/dist/editor/index.js +15 -12
- package/dist/index.js +104 -13
- package/dist/intl.js +17 -10
- package/dist/locale/index.js +23 -16
- package/dist/locale/lang/de.js +7 -1
- package/dist/locale/lang/en.js +7 -1
- package/dist/locale/lang/es.js +7 -1
- package/dist/locale/lang/fr.js +7 -1
- package/dist/locale/lang/pt.js +7 -1
- package/dist/locale/lang/ru.js +7 -1
- package/dist/locale/lang/zh_CN.js +7 -1
- package/dist/model/area-group.js +19 -12
- package/dist/model/area.js +19 -12
- package/dist/model/bar-custom.js +18 -11
- package/dist/model/bar-group.js +19 -12
- package/dist/model/bar-stack.js +17 -10
- package/dist/model/bar.js +18 -11
- package/dist/model/base-model.js +11 -4
- package/dist/model/basic-number-card.js +20 -13
- package/dist/model/chart.js +13 -7
- package/dist/model/combination.js +22 -15
- package/dist/model/compare-bar.js +21 -14
- package/dist/model/completeness-group.js +18 -11
- package/dist/model/completeness.js +17 -10
- package/dist/model/dashboard.js +14 -7
- package/dist/model/funnel.js +21 -14
- package/dist/model/generic-model.js +143 -135
- package/dist/model/heat-map.js +16 -9
- package/dist/model/horizontal-bar.js +18 -11
- package/dist/model/horizontal-group-bar.js +17 -10
- package/dist/model/index.js +93 -69
- package/dist/model/line-group.js +20 -13
- package/dist/model/line.js +19 -12
- package/dist/model/map-bubble.js +17 -10
- package/dist/model/map.js +19 -12
- package/dist/model/mirror.js +20 -13
- package/dist/model/pie.js +19 -12
- package/dist/model/ring.js +19 -12
- package/dist/model/scatter.js +17 -10
- package/dist/model/stacked-horizontal-bar.js +18 -11
- package/dist/model/table-element.js +12 -5
- package/dist/model/table.js +14 -7
- package/dist/model/tree-map.js +14 -7
- package/dist/model/trend.js +18 -11
- package/dist/model/user.js +7 -1
- package/dist/model/world-map-bubble.js +19 -12
- package/dist/model/world-map.js +19 -12
- package/dist/services/map-json.js +13 -7
- package/dist/settings/advance-bar-settings/data-settings.js +46 -42
- package/dist/settings/advance-bar-settings/index.js +20 -3
- package/dist/settings/advance-bar-settings/style-settings.js +73 -69
- package/dist/settings/bar-settings/data-settings.js +49 -45
- package/dist/settings/bar-settings/index.js +20 -3
- package/dist/settings/bar-settings/style-settings.js +59 -55
- package/dist/settings/basic-number-card/data-settings.js +57 -49
- package/dist/settings/basic-number-card/index.js +20 -3
- package/dist/settings/basic-number-card/style-settings.js +26 -18
- package/dist/settings/combination-settings/data-settings.js +65 -60
- package/dist/settings/combination-settings/index.js +20 -3
- package/dist/settings/combination-settings/style-settings.js +74 -69
- package/dist/settings/completeness-settings/callbacks/callbacks.js +27 -16
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +28 -21
- package/dist/settings/completeness-settings/data-settings/data-settings.js +32 -25
- package/dist/settings/completeness-settings/index.js +20 -3
- package/dist/settings/completeness-settings/style-settings.js +26 -19
- package/dist/settings/dashboard-settings/data-settings.js +51 -43
- package/dist/settings/dashboard-settings/index.js +13 -2
- package/dist/settings/data-settings.js +79 -72
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +19 -12
- package/dist/settings/funnel-settings/components/dnd-list.js +23 -15
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +40 -32
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +30 -22
- package/dist/settings/funnel-settings/data-settings.js +31 -23
- package/dist/settings/funnel-settings/index.js +20 -3
- package/dist/settings/funnel-settings/style-settings.js +19 -11
- package/dist/settings/heat-map-settings/data-settings.js +26 -18
- package/dist/settings/heat-map-settings/index.js +20 -3
- package/dist/settings/heat-map-settings/style-settings.js +26 -18
- package/dist/settings/horizontal-bar-settings/data-settings.js +19 -12
- package/dist/settings/horizontal-bar-settings/index.js +20 -3
- package/dist/settings/horizontal-bar-settings/style-settings.js +19 -12
- package/dist/settings/index.js +75 -58
- package/dist/settings/map-settings/components/location-field-selector.js +17 -10
- package/dist/settings/map-settings/components/map-level-selector.js +18 -11
- package/dist/settings/map-settings/components/map-province-city-selector.js +26 -19
- package/dist/settings/map-settings/index.js +20 -3
- package/dist/settings/map-settings/map-data-settings.js +30 -23
- package/dist/settings/map-settings/map-style-settings.js +34 -26
- package/dist/settings/mirror-settings/data-settings.js +34 -26
- package/dist/settings/mirror-settings/index.js +13 -2
- package/dist/settings/pie-settings/data-settings.js +41 -33
- package/dist/settings/pie-settings/index.js +20 -3
- package/dist/settings/pie-settings/style-settings.js +55 -47
- package/dist/settings/scatter/data-settings.js +34 -27
- package/dist/settings/scatter/index.js +12 -3
- package/dist/settings/stacks-settings/index.js +27 -19
- package/dist/settings/stacks-settings/stack-item-settings.js +27 -19
- package/dist/settings/style-settings.js +72 -64
- package/dist/settings/table-element-settings/components/data-filter.js +37 -29
- package/dist/settings/table-element-settings/data-settings.js +29 -21
- package/dist/settings/table-element-settings/index.js +13 -2
- package/dist/settings/table-settings/data-settings.js +119 -111
- package/dist/settings/table-settings/index.js +13 -2
- package/dist/settings/time-comparison-settings/data-settings.js +51 -43
- package/dist/settings/time-comparison-settings/index.js +20 -3
- package/dist/settings/time-comparison-settings/style-settings.js +50 -42
- package/dist/settings/trend-settings/data-settings.js +32 -24
- package/dist/settings/trend-settings/index.js +20 -3
- package/dist/settings/trend-settings/style-setting.js +25 -17
- package/dist/settings/widgets/basic-summary/index.js +66 -66
- package/dist/settings/widgets/chart-type/index.js +34 -19
- package/dist/settings/widgets/color-settings/index.js +80 -72
- package/dist/settings/widgets/common-data-settings.js +30 -25
- package/dist/settings/widgets/data-filter/index.js +40 -32
- package/dist/settings/widgets/data-sort.js +24 -16
- package/dist/settings/widgets/date-summary-item.js +32 -24
- package/dist/settings/widgets/display-values-settings/index.js +22 -14
- package/dist/settings/widgets/divider/index.js +16 -8
- package/dist/settings/widgets/font-settings/font-color-settings.js +19 -11
- package/dist/settings/widgets/font-settings/font-size-settings.js +22 -14
- package/dist/settings/widgets/font-settings/font-weight-settings.js +25 -17
- package/dist/settings/widgets/font-settings/index.js +27 -4
- package/dist/settings/widgets/group-by.js +59 -51
- package/dist/settings/widgets/min-max-setting.js +18 -10
- package/dist/settings/widgets/mininum-slice-percent.js +18 -10
- package/dist/settings/widgets/numeric-summary-item.js +31 -23
- package/dist/settings/widgets/select-line-type/index.js +17 -10
- package/dist/settings/widgets/select-table/index.js +16 -9
- package/dist/settings/widgets/select-view/index.js +28 -20
- package/dist/settings/widgets/stack.js +22 -14
- package/dist/settings/widgets/summary-method-setting.js +25 -17
- package/dist/settings/widgets/summary-settings.js +80 -72
- package/dist/settings/widgets/switch/index.js +15 -8
- package/dist/settings/widgets/text-horizontal-settings.js +23 -15
- package/dist/settings/widgets/time-picker.js +37 -29
- package/dist/settings/widgets/title-settings/index.js +37 -29
- package/dist/settings/widgets/title-settings/title-text.js +12 -5
- package/dist/settings/widgets/x-axios.js +1 -0
- package/dist/settings/widgets/y-axis-group-settings.js +71 -63
- package/dist/utils/cell-format-utils.js +29 -19
- package/dist/utils/cell-value-utils.js +11 -4
- package/dist/utils/chart-utils/base-utils.js +290 -279
- package/dist/utils/chart-utils/index.js +39 -26
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +84 -77
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +20 -13
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +52 -45
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +26 -19
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +39 -32
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +23 -16
- package/dist/utils/chart-utils/original-data-utils/index.js +57 -50
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +26 -19
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +96 -90
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +25 -18
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +34 -27
- package/dist/utils/chart-utils/sql-statistics-utils.js +237 -229
- package/dist/utils/chart.js +17 -9
- package/dist/utils/collaborator-manager.js +9 -3
- package/dist/utils/collaborator-utils.js +30 -18
- package/dist/utils/collaborator.js +13 -4
- package/dist/utils/color-utils.js +29 -18
- package/dist/utils/column-utils.js +88 -63
- package/dist/utils/common-utils.js +52 -27
- package/dist/utils/concurrency-manager.js +7 -1
- package/dist/utils/contexts.js +11 -4
- package/dist/utils/custom-g2.js +241 -212
- package/dist/utils/date-translate.js +19 -11
- package/dist/utils/digital-sign-utils.js +14 -7
- package/dist/utils/event-bus.js +7 -1
- package/dist/utils/hotkey.js +11 -5
- package/dist/utils/index.js +219 -53
- package/dist/utils/key-generator.js +9 -2
- package/dist/utils/map.js +31 -22
- package/dist/utils/object-utils.js +7 -1
- package/dist/utils/options-utils.js +16 -8
- package/dist/utils/row-record-utils.js +164 -152
- package/dist/utils/row-utils.js +38 -27
- package/dist/utils/search.js +32 -24
- package/dist/utils/sql/chart-data-sql.js +55 -49
- package/dist/utils/sql/column-2-sql-column.js +153 -143
- package/dist/utils/sql/index.js +27 -3
- package/dist/utils/trend-utils.js +45 -37
- package/dist/view/index.js +96 -87
- package/dist/view/title/index.js +23 -15
- package/dist/view/wrapper/area.js +46 -39
- package/dist/view/wrapper/bar-custom.js +40 -33
- package/dist/view/wrapper/bar-group.js +58 -51
- package/dist/view/wrapper/bar.js +42 -35
- package/dist/view/wrapper/basic-number-card.js +25 -17
- package/dist/view/wrapper/chart-component.js +116 -54
- package/dist/view/wrapper/combination.js +82 -75
- package/dist/view/wrapper/compare.js +57 -50
- package/dist/view/wrapper/completeness.js +32 -24
- package/dist/view/wrapper/dashboard.js +21 -14
- package/dist/view/wrapper/funnel.js +26 -19
- package/dist/view/wrapper/heat-map.js +60 -53
- package/dist/view/wrapper/horizontal-bar-group.js +48 -41
- package/dist/view/wrapper/horizontal-bar.js +39 -32
- package/dist/view/wrapper/horizontal-component.js +23 -15
- package/dist/view/wrapper/index.js +148 -96
- package/dist/view/wrapper/line-group.js +41 -34
- package/dist/view/wrapper/line.js +39 -32
- package/dist/view/wrapper/map.js +54 -46
- package/dist/view/wrapper/mirror.js +38 -31
- package/dist/view/wrapper/pie.js +50 -43
- package/dist/view/wrapper/ring.js +59 -52
- package/dist/view/wrapper/scatter.js +30 -22
- package/dist/view/wrapper/table/index.js +21 -13
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +57 -49
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +58 -50
- package/dist/view/wrapper/table/pivot-table-display-name.js +90 -82
- package/dist/view/wrapper/table/two-dimension-table.js +84 -76
- package/dist/view/wrapper/table-element/components/dataset-utils.js +36 -23
- package/dist/view/wrapper/table-element/components/formatter.js +98 -89
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +31 -22
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +16 -9
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +80 -73
- package/dist/view/wrapper/table-element/components/formula-formatter.js +16 -9
- package/dist/view/wrapper/table-element/components/link-formatter.js +80 -73
- package/dist/view/wrapper/table-element/components/record.js +17 -10
- package/dist/view/wrapper/table-element/components/records-body.js +17 -9
- package/dist/view/wrapper/table-element/components/records-header/index.js +16 -8
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +16 -8
- package/dist/view/wrapper/table-element/components/records.js +29 -21
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +13 -6
- package/dist/view/wrapper/table-element/components/utils.js +15 -5
- package/dist/view/wrapper/table-element/components/value-display-utils.js +11 -4
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +13 -6
- package/dist/view/wrapper/table-element/index.js +24 -16
- package/dist/view/wrapper/treemap.js +43 -36
- package/dist/view/wrapper/trend.js +47 -39
- package/dist/view/wrapper/world-map.js +60 -52
- package/dist/view/wrapper/wrappers-d3/bar.js +262 -0
- package/package.json +15 -17
package/dist/utils/sql/index.js
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "ChartDataSQL", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _chartDataSql.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "chartColumn2SqlColumn", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _column2SqlColumn.default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "summaryMethodColumn2SqlColumn", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return _column2SqlColumn.summaryMethodColumn2SqlColumn;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
var _column2SqlColumn = _interopRequireWildcard(require("./column-2-sql-column"));
|
|
27
|
+
var _chartDataSql = _interopRequireDefault(require("./chart-data-sql"));
|
|
@@ -1,43 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getCompareDate = getCompareDate;
|
|
8
|
+
exports.summaryDurationResult = summaryDurationResult;
|
|
9
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
10
|
+
var _quarterOfYear = _interopRequireDefault(require("dayjs/plugin/quarterOfYear"));
|
|
11
|
+
var _constants = require("../constants");
|
|
12
|
+
var _chartUtils = require("./chart-utils");
|
|
13
|
+
_dayjs.default.extend(_quarterOfYear.default);
|
|
14
|
+
function getCompareDate(dateGranularity) {
|
|
15
|
+
const currentDate = (0, _dayjs.default)();
|
|
8
16
|
switch (dateGranularity) {
|
|
9
|
-
case CHART_SUMMARY_TYPE.DAY:
|
|
17
|
+
case _constants.CHART_SUMMARY_TYPE.DAY:
|
|
10
18
|
{
|
|
11
|
-
const compareDate =
|
|
12
|
-
const comparedDate =
|
|
19
|
+
const compareDate = (0, _dayjs.default)(currentDate).subtract(1, 'days').format('YYYY-MM-DD');
|
|
20
|
+
const comparedDate = (0, _dayjs.default)(currentDate).subtract(2, 'days').format('YYYY-MM-DD');
|
|
13
21
|
return {
|
|
14
22
|
compareDate,
|
|
15
23
|
comparedDate
|
|
16
24
|
};
|
|
17
25
|
}
|
|
18
|
-
case CHART_SUMMARY_TYPE.WEEK:
|
|
26
|
+
case _constants.CHART_SUMMARY_TYPE.WEEK:
|
|
19
27
|
{
|
|
20
|
-
const currentWeek =
|
|
21
|
-
const compareDate =
|
|
22
|
-
const comparedDate =
|
|
28
|
+
const currentWeek = (0, _dayjs.default)().day(1);
|
|
29
|
+
const compareDate = (0, _dayjs.default)(currentWeek).subtract(1, 'weeks').format('YYYY-MM-DD');
|
|
30
|
+
const comparedDate = (0, _dayjs.default)(currentWeek).subtract(2, 'weeks').format('YYYY-MM-DD');
|
|
23
31
|
return {
|
|
24
32
|
compareDate,
|
|
25
33
|
comparedDate
|
|
26
34
|
};
|
|
27
35
|
}
|
|
28
|
-
case CHART_SUMMARY_TYPE.MONTH:
|
|
36
|
+
case _constants.CHART_SUMMARY_TYPE.MONTH:
|
|
29
37
|
{
|
|
30
|
-
const compareDate =
|
|
31
|
-
const comparedDate =
|
|
38
|
+
const compareDate = (0, _dayjs.default)(currentDate).subtract(1, 'months').format('YYYY-MM');
|
|
39
|
+
const comparedDate = (0, _dayjs.default)(currentDate).subtract(2, 'months').format('YYYY-MM');
|
|
32
40
|
return {
|
|
33
41
|
compareDate,
|
|
34
42
|
comparedDate
|
|
35
43
|
};
|
|
36
44
|
}
|
|
37
|
-
case CHART_SUMMARY_TYPE.QUARTER:
|
|
45
|
+
case _constants.CHART_SUMMARY_TYPE.QUARTER:
|
|
38
46
|
{
|
|
39
|
-
const currentQuarter =
|
|
40
|
-
const currentYear =
|
|
47
|
+
const currentQuarter = (0, _dayjs.default)().quarter();
|
|
48
|
+
const currentYear = (0, _dayjs.default)().year();
|
|
41
49
|
let lastQuarter = currentQuarter - 1;
|
|
42
50
|
let compareDate, comparedDate;
|
|
43
51
|
if (lastQuarter < 1) {
|
|
@@ -58,9 +66,9 @@ export function getCompareDate(dateGranularity) {
|
|
|
58
66
|
comparedDate
|
|
59
67
|
};
|
|
60
68
|
}
|
|
61
|
-
case CHART_SUMMARY_TYPE.YEAR:
|
|
69
|
+
case _constants.CHART_SUMMARY_TYPE.YEAR:
|
|
62
70
|
{
|
|
63
|
-
const currentYear =
|
|
71
|
+
const currentYear = (0, _dayjs.default)().year();
|
|
64
72
|
return {
|
|
65
73
|
compareDate: currentYear - 1 + '',
|
|
66
74
|
comparedDate: currentYear - 2 + ''
|
|
@@ -72,17 +80,17 @@ export function getCompareDate(dateGranularity) {
|
|
|
72
80
|
}
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
|
-
|
|
76
|
-
const currentTime =
|
|
83
|
+
function summaryDurationResult(result, duration, summaryType, summaryMethod, useDataDb, dbDateKey, valueKey) {
|
|
84
|
+
const currentTime = (0, _dayjs.default)();
|
|
77
85
|
const days = duration === 'days_30' ? 30 : 7;
|
|
78
86
|
|
|
79
87
|
// set date to start of the day
|
|
80
88
|
const formattedEndDate = currentTime.format('YYYY-MM-DD');
|
|
81
89
|
const formattedMiddleDate = currentTime.subtract(days, 'days').format('YYYY-MM-DD');
|
|
82
|
-
const formattedStartDate =
|
|
83
|
-
const endDate =
|
|
84
|
-
const middleDate =
|
|
85
|
-
const startDate =
|
|
90
|
+
const formattedStartDate = (0, _dayjs.default)(formattedMiddleDate).subtract(days, 'days').format('YYYY-MM-DD');
|
|
91
|
+
const endDate = (0, _dayjs.default)(formattedEndDate);
|
|
92
|
+
const middleDate = (0, _dayjs.default)(formattedMiddleDate);
|
|
93
|
+
const startDate = (0, _dayjs.default)(formattedStartDate);
|
|
86
94
|
let compareValue = [];
|
|
87
95
|
let comparedValue = [];
|
|
88
96
|
if (useDataDb) {
|
|
@@ -90,7 +98,7 @@ export function summaryDurationResult(result, duration, summaryType, summaryMeth
|
|
|
90
98
|
const days2 = [];
|
|
91
99
|
for (let index = 0; index < result.length; index++) {
|
|
92
100
|
const item = result[index];
|
|
93
|
-
const key =
|
|
101
|
+
const key = (0, _dayjs.default)(item[dbDateKey]);
|
|
94
102
|
if (!key.isValid()) continue;
|
|
95
103
|
if (key >= startDate && key < middleDate) {
|
|
96
104
|
comparedValue.push(item[valueKey]);
|
|
@@ -103,16 +111,16 @@ export function summaryDurationResult(result, duration, summaryType, summaryMeth
|
|
|
103
111
|
} else {
|
|
104
112
|
// eslint-disable-next-line
|
|
105
113
|
for (let item of result) {
|
|
106
|
-
const key =
|
|
114
|
+
const key = (0, _dayjs.default)(item[0]);
|
|
107
115
|
if (!key.isValid()) continue;
|
|
108
116
|
if (key >= startDate && key < middleDate) {
|
|
109
|
-
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
117
|
+
if (summaryType === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
|
|
110
118
|
comparedValue = comparedValue.concat(item[1] || []);
|
|
111
119
|
} else {
|
|
112
120
|
comparedValue.push(item[1]);
|
|
113
121
|
}
|
|
114
122
|
} else if (key >= middleDate && key < endDate) {
|
|
115
|
-
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
123
|
+
if (summaryType === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
|
|
116
124
|
compareValue = compareValue.concat(item[1] || []);
|
|
117
125
|
} else {
|
|
118
126
|
compareValue.push(item[1]);
|
|
@@ -120,12 +128,12 @@ export function summaryDurationResult(result, duration, summaryType, summaryMeth
|
|
|
120
128
|
}
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
|
-
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
124
|
-
comparedValue = BaseUtils.getSummaryResult(comparedValue, summaryMethod);
|
|
125
|
-
compareValue = BaseUtils.getSummaryResult(compareValue, summaryMethod);
|
|
131
|
+
if (summaryType === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
|
|
132
|
+
comparedValue = _chartUtils.BaseUtils.getSummaryResult(comparedValue, summaryMethod);
|
|
133
|
+
compareValue = _chartUtils.BaseUtils.getSummaryResult(compareValue, summaryMethod);
|
|
126
134
|
} else {
|
|
127
|
-
compareValue = BaseUtils.getSummaryResult(compareValue, 'Sum');
|
|
128
|
-
comparedValue = BaseUtils.getSummaryResult(comparedValue, 'Sum');
|
|
135
|
+
compareValue = _chartUtils.BaseUtils.getSummaryResult(compareValue, 'Sum');
|
|
136
|
+
comparedValue = _chartUtils.BaseUtils.getSummaryResult(comparedValue, 'Sum');
|
|
129
137
|
}
|
|
130
138
|
return {
|
|
131
139
|
compareValue,
|
package/dist/view/index.js
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.propTypes = exports.defaultProps = exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _shallowequal = _interopRequireDefault(require("shallowequal"));
|
|
12
|
+
var _context = _interopRequireDefault(require("../context"));
|
|
13
|
+
var _intl = _interopRequireDefault(require("../intl"));
|
|
14
|
+
var _eventBus = _interopRequireDefault(require("../utils/event-bus"));
|
|
15
|
+
var _components = require("../components");
|
|
16
|
+
var _chartUtils = require("../utils/chart-utils");
|
|
17
|
+
var _constants = require("../constants");
|
|
18
|
+
var _commonConstants = require("../constants/common-constants");
|
|
19
|
+
var _concurrencyManager = _interopRequireDefault(require("../utils/concurrency-manager"));
|
|
20
|
+
var _wrapper = _interopRequireDefault(require("./wrapper"));
|
|
21
|
+
var _title = _interopRequireDefault(require("./title"));
|
|
22
|
+
require("./index.css");
|
|
23
|
+
class View extends _react.default.PureComponent {
|
|
17
24
|
constructor(props) {
|
|
18
25
|
var _this;
|
|
19
26
|
super(props);
|
|
@@ -29,7 +36,7 @@ class View extends React.PureComponent {
|
|
|
29
36
|
const {
|
|
30
37
|
chart
|
|
31
38
|
} = this.props;
|
|
32
|
-
if ((
|
|
39
|
+
if ((_chart$config = chart.config) !== null && _chart$config !== void 0 && _chart$config.table_id && table_id === ((_chart$config2 = chart.config) === null || _chart$config2 === void 0 ? void 0 : _chart$config2.table_id)) {
|
|
33
40
|
// refresh cache calculated before
|
|
34
41
|
const refreshCache = true;
|
|
35
42
|
this.calculateStatistic(true, null, refreshCache);
|
|
@@ -85,15 +92,15 @@ class View extends React.PureComponent {
|
|
|
85
92
|
const {
|
|
86
93
|
data
|
|
87
94
|
} = _this.state;
|
|
88
|
-
const collaborators =
|
|
95
|
+
const collaborators = _context.default.getCollaboratorsFromCache();
|
|
89
96
|
if (isCalculateByView) {
|
|
90
|
-
if (BaseUtils.isArchiveView(chart.config, tables)) {
|
|
91
|
-
ChartUtils.calculateChart(chart, {
|
|
97
|
+
if (_chartUtils.BaseUtils.isArchiveView(chart.config, tables)) {
|
|
98
|
+
_chartUtils.ChartUtils.calculateChart(chart, {
|
|
92
99
|
tables,
|
|
93
100
|
collaborators
|
|
94
101
|
}, _this.callback);
|
|
95
102
|
} else {
|
|
96
|
-
ChartUtils.calculateStaticChart(chart, {
|
|
103
|
+
_chartUtils.ChartUtils.calculateStaticChart(chart, {
|
|
97
104
|
tables,
|
|
98
105
|
collaborators
|
|
99
106
|
}, {
|
|
@@ -105,7 +112,7 @@ class View extends React.PureComponent {
|
|
|
105
112
|
return;
|
|
106
113
|
}
|
|
107
114
|
if (!isNeedRequestData) {
|
|
108
|
-
ChartUtils.calculateStaticChart(chart, {
|
|
115
|
+
_chartUtils.ChartUtils.calculateStaticChart(chart, {
|
|
109
116
|
tables,
|
|
110
117
|
collaborators
|
|
111
118
|
}, {
|
|
@@ -113,7 +120,7 @@ class View extends React.PureComponent {
|
|
|
113
120
|
data_sources: null
|
|
114
121
|
}, _this.callback);
|
|
115
122
|
} else {
|
|
116
|
-
ChartUtils.calculateChart(chart, {
|
|
123
|
+
_chartUtils.ChartUtils.calculateChart(chart, {
|
|
117
124
|
tables,
|
|
118
125
|
collaborators
|
|
119
126
|
}, _this.callback);
|
|
@@ -125,10 +132,10 @@ class View extends React.PureComponent {
|
|
|
125
132
|
errorMessage: '',
|
|
126
133
|
tipMessage: ''
|
|
127
134
|
};
|
|
128
|
-
|
|
135
|
+
_context.default.init(props);
|
|
129
136
|
props.onViewRef && props.onViewRef(this);
|
|
130
|
-
const lang =
|
|
131
|
-
|
|
137
|
+
const lang = _context.default.getSetting('lang') || _constants.DEFAULT_LANG;
|
|
138
|
+
_intl.default.setLang(lang);
|
|
132
139
|
}
|
|
133
140
|
componentDidMount() {
|
|
134
141
|
var _window$app;
|
|
@@ -138,17 +145,17 @@ class View extends React.PureComponent {
|
|
|
138
145
|
refreshInterval,
|
|
139
146
|
pageId
|
|
140
147
|
} = this.props;
|
|
141
|
-
this.unsubscribeReFreshChart =
|
|
148
|
+
this.unsubscribeReFreshChart = _eventBus.default.subscribe(_commonConstants.CommonEventTypes.REFRESH_CHARTS, this.refreshChart);
|
|
142
149
|
|
|
143
150
|
// pageId was used to determine whether the page has changed
|
|
144
151
|
// cancel all the cached request if pageId changed
|
|
145
|
-
if (pageId &&
|
|
146
|
-
|
|
147
|
-
|
|
152
|
+
if (pageId && _concurrencyManager.default.currentPageId !== pageId) {
|
|
153
|
+
_concurrencyManager.default.clearPendingRequests();
|
|
154
|
+
_concurrencyManager.default.setCurrentPageId(pageId);
|
|
148
155
|
}
|
|
149
|
-
if ((
|
|
150
|
-
window.app.eventBus.subscribe(CommonEventTypes.EXPAND_ROW_UPDATED, this.handleModifyRecord);
|
|
151
|
-
window.app.eventBus.subscribe(CommonEventTypes.EXPAND_ROW_DELETED, this.handleDeleteRecord);
|
|
156
|
+
if ((_window$app = window.app) !== null && _window$app !== void 0 && _window$app.eventBus && isCalculateByView) {
|
|
157
|
+
window.app.eventBus.subscribe(_commonConstants.CommonEventTypes.EXPAND_ROW_UPDATED, this.handleModifyRecord);
|
|
158
|
+
window.app.eventBus.subscribe(_commonConstants.CommonEventTypes.EXPAND_ROW_DELETED, this.handleDeleteRecord);
|
|
152
159
|
}
|
|
153
160
|
|
|
154
161
|
// refreshInterval is minutes
|
|
@@ -195,13 +202,13 @@ class View extends React.PureComponent {
|
|
|
195
202
|
} else {
|
|
196
203
|
this.refreshTimer && clearInterval(this.refreshTimer);
|
|
197
204
|
}
|
|
198
|
-
|
|
205
|
+
_context.default.api = this.props.api;
|
|
199
206
|
|
|
200
207
|
// pageId was used to determine whether the page has changed
|
|
201
208
|
// cancel all the cached request if pageId changed
|
|
202
|
-
if (pageId &&
|
|
203
|
-
|
|
204
|
-
|
|
209
|
+
if (pageId && _concurrencyManager.default.currentPageId !== pageId) {
|
|
210
|
+
_concurrencyManager.default.clearPendingRequests();
|
|
211
|
+
_concurrencyManager.default.setCurrentPageId(pageId);
|
|
205
212
|
}
|
|
206
213
|
|
|
207
214
|
// universal-apps will not trigger calculation of the chart before the chart config saved
|
|
@@ -213,25 +220,25 @@ class View extends React.PureComponent {
|
|
|
213
220
|
}
|
|
214
221
|
|
|
215
222
|
// version was used to dectect table change in big screen plugin
|
|
216
|
-
if (
|
|
223
|
+
if ((0, _shallowequal.default)(chart, oldChart) && version === nextVersion) return;
|
|
217
224
|
this.setState({
|
|
218
225
|
isCalculated: false
|
|
219
226
|
}, () => {
|
|
220
|
-
if (BaseUtils.isChartTypeChange(chart, oldChart)) {
|
|
227
|
+
if (_chartUtils.BaseUtils.isChartTypeChange(chart, oldChart)) {
|
|
221
228
|
this.calculateStatistic();
|
|
222
229
|
return;
|
|
223
230
|
}
|
|
224
|
-
if (BaseUtils.isChartViewChange(chart, oldChart)) {
|
|
231
|
+
if (_chartUtils.BaseUtils.isChartViewChange(chart, oldChart)) {
|
|
225
232
|
this.calculateStatistic();
|
|
226
233
|
return;
|
|
227
234
|
}
|
|
228
|
-
if (BaseUtils.isChartStyleChange(chart, oldChart)) {
|
|
235
|
+
if (_chartUtils.BaseUtils.isChartStyleChange(chart, oldChart)) {
|
|
229
236
|
this.setState({
|
|
230
237
|
isCalculated: true
|
|
231
238
|
});
|
|
232
239
|
return;
|
|
233
240
|
}
|
|
234
|
-
if (BaseUtils.isChartSortChange(chart, oldChart)) {
|
|
241
|
+
if (_chartUtils.BaseUtils.isChartSortChange(chart, oldChart)) {
|
|
235
242
|
this.calculateStatistic(false);
|
|
236
243
|
return;
|
|
237
244
|
}
|
|
@@ -250,6 +257,7 @@ class View extends React.PureComponent {
|
|
|
250
257
|
globalTheme,
|
|
251
258
|
chartColorTheme,
|
|
252
259
|
isCalculateByView,
|
|
260
|
+
isRenderByD3,
|
|
253
261
|
dtableStoreValue,
|
|
254
262
|
integratedEventTypes,
|
|
255
263
|
integratedEventBus,
|
|
@@ -274,50 +282,51 @@ class View extends React.PureComponent {
|
|
|
274
282
|
title
|
|
275
283
|
} = style_config;
|
|
276
284
|
const hasTitle = title && ((_title$text = title.text) === null || _title$text === void 0 ? void 0 : _title$text.length);
|
|
277
|
-
const validClassName =
|
|
285
|
+
const validClassName = (0, _classnames.default)('sea-chart-formatter', className);
|
|
278
286
|
const tipBackgroundColorClassName = 'sea-chart-formatter-tip';
|
|
279
287
|
if (!isCalculated) {
|
|
280
|
-
return /*#__PURE__*/
|
|
281
|
-
className:
|
|
282
|
-
}, /*#__PURE__*/
|
|
288
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
289
|
+
className: (0, _classnames.default)('loading', validClassName)
|
|
290
|
+
}, /*#__PURE__*/_react.default.createElement(_components.Loading, null));
|
|
283
291
|
}
|
|
284
292
|
if (errorMessage) {
|
|
285
|
-
return /*#__PURE__*/
|
|
286
|
-
className:
|
|
287
|
-
}, /*#__PURE__*/
|
|
293
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
294
|
+
className: (0, _classnames.default)('error', validClassName, tipBackgroundColorClassName)
|
|
295
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, errorMessage));
|
|
288
296
|
}
|
|
289
297
|
if (tipMessage) {
|
|
290
|
-
return /*#__PURE__*/
|
|
291
|
-
className:
|
|
292
|
-
}, /*#__PURE__*/
|
|
298
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
299
|
+
className: (0, _classnames.default)('error', validClassName, tipBackgroundColorClassName)
|
|
300
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, _intl.default.get(tipMessage)));
|
|
293
301
|
}
|
|
294
|
-
if (BaseUtils.imEmptyChartResult(data) && !chartType.includes('map')) {
|
|
295
|
-
return /*#__PURE__*/
|
|
296
|
-
className:
|
|
297
|
-
}, /*#__PURE__*/
|
|
302
|
+
if (_chartUtils.BaseUtils.imEmptyChartResult(data) && !chartType.includes('map')) {
|
|
303
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
304
|
+
className: (0, _classnames.default)('error', validClassName, tipBackgroundColorClassName)
|
|
305
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, _intl.default.get('There_are_no_statistic_results_yet')));
|
|
298
306
|
}
|
|
299
|
-
return /*#__PURE__*/
|
|
307
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
300
308
|
className: validClassName
|
|
301
|
-
}, /*#__PURE__*/
|
|
302
|
-
className:
|
|
309
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
310
|
+
className: (0, _classnames.default)('sea-chart-formatter-container', "sea-chart-".concat(chart === null || chart === void 0 ? void 0 : (_chart$config3 = chart.config) === null || _chart$config3 === void 0 ? void 0 : _chart$config3.type, "-formatter-container"), {
|
|
303
311
|
'big_screen_plugin': isBigScreenPlugin
|
|
304
312
|
})
|
|
305
|
-
}, !hideTitle && /*#__PURE__*/
|
|
313
|
+
}, !hideTitle && /*#__PURE__*/_react.default.createElement(_title.default, {
|
|
306
314
|
chart: chart
|
|
307
|
-
}), /*#__PURE__*/
|
|
315
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
308
316
|
id: "sea-chart-cavans-container-".concat(chart.id),
|
|
309
|
-
className:
|
|
317
|
+
className: (0, _classnames.default)('sea-chart-cavans-container', {
|
|
310
318
|
'has-title': hasTitle
|
|
311
319
|
})
|
|
312
|
-
}, /*#__PURE__*/
|
|
320
|
+
}, /*#__PURE__*/_react.default.createElement(_wrapper.default, {
|
|
313
321
|
chart: chart,
|
|
314
322
|
data: data,
|
|
315
323
|
dtableStoreValue: dtableStoreValue,
|
|
316
324
|
tables: tables,
|
|
317
325
|
canvasStyle: canvasStyle,
|
|
318
326
|
customRender: render,
|
|
319
|
-
globalTheme: globalTheme ? globalTheme : THEME_NAME_MAP.LIGHT,
|
|
327
|
+
globalTheme: globalTheme ? globalTheme : _constants.THEME_NAME_MAP.LIGHT,
|
|
320
328
|
isCalculateByView: isCalculateByView,
|
|
329
|
+
isRenderByD3: isRenderByD3,
|
|
321
330
|
isBigScreenPlugin: isBigScreenPlugin,
|
|
322
331
|
chartColorTheme: chartColorTheme,
|
|
323
332
|
integratedEventTypes: integratedEventTypes,
|
|
@@ -325,33 +334,34 @@ class View extends React.PureComponent {
|
|
|
325
334
|
}))));
|
|
326
335
|
}
|
|
327
336
|
}
|
|
328
|
-
const propTypes = {
|
|
337
|
+
const propTypes = exports.propTypes = {
|
|
329
338
|
// style
|
|
330
|
-
className:
|
|
331
|
-
canvasStyle:
|
|
332
|
-
globalTheme:
|
|
339
|
+
className: _propTypes.default.string,
|
|
340
|
+
canvasStyle: _propTypes.default.object,
|
|
341
|
+
globalTheme: _propTypes.default.string,
|
|
333
342
|
// light or dark
|
|
334
|
-
chartColorTheme:
|
|
335
|
-
hideTitle:
|
|
336
|
-
render:
|
|
343
|
+
chartColorTheme: _propTypes.default.string,
|
|
344
|
+
hideTitle: _propTypes.default.bool,
|
|
345
|
+
render: _propTypes.default.func,
|
|
337
346
|
// User-defined rendering content
|
|
338
347
|
|
|
339
348
|
// data
|
|
340
|
-
chart:
|
|
341
|
-
tables:
|
|
342
|
-
api:
|
|
343
|
-
config:
|
|
344
|
-
collaboratorManager:
|
|
345
|
-
collaborators:
|
|
346
|
-
departments:
|
|
347
|
-
dtableStoreValue:
|
|
348
|
-
isCalculateByView:
|
|
349
|
+
chart: _propTypes.default.object.isRequired,
|
|
350
|
+
tables: _propTypes.default.array.isRequired,
|
|
351
|
+
api: _propTypes.default.object.isRequired,
|
|
352
|
+
config: _propTypes.default.object,
|
|
353
|
+
collaboratorManager: _propTypes.default.object,
|
|
354
|
+
collaborators: _propTypes.default.array,
|
|
355
|
+
departments: _propTypes.default.array,
|
|
356
|
+
dtableStoreValue: _propTypes.default.object,
|
|
357
|
+
isCalculateByView: _propTypes.default.bool,
|
|
358
|
+
isRenderByD3: _propTypes.default.bool,
|
|
349
359
|
// event
|
|
350
|
-
integratedEventTypes:
|
|
351
|
-
integratedEventBus:
|
|
352
|
-
onViewRef:
|
|
360
|
+
integratedEventTypes: _propTypes.default.object,
|
|
361
|
+
integratedEventBus: _propTypes.default.object,
|
|
362
|
+
onViewRef: _propTypes.default.func
|
|
353
363
|
};
|
|
354
|
-
const defaultProps = {
|
|
364
|
+
const defaultProps = exports.defaultProps = {
|
|
355
365
|
canvasStyle: {},
|
|
356
366
|
tables: [],
|
|
357
367
|
chart: {
|
|
@@ -360,9 +370,8 @@ const defaultProps = {
|
|
|
360
370
|
style_config: {}
|
|
361
371
|
},
|
|
362
372
|
collaborators: [],
|
|
363
|
-
globalTheme: THEME_NAME_MAP.LIGHT,
|
|
373
|
+
globalTheme: _constants.THEME_NAME_MAP.LIGHT,
|
|
364
374
|
isCalculateByView: false
|
|
365
375
|
};
|
|
366
376
|
View.defaultProps = defaultProps;
|
|
367
|
-
|
|
368
|
-
export { defaultProps, propTypes };
|
|
377
|
+
var _default = exports.default = View;
|
package/dist/view/title/index.js
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _dtableUtils = require("dtable-utils");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _constants = require("../../constants");
|
|
13
|
+
require("./index.css");
|
|
6
14
|
const Title = _ref => {
|
|
7
15
|
let {
|
|
8
16
|
chart,
|
|
9
17
|
className
|
|
10
18
|
} = _ref;
|
|
11
|
-
const getTitleStyle = useCallback(() => {
|
|
19
|
+
const getTitleStyle = (0, _react.useCallback)(() => {
|
|
12
20
|
var _chart$style_config, _chart$style_config2;
|
|
13
21
|
let style = {
|
|
14
|
-
fontSize: "".concat(DEFAULT_CHART_TITLE_FONT_SIZE, "px"),
|
|
15
|
-
fontWeight: DEFAULT_CHART_FONT_WEIGHT
|
|
22
|
+
fontSize: "".concat(_constants.DEFAULT_CHART_TITLE_FONT_SIZE, "px"),
|
|
23
|
+
fontWeight: _constants.DEFAULT_CHART_FONT_WEIGHT
|
|
16
24
|
};
|
|
17
|
-
if (!chart || !chart.style_config || !((_chart$style_config = chart.style_config)
|
|
25
|
+
if (!chart || !chart.style_config || !((_chart$style_config = chart.style_config) !== null && _chart$style_config !== void 0 && _chart$style_config.title)) {
|
|
18
26
|
return style;
|
|
19
27
|
}
|
|
20
28
|
const {
|
|
@@ -23,16 +31,16 @@ const Title = _ref => {
|
|
|
23
31
|
font_color,
|
|
24
32
|
horizontal_align
|
|
25
33
|
} = (_chart$style_config2 = chart.style_config) === null || _chart$style_config2 === void 0 ? void 0 : _chart$style_config2.title;
|
|
26
|
-
if (isNumber(font_size)) {
|
|
34
|
+
if ((0, _dtableUtils.isNumber)(font_size)) {
|
|
27
35
|
style.fontSize = font_size < 0 ? 0 : "".concat(font_size, "px");
|
|
28
36
|
}
|
|
29
|
-
if (CHART_SUPPORT_FONT_WEIGHTS.includes(font_weight)) {
|
|
37
|
+
if (_constants.CHART_SUPPORT_FONT_WEIGHTS.includes(font_weight)) {
|
|
30
38
|
style.fontWeight = font_weight;
|
|
31
39
|
}
|
|
32
40
|
if (font_color) {
|
|
33
41
|
style.color = font_color;
|
|
34
42
|
}
|
|
35
|
-
style.textAlign = horizontal_align && HORIZONTAL_ALIGNS.includes(horizontal_align) ? horizontal_align : HORIZONTAL_ALIGN.LEFT;
|
|
43
|
+
style.textAlign = horizontal_align && _constants.HORIZONTAL_ALIGNS.includes(horizontal_align) ? horizontal_align : _constants.HORIZONTAL_ALIGN.LEFT;
|
|
36
44
|
return style;
|
|
37
45
|
}, [chart]);
|
|
38
46
|
if (!chart) return null;
|
|
@@ -40,9 +48,9 @@ const Title = _ref => {
|
|
|
40
48
|
const text = title && title.text;
|
|
41
49
|
if (!text) return null;
|
|
42
50
|
const style = getTitleStyle();
|
|
43
|
-
return /*#__PURE__*/
|
|
44
|
-
className:
|
|
51
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
52
|
+
className: (0, _classnames.default)('sea-chart-title', className),
|
|
45
53
|
style: style
|
|
46
54
|
}, text);
|
|
47
55
|
};
|
|
48
|
-
|
|
56
|
+
var _default = exports.default = Title;
|