Skip to content

Commit 4f9ce9d

Browse files
committed
feat: 图例与标题同行展示示例
1 parent a351567 commit 4f9ce9d

File tree

6 files changed

+101
-17
lines changed

6 files changed

+101
-17
lines changed

docs/charts/demo/Area/basic.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ function Example() {
1010
},
1111
xField: 'date',
1212
yField: 'value',
13+
legends: [
14+
{
15+
visible: true,
16+
position: 'end',
17+
orient: 'top',
18+
item: {
19+
shape: {
20+
style: {
21+
size: 10,
22+
symbolType: hyphenPointPath,
23+
dy: -5,
24+
fill: colorBlue2,
25+
},
26+
},
27+
label: {
28+
formatMethod: () => {
29+
return '测试图例';
30+
},
31+
},
32+
},
33+
layoutType: 'absolute',
34+
left: 0,
35+
right: -20,
36+
top: 2,
37+
},
38+
],
1339
data: {
1440
values: [
1541
{ date: 0, value: 11635 },

packages/chart/src/Area/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
import { AreaChart } from '@visactor/react-vchart';
2-
3-
export type { AreaChartProps as AreaProps } from '@visactor/react-vchart';
4-
export default AreaChart;
1+
export { Area } from './Area';
2+
export type { AreaProps } from './Area';

packages/theme/src/common/component/discreteLegend.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const discreteLegend: IDiscreteLegendTheme = {
5454
spaceRow: 6,
5555
padding: 2,
5656
background: {
57+
visible: false,
5758
state: {
5859
selectedHover: {
5960
fill: {
@@ -70,7 +71,7 @@ export const discreteLegend: IDiscreteLegendTheme = {
7071
},
7172
},
7273
shape: {
73-
space: 6,
74+
space: 10,
7475
style: {
7576
lineWidth: 0,
7677
fillOpacity: 1,

packages/theme/src/common/component/tooltip.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const tooltip: ITooltipTheme = {
55
/** 偏移量 */
66
offset: {
77
x: 10,
8-
y: 10
8+
y: 10,
99
},
1010
panel: {
1111
padding: {
@@ -16,12 +16,12 @@ export const tooltip: ITooltipTheme = {
1616
},
1717
backgroundColor: {
1818
type: 'palette',
19-
key: 'popupBackgroundColor'
19+
key: 'popupBackgroundColor',
2020
} as any,
2121
border: {
2222
color: {
2323
type: 'palette',
24-
key: 'popupBackgroundColor'
24+
key: 'popupBackgroundColor',
2525
} as any,
2626
width: 0,
2727
radius: 0,
@@ -33,9 +33,9 @@ export const tooltip: ITooltipTheme = {
3333
spread: 0,
3434
color: {
3535
type: 'palette',
36-
key: 'shadowColor'
37-
} as any
38-
}
36+
key: 'shadowColor',
37+
} as any,
38+
},
3939
},
4040
spaceRow: 6,
4141
titleLabel: {
@@ -44,25 +44,25 @@ export const tooltip: ITooltipTheme = {
4444
fontColor: colorGrey06,
4545
fontWeight: 'bold',
4646
textBaseline: 'middle',
47-
spacing: 0
47+
spacing: 0,
4848
},
4949
shape: {
5050
size: 8,
51-
spacing: 6
51+
spacing: 6,
5252
},
5353
keyLabel: {
5454
fontSize: 12,
5555
lineHeight: 20,
5656
fontColor: '#fff',
5757
textBaseline: 'middle',
58-
spacing: 26
58+
spacing: 26,
5959
},
6060
valueLabel: {
6161
fontSize: 12,
6262
lineHeight: 20,
6363
fontColor: '#fff',
6464
fontWeight: 'bold',
6565
textBaseline: 'middle',
66-
spacing: 0
66+
spacing: 0,
6767
},
68-
}
68+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type { ISeriesTheme } from '@visactor/vchart';
2+
3+
export const area: ISeriesTheme['area'] = {
4+
line: {
5+
style: {
6+
lineWidth: 2,
7+
curveType: 'monotone',
8+
},
9+
},
10+
point: {
11+
style: {
12+
symbolType: 'circle',
13+
size: 0,
14+
},
15+
state: {
16+
hover: {
17+
size: 10,
18+
},
19+
dimension_hover: {
20+
size: 10,
21+
},
22+
},
23+
},
24+
area: {
25+
style: {
26+
stroke: {
27+
type: 'palette',
28+
key: 'backgroundColor',
29+
},
30+
fillOpacity: 1,
31+
fill: {
32+
gradient: 'linear',
33+
x0: 0.5,
34+
y0: 0,
35+
x1: 0.5,
36+
y1: 1,
37+
stops: [
38+
{
39+
offset: 0,
40+
opacity: 0.1,
41+
},
42+
{
43+
offset: 1,
44+
opacity: 0,
45+
},
46+
],
47+
},
48+
},
49+
},
50+
label: {
51+
position: 'top',
52+
offset: 4,
53+
style: {
54+
fill: { type: 'palette', key: 'secondaryFontColor' },
55+
},
56+
},
57+
seriesMark: 'line',
58+
};

packages/theme/src/light/colorScheme.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
colorGrey04,
55
colorGrey06,
66
colorGrey10,
7+
colorGreyPro08,
78
colorGreyPro09,
89
colorWhite,
910
dataScheme,
@@ -33,7 +34,7 @@ export const colorScheme: IThemeColorScheme = {
3334
/** 主要字色 */
3435
primaryFontColor: colorGrey10,
3536
/** 次要字色 */
36-
secondaryFontColor: 'rgba(78,89,105,1)',
37+
secondaryFontColor: colorGreyPro08,
3738
/** 第三字色 */
3839
tertiaryFontColor: 'rgba(134,144,156,1)',
3940
/** 轴标签字色 */

0 commit comments

Comments
 (0)