sea-chart 1.1.102 → 1.1.104
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.
|
@@ -2,7 +2,17 @@ import dayjs from 'dayjs';
|
|
|
2
2
|
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
3
3
|
import { CHART_SUMMARY_TYPE } from '../constants';
|
|
4
4
|
import { BaseUtils } from './chart-utils';
|
|
5
|
+
import { getFirstDayOfWeekForGroupby } from './index';
|
|
5
6
|
dayjs.extend(quarterOfYear);
|
|
7
|
+
const dayOfWeekMap = {
|
|
8
|
+
'Sunday': 0,
|
|
9
|
+
'Monday': 1,
|
|
10
|
+
'Tuesday': 2,
|
|
11
|
+
'Wednesday': 3,
|
|
12
|
+
'Thursday': 4,
|
|
13
|
+
'Friday': 5,
|
|
14
|
+
'Saturday': 6
|
|
15
|
+
};
|
|
6
16
|
export function getCompareDate(dateGranularity) {
|
|
7
17
|
const currentDate = dayjs();
|
|
8
18
|
switch (dateGranularity) {
|
|
@@ -17,7 +27,9 @@ export function getCompareDate(dateGranularity) {
|
|
|
17
27
|
}
|
|
18
28
|
case CHART_SUMMARY_TYPE.WEEK:
|
|
19
29
|
{
|
|
20
|
-
const
|
|
30
|
+
const firstDayOfWeek = getFirstDayOfWeekForGroupby('app');
|
|
31
|
+
const startDayIndex = dayOfWeekMap[firstDayOfWeek] || 6; // default to Saturday
|
|
32
|
+
const currentWeek = dayjs().day(startDayIndex);
|
|
21
33
|
const compareDate = dayjs(currentWeek).subtract(1, 'weeks').format('YYYY-MM-DD');
|
|
22
34
|
const comparedDate = dayjs(currentWeek).subtract(2, 'weeks').format('YYYY-MM-DD');
|
|
23
35
|
return {
|
|
@@ -3,6 +3,11 @@ import { isNumber } from 'dtable-utils';
|
|
|
3
3
|
import { Chart, registerShape } from '../../utils/custom-g2';
|
|
4
4
|
import { BaseUtils, isFunction } from '../../utils';
|
|
5
5
|
import { CHART_THEME_COLOR } from '../../constants';
|
|
6
|
+
const textAlignPositionMap = {
|
|
7
|
+
left: '43%',
|
|
8
|
+
center: '50%',
|
|
9
|
+
right: '57%'
|
|
10
|
+
};
|
|
6
11
|
class Dashboard extends Component {
|
|
7
12
|
constructor() {
|
|
8
13
|
super(...arguments);
|
|
@@ -22,6 +27,16 @@ class Dashboard extends Component {
|
|
|
22
27
|
const {
|
|
23
28
|
config
|
|
24
29
|
} = chart;
|
|
30
|
+
const {
|
|
31
|
+
font_size,
|
|
32
|
+
font_weight,
|
|
33
|
+
font_color,
|
|
34
|
+
card_label_font_size,
|
|
35
|
+
label_font_weight,
|
|
36
|
+
label_font_color,
|
|
37
|
+
text_align,
|
|
38
|
+
label_text_align
|
|
39
|
+
} = config;
|
|
25
40
|
this.chart = new Chart({
|
|
26
41
|
container: this.container,
|
|
27
42
|
autoFit: true,
|
|
@@ -126,11 +141,12 @@ class Dashboard extends Component {
|
|
|
126
141
|
offsetY: -15
|
|
127
142
|
});
|
|
128
143
|
this.chart.annotation().text({
|
|
129
|
-
position: ['50%', '85%'],
|
|
144
|
+
position: [textAlignPositionMap[label_text_align] || '50%', '85%'],
|
|
130
145
|
content: config.name,
|
|
131
146
|
style: {
|
|
132
|
-
fontSize: canvasStyle.height > 240 ? 20 : 12,
|
|
133
|
-
fill: '#545454',
|
|
147
|
+
fontSize: card_label_font_size || (canvasStyle.height > 240 ? 20 : 12),
|
|
148
|
+
fill: label_font_color || '#545454',
|
|
149
|
+
fontWeight: label_font_weight || 'normal',
|
|
134
150
|
textAlign: 'center'
|
|
135
151
|
},
|
|
136
152
|
offsetY: -10
|
|
@@ -141,11 +157,12 @@ class Dashboard extends Component {
|
|
|
141
157
|
shownValue = shownValue.toFixed(1);
|
|
142
158
|
}
|
|
143
159
|
this.chart.annotation().text({
|
|
144
|
-
position: ['50%', '90%'],
|
|
160
|
+
position: [textAlignPositionMap[text_align] || '50%', '90%'],
|
|
145
161
|
content: `${shownValue} %`,
|
|
146
162
|
style: {
|
|
147
|
-
fontSize: canvasStyle.height > 240 ? 36 : 16,
|
|
148
|
-
fill: theme.textColor,
|
|
163
|
+
fontSize: font_size || (canvasStyle.height > 240 ? 36 : 16),
|
|
164
|
+
fill: font_color || theme.textColor,
|
|
165
|
+
fontWeight: font_weight || 'bold',
|
|
149
166
|
textAlign: 'center'
|
|
150
167
|
},
|
|
151
168
|
offsetY: 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sea-chart",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.104",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@antv/data-set": "0.11.8",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@antv/scale": "0.3.14",
|
|
26
|
-
"dtable-ui-component": "^6.0.
|
|
26
|
+
"dtable-ui-component": "^6.0.53",
|
|
27
27
|
"dtable-utils": "~5.0.*",
|
|
28
28
|
"prop-types": "15.8.1",
|
|
29
29
|
"react": "^18.3.1",
|
|
@@ -143,9 +143,9 @@
|
|
|
143
143
|
"resolve": "1.12.0",
|
|
144
144
|
"resolve-url-loader": "5.0.0",
|
|
145
145
|
"rimraf": "^5.0.7",
|
|
146
|
-
"svgo-loader": "^3.0.0",
|
|
147
146
|
"sass-loader": "13.3.2",
|
|
148
147
|
"style-loader": "^1.0.1",
|
|
148
|
+
"svgo-loader": "^3.0.0",
|
|
149
149
|
"terser-webpack-plugin": "4.2.3",
|
|
150
150
|
"ts-pnp": "1.1.4",
|
|
151
151
|
"url-loader": "4.1.1",
|