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
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS } from '../../constants';
|
|
4
|
+
import { ChartUtils } from '../../utils';
|
|
5
|
+
import ChartComponent from './chart-component';
|
|
6
|
+
import intl from '../../intl';
|
|
7
|
+
class Pie extends ChartComponent {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.createChart = () => {
|
|
11
|
+
const {
|
|
12
|
+
canvasStyle
|
|
13
|
+
} = this.props;
|
|
14
|
+
this.initChart(this.container, canvasStyle, 0);
|
|
15
|
+
};
|
|
16
|
+
this.destroyChart = () => {
|
|
17
|
+
this.chart.destroy();
|
|
18
|
+
this.chart = null;
|
|
19
|
+
};
|
|
20
|
+
this.clearChart = () => {
|
|
21
|
+
this.chart.annotation().clear(true);
|
|
22
|
+
this.chart.clear(true);
|
|
23
|
+
};
|
|
24
|
+
this.drawChart = () => {
|
|
25
|
+
let {
|
|
26
|
+
result: data,
|
|
27
|
+
chart,
|
|
28
|
+
tables,
|
|
29
|
+
theme,
|
|
30
|
+
summaryColumn
|
|
31
|
+
} = this.props;
|
|
32
|
+
if (data.length === 0) return;
|
|
33
|
+
this.chart.coordinate('theta', {
|
|
34
|
+
radius: 0.95
|
|
35
|
+
});
|
|
36
|
+
const {
|
|
37
|
+
show_legend,
|
|
38
|
+
display_label,
|
|
39
|
+
label_position,
|
|
40
|
+
label_font_size,
|
|
41
|
+
summary_method
|
|
42
|
+
} = chart.config;
|
|
43
|
+
const {
|
|
44
|
+
data: newData,
|
|
45
|
+
colorSet
|
|
46
|
+
} = ChartUtils.formatPieChartData(data, chart, tables);
|
|
47
|
+
if (!Array.isArray(newData)) return;
|
|
48
|
+
this.loadData(newData);
|
|
49
|
+
this.chart.on('interval:click', e => {
|
|
50
|
+
this.props.toggleRecords(e.data.data);
|
|
51
|
+
});
|
|
52
|
+
if (show_legend) {
|
|
53
|
+
this.chart.legend('name', {
|
|
54
|
+
position: 'right',
|
|
55
|
+
custom: true,
|
|
56
|
+
itemName: {
|
|
57
|
+
style: {
|
|
58
|
+
fill: theme.textColor
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
items: newData.map((obj, index) => {
|
|
62
|
+
let name = obj.name;
|
|
63
|
+
if (!obj.name && typeof obj.name !== 'number') {
|
|
64
|
+
name = intl.get('Empty');
|
|
65
|
+
} else if (obj.name === '_Others') {
|
|
66
|
+
name = intl.get('Others');
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
name,
|
|
70
|
+
value: obj.value,
|
|
71
|
+
marker: {
|
|
72
|
+
symbol: 'circle',
|
|
73
|
+
style: {
|
|
74
|
+
r: 5,
|
|
75
|
+
fill: colorSet[index]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
this.chart.legend(false);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Do not automatically adjust the maximum and minimum values in pie chart
|
|
86
|
+
this.chart.scale({
|
|
87
|
+
value: {
|
|
88
|
+
nice: false
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('value*percent', (value, percent) => {
|
|
92
|
+
const displayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
93
|
+
return {
|
|
94
|
+
content: this.getLabel(displayValue, percent)
|
|
95
|
+
};
|
|
96
|
+
}, {
|
|
97
|
+
offset: !label_position || label_position === CHART_LABEL_POSITIONS[0] ? -2 : undefined,
|
|
98
|
+
style: {
|
|
99
|
+
fill: '#000000',
|
|
100
|
+
fontSize: ChartUtils.getLabelFontSize(label_font_size),
|
|
101
|
+
shadowBlur: 2,
|
|
102
|
+
shadowColor: 'rgba(0, 0, 0, .45)'
|
|
103
|
+
}
|
|
104
|
+
}).tooltip('name*value*percent', (name, value, percent) => {
|
|
105
|
+
let title = name;
|
|
106
|
+
if (!name || name === 'undefined') {
|
|
107
|
+
title = intl.get('Empty');
|
|
108
|
+
} else if (name === '_Others') {
|
|
109
|
+
title = intl.get('Others');
|
|
110
|
+
}
|
|
111
|
+
const displayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
112
|
+
return {
|
|
113
|
+
name: title,
|
|
114
|
+
value: display_label ? this.getLabel(displayValue, percent) : displayValue
|
|
115
|
+
};
|
|
116
|
+
}).state({
|
|
117
|
+
active: {
|
|
118
|
+
style: {
|
|
119
|
+
fillOpacity: 0.7,
|
|
120
|
+
border: 'none',
|
|
121
|
+
stroke: 0
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
this.chart.tooltip({
|
|
126
|
+
showTitle: false,
|
|
127
|
+
showMarkers: false,
|
|
128
|
+
itemTpl: '<div class="g2-tooltip-list-item"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</div>'
|
|
129
|
+
});
|
|
130
|
+
this.chart.interaction('chart-active');
|
|
131
|
+
this.chart.render();
|
|
132
|
+
};
|
|
133
|
+
this.getLabel = (value, percent) => {
|
|
134
|
+
const {
|
|
135
|
+
display_label,
|
|
136
|
+
label_format
|
|
137
|
+
} = this.props.chart.config;
|
|
138
|
+
if (!display_label) {
|
|
139
|
+
return '';
|
|
140
|
+
}
|
|
141
|
+
switch (label_format) {
|
|
142
|
+
case CHART_LABEL_FORMATS[0]:
|
|
143
|
+
return percent;
|
|
144
|
+
case CHART_LABEL_FORMATS[1]:
|
|
145
|
+
return value;
|
|
146
|
+
case CHART_LABEL_FORMATS[2]:
|
|
147
|
+
return "".concat(value, " (").concat(percent, ")");
|
|
148
|
+
default:
|
|
149
|
+
return percent;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
this.chart = null;
|
|
153
|
+
}
|
|
154
|
+
componentDidMount() {
|
|
155
|
+
this.createChart();
|
|
156
|
+
this.drawChart();
|
|
157
|
+
}
|
|
158
|
+
componentDidUpdate(prevProps) {
|
|
159
|
+
if (ChartUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
160
|
+
this.chart && this.destroyChart();
|
|
161
|
+
this.createChart();
|
|
162
|
+
this.drawChart();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
componentWillUnmount() {
|
|
166
|
+
this.chart && this.destroyChart();
|
|
167
|
+
}
|
|
168
|
+
render() {
|
|
169
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
170
|
+
className: "sea-chart-container w-100",
|
|
171
|
+
ref: ref => this.container = ref
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
Pie.propTypes = {
|
|
176
|
+
canvasStyle: PropTypes.object,
|
|
177
|
+
chart: PropTypes.object,
|
|
178
|
+
groupbyColumn: PropTypes.object,
|
|
179
|
+
summaryColumn: PropTypes.object,
|
|
180
|
+
result: PropTypes.array,
|
|
181
|
+
tables: PropTypes.array,
|
|
182
|
+
theme: PropTypes.object,
|
|
183
|
+
toggleRecords: PropTypes.func
|
|
184
|
+
};
|
|
185
|
+
export default Pie;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS } from '../../constants';
|
|
4
|
+
import { ChartUtils } from '../../utils';
|
|
5
|
+
import ChartComponent from './chart-component';
|
|
6
|
+
import intl from '../../intl';
|
|
7
|
+
class Ring extends ChartComponent {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
var _this;
|
|
10
|
+
super(props);
|
|
11
|
+
_this = this;
|
|
12
|
+
this.createChart = () => {
|
|
13
|
+
const {
|
|
14
|
+
canvasStyle
|
|
15
|
+
} = this.props;
|
|
16
|
+
this.initChart(this.container, canvasStyle, 0);
|
|
17
|
+
};
|
|
18
|
+
this.destroyChart = () => {
|
|
19
|
+
this.chart.destroy();
|
|
20
|
+
this.chart = null;
|
|
21
|
+
};
|
|
22
|
+
this.clearChart = () => {
|
|
23
|
+
this.chart.annotation().clear(true);
|
|
24
|
+
this.chart.clear(true);
|
|
25
|
+
};
|
|
26
|
+
this.drawChart = () => {
|
|
27
|
+
let {
|
|
28
|
+
result: data,
|
|
29
|
+
chart,
|
|
30
|
+
tables,
|
|
31
|
+
summaryColumn
|
|
32
|
+
} = this.props;
|
|
33
|
+
if (data.length === 0) return;
|
|
34
|
+
this.sum = data.total;
|
|
35
|
+
this.chart.coordinate('theta', {
|
|
36
|
+
radius: 0.95,
|
|
37
|
+
innerRadius: 0.7
|
|
38
|
+
});
|
|
39
|
+
const {
|
|
40
|
+
show_legend,
|
|
41
|
+
display_label,
|
|
42
|
+
label_position,
|
|
43
|
+
label_font_size,
|
|
44
|
+
summary_method
|
|
45
|
+
} = chart.config;
|
|
46
|
+
const {
|
|
47
|
+
data: newData,
|
|
48
|
+
colorSet,
|
|
49
|
+
total
|
|
50
|
+
} = ChartUtils.formatPieChartData(data, chart, tables);
|
|
51
|
+
if (!Array.isArray(newData)) return;
|
|
52
|
+
this.sum = total;
|
|
53
|
+
this.loadData(newData);
|
|
54
|
+
this.chart.on('interval:click', e => {
|
|
55
|
+
this.props.toggleRecords(e.data.data);
|
|
56
|
+
});
|
|
57
|
+
if (show_legend) {
|
|
58
|
+
this.chart.legend('name', {
|
|
59
|
+
position: 'right',
|
|
60
|
+
custom: true,
|
|
61
|
+
itemName: {
|
|
62
|
+
style: {
|
|
63
|
+
fill: '#6e6e6e'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
items: newData.map((obj, index) => {
|
|
67
|
+
let name = obj.name;
|
|
68
|
+
if (!obj.name && typeof obj.name !== 'number') {
|
|
69
|
+
name = intl.get('Empty');
|
|
70
|
+
} else if (obj.name === '_Others') {
|
|
71
|
+
name = intl.get('Others');
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
name,
|
|
75
|
+
value: obj.value,
|
|
76
|
+
marker: {
|
|
77
|
+
symbol: 'circle',
|
|
78
|
+
style: {
|
|
79
|
+
r: 5,
|
|
80
|
+
fill: colorSet[index]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
this.chart.legend(false);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Do not automatically adjust the maximum and minimum values in pie chart
|
|
91
|
+
this.chart.scale({
|
|
92
|
+
value: {
|
|
93
|
+
nice: false
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
this.chart.interval().adjust('stack').position('value').color('name', colorSet).label('value*percent', (value, percent) => {
|
|
97
|
+
const displayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
98
|
+
return {
|
|
99
|
+
content: this.getLabel(displayValue, percent)
|
|
100
|
+
};
|
|
101
|
+
}, {
|
|
102
|
+
offset: !label_position || label_position === CHART_LABEL_POSITIONS[0] ? -2 : undefined,
|
|
103
|
+
style: {
|
|
104
|
+
fill: '#000000',
|
|
105
|
+
fontSize: ChartUtils.getLabelFontSize(label_font_size),
|
|
106
|
+
shadowBlur: 2,
|
|
107
|
+
shadowColor: 'rgba(0, 0, 0, .45)'
|
|
108
|
+
}
|
|
109
|
+
}).tooltip('name*value*percent', (name, value, percent) => {
|
|
110
|
+
let title = name;
|
|
111
|
+
if (!name || name === 'undefined') {
|
|
112
|
+
title = intl.get('Empty');
|
|
113
|
+
} else if (name === '_Others') {
|
|
114
|
+
title = intl.get('Others');
|
|
115
|
+
}
|
|
116
|
+
const displayValue = ChartUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
117
|
+
return {
|
|
118
|
+
name: title,
|
|
119
|
+
value: display_label ? this.getLabel(displayValue, percent) : displayValue
|
|
120
|
+
};
|
|
121
|
+
}).state({
|
|
122
|
+
active: {
|
|
123
|
+
style: {
|
|
124
|
+
fillOpacity: 0.7,
|
|
125
|
+
border: 'none',
|
|
126
|
+
stroke: 0
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
this.chart.tooltip({
|
|
131
|
+
showTitle: false,
|
|
132
|
+
showMarkers: false,
|
|
133
|
+
itemTpl: '<div class="g2-tooltip-list-item"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</div>'
|
|
134
|
+
});
|
|
135
|
+
this.chart.interaction('chart-active');
|
|
136
|
+
this.setAnnotation({
|
|
137
|
+
name: intl.get('Total'),
|
|
138
|
+
value: ChartUtils.getSummaryValueDisplayString(summaryColumn, this.sum, summary_method)
|
|
139
|
+
}, '#000000');
|
|
140
|
+
this.chart.on('interval:mouseenter', evt => this.onEnterRingChart(evt, '#000000', {
|
|
141
|
+
summaryColumn,
|
|
142
|
+
summaryMethod: summary_method
|
|
143
|
+
}));
|
|
144
|
+
this.chart.on('interval:mouseleave', evt => this.onLeaveRingChart(evt, '#000000', {
|
|
145
|
+
summaryColumn,
|
|
146
|
+
summaryMethod: summary_method
|
|
147
|
+
}));
|
|
148
|
+
this.chart.render();
|
|
149
|
+
};
|
|
150
|
+
this.getLabel = (value, percent) => {
|
|
151
|
+
const {
|
|
152
|
+
display_label,
|
|
153
|
+
label_format
|
|
154
|
+
} = this.props.chart.config;
|
|
155
|
+
if (!display_label) {
|
|
156
|
+
return '';
|
|
157
|
+
}
|
|
158
|
+
switch (label_format) {
|
|
159
|
+
case CHART_LABEL_FORMATS[0]:
|
|
160
|
+
return percent;
|
|
161
|
+
case CHART_LABEL_FORMATS[1]:
|
|
162
|
+
return value;
|
|
163
|
+
case CHART_LABEL_FORMATS[2]:
|
|
164
|
+
return "".concat(value, " (").concat(percent, ")");
|
|
165
|
+
default:
|
|
166
|
+
return percent;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
this.setAnnotation = function (content, fontColor) {
|
|
170
|
+
let {
|
|
171
|
+
summaryColumn,
|
|
172
|
+
summaryMethod
|
|
173
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
174
|
+
let name = content.name;
|
|
175
|
+
if (!name || name === 'undefined') {
|
|
176
|
+
name = intl.get('Empty');
|
|
177
|
+
} else if (name === '_Others') {
|
|
178
|
+
name = intl.get('Others');
|
|
179
|
+
}
|
|
180
|
+
_this.chart.annotation().text({
|
|
181
|
+
content: name,
|
|
182
|
+
position: ['50%', '50%'],
|
|
183
|
+
style: {
|
|
184
|
+
fontSize: 12,
|
|
185
|
+
fill: fontColor,
|
|
186
|
+
fontWeight: '300',
|
|
187
|
+
textAlign: 'center'
|
|
188
|
+
},
|
|
189
|
+
offsetY: -20
|
|
190
|
+
}).text({
|
|
191
|
+
position: ['50%', '50%'],
|
|
192
|
+
content: summaryColumn ? ChartUtils.getSummaryValueDisplayString(summaryColumn, content.value, summaryMethod) : content.value,
|
|
193
|
+
style: {
|
|
194
|
+
fontSize: 20,
|
|
195
|
+
fill: fontColor,
|
|
196
|
+
textAlign: 'center'
|
|
197
|
+
},
|
|
198
|
+
offsetY: 20
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
this.onEnterRingChart = (ev, color, _ref) => {
|
|
202
|
+
let {
|
|
203
|
+
summaryColumn,
|
|
204
|
+
summaryMethod
|
|
205
|
+
} = _ref;
|
|
206
|
+
const item = ev.data.data;
|
|
207
|
+
this.chart.annotation().clear(true);
|
|
208
|
+
this.setAnnotation(item, color, {
|
|
209
|
+
summaryColumn,
|
|
210
|
+
summaryMethod
|
|
211
|
+
});
|
|
212
|
+
this.chart.render(true);
|
|
213
|
+
};
|
|
214
|
+
this.onLeaveRingChart = (ev, color, _ref2) => {
|
|
215
|
+
let {
|
|
216
|
+
summaryColumn,
|
|
217
|
+
summaryMethod
|
|
218
|
+
} = _ref2;
|
|
219
|
+
this.chart.annotation().clear(true);
|
|
220
|
+
this.setAnnotation({
|
|
221
|
+
name: intl.get('Total'),
|
|
222
|
+
value: this.sum
|
|
223
|
+
}, color, {
|
|
224
|
+
summaryColumn,
|
|
225
|
+
summaryMethod
|
|
226
|
+
});
|
|
227
|
+
this.chart.render(true);
|
|
228
|
+
};
|
|
229
|
+
this.sum = 0;
|
|
230
|
+
this.chart = null;
|
|
231
|
+
}
|
|
232
|
+
componentDidMount() {
|
|
233
|
+
this.createChart();
|
|
234
|
+
this.drawChart();
|
|
235
|
+
}
|
|
236
|
+
componentDidUpdate(prevProps) {
|
|
237
|
+
if (ChartUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
238
|
+
this.chart && this.destroyChart();
|
|
239
|
+
this.sum = 0;
|
|
240
|
+
this.createChart();
|
|
241
|
+
this.drawChart();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
componentWillUnmount() {
|
|
245
|
+
this.chart && this.destroyChart();
|
|
246
|
+
}
|
|
247
|
+
render() {
|
|
248
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
249
|
+
className: "sea-chart-container w-100",
|
|
250
|
+
ref: ref => this.container = ref
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
Ring.propTypes = {
|
|
255
|
+
canvasStyle: PropTypes.object,
|
|
256
|
+
chart: PropTypes.object,
|
|
257
|
+
groupbyColumn: PropTypes.object,
|
|
258
|
+
columnGroupbyColumn: PropTypes.object,
|
|
259
|
+
summaryColumn: PropTypes.object,
|
|
260
|
+
result: PropTypes.array,
|
|
261
|
+
tables: PropTypes.array,
|
|
262
|
+
toggleRecords: PropTypes.func
|
|
263
|
+
};
|
|
264
|
+
export default Ring;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
.
|
|
1
|
+
.sea-chart-pivot-table {
|
|
2
2
|
width: 100%;
|
|
3
3
|
position: relative;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
.
|
|
6
|
+
.sea-chart-pivot-table thead {
|
|
7
7
|
border-top: 1px solid #ccc;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.
|
|
10
|
+
.sea-chart-pivot-table tr {
|
|
11
11
|
border-bottom: 1px solid #ccc;
|
|
12
12
|
text-align: center;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
.
|
|
15
|
+
.sea-chart-pivot-table th {
|
|
16
16
|
color: #212529;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.
|
|
20
|
-
.
|
|
19
|
+
.sea-chart-pivot-table th,
|
|
20
|
+
.sea-chart-pivot-table td {
|
|
21
21
|
padding: 10px;
|
|
22
22
|
border-right: 1px solid #ccc;
|
|
23
23
|
border-left: 1px solid #ccc;
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
text-align: center;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
.
|
|
36
|
-
.
|
|
35
|
+
.sea-chart-pivot-table .column-title,
|
|
36
|
+
.sea-chart-pivot-table .row-title {
|
|
37
37
|
padding: 0;
|
|
38
38
|
text-align: center;
|
|
39
39
|
color: inherit;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
.
|
|
42
|
+
.sea-chart-pivot-table .column-title {
|
|
43
43
|
caption-side: top;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.
|
|
46
|
+
.sea-chart-pivot-table .row-title {
|
|
47
47
|
position: absolute;
|
|
48
48
|
transform: rotate(-90deg);
|
|
49
49
|
width: 100px;
|
|
@@ -54,29 +54,29 @@
|
|
|
54
54
|
text-overflow: ellipsis;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
.
|
|
57
|
+
.sea-chart-pivot-table .pivot-cell {
|
|
58
58
|
position: relative;
|
|
59
59
|
overflow: hidden;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
.
|
|
62
|
+
.sea-chart-pivot-table .pivot-cell:hover {
|
|
63
63
|
cursor: pointer;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
.
|
|
66
|
+
.sea-chart-pivot-table .selected-pivot-cell {
|
|
67
67
|
border-bottom: 1px solid #66afe9;
|
|
68
68
|
border-right: 1px solid #66afe9;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
.
|
|
71
|
+
.sea-chart-pivot-table .selected-pivot-cell-top {
|
|
72
72
|
border-bottom: 1px solid #66afe9;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
.
|
|
75
|
+
.sea-chart-pivot-table .selected-pivot-cell-left {
|
|
76
76
|
border-right: 1px solid #66afe9 ;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
.
|
|
79
|
+
.sea-chart-pivot-table .selected-pivot-cell-border {
|
|
80
80
|
display: inline-block;
|
|
81
81
|
width: 100%;
|
|
82
82
|
height: 100%;
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
border: 1px solid #66afe9;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
.
|
|
89
|
+
.sea-chart-pivot-table .pivot-empty-cell i {
|
|
90
90
|
display: inline-block;
|
|
91
91
|
height: 6px;
|
|
92
92
|
width: 16px;
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
background: #f1f1f1;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
.
|
|
97
|
+
.sea-chart-pivot-table td>div {
|
|
98
98
|
white-space: nowrap;
|
|
99
99
|
text-overflow: ellipsis;
|
|
100
100
|
overflow: hidden;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import TwoDimensionTable from './two-dimension-table';
|
|
3
|
+
import OneDimensionTableNoNumericColumns from './one-dimension-table-no-numeric-columns';
|
|
4
|
+
import OneDimensionTableWithNumericColumns from './one-dimension-table-with-numeric-columns';
|
|
5
|
+
import intl from '../../../intl';
|
|
6
|
+
import './index.css';
|
|
7
|
+
class Table extends PureComponent {
|
|
8
|
+
render() {
|
|
9
|
+
const {
|
|
10
|
+
groupbyColumn,
|
|
11
|
+
columnGroupbyColumn,
|
|
12
|
+
result
|
|
13
|
+
} = this.props;
|
|
14
|
+
const {
|
|
15
|
+
pivot_columns
|
|
16
|
+
} = result;
|
|
17
|
+
if (!groupbyColumn) return '';
|
|
18
|
+
if (Array.isArray(pivot_columns) && pivot_columns.length > 100) {
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", null, intl.get('There_are_too_many_statistics_entries_to_display'));
|
|
20
|
+
}
|
|
21
|
+
if (columnGroupbyColumn) {
|
|
22
|
+
return /*#__PURE__*/React.createElement(TwoDimensionTable, this.props);
|
|
23
|
+
}
|
|
24
|
+
if (!Array.isArray(pivot_columns)) return null;
|
|
25
|
+
if (pivot_columns.length < 2) {
|
|
26
|
+
return /*#__PURE__*/React.createElement(OneDimensionTableNoNumericColumns, this.props);
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/React.createElement(OneDimensionTableWithNumericColumns, this.props);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export default Table;
|