antvis/G2







The issue has been closed
[v5 求助]: 为什么加了scale 图表就坏了? #4440
Valar103769 posted onGitHub
https://g2.antv.antgroup.com/examples/general/line#line-connect-nulls
/**
* A recreation of this demo: https://observablehq.com/@d3/line-with-missing-data
*/
import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
autoFit: true,
});
const data = [
{
"hour": "2022-12-09 16",
"recharge_orders": 18,
"total_row": false,
"user_group": "新用户"
},
{
"hour": "2022-12-09 16",
"recharge_orders": 39,
"total_row": false,
"user_group": "次新用户"
},
]
chart.line()
.data(data)
.encode('x', 'hour')
.encode('y', 'recharge_orders')
.encode('color', 'user_group')
.axis('x', {
title: '时间',
})
.scale('x', {
type: 'time',
mask: 'YY',
/* 其他配置项 */
})
.interaction({
type: 'tooltip',
shared: true,
})
.interaction({ type: 'elementHighlight' }) // 图形高亮
chart.render()