折线图示例
import React, { useEffect } from 'react';
import { Line } from '@antv/g2plot';
function LineCharts() {
useEffect(() => {
fetch('https://gw.alipayobjects.com/os/bmw-prod/55424a73-7cb8-4f79-b60d-3ab627ac5698.json')
.then((res) => res.json())
.then((data) => {
const line = new Line('container', {
data,
xField: 'year',
yField: 'value',
seriesField: 'category',
xAxis: {
type: 'time',
},
yAxis: {
label: {
formatter: (v) => `${v}`.replace(/\d{1,3}(?=(\d{3})+$)/g, (s) => `${s},`),
},
tickInterval:1900,
},
});
line.render();
});
}, [])
return <div>
<div className="container" id='container'></div>
</div>
}
export default LineCharts;