Skip to content

Commit d17e6be

Browse files
lxfu1liufu.lf
and
liufu.lf
authored
docs: 去除重复图表 (#1794)
* docs: 去除重复图表 * fix: conversation Co-authored-by: liufu.lf <[email protected]>
1 parent d0417c0 commit d17e6be

File tree

13 files changed

+131
-201
lines changed

13 files changed

+131
-201
lines changed

examples/bar/range/demo/basic.ts

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const barPlot = new Bar('container', {
1616
xField: 'values',
1717
yField: 'type',
1818
isRange: true,
19+
label: {
20+
position: 'middle',
21+
layout: [{ type: 'adjust-color' }],
22+
},
1923
});
2024

2125
barPlot.render();

examples/bar/range/demo/label.ts

-31
This file was deleted.

examples/bar/range/demo/meta.json

-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
"en": "Range Bar chart"
1212
},
1313
"screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*tCDCQaO1ZZsAAAAAAAAAAAAAARQnAQ"
14-
},
15-
{
16-
"filename": "label.ts",
17-
"title": {
18-
"zh": "区间条形图-label样式",
19-
"en": "Range Bar chart"
20-
},
21-
"screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*5GzVQKRzXcQAAAAAAAAAAAAAARQnAQ"
2214
}
2315
]
2416
}

examples/column/range/demo/basic.ts

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const barPlot = new Column('container', {
1616
xField: 'type',
1717
yField: 'values',
1818
isRange: true,
19+
label: {
20+
position: 'middle',
21+
layout: [{ type: 'adjust-color' }],
22+
},
1923
});
2024

2125
barPlot.render();

examples/column/range/demo/label.ts

-31
This file was deleted.

examples/column/range/demo/meta.json

-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
"en": "Range Column chart"
1212
},
1313
"screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*Il5JQZkHxiIAAAAAAAAAAAAAARQnAQ"
14-
},
15-
{
16-
"filename": "label.ts",
17-
"title": {
18-
"zh": "区间柱状图-label样式",
19-
"en": "Range Column chart"
20-
},
21-
"screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*MDn_SpazLvwAAAAAAAAAAAAAARQnAQ"
2214
}
2315
]
2416
}
+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { Scatter } from '@antv/g2plot';
2+
3+
fetch('https://gw.alipayobjects.com/os/bmw-prod/f950b2f1-038b-47c2-afcc-63001bc8d07c.json')
4+
.then((res) => res.json())
5+
.then((data) => {
6+
const processData = data.map((item) => {
7+
item['Average annual wage'] = item['Average annual wage'] * 1;
8+
item['probability'] = item['probability'] * 1;
9+
item['numbEmployed'] = item['numbEmployed'] * 1;
10+
return item;
11+
});
12+
const labels = ['Airline Pilots, Copilots and Flight Engineers', 'Benefits Managers'];
13+
const scatterPlot = new Scatter('container', {
14+
appendPadding: 30,
15+
data: processData,
16+
xField: 'probability',
17+
yField: 'Average annual wage',
18+
colorField: 'education',
19+
size: [2, 16],
20+
sizeField: 'numbEmployed',
21+
shape: 'circle',
22+
yAxis: {
23+
nice: false,
24+
min: -20000,
25+
tickCount: 5,
26+
position: 'right',
27+
label: {
28+
formatter: (value) => {
29+
return Math.floor(value / 1000) + 'K';
30+
},
31+
},
32+
grid: {
33+
line: {
34+
style: {
35+
stroke: '#eee',
36+
},
37+
},
38+
},
39+
line: {
40+
style: {
41+
stroke: '#aaa',
42+
},
43+
},
44+
},
45+
tooltip: {
46+
fields: ['probability', 'Average annual wage', 'numbEmployed'],
47+
},
48+
legend: {
49+
position: 'top',
50+
},
51+
xAxis: {
52+
min: -0.04,
53+
max: 1.04,
54+
nice: false,
55+
grid: {
56+
line: {
57+
style: {
58+
stroke: '#eee',
59+
},
60+
},
61+
},
62+
line: false,
63+
label: false,
64+
},
65+
label: {
66+
formatter: (item) => {
67+
return labels.includes(item['short occupation']) ? item['short occupation'] : '';
68+
},
69+
offsetY: -10,
70+
},
71+
annotations: [
72+
{
73+
type: 'line',
74+
start: [-0.04, 100000],
75+
end: [1.04, 30000],
76+
style: {
77+
stroke: '#aaa',
78+
},
79+
},
80+
{
81+
type: 'text',
82+
position: ['1.03', 'max'],
83+
content: 'Average annual wage',
84+
style: {
85+
textAlign: 'right',
86+
fontWeight: '500',
87+
fill: 'rgb(92, 92, 92)',
88+
},
89+
},
90+
{
91+
type: 'text',
92+
position: ['1.03', 'min'],
93+
content: 'Most likely to \nbe automated ',
94+
style: {
95+
textAlign: 'right',
96+
fontWeight: '500',
97+
fill: 'rgb(92, 92, 92)',
98+
},
99+
},
100+
{
101+
type: 'text',
102+
position: ['-0.03', 'min'],
103+
content: 'Least likely to \nbe automated ',
104+
style: {
105+
textAlign: 'left',
106+
fontWeight: '500',
107+
fill: 'rgb(92, 92, 92)',
108+
},
109+
},
110+
],
111+
});
112+
scatterPlot.render();
113+
});

examples/scatter/basic/demo/basic.ts

-40
This file was deleted.

examples/scatter/basic/demo/color-mapping.ts

-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ fetch('https://gw.alipayobjects.com/os/antfincdn/aao6XnO5pW/IMDB.json')
1010
yField: 'Rating',
1111
shape: 'circle',
1212
colorField: 'Genre',
13-
color: ['#d62728', '#2ca02c', '#000000', '#9467bd', '#ffd500', '#1f77b4', '#00518a', '#ffbc69', '#9bd646'],
1413
size: 4,
1514
yAxis: {
1615
nice: true,
@@ -35,9 +34,6 @@ fetch('https://gw.alipayobjects.com/os/antfincdn/aao6XnO5pW/IMDB.json')
3534
},
3635
},
3736
},
38-
pointStyle: {
39-
stroke: '#fff',
40-
},
4137
});
4238
scatterPlot.render();
4339
});

examples/scatter/basic/demo/meta.json

+8-16
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
"en": "Category"
55
},
66
"demos": [
7-
{
8-
"filename": "basic.ts",
9-
"title": {
10-
"zh": "基础散点图",
11-
"en": "basic Scatter chart"
12-
},
13-
"screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*Cu0wSYK_U6YAAAAAAAAAAABkARQnAQ"
14-
},
157
{
168
"filename": "color-mapping.ts",
179
"title": {
@@ -28,21 +20,21 @@
2820
},
2921
"screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*XlOeS4YAHbYAAAAAAAAAAABkARQnAQ"
3022
},
31-
{
32-
"filename": "size.ts",
33-
"title": {
34-
"zh": "散点图-气泡",
35-
"en": "Bubble chart"
36-
},
37-
"screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*_lGkQrhj53gAAAAAAAAAAABkARQnAQ"
38-
},
3923
{
4024
"filename": "quadrant.ts",
4125
"title": {
4226
"zh": "散点图-气泡四象限",
4327
"en": "Bubble chart quadrant"
4428
},
4529
"screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*tdedT4uaPaYAAAAAAAAAAABkARQnAQ"
30+
},
31+
{
32+
"filename": "axis-right.ts",
33+
"title": {
34+
"zh": "散点图-右侧坐标轴",
35+
"en": "Bubble chart yAxis on the right"
36+
},
37+
"screenshot": "https://gw.alipayobjects.com/mdn/rms_d314dd/afts/img/A*0luHTJODdMUAAAAAAAAAAAAAARQnAQ"
4638
}
4739
]
4840
}

examples/scatter/basic/demo/size.ts

-45
This file was deleted.

src/plots/scatter/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ export class Scatter extends Plot<ScatterOptions> {
1919
}
2020

2121
protected getDefaultOptions(options: ScatterOptions) {
22-
const { shapeField, colorField, legend } = options;
22+
const { shapeField, colorField, legend, xField, yField, sizeField } = options;
2323
return deepMix({}, super.getDefaultOptions(), {
2424
size: 4,
2525
/** pointStyle 跟随主题默认样式 */
2626
tooltip: {
2727
shared: null,
2828
showTitle: false,
29+
fields: [xField, yField, colorField, sizeField, shapeField],
2930
},
3031
/**
3132
* legend 没有指定时根据 shapeField 和 colorField 来设置默认值

0 commit comments

Comments
 (0)