Skip to content

Commit

Permalink
docs: add scrollbar demo #5688 (#5707)
Browse files Browse the repository at this point in the history
  • Loading branch information
BENcorry authored Nov 1, 2023
1 parent b41c36b commit 4b27ba7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
16 changes: 16 additions & 0 deletions site/examples/component/scrollbar/demo/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": {
"zh": "中文分类",
"en": "Category"
},
"demos": [
{
"filename": "scrollbar.ts",
"title": {
"zh": "滚动条",
"en": "Scrollbar"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*ompnRpW0vycAAAAAAAAAAAAADmJ7AQ/original"
}
]
}
30 changes: 30 additions & 0 deletions site/examples/component/scrollbar/demo/scrollbar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Chart } from '@antv/g2';

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

chart
.line()
.data({
type: 'fetch',
value:
'https://gw.alipayobjects.com/os/bmw-prod/551d80c6-a6be-4f3c-a82a-abd739e12977.csv',
})
.encode('x', 'date')
.encode('y', 'close')
// 开启 X 轴方向上的滚动条
.scrollbar('x', {})
.scrollbar('y', { value: 0.2 });

chart.on('afterrender', () => {
const { canvas } = chart.getContext();
const { document } = canvas;
document
.querySelector('.g2-scrollbar')
.addEventListener('valuechange', (evt) => {
console.info(evt.detail);
});
});

chart.render();
4 changes: 4 additions & 0 deletions site/examples/component/scrollbar/index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: 滚动条
order: 5
---
4 changes: 4 additions & 0 deletions site/examples/component/scrollbar/index.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Scrollbar
order: 5
---

0 comments on commit 4b27ba7

Please sign in to comment.