/** @jsx jsx */
import { jsx, Canvas, Chart, Line, Axis, Legend, ScrollBar, Point } from '@antv/f2';
import _ from 'lodash';
fetch('https://gw.alipayobjects.com/os/antfincdn/OVMtvjbnut/series-line.json')
.then((res) => res.json())
.then((data) => {
const context = document.getElementById('container').getContext('2d');
const { props } = (
<Canvas context={context} pixelRatio={window.devicePixelRatio}>
<Chart data={data}>
<Axis
field="date"
tickCount={3}
style={{
label: { align: 'between' },
}}
/>
<Axis field="value" tickCount={5} />
<Line x="date" y="value" lineWidth="4px" color="type" />
<Legend
position="top"
style={{
justifyContent: 'space-around',
}}
triggerMap={{
press: (items, records, legend) => {
const map = {};
items.forEach((item) => (map[item.name] = _.clone(item)));
records.forEach((record) => {
map[record.type].value = record.value;
});
legend.setItems(_.values(map));
},
pressend: (items, records, legend) => {
legend.setItems(items);
},
}}
/>
<Point
x="date"
y="value"
color={['type', ['#FFC22D', '#00CF7B']]}
shape="hollowCircle"
style={{
fill: '#ffffff',
lineWidth: 2,
strokeOpacity: 1
}}
/>
<ScrollBar mode="x" range={[0, 0.2]} />
</Chart>
</Canvas>
);
const chart = new Canvas(props);
chart.render();
});
多折线的情况下,使用Point,并且带有滚动的情况下,Point 显示异常。
文档示例:https://f2.antv.antgroup.com/examples/line/multiple/#series
代码片段在最后。
左侧为初始渲染,右侧是滚动几下后,会随机显示出所有点。有时候这些点闪烁一下就消失了。
以下代码,粘贴到文档示例中即可复现。
文档示例:https://f2.antv.antgroup.com/examples/line/multiple/#series