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,266 +0,0 @@
|
|
|
1
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
-
import { Component } from 'react';
|
|
6
|
-
import { getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
7
|
-
import { Chart } from '../../utils/custom-g2';
|
|
8
|
-
import { StatisticsUtils } from '../../utils';
|
|
9
|
-
import { STATISTIC_SUMMARY_TYPE, LABEL_POSITION_TYPE, STATISTIC_THEME_COLOR, EMPTY_NAME } from '../../constants';
|
|
10
|
-
import intl from '../../intl';
|
|
11
|
-
var ChartComponent = /*#__PURE__*/function (_Component) {
|
|
12
|
-
_inherits(ChartComponent, _Component);
|
|
13
|
-
var _super = _createSuper(ChartComponent);
|
|
14
|
-
function ChartComponent() {
|
|
15
|
-
var _this;
|
|
16
|
-
_classCallCheck(this, ChartComponent);
|
|
17
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
-
args[_key] = arguments[_key];
|
|
19
|
-
}
|
|
20
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
21
|
-
_this.initChart = function (container, _ref) {
|
|
22
|
-
var appendPadding = _ref.appendPadding;
|
|
23
|
-
var config = {
|
|
24
|
-
container: container,
|
|
25
|
-
autoFit: true,
|
|
26
|
-
width: '100%',
|
|
27
|
-
height: '100%'
|
|
28
|
-
};
|
|
29
|
-
if (appendPadding) {
|
|
30
|
-
config.appendPadding = appendPadding;
|
|
31
|
-
}
|
|
32
|
-
_this.chart = new Chart(config);
|
|
33
|
-
};
|
|
34
|
-
_this.loadData = function (data) {
|
|
35
|
-
_this.chart.data(data, {
|
|
36
|
-
'name': {
|
|
37
|
-
type: 'cat',
|
|
38
|
-
nice: false
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
_this.getChartDisplayLabels = function (containerWidth, minItemWidth, statistics) {
|
|
43
|
-
var labels = [];
|
|
44
|
-
var labelCount = Math.floor(containerWidth / minItemWidth);
|
|
45
|
-
labelCount = labelCount % 2 ? labelCount + 1 : labelCount;
|
|
46
|
-
var avg = Math.round(statistics.length / labelCount);
|
|
47
|
-
avg = avg > 2 ? avg : 2;
|
|
48
|
-
Array.isArray(statistics) && statistics.forEach(function (v, i) {
|
|
49
|
-
if (i % avg === 0) {
|
|
50
|
-
labels.push(v.name);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return labels;
|
|
54
|
-
};
|
|
55
|
-
_this.getChartGroupData = function (data) {
|
|
56
|
-
var chartGroupData = [];
|
|
57
|
-
Array.isArray(data) && data.forEach(function (item) {
|
|
58
|
-
if (!chartGroupData.find(function (g) {
|
|
59
|
-
return g.name === item.name;
|
|
60
|
-
})) {
|
|
61
|
-
chartGroupData.push(item);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
return chartGroupData;
|
|
65
|
-
};
|
|
66
|
-
_this.drawLabels = function () {
|
|
67
|
-
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
68
|
-
if (!_this.chart) return;
|
|
69
|
-
var width = _this.chart.coordinateBBox.width;
|
|
70
|
-
_this.labelCount = data.length;
|
|
71
|
-
if (Math.floor(width / _this.labelCount) <= 20) {
|
|
72
|
-
var displayLabels = _this.getChartDisplayLabels(width, 20, data);
|
|
73
|
-
_this.labelCount = displayLabels.length;
|
|
74
|
-
_this.chart.scale('name', {
|
|
75
|
-
type: 'cat',
|
|
76
|
-
ticks: displayLabels
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
_this.renderAxisLabel = function (statistic, tables) {
|
|
81
|
-
if (!_this.chart || !statistic) return;
|
|
82
|
-
var _statistic$config = statistic.config,
|
|
83
|
-
table_id = _statistic$config.table_id,
|
|
84
|
-
x_axis_column_key = _statistic$config.x_axis_column_key,
|
|
85
|
-
y_axis_summary_column_key = _statistic$config.y_axis_summary_column_key,
|
|
86
|
-
y_axis_show_label = _statistic$config.y_axis_show_label,
|
|
87
|
-
x_axis_show_label = _statistic$config.x_axis_show_label,
|
|
88
|
-
y_axis_label_position = _statistic$config.y_axis_label_position,
|
|
89
|
-
x_axis_label_position = _statistic$config.x_axis_label_position,
|
|
90
|
-
y_axis_summary_type = _statistic$config.y_axis_summary_type;
|
|
91
|
-
var table = getTableById(tables, table_id);
|
|
92
|
-
var autoPadding = _this.chart.autoPadding;
|
|
93
|
-
var textColor = '#999';
|
|
94
|
-
var xAxisID = "chart-x-axis-label_".concat(statistic.id);
|
|
95
|
-
var chartContainer = _this.chart.getCanvas().get('container');
|
|
96
|
-
var xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
97
|
-
if (!xLabel && x_axis_show_label) {
|
|
98
|
-
var div = document.createElement('div');
|
|
99
|
-
div.id = xAxisID;
|
|
100
|
-
div.className = 'chart-axis-label';
|
|
101
|
-
var column = getTableColumnByKey(table, x_axis_column_key);
|
|
102
|
-
div.innerHTML = "".concat(column ? column.name : '');
|
|
103
|
-
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
|
|
104
|
-
chartContainer.appendChild(div);
|
|
105
|
-
}
|
|
106
|
-
if (xLabel && x_axis_show_label) {
|
|
107
|
-
xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
|
|
108
|
-
}
|
|
109
|
-
if (xLabel && !x_axis_show_label) {
|
|
110
|
-
xLabel.parentNode.removeChild(xLabel);
|
|
111
|
-
}
|
|
112
|
-
var yAxisID = "chart-y-axis-label_".concat(statistic.id);
|
|
113
|
-
var yLabel = chartContainer.querySelector("#".concat(yAxisID));
|
|
114
|
-
if (!yLabel && y_axis_show_label) {
|
|
115
|
-
var _div = document.createElement('div');
|
|
116
|
-
_div.id = yAxisID;
|
|
117
|
-
_div.className = 'chart-axis-label';
|
|
118
|
-
if (y_axis_summary_type === STATISTIC_SUMMARY_TYPE.COUNT) {
|
|
119
|
-
_div.innerHTML = intl.get('Amount');
|
|
120
|
-
} else {
|
|
121
|
-
var _column = getTableColumnByKey(table, y_axis_summary_column_key) || {};
|
|
122
|
-
_div.innerHTML = _column.name || '';
|
|
123
|
-
}
|
|
124
|
-
var containerHeight = chartContainer.offsetHeight;
|
|
125
|
-
var textAlign = 'center';
|
|
126
|
-
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
127
|
-
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
128
|
-
_div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
129
|
-
chartContainer.appendChild(_div);
|
|
130
|
-
}
|
|
131
|
-
if (yLabel && y_axis_show_label) {
|
|
132
|
-
var _containerHeight = chartContainer.offsetHeight;
|
|
133
|
-
var _textAlign = 'center';
|
|
134
|
-
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) _textAlign = 'left';
|
|
135
|
-
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) _textAlign = 'right';
|
|
136
|
-
yLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(_containerHeight, "px; text-align: ").concat(_textAlign, "; top: 0; left: 0; transform: translate(-").concat(_containerHeight / 2 + 12, "px, ").concat((_containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
137
|
-
}
|
|
138
|
-
if (yLabel && !y_axis_show_label) {
|
|
139
|
-
yLabel.parentNode.removeChild(yLabel);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
// Automatic adjustment of maximum and minimum values
|
|
143
|
-
_this.autoAdjustDataOptions = function (statistic) {
|
|
144
|
-
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
145
|
-
var summaryColumn = arguments.length > 2 ? arguments[2] : undefined;
|
|
146
|
-
if (!_this.chart || !statistic) return;
|
|
147
|
-
var valueScaleOptions = {};
|
|
148
|
-
var config = statistic.config;
|
|
149
|
-
var y_axis_auto_range = config.y_axis_auto_range,
|
|
150
|
-
y_axis_min = config.y_axis_min,
|
|
151
|
-
y_axis_max = config.y_axis_max,
|
|
152
|
-
y_axis_summary_method = config.y_axis_summary_method;
|
|
153
|
-
if (summaryColumn) {
|
|
154
|
-
valueScaleOptions['formatter'] = function (value) {
|
|
155
|
-
return StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method);
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
if (y_axis_auto_range === undefined || y_axis_auto_range) {
|
|
159
|
-
valueScaleOptions['nice'] = true;
|
|
160
|
-
} else {
|
|
161
|
-
valueScaleOptions['min'] = y_axis_min;
|
|
162
|
-
valueScaleOptions['max'] = y_axis_max;
|
|
163
|
-
// set the filter rule
|
|
164
|
-
_this.chart.filter('value', function (value) {
|
|
165
|
-
return value >= y_axis_min;
|
|
166
|
-
});
|
|
167
|
-
// filter the data
|
|
168
|
-
_this.chart.filterData(data);
|
|
169
|
-
}
|
|
170
|
-
_this.chart.scale({
|
|
171
|
-
name: {
|
|
172
|
-
type: 'cat'
|
|
173
|
-
},
|
|
174
|
-
value: valueScaleOptions
|
|
175
|
-
});
|
|
176
|
-
};
|
|
177
|
-
// set axis label and tooltip
|
|
178
|
-
_this.setNameLabelAndTooltip = function () {
|
|
179
|
-
var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : STATISTIC_THEME_COLOR['light'];
|
|
180
|
-
var labelCount = arguments.length > 1 ? arguments[1] : undefined;
|
|
181
|
-
if (!_this.chart) return;
|
|
182
|
-
_this.chart.axis('name', {
|
|
183
|
-
line: {
|
|
184
|
-
style: theme.gridColor
|
|
185
|
-
},
|
|
186
|
-
label: {
|
|
187
|
-
style: {
|
|
188
|
-
fill: theme.textColor
|
|
189
|
-
},
|
|
190
|
-
offset: 20,
|
|
191
|
-
autoRotate: true,
|
|
192
|
-
rotate: labelCount > 11 ? 0.3 : 0,
|
|
193
|
-
formatter: function formatter(name) {
|
|
194
|
-
var isString = typeof name === 'string';
|
|
195
|
-
if (!isString) name = String(name);
|
|
196
|
-
if (name === 'undefined') {
|
|
197
|
-
return intl.get(EMPTY_NAME);
|
|
198
|
-
}
|
|
199
|
-
if (name.length > 10) {
|
|
200
|
-
return "".concat(name.slice(0, 10), "...");
|
|
201
|
-
}
|
|
202
|
-
return name;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
// set value label
|
|
208
|
-
_this.setValueLabel = function () {
|
|
209
|
-
var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : STATISTIC_THEME_COLOR['light'];
|
|
210
|
-
if (!_this.chart) return;
|
|
211
|
-
_this.chart.axis('value', {
|
|
212
|
-
label: {
|
|
213
|
-
style: {
|
|
214
|
-
fill: theme.textColor
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
grid: {
|
|
218
|
-
line: {
|
|
219
|
-
style: {
|
|
220
|
-
stroke: theme.gridColor
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
// set legend
|
|
227
|
-
_this.setLegend = function (legendName, theme) {
|
|
228
|
-
var legendPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'bottom';
|
|
229
|
-
if (!_this.chart) return;
|
|
230
|
-
_this.chart.legend(legendName, {
|
|
231
|
-
position: legendPosition,
|
|
232
|
-
itemName: {
|
|
233
|
-
style: {
|
|
234
|
-
fill: theme.textColor
|
|
235
|
-
},
|
|
236
|
-
formatter: function formatter(name) {
|
|
237
|
-
return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
pageNavigator: {
|
|
241
|
-
text: {
|
|
242
|
-
style: {
|
|
243
|
-
fill: theme.textColor
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
marker: {
|
|
247
|
-
style: {
|
|
248
|
-
fill: theme.legendPageNavigatorMarkerColor,
|
|
249
|
-
inactiveFill: theme.legendPageNavigatorMarkerColor,
|
|
250
|
-
inactiveOpacity: 0.45
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
};
|
|
256
|
-
_this.isShowXAxisLabel = function (statistic) {
|
|
257
|
-
return !!(statistic && statistic.config && statistic.config.x_axis_show_label);
|
|
258
|
-
};
|
|
259
|
-
_this.isShowYAxisLabel = function (statistic) {
|
|
260
|
-
return !!(statistic && statistic.config && statistic.config.y_axis_show_label);
|
|
261
|
-
};
|
|
262
|
-
return _this;
|
|
263
|
-
}
|
|
264
|
-
return _createClass(ChartComponent);
|
|
265
|
-
}(Component);
|
|
266
|
-
export { ChartComponent as default };
|
|
@@ -1,407 +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 classnames from 'classnames';
|
|
7
|
-
import { getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
8
|
-
import { Chart } from '../../utils/custom-g2';
|
|
9
|
-
import { StatisticsUtils } from '../../utils';
|
|
10
|
-
import { STATISTIC_SUMMARY_TYPE, LABEL_COLORS, STATISTIC_SUMMARY_SHOW, LABEL_POSITION_TYPE, EMPTY_NAME } from '../../constants';
|
|
11
|
-
import intl from '../../intl';
|
|
12
|
-
var Combination = /*#__PURE__*/function (_React$Component) {
|
|
13
|
-
_inherits(Combination, _React$Component);
|
|
14
|
-
var _super = _createSuper(Combination);
|
|
15
|
-
function Combination(props) {
|
|
16
|
-
var _this;
|
|
17
|
-
_classCallCheck(this, Combination);
|
|
18
|
-
_this = _super.call(this, props);
|
|
19
|
-
_this.clearChart = function () {
|
|
20
|
-
_this.chart.annotation().clear(true);
|
|
21
|
-
_this.chart.clear(true);
|
|
22
|
-
};
|
|
23
|
-
_this.drawChart = function () {
|
|
24
|
-
var data = _this.props.result;
|
|
25
|
-
_this.draw(data);
|
|
26
|
-
};
|
|
27
|
-
_this.draw = function (data) {
|
|
28
|
-
if (!Array.isArray(data)) return;
|
|
29
|
-
var _this$props = _this.props,
|
|
30
|
-
statistic = _this$props.statistic,
|
|
31
|
-
theme = _this$props.theme,
|
|
32
|
-
tables = _this$props.tables,
|
|
33
|
-
themeName = _this$props.themeName;
|
|
34
|
-
var _statistic$config = statistic.config,
|
|
35
|
-
table_id = _statistic$config.table_id,
|
|
36
|
-
y_axis_left_summary_column = _statistic$config.y_axis_left_summary_column,
|
|
37
|
-
y_axis_right_summary_column = _statistic$config.y_axis_right_summary_column,
|
|
38
|
-
y_axis_left_summary_method = _statistic$config.y_axis_left_summary_method,
|
|
39
|
-
y_axis_right_summary_method = _statistic$config.y_axis_right_summary_method,
|
|
40
|
-
y_axis_left_summary_type = _statistic$config.y_axis_left_summary_type,
|
|
41
|
-
y_axis_right_summary_type = _statistic$config.y_axis_right_summary_type,
|
|
42
|
-
y_axis_left_group_by_multiple_numeric_column = _statistic$config.y_axis_left_group_by_multiple_numeric_column,
|
|
43
|
-
y_axis_auto_range_left = _statistic$config.y_axis_auto_range_left,
|
|
44
|
-
y_axis_min_left = _statistic$config.y_axis_min_left,
|
|
45
|
-
y_axis_max_left = _statistic$config.y_axis_max_left,
|
|
46
|
-
y_axis_auto_range_right = _statistic$config.y_axis_auto_range_right,
|
|
47
|
-
y_axis_min_right = _statistic$config.y_axis_min_right,
|
|
48
|
-
y_axis_max_right = _statistic$config.y_axis_max_right,
|
|
49
|
-
display_data = _statistic$config.display_data,
|
|
50
|
-
label_font_size = _statistic$config.label_font_size;
|
|
51
|
-
_this.chart = new Chart({
|
|
52
|
-
container: _this.container,
|
|
53
|
-
autoFit: true,
|
|
54
|
-
width: '100%',
|
|
55
|
-
height: '100%',
|
|
56
|
-
appendPadding: [display_data ? 17 : 0, 0, 0, 0]
|
|
57
|
-
});
|
|
58
|
-
var currentTheme = StatisticsUtils.getCurrentTheme(themeName);
|
|
59
|
-
_this.chart.data(data);
|
|
60
|
-
_this.chart.coordinate('rect');
|
|
61
|
-
var table = getTableById(tables, table_id);
|
|
62
|
-
var leftSummaryColumn = getTableColumnByKey(table, y_axis_left_summary_column) || {};
|
|
63
|
-
var rightSummaryColumn = getTableColumnByKey(table, y_axis_right_summary_column) || {};
|
|
64
|
-
var leftValueScaleOptions = {
|
|
65
|
-
formatter: function formatter(value) {
|
|
66
|
-
return StatisticsUtils.getSummaryValueDisplayString(leftSummaryColumn, value, y_axis_left_summary_method);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var rightValueScaleOptions = {
|
|
70
|
-
formatter: function formatter(value) {
|
|
71
|
-
return StatisticsUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
if (!y_axis_auto_range_left) {
|
|
75
|
-
leftValueScaleOptions = Object.assign(leftValueScaleOptions, {
|
|
76
|
-
min: y_axis_min_left,
|
|
77
|
-
max: y_axis_max_left
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
if (!y_axis_auto_range_right) {
|
|
81
|
-
rightValueScaleOptions = Object.assign(rightValueScaleOptions, {
|
|
82
|
-
min: y_axis_min_right,
|
|
83
|
-
max: y_axis_max_right
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
_this.chart.scale({
|
|
87
|
-
name: {
|
|
88
|
-
type: 'cat'
|
|
89
|
-
},
|
|
90
|
-
// Automatic adjustment of maximum and minimum values
|
|
91
|
-
value_left: leftValueScaleOptions,
|
|
92
|
-
value_right: rightValueScaleOptions
|
|
93
|
-
});
|
|
94
|
-
_this.chart.axis('name', {
|
|
95
|
-
label: {
|
|
96
|
-
style: {
|
|
97
|
-
fill: theme.textColor
|
|
98
|
-
},
|
|
99
|
-
formatter: function formatter(name) {
|
|
100
|
-
var isString = typeof name === 'string';
|
|
101
|
-
if (!isString) name = String(name);
|
|
102
|
-
if (name === 'undefined') {
|
|
103
|
-
return intl.get(EMPTY_NAME);
|
|
104
|
-
}
|
|
105
|
-
if (name.length > 10) {
|
|
106
|
-
return "".concat(name.slice(0, 10), "...");
|
|
107
|
-
}
|
|
108
|
-
return name;
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
line: {
|
|
112
|
-
style: theme.gridColor
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
_this.chart.axis('value_left', {
|
|
116
|
-
grid: {
|
|
117
|
-
line: {
|
|
118
|
-
style: {
|
|
119
|
-
stroke: theme.gridColor
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
label: {
|
|
124
|
-
style: {
|
|
125
|
-
fill: theme.textColor
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
_this.chart.axis('value_right', {
|
|
130
|
-
grid: null,
|
|
131
|
-
label: {
|
|
132
|
-
style: {
|
|
133
|
-
fill: theme.textColor
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
var legendPosition = 'bottom';
|
|
138
|
-
_this.chart.legend({
|
|
139
|
-
custom: true,
|
|
140
|
-
position: legendPosition,
|
|
141
|
-
itemName: {
|
|
142
|
-
style: {
|
|
143
|
-
fill: theme.textColor
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
items: _this.getLegend(leftSummaryColumn, rightSummaryColumn, table, currentTheme)
|
|
147
|
-
});
|
|
148
|
-
_this.chart.interval().position('name*value_left').color('color', function (color) {
|
|
149
|
-
if (!y_axis_left_group_by_multiple_numeric_column) {
|
|
150
|
-
return currentTheme.colors[0];
|
|
151
|
-
}
|
|
152
|
-
return color;
|
|
153
|
-
}).adjust('dodge').tooltip('name*value_left', function (name, value) {
|
|
154
|
-
return {
|
|
155
|
-
title: y_axis_left_summary_type === STATISTIC_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(STATISTIC_SUMMARY_SHOW[y_axis_left_summary_method]),
|
|
156
|
-
value: StatisticsUtils.getSummaryValueDisplayString(leftSummaryColumn, value, y_axis_left_summary_method),
|
|
157
|
-
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
|
|
158
|
-
};
|
|
159
|
-
});
|
|
160
|
-
_this.chart.tooltip({
|
|
161
|
-
showMarkers: false
|
|
162
|
-
});
|
|
163
|
-
_this.chart.line().position('name*value_right').color(currentTheme.colors[1]).size(3).tooltip('name*value_right', function (name, value) {
|
|
164
|
-
return {
|
|
165
|
-
title: y_axis_right_summary_type === STATISTIC_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(STATISTIC_SUMMARY_SHOW[y_axis_right_summary_method]),
|
|
166
|
-
value: StatisticsUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method),
|
|
167
|
-
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
|
|
168
|
-
};
|
|
169
|
-
});
|
|
170
|
-
_this.chart.point().position('name*value_right').color(currentTheme.colors[1]).size(3).shape('circle').label(display_data ? 'value_right' : false, {
|
|
171
|
-
style: {
|
|
172
|
-
fontSize: StatisticsUtils.getLabelFontSize(label_font_size),
|
|
173
|
-
fill: theme.textColor
|
|
174
|
-
}
|
|
175
|
-
}).tooltip('name*value_right', function (name, value) {
|
|
176
|
-
return {
|
|
177
|
-
title: y_axis_right_summary_type === STATISTIC_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(STATISTIC_SUMMARY_SHOW[y_axis_right_summary_method]),
|
|
178
|
-
value: StatisticsUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method),
|
|
179
|
-
name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
|
|
180
|
-
};
|
|
181
|
-
});
|
|
182
|
-
_this.chart.removeInteraction('legend-filter');
|
|
183
|
-
_this.chart.render();
|
|
184
|
-
_this.renderAxisLabel();
|
|
185
|
-
};
|
|
186
|
-
_this.renderAxisLabel = function () {
|
|
187
|
-
if (!_this.chart) return;
|
|
188
|
-
var _this$props2 = _this.props,
|
|
189
|
-
statistic = _this$props2.statistic,
|
|
190
|
-
tables = _this$props2.tables;
|
|
191
|
-
var config = statistic.config;
|
|
192
|
-
var table_id = config.table_id,
|
|
193
|
-
x_axis_column_key = config.x_axis_column_key,
|
|
194
|
-
show_y_axis_left_label = config.show_y_axis_left_label,
|
|
195
|
-
show_y_axis_right_label = config.show_y_axis_right_label,
|
|
196
|
-
x_axis_show_label = config.x_axis_show_label,
|
|
197
|
-
y_axis_left_label_position = config.y_axis_left_label_position,
|
|
198
|
-
y_axis_right_label_position = config.y_axis_right_label_position,
|
|
199
|
-
y_axis_left_summary_column = config.y_axis_left_summary_column,
|
|
200
|
-
y_axis_right_summary_column = config.y_axis_right_summary_column,
|
|
201
|
-
x_axis_label_position = config.x_axis_label_position,
|
|
202
|
-
y_axis_left_summary_type = config.y_axis_left_summary_type,
|
|
203
|
-
y_axis_right_summary_type = config.y_axis_right_summary_type;
|
|
204
|
-
var table = getTableById(tables, table_id);
|
|
205
|
-
var autoPadding = _this.chart.autoPadding;
|
|
206
|
-
var textColor = '#999';
|
|
207
|
-
var xAxisID = "chart-x-axis-label_".concat(statistic.id);
|
|
208
|
-
var chartContainer = _this.chart.getCanvas().get('container');
|
|
209
|
-
var xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
210
|
-
if (!xLabel && x_axis_show_label) {
|
|
211
|
-
var div = document.createElement('div');
|
|
212
|
-
div.id = xAxisID;
|
|
213
|
-
div.className = 'chart-axis-label text-truncate';
|
|
214
|
-
var column = getTableColumnByKey(table, x_axis_column_key);
|
|
215
|
-
div.innerHTML = "".concat(column ? column.name : '');
|
|
216
|
-
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
|
|
217
|
-
chartContainer.appendChild(div);
|
|
218
|
-
}
|
|
219
|
-
if (xLabel && x_axis_show_label) {
|
|
220
|
-
xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
|
|
221
|
-
}
|
|
222
|
-
if (xLabel && !x_axis_show_label) {
|
|
223
|
-
xLabel.parentNode.removeChild(xLabel);
|
|
224
|
-
}
|
|
225
|
-
var yAxisLeftID = "chart-y-axis-left-label_".concat(statistic.id);
|
|
226
|
-
var yAxisLeftLabel = chartContainer.querySelector("#".concat(yAxisLeftID));
|
|
227
|
-
if (!yAxisLeftLabel && show_y_axis_left_label) {
|
|
228
|
-
var _div = document.createElement('div');
|
|
229
|
-
_div.id = yAxisLeftID;
|
|
230
|
-
_div.className = 'chart-axis-label text-truncate';
|
|
231
|
-
if (y_axis_left_summary_type === STATISTIC_SUMMARY_TYPE.COUNT) {
|
|
232
|
-
_div.innerHTML = intl.get('Amount');
|
|
233
|
-
} else {
|
|
234
|
-
var _column = getTableColumnByKey(table, y_axis_left_summary_column) || {};
|
|
235
|
-
_div.innerHTML = _column.name || '';
|
|
236
|
-
}
|
|
237
|
-
var containerHeight = chartContainer.offsetHeight;
|
|
238
|
-
var textAlign = 'center';
|
|
239
|
-
if (y_axis_left_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
240
|
-
if (y_axis_left_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
241
|
-
_div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
242
|
-
chartContainer.appendChild(_div);
|
|
243
|
-
}
|
|
244
|
-
if (yAxisLeftLabel && show_y_axis_left_label) {
|
|
245
|
-
var _containerHeight = chartContainer.offsetHeight;
|
|
246
|
-
var _textAlign = 'center';
|
|
247
|
-
if (y_axis_left_label_position === 'bottom') _textAlign = 'left';
|
|
248
|
-
if (y_axis_left_label_position === 'top') _textAlign = 'right';
|
|
249
|
-
yAxisLeftLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(_containerHeight, "px; text-align: ").concat(_textAlign, "; top: 0; left: 0; transform: translate(-").concat(_containerHeight / 2 + 12, "px, ").concat((_containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
250
|
-
}
|
|
251
|
-
if (yAxisLeftLabel && !show_y_axis_left_label) {
|
|
252
|
-
yAxisLeftLabel.parentNode.removeChild(yAxisLeftLabel);
|
|
253
|
-
}
|
|
254
|
-
var yAxisRightID = "chart-y-axis-right-label_".concat(statistic.id);
|
|
255
|
-
var yAxisRightLabel = chartContainer.querySelector("#".concat(yAxisRightID));
|
|
256
|
-
if (!yAxisRightLabel && show_y_axis_right_label) {
|
|
257
|
-
var _div2 = document.createElement('div');
|
|
258
|
-
_div2.id = yAxisRightID;
|
|
259
|
-
_div2.className = 'chart-axis-label text-truncate';
|
|
260
|
-
if (y_axis_right_summary_type === STATISTIC_SUMMARY_TYPE.COUNT) {
|
|
261
|
-
_div2.innerHTML = intl.get('Amount');
|
|
262
|
-
} else {
|
|
263
|
-
var _column2 = getTableColumnByKey(table, y_axis_right_summary_column) || {};
|
|
264
|
-
_div2.innerHTML = _column2.name || '';
|
|
265
|
-
}
|
|
266
|
-
var _containerHeight2 = chartContainer.offsetHeight;
|
|
267
|
-
var _textAlign2 = 'center';
|
|
268
|
-
if (y_axis_right_label_position === LABEL_POSITION_TYPE.BOTTOM) _textAlign2 = 'left';
|
|
269
|
-
if (y_axis_right_label_position === LABEL_POSITION_TYPE.TOP) _textAlign2 = 'right';
|
|
270
|
-
_div2.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(_containerHeight2, "px; text-align: ").concat(_textAlign2, "; top: 0; right: 0; transform: translate(").concat(_containerHeight2 / 2 + 12, "px, ").concat((_containerHeight2 - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
271
|
-
chartContainer.appendChild(_div2);
|
|
272
|
-
}
|
|
273
|
-
if (yAxisRightLabel && show_y_axis_right_label) {
|
|
274
|
-
var _containerHeight3 = chartContainer.offsetHeight;
|
|
275
|
-
var _textAlign3 = 'center';
|
|
276
|
-
if (y_axis_right_label_position === 'bottom') _textAlign3 = 'left';
|
|
277
|
-
if (y_axis_right_label_position === 'top') _textAlign3 = 'right';
|
|
278
|
-
yAxisRightLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(_containerHeight3, "px; text-align: ").concat(_textAlign3, "; top: 0; right: 0; transform: translate(").concat(_containerHeight3 / 2 + 12, "px, ").concat((_containerHeight3 - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
|
|
279
|
-
}
|
|
280
|
-
if (yAxisRightLabel && !show_y_axis_right_label) {
|
|
281
|
-
yAxisRightLabel.parentNode.removeChild(yAxisRightLabel);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
_this.getLegend = function (leftSummaryColumn, rightSummaryColumn, table, currentTheme) {
|
|
285
|
-
var statistic = _this.props.statistic;
|
|
286
|
-
var _statistic$config2 = statistic.config,
|
|
287
|
-
y_axis_left_group_by_multiple_numeric_column = _statistic$config2.y_axis_left_group_by_multiple_numeric_column,
|
|
288
|
-
y_axis_left_group_by_numeric_columns = _statistic$config2.y_axis_left_group_by_numeric_columns;
|
|
289
|
-
var legendItems = [];
|
|
290
|
-
if (!y_axis_left_group_by_multiple_numeric_column) {
|
|
291
|
-
legendItems.push({
|
|
292
|
-
value: 'value_left',
|
|
293
|
-
name: leftSummaryColumn.name || intl.get('Left'),
|
|
294
|
-
marker: {
|
|
295
|
-
symbol: 'square',
|
|
296
|
-
style: {
|
|
297
|
-
fill: currentTheme.colors[0],
|
|
298
|
-
r: 5
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}, {
|
|
302
|
-
value: 'value_right',
|
|
303
|
-
name: rightSummaryColumn.name || intl.get('Right'),
|
|
304
|
-
marker: {
|
|
305
|
-
symbol: 'hyphen',
|
|
306
|
-
style: {
|
|
307
|
-
stroke: currentTheme.colors[1],
|
|
308
|
-
r: 5,
|
|
309
|
-
lineWidth: 3
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
} else {
|
|
314
|
-
legendItems.push({
|
|
315
|
-
value: 'value_left',
|
|
316
|
-
name: leftSummaryColumn.name || intl.get('Left'),
|
|
317
|
-
marker: {
|
|
318
|
-
fill: LABEL_COLORS[0],
|
|
319
|
-
symbol: 'square',
|
|
320
|
-
style: {
|
|
321
|
-
r: 5
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
y_axis_left_group_by_numeric_columns.forEach(function (item, index) {
|
|
326
|
-
var column = getTableColumnByKey(table, item.column_key);
|
|
327
|
-
if (column) {
|
|
328
|
-
legendItems.push({
|
|
329
|
-
value: 'group_name',
|
|
330
|
-
name: column.name || intl.get('Left'),
|
|
331
|
-
marker: {
|
|
332
|
-
symbol: 'square',
|
|
333
|
-
style: {
|
|
334
|
-
fill: LABEL_COLORS[(index + 1) % 12],
|
|
335
|
-
r: 5
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
legendItems.push({
|
|
342
|
-
value: 'value_right',
|
|
343
|
-
name: rightSummaryColumn.name || intl.get('Right'),
|
|
344
|
-
marker: {
|
|
345
|
-
symbol: 'hyphen',
|
|
346
|
-
style: {
|
|
347
|
-
stroke: currentTheme.colors[1],
|
|
348
|
-
r: 5,
|
|
349
|
-
lineWidth: 3
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
return legendItems;
|
|
355
|
-
};
|
|
356
|
-
_this.isShowXAxisLabel = function (statistic) {
|
|
357
|
-
return !!(statistic && statistic.config && statistic.config.x_axis_show_label);
|
|
358
|
-
};
|
|
359
|
-
_this.isShowYAxisLeftLabel = function (statistic) {
|
|
360
|
-
return !!(statistic && statistic.config && statistic.config.show_y_axis_left_label);
|
|
361
|
-
};
|
|
362
|
-
_this.isShowYAxisRightLabel = function (statistic) {
|
|
363
|
-
return !!(statistic && statistic.config && statistic.config.show_y_axis_right_label);
|
|
364
|
-
};
|
|
365
|
-
_this.chart = null;
|
|
366
|
-
return _this;
|
|
367
|
-
}
|
|
368
|
-
_createClass(Combination, [{
|
|
369
|
-
key: "componentDidMount",
|
|
370
|
-
value: function componentDidMount() {
|
|
371
|
-
this.drawChart();
|
|
372
|
-
this.renderAxisLabel(this.props.statistic, this.props.tables);
|
|
373
|
-
}
|
|
374
|
-
}, {
|
|
375
|
-
key: "componentDidUpdate",
|
|
376
|
-
value: function componentDidUpdate(prevProps) {
|
|
377
|
-
if (StatisticsUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
378
|
-
this.chart && this.chart.destroy();
|
|
379
|
-
this.drawChart();
|
|
380
|
-
this.renderAxisLabel(prevProps.statistic, prevProps.tables);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}, {
|
|
384
|
-
key: "componentWillUnmount",
|
|
385
|
-
value: function componentWillUnmount() {
|
|
386
|
-
this.chart && this.chart.destroy();
|
|
387
|
-
}
|
|
388
|
-
}, {
|
|
389
|
-
key: "render",
|
|
390
|
-
value: function render() {
|
|
391
|
-
var _this2 = this;
|
|
392
|
-
var statistic = this.props.statistic;
|
|
393
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
394
|
-
className: classnames('seastatistic-container w-100', {
|
|
395
|
-
'show-x-axis-label': this.isShowXAxisLabel(statistic),
|
|
396
|
-
'show-y-axis-left-label': this.isShowYAxisLeftLabel(statistic),
|
|
397
|
-
'show-y-axis-right-label': this.isShowYAxisRightLabel(statistic)
|
|
398
|
-
}),
|
|
399
|
-
ref: function ref(_ref) {
|
|
400
|
-
return _this2.container = _ref;
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
}]);
|
|
405
|
-
return Combination;
|
|
406
|
-
}(React.Component);
|
|
407
|
-
export default Combination;
|