Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add national day image #6475

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions site/examples/interesting/interesting/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
"en": "Timeline"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*NUHAS79kw-kAAAAAAAAAAAAADmJ7AQ/fmt.webp"
},
{
"filename": "national.ts",
"title": {
"zh": "国庆节头像",
"en": "National Image"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*8RvJQJzRMMsAAAAAAAAAAAAADmJ7AQ/fmt.webp"
}
]
}
47 changes: 47 additions & 0 deletions site/examples/interesting/interesting/demo/national.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Chart } from '@antv/g2';

const SIZE = 256;

const chart = new Chart({
container: 'container',
width: SIZE,
height: SIZE,
});

const FLAG_TEMPLATE = [
'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*FpxcQI7WEusAAAAAAAAAAAAADmJ7AQ/original',
'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*rx6ST7V6cA0AAAAAAAAAAAAADmJ7AQ/original',
'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*7rKcTJiP1rMAAAAAAAAAAAAADmJ7AQ/original',
'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*_GUISa64kgYAAAAAAAAAAAAADmJ7AQ/original',
'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*Wwy8TJAoCeUAAAAAAAAAAAAADmJ7AQ/original',
'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*DphFRIpOYWQAAAAAAAAAAAAADmJ7AQ/original',
];

// 换成你自己的,可以使用远程 CDN 地址,也可以使用 Base64 编码
const MY_PHOTO =
'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*vYY6RrxEWKwAAAAAAAAAAAAADmJ7AQ/original';

chart
.image()
.data([{ x: 0.5, y: 0.5 }])
.encode('x', 'x')
.encode('y', 'y')
.encode('src', MY_PHOTO)
.encode('size', SIZE)
.axis(false)
.tooltip(false);

chart
.image()
.data([{ x: 0.5, y: 0.5 }])
.encode('x', 'x')
.encode('y', 'y')
.encode(
'src',
() => FLAG_TEMPLATE[Math.floor(Math.random() * FLAG_TEMPLATE.length)],
)
.encode('size', SIZE)
.axis(false)
.tooltip(false);

chart.render();
Loading