欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

G2画图表

程序员文章站 2022-04-21 21:38:08
...
var list= [{xAxis: "周一", name: "规划局", ynum: 10}
{xAxis: "周二", name: "规划局", ynum: 15}
{xAxis: "周三", name: "规划局", ynum: 20}
{xAxis: "周四", name: "规划局", ynum: 9}
{xAxis: "周五", name: "规划局", ynum:35}
{xAxis: "周六", name: "规划局", ynum: 40}
{xAxis: "周日", name: "规划局", ynum: 7}

{xAxis: "周一", name: "撒旦法", ynum: 5}
{xAxis: "周二", name: "撒旦法", ynum: 8}
{xAxis: "周三", name: "撒旦法", ynum: 15}
 {xAxis: "周四", name: "撒旦法", ynum: 6}
 {xAxis: "周五", name: "撒旦法", ynum: 30}
 {xAxis: "周六", name: "撒旦法", ynum: 23}
 {xAxis: "周日", name: "撒旦法", ynum: 14} ]
           chart = new Chart({
                container: 'c1',
                autoFit: true,
                height: 500,
            })
            chart.data(list)
            chart.scale({
                xAxis: {
                    range: [0, 1],
                },
                ynum: {
                    nice: true,
                },
            })

            chart.tooltip({
                showCrosshairs: true,
                shared: true,
            })

            chart
                .line()
                .position('xAxis*ynum')
                .color('name')
                .shape('smooth')

            chart
                .point()
                .position('xAxis*ynum')
                .color('name')
                .shape('circle')

            chart.render()
            // 初始化表格后加入这段代码,使图表自适应
            const e = document.createEvent('Event')
            e.initEvent('resize', true, true)
            window.dispatchEvent(e)
相关标签: antV G2