-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(charts): Add autoFit demo for Line
- Loading branch information
1 parent
ea73549
commit 0056ca6
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { Line } from '@oceanbase/charts'; | ||
|
||
export default () => { | ||
const [data, setData] = useState([]); | ||
const asyncFetch = () => { | ||
fetch('https://gw.alipayobjects.com/os/bmw-prod/55424a73-7cb8-4f79-b60d-3ab627ac5698.json') | ||
.then(response => response.json()) | ||
.then(json => setData(json)) | ||
.catch(error => { | ||
console.log('fetch data failed', error); | ||
}); | ||
}; | ||
useEffect(() => { | ||
asyncFetch(); | ||
}, []); | ||
const config = { | ||
data, | ||
xField: 'year', | ||
yField: 'value', | ||
seriesField: 'category', | ||
xAxis: { | ||
type: 'time', | ||
}, | ||
yAxis: { | ||
label: { | ||
// 数值格式化为千分位 | ||
formatter: v => `${v}`.replace(/\d{1,3}(?=(\d{3})+$)/g, s => `${s},`), | ||
}, | ||
}, | ||
style: { | ||
height: '50vh', | ||
}, | ||
}; | ||
return <Line {...config} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters