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,164 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { isNumber } from 'dtable-utils';
|
|
3
|
+
import { Chart, registerShape } from '../../utils/custom-g2';
|
|
4
|
+
import { ChartUtils } from '../../utils';
|
|
5
|
+
class Dashboard extends Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.componentDidMount = () => {
|
|
9
|
+
this.drawChart();
|
|
10
|
+
};
|
|
11
|
+
this.drawChart = () => {
|
|
12
|
+
const {
|
|
13
|
+
chart,
|
|
14
|
+
theme,
|
|
15
|
+
canvasStyle,
|
|
16
|
+
result
|
|
17
|
+
} = this.props;
|
|
18
|
+
const value = isNumber(result) ? result : 0;
|
|
19
|
+
const {
|
|
20
|
+
config
|
|
21
|
+
} = chart;
|
|
22
|
+
this.chart = new Chart({
|
|
23
|
+
container: this.container,
|
|
24
|
+
autoFit: true,
|
|
25
|
+
width: '100%',
|
|
26
|
+
height: '100%'
|
|
27
|
+
});
|
|
28
|
+
registerShape('point', 'pointer', {
|
|
29
|
+
draw(cfg, container) {
|
|
30
|
+
const group = container.addGroup();
|
|
31
|
+
const center = this.parsePoint({
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0
|
|
34
|
+
});
|
|
35
|
+
group.addShape('line', {
|
|
36
|
+
attrs: {
|
|
37
|
+
x1: center.x,
|
|
38
|
+
y1: center.y - 15,
|
|
39
|
+
x2: cfg.x,
|
|
40
|
+
y2: cfg.y - 15,
|
|
41
|
+
stroke: cfg.color,
|
|
42
|
+
lineWidth: 5,
|
|
43
|
+
lineCap: 'round'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
group.addShape('circle', {
|
|
47
|
+
attrs: {
|
|
48
|
+
x: center.x,
|
|
49
|
+
y: center.y - 15,
|
|
50
|
+
r: 9.75,
|
|
51
|
+
stroke: cfg.color,
|
|
52
|
+
lineWidth: 4.5,
|
|
53
|
+
fill: '#fff'
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return group;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const number = value > 1 ? 10 : value * 10;
|
|
60
|
+
const data = [{
|
|
61
|
+
value: number
|
|
62
|
+
}];
|
|
63
|
+
this.chart.data(data);
|
|
64
|
+
this.chart.scale('value', {
|
|
65
|
+
min: 0,
|
|
66
|
+
max: 10,
|
|
67
|
+
tickInterval: 1
|
|
68
|
+
});
|
|
69
|
+
this.chart.coordinate('polar', {
|
|
70
|
+
startAngle: -9 / 8 * Math.PI,
|
|
71
|
+
endAngle: 1 / 8 * Math.PI,
|
|
72
|
+
radius: 0.75
|
|
73
|
+
});
|
|
74
|
+
this.chart.axis('1', false);
|
|
75
|
+
this.chart.axis('value', {
|
|
76
|
+
line: null,
|
|
77
|
+
label: {
|
|
78
|
+
offset: -36,
|
|
79
|
+
style: {
|
|
80
|
+
fontSize: 12,
|
|
81
|
+
textAlign: 'center',
|
|
82
|
+
textBaseline: 'middle'
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
subTickLine: {
|
|
86
|
+
count: 4,
|
|
87
|
+
length: -15
|
|
88
|
+
},
|
|
89
|
+
tickLine: {
|
|
90
|
+
length: -24
|
|
91
|
+
},
|
|
92
|
+
grid: null,
|
|
93
|
+
offsetY: -15
|
|
94
|
+
});
|
|
95
|
+
this.chart.legend(false);
|
|
96
|
+
this.chart.point().position('value*1').shape('pointer').color('#1890FF').animate({
|
|
97
|
+
appear: {
|
|
98
|
+
animation: 'fade-in'
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
this.chart.annotation().arc({
|
|
102
|
+
top: false,
|
|
103
|
+
start: [0, 1],
|
|
104
|
+
end: [10, 1],
|
|
105
|
+
style: {
|
|
106
|
+
stroke: '#CBCBCB',
|
|
107
|
+
lineWidth: 10,
|
|
108
|
+
lineDash: null
|
|
109
|
+
},
|
|
110
|
+
offsetY: -15
|
|
111
|
+
});
|
|
112
|
+
this.chart.annotation().arc({
|
|
113
|
+
start: [0, 1],
|
|
114
|
+
end: [data[0].value, 1],
|
|
115
|
+
style: {
|
|
116
|
+
stroke: '#1890FF',
|
|
117
|
+
lineWidth: 10,
|
|
118
|
+
lineDash: null
|
|
119
|
+
},
|
|
120
|
+
offsetY: -15
|
|
121
|
+
});
|
|
122
|
+
this.chart.annotation().text({
|
|
123
|
+
position: ['50%', '85%'],
|
|
124
|
+
content: config.name,
|
|
125
|
+
style: {
|
|
126
|
+
fontSize: canvasStyle.height > 240 ? 20 : 12,
|
|
127
|
+
fill: '#545454',
|
|
128
|
+
textAlign: 'center'
|
|
129
|
+
},
|
|
130
|
+
offsetY: -10
|
|
131
|
+
});
|
|
132
|
+
let shownValue = value * 100;
|
|
133
|
+
const shownDotPos = "".concat(shownValue).indexOf('.');
|
|
134
|
+
if (shownDotPos > -1 && shownDotPos < "".concat(shownValue).length - 2) {
|
|
135
|
+
shownValue = shownValue.toFixed(1);
|
|
136
|
+
}
|
|
137
|
+
this.chart.annotation().text({
|
|
138
|
+
position: ['50%', '90%'],
|
|
139
|
+
content: "".concat(shownValue, " %"),
|
|
140
|
+
style: {
|
|
141
|
+
fontSize: canvasStyle.height > 240 ? 36 : 16,
|
|
142
|
+
fill: theme.textColor,
|
|
143
|
+
textAlign: 'center'
|
|
144
|
+
},
|
|
145
|
+
offsetY: 0
|
|
146
|
+
});
|
|
147
|
+
this.chart.render();
|
|
148
|
+
this.container.title = "".concat(data[0].value * 10, " %");
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
componentDidUpdate(prevProps) {
|
|
152
|
+
if (ChartUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
153
|
+
this.chart && this.chart.destroy();
|
|
154
|
+
this.drawChart();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
render() {
|
|
158
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
159
|
+
ref: ref => this.container = ref,
|
|
160
|
+
className: "sea-chart-container w-100"
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export default Dashboard;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { EMPTY_NAME } from '../../constants';
|
|
5
|
+
import { ChartUtils } from '../../utils';
|
|
6
|
+
import HorizontalComponent from './horizontal-component';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
class HorizontalBarGroup extends HorizontalComponent {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.createChart = () => {
|
|
12
|
+
const {
|
|
13
|
+
chart
|
|
14
|
+
} = this.props;
|
|
15
|
+
const {
|
|
16
|
+
display_data
|
|
17
|
+
} = chart.config;
|
|
18
|
+
const appendPadding = [0, display_data ? 17 : 0, 0, 0];
|
|
19
|
+
this.initChart(this.container, {
|
|
20
|
+
appendPadding
|
|
21
|
+
});
|
|
22
|
+
this.chart.on('interval:click', e => {
|
|
23
|
+
this.props.toggleRecords(e.data.data);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
this.clearChart = () => {
|
|
27
|
+
this.chart.annotation().clear(true);
|
|
28
|
+
this.chart.clear(true);
|
|
29
|
+
};
|
|
30
|
+
this.drawChart = () => {
|
|
31
|
+
let {
|
|
32
|
+
result: data
|
|
33
|
+
} = this.props;
|
|
34
|
+
data = ChartUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
35
|
+
if (!Array.isArray(data)) return;
|
|
36
|
+
this.chart.scale(this.groupName, {
|
|
37
|
+
type: 'cat'
|
|
38
|
+
});
|
|
39
|
+
this.loadData(data);
|
|
40
|
+
this.draw(data);
|
|
41
|
+
this.chart.render();
|
|
42
|
+
};
|
|
43
|
+
this.draw = data => {
|
|
44
|
+
const {
|
|
45
|
+
chart,
|
|
46
|
+
summaryColumn,
|
|
47
|
+
theme
|
|
48
|
+
} = this.props;
|
|
49
|
+
const {
|
|
50
|
+
horizontal_axis_summary_method,
|
|
51
|
+
display_data,
|
|
52
|
+
label_font_size
|
|
53
|
+
} = chart.config;
|
|
54
|
+
const chartBarColor = this.groupName;
|
|
55
|
+
const newData = this.getChartGroupData(data);
|
|
56
|
+
this.drawLabels(newData);
|
|
57
|
+
|
|
58
|
+
// set Coord type
|
|
59
|
+
this.chart.coordinate('rect');
|
|
60
|
+
this.autoAdjustDataOptions(chart, data, summaryColumn);
|
|
61
|
+
this.chart.interval().label(display_data ? 'value' : false, {
|
|
62
|
+
formatter: value => {
|
|
63
|
+
return value;
|
|
64
|
+
},
|
|
65
|
+
style: {
|
|
66
|
+
fontSize: ChartUtils.getLabelFontSize(label_font_size),
|
|
67
|
+
fill: theme.textColor
|
|
68
|
+
}
|
|
69
|
+
}).position('name*value').color(chartBarColor).tooltip('name*value*group_name*raw_name', (name, value, group_name, raw_name) => {
|
|
70
|
+
return {
|
|
71
|
+
title: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name,
|
|
72
|
+
value: ChartUtils.getSummaryValueDisplayString(summaryColumn, value, horizontal_axis_summary_method),
|
|
73
|
+
name: !group_name && typeof group_name !== 'number' ? intl.get(EMPTY_NAME) : group_name
|
|
74
|
+
};
|
|
75
|
+
}).adjust([{
|
|
76
|
+
type: 'dodge'
|
|
77
|
+
}]).state({
|
|
78
|
+
active: {
|
|
79
|
+
style: {
|
|
80
|
+
stroke: null
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
this.chart.tooltip({
|
|
85
|
+
showTitle: true,
|
|
86
|
+
showMarkers: false,
|
|
87
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
88
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
89
|
+
domStyles: {
|
|
90
|
+
'g2-tooltip': {
|
|
91
|
+
borderRadius: '2px',
|
|
92
|
+
backgroundColor: '#fff',
|
|
93
|
+
padding: '10px'
|
|
94
|
+
},
|
|
95
|
+
'tooltip-item': {
|
|
96
|
+
marginTop: '5px'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
this.setNameLabelAndTooltip(theme, this.labelCount);
|
|
101
|
+
this.setValueLabel(theme);
|
|
102
|
+
this.setLegend(this.groupName, theme, 'bottom');
|
|
103
|
+
this.chart.coordinate().transpose();
|
|
104
|
+
this.chart.interaction('active-region');
|
|
105
|
+
};
|
|
106
|
+
this.chart = null;
|
|
107
|
+
this.groupName = 'group_name';
|
|
108
|
+
}
|
|
109
|
+
componentDidMount() {
|
|
110
|
+
this.createChart();
|
|
111
|
+
this.drawChart();
|
|
112
|
+
this.renderHorizontalLabel(this.props.chart, this.props.tables);
|
|
113
|
+
}
|
|
114
|
+
componentDidUpdate(prevProps) {
|
|
115
|
+
if (ChartUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
116
|
+
this.chart && this.chart.destroy();
|
|
117
|
+
this.createChart();
|
|
118
|
+
this.drawChart();
|
|
119
|
+
this.renderHorizontalLabel(prevProps.chart, prevProps.tables);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
componentWillUnmount() {
|
|
123
|
+
this.chart && this.chart.destroy();
|
|
124
|
+
}
|
|
125
|
+
render() {
|
|
126
|
+
const {
|
|
127
|
+
chart
|
|
128
|
+
} = this.props;
|
|
129
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
130
|
+
className: classnames('sea-chart-container w-100', {
|
|
131
|
+
'show-vertical-axis-label': this.isShowVerticalAxisLabel(chart),
|
|
132
|
+
'show-horizontal-axis-label': this.isShowHorizontalAxisLabel(chart)
|
|
133
|
+
}),
|
|
134
|
+
ref: ref => this.container = ref
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
HorizontalBarGroup.propTypes = {
|
|
139
|
+
canvasStyle: PropTypes.object,
|
|
140
|
+
chart: PropTypes.object,
|
|
141
|
+
groupbyColumn: PropTypes.object,
|
|
142
|
+
columnGroupbyColumn: PropTypes.object,
|
|
143
|
+
summaryColumn: PropTypes.object,
|
|
144
|
+
result: PropTypes.array,
|
|
145
|
+
tables: PropTypes.array,
|
|
146
|
+
theme: PropTypes.object,
|
|
147
|
+
toggleRecords: PropTypes.func
|
|
148
|
+
};
|
|
149
|
+
export default HorizontalBarGroup;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW } from '../../constants';
|
|
5
|
+
import { ChartUtils } from '../../utils';
|
|
6
|
+
import HorizontalComponent from './horizontal-component';
|
|
7
|
+
import intl from '../../intl';
|
|
8
|
+
class HorizontalBar extends HorizontalComponent {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.createChart = () => {
|
|
12
|
+
const {
|
|
13
|
+
chart
|
|
14
|
+
} = this.props;
|
|
15
|
+
const {
|
|
16
|
+
display_data
|
|
17
|
+
} = chart.config;
|
|
18
|
+
const appendPadding = [0, display_data ? 17 : 0, 0, 0]; // used to display value on the right
|
|
19
|
+
this.initChart(this.container, {
|
|
20
|
+
appendPadding
|
|
21
|
+
});
|
|
22
|
+
this.chart.on('interval:click', e => {
|
|
23
|
+
this.props.toggleRecords(e.data.data);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
this.clearChart = () => {
|
|
27
|
+
this.chart.annotation().clear(true);
|
|
28
|
+
this.chart.clear(true);
|
|
29
|
+
};
|
|
30
|
+
this.drawChart = () => {
|
|
31
|
+
let {
|
|
32
|
+
result: data
|
|
33
|
+
} = this.props;
|
|
34
|
+
data = ChartUtils.formatEmptyName(data, '', intl.get('Empty'));
|
|
35
|
+
if (!Array.isArray(data)) return;
|
|
36
|
+
this.loadData(data);
|
|
37
|
+
this.draw(data);
|
|
38
|
+
this.chart.render();
|
|
39
|
+
this.renderHorizontalLabel(this.props.chart, this.props.tables);
|
|
40
|
+
};
|
|
41
|
+
this.draw = data => {
|
|
42
|
+
const {
|
|
43
|
+
chart,
|
|
44
|
+
summaryColumn,
|
|
45
|
+
theme
|
|
46
|
+
} = this.props;
|
|
47
|
+
const {
|
|
48
|
+
horizontal_axis_summary_type,
|
|
49
|
+
horizontal_axis_summary_method,
|
|
50
|
+
horizontal_axis_label_color,
|
|
51
|
+
display_data,
|
|
52
|
+
label_font_size
|
|
53
|
+
} = chart.config;
|
|
54
|
+
const chartBarColor = horizontal_axis_label_color || '#2a67d1';
|
|
55
|
+
data.reverse();
|
|
56
|
+
this.drawLabels(data);
|
|
57
|
+
|
|
58
|
+
// set Coord type
|
|
59
|
+
this.chart.coordinate('rect');
|
|
60
|
+
this.autoAdjustDataOptions(chart, data, summaryColumn);
|
|
61
|
+
this.chart.interval().label(display_data ? 'value' : false, {
|
|
62
|
+
style: {
|
|
63
|
+
fontSize: ChartUtils.getLabelFontSize(label_font_size),
|
|
64
|
+
fill: theme.textColor
|
|
65
|
+
}
|
|
66
|
+
}).position('name*value').color(chartBarColor).tooltip('name*value', (name, value) => {
|
|
67
|
+
return {
|
|
68
|
+
title: horizontal_axis_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[horizontal_axis_summary_method]),
|
|
69
|
+
value: ChartUtils.getSummaryValueDisplayString(summaryColumn, value, horizontal_axis_summary_method),
|
|
70
|
+
name
|
|
71
|
+
};
|
|
72
|
+
}).state({
|
|
73
|
+
active: {
|
|
74
|
+
style: {
|
|
75
|
+
stroke: null
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
this.chart.tooltip({
|
|
80
|
+
showTitle: true,
|
|
81
|
+
showMarkers: false,
|
|
82
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
83
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{title}<div><div class="tooltip-item">{name}: {value}<div></div>',
|
|
84
|
+
domStyles: {
|
|
85
|
+
'g2-tooltip': {
|
|
86
|
+
borderRadius: '2px',
|
|
87
|
+
backgroundColor: '#fff',
|
|
88
|
+
padding: '10px'
|
|
89
|
+
},
|
|
90
|
+
'tooltip-item': {
|
|
91
|
+
marginTop: '5px'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
this.setNameLabelAndTooltip(theme, this.labelCount);
|
|
96
|
+
this.setValueLabel(theme);
|
|
97
|
+
this.chart.coordinate().transpose();
|
|
98
|
+
this.chart.interaction('active-region');
|
|
99
|
+
};
|
|
100
|
+
this.chart = null;
|
|
101
|
+
}
|
|
102
|
+
componentDidMount() {
|
|
103
|
+
this.createChart();
|
|
104
|
+
this.drawChart();
|
|
105
|
+
}
|
|
106
|
+
componentDidUpdate(prevProps) {
|
|
107
|
+
if (ChartUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
108
|
+
this.chart && this.chart.destroy();
|
|
109
|
+
this.createChart();
|
|
110
|
+
this.drawChart();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
componentWillUnmount() {
|
|
114
|
+
this.chart && this.chart.destroy();
|
|
115
|
+
}
|
|
116
|
+
render() {
|
|
117
|
+
const {
|
|
118
|
+
chart
|
|
119
|
+
} = this.props;
|
|
120
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
121
|
+
className: classnames('sea-chart-container w-100', {
|
|
122
|
+
'show-vertical-axis-label': this.isShowVerticalAxisLabel(chart),
|
|
123
|
+
'show-horizontal-axis-label': this.isShowHorizontalAxisLabel(chart)
|
|
124
|
+
}),
|
|
125
|
+
ref: ref => this.container = ref
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
HorizontalBar.propTypes = {
|
|
130
|
+
canvasStyle: PropTypes.object,
|
|
131
|
+
chart: PropTypes.object,
|
|
132
|
+
groupbyColumn: PropTypes.object,
|
|
133
|
+
columnGroupbyColumn: PropTypes.object,
|
|
134
|
+
summaryColumn: PropTypes.object,
|
|
135
|
+
result: PropTypes.array,
|
|
136
|
+
tables: PropTypes.array,
|
|
137
|
+
theme: PropTypes.object,
|
|
138
|
+
toggleRecords: PropTypes.func
|
|
139
|
+
};
|
|
140
|
+
export default HorizontalBar;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getTableById, getTableColumnByKey } from 'dtable-utils';
|
|
2
|
+
import ChartComponent from './chart-component';
|
|
3
|
+
import { CHART_SUMMARY_TYPE, LABEL_POSITION_TYPE } from '../../constants';
|
|
4
|
+
import intl from '../../intl';
|
|
5
|
+
export default class HorizontalComponent extends ChartComponent {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.renderHorizontalLabel = (chart, tables) => {
|
|
9
|
+
if (!this.chart || !chart) return;
|
|
10
|
+
let {
|
|
11
|
+
table_id,
|
|
12
|
+
x_axis_column_key,
|
|
13
|
+
y_axis_summary_column_key,
|
|
14
|
+
y_axis_label_position,
|
|
15
|
+
x_axis_label_position,
|
|
16
|
+
y_axis_summary_type,
|
|
17
|
+
show_vertical_axis_label,
|
|
18
|
+
show_horizontal_axis_label
|
|
19
|
+
} = chart.config;
|
|
20
|
+
const table = getTableById(tables, table_id);
|
|
21
|
+
const autoPadding = this.chart.autoPadding;
|
|
22
|
+
const textColor = '#999999';
|
|
23
|
+
const xAxisID = "chart-x-axis-label_".concat(chart.id);
|
|
24
|
+
const chartContainer = this.chart.getCanvas().get('container');
|
|
25
|
+
const xLabel = chartContainer.querySelector("#".concat(xAxisID));
|
|
26
|
+
if (!xLabel && show_horizontal_axis_label) {
|
|
27
|
+
const div = document.createElement('div');
|
|
28
|
+
div.id = xAxisID;
|
|
29
|
+
div.className = 'chart-axis-label';
|
|
30
|
+
if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
31
|
+
div.innerHTML = intl.get('Amount');
|
|
32
|
+
} else {
|
|
33
|
+
const column = getTableColumnByKey(table, y_axis_summary_column_key);
|
|
34
|
+
div.innerHTML = "".concat(column ? column.name : '');
|
|
35
|
+
}
|
|
36
|
+
div.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
|
|
37
|
+
chartContainer.appendChild(div);
|
|
38
|
+
}
|
|
39
|
+
if (xLabel && show_horizontal_axis_label) {
|
|
40
|
+
xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
|
|
41
|
+
}
|
|
42
|
+
if (xLabel && !show_horizontal_axis_label) {
|
|
43
|
+
xLabel.parentNode.removeChild(xLabel);
|
|
44
|
+
}
|
|
45
|
+
const yAxisID = "chart-y-axis-label_".concat(chart.id);
|
|
46
|
+
const yLabel = chartContainer.querySelector("#".concat(yAxisID));
|
|
47
|
+
if (!yLabel && show_vertical_axis_label) {
|
|
48
|
+
const div = document.createElement('div');
|
|
49
|
+
div.id = yAxisID;
|
|
50
|
+
div.className = 'chart-axis-label';
|
|
51
|
+
const column = getTableColumnByKey(table, x_axis_column_key) || {};
|
|
52
|
+
div.innerHTML = column.name || '';
|
|
53
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
54
|
+
let textAlign = 'center';
|
|
55
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
56
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
57
|
+
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)"));
|
|
58
|
+
chartContainer.appendChild(div);
|
|
59
|
+
}
|
|
60
|
+
if (yLabel && show_horizontal_axis_label) {
|
|
61
|
+
const containerHeight = chartContainer.offsetHeight;
|
|
62
|
+
let textAlign = 'center';
|
|
63
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
|
|
64
|
+
if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
|
|
65
|
+
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)"));
|
|
66
|
+
}
|
|
67
|
+
if (yLabel && !show_horizontal_axis_label) {
|
|
68
|
+
yLabel.parentNode.removeChild(yLabel);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
this.isShowVerticalAxisLabel = chart => {
|
|
72
|
+
return !!(chart && chart.config && chart.config.show_vertical_axis_label);
|
|
73
|
+
};
|
|
74
|
+
this.isShowHorizontalAxisLabel = chart => {
|
|
75
|
+
return !!(chart && chart.config && chart.config.show_horizontal_axis_label);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|