echarts甘特图

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Gattery</title>
    <script src="./node_modules/echarts/dist/echarts.min.js"></script>
</head>

<body>
    <div id='main' style="width:1300px;height:600px"></div>
    <script>
        // 基于准备好的dmo,初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
        // 指定图表的配置项和数据
        var option = option = {
            title: {
                text: '项目实施进度表',
                left: 10
            },
            legend: {
                data: ['计划实施时间', '实际实施时间']

            },
            grid: {
                containLabel: true,
                left: 20
            },
            xAxis: {
                type: 'time'
            },

            yAxis: {

                data: ['任务一', '任务二', '任务三', '任务四', '任务五', '任务六', '任务七']

            },
            tooltip: {
                trigger: 'axis',
                formatter: function (params) {
                    var res = params[0].name + "</br>"
                    var date0 = params[0].data;
                    var date1 = params[1].data;
                    var date2 = params[2].data;
                    var date3 = params[3].data;
                    date0 = date0.getFullYear() + "-" + (date0.getMonth() + 1) + "-" + date0.getDate();
                    date1 = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate();
                    date2 = date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate();
                    date3 = date3.getFullYear() + "-" + (date3.getMonth() + 1) + "-" + date3.getDate();
                    res += params[0].seriesName + "~" + params[1].seriesName + ":</br>" + date0 + "~" + date1 + "</br>"
                    res += params[2].seriesName + "~" + params[3].seriesName + ":</br>" + date2 + "~" + date3 + "</br>"
                    console.log(params[0]);
                    return res;
                }
            },
            series: [
                {
                    name: '计划开始时间',
                    type: 'bar',
                    stack: 'test1',
                    itemStyle: {
                        normal: {
                            color: 'rgba(0,0,0,0)'
                        }
                    },
                    data: [
                        new Date("2015/09/2"),
                        new Date("2015/09/15"),
                        new Date("2015/09/15"),
                        new Date("2015/10/03"),
                        new Date("2015/10/04"),
                        new Date("2015/10/05"),
                        new Date("2015/10/06")
                    ]
                },
                {
                    name: '计划完成时间',
                    type: 'bar',
                    stack: 'test1',
                    itemStyle: {
                        normal: {
                            color   
                        }
                    },
                    data: [
                        new Date("2015/09/12"),
                        new Date("2015/09/20"),
                        new Date("2015/09/25"),
                        new Date("2015/10/05"),
                        new Date("2015/10/07"),
                        new Date("2015/10/09"),
                        new Date("2015/10/12")
                    ]
                },
                {
                    name: '实际开始时间',
                    type: 'bar',
                    stack: 'test2',
                    itemStyle: {
                        normal: {
                            color: 'rgba(0,0,0,0)'
                        }
                    },
                    data: [
                        new Date("2015/09/2"),
                        new Date("2015/09/15"),
                        new Date("2015/09/15"),
                        new Date("2015/10/03"),
                        new Date("2015/10/04"),
                        new Date("2015/10/05"),
                        new Date("2015/10/06")
                    ]
                },
                {
                    name: '实际完成时间',
                    type: 'bar',
                    stack: 'test2',
                    data: [
                        new Date("2015/09/6"),
                        new Date("2015/09/20"),
                        new Date("2015/09/27"),
                        new Date("2015/10/11"),
                        new Date("2015/10/16"),
                        new Date("2015/10/18"),
                        new Date("2015/10/17")
                    ]
                }
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
</body>

</html>

这里面尤其要注意的是echarts的版本,经过测试,echarts版本大于4.0.2之后,工作流程图color:rgba(0,0,0,0)显示没有效果

文章的内容主要来自于http://gallery.echartsjs.com/editor.html?c=xryzwi7fVl,内容来自于该作者,我只是测试版本使用

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值