打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
echarts 树图tree 改为流程图

先上图:

 

 上代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../../../static/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../../static/js/echarts.min.4.2.1.js"></script>
    <!--<script type="text/javascript" src="../../../static/js/echarts.min.js"></script>-->
</head>
<body>

<!--流程图-->
<div id="processFlow" style="width: 100%;"></div>

</body>
<script>

    var _data = [];
    var _flows = [
        [
            {"name": "步骤1", "id": 87, "count": 2,},
            {"name": "步骤2", "id": 88, "count": 2,},
            {"name": "步骤3", "id": 89, "count": 2,},
            {"name": "步骤4", "id": 90, "count": 2,},
            {"name": "步骤5", "id": 91, "count": 2,}],
        [
            {"name": "步骤1", "id": 74, "count": 2,},
            {"name": "步骤1", "id": 75, "count": 2,},
            {"name": "步骤1", "id": 76, "count": 2,}
        ]
    ];

    $.each(_flows, function (i, v) {
        var _current;
        $.each(v.reverse(), function (j, k) {

            if (j === 0) {
                _current = {
                    "name": k.name,
                    "value": k.count ? k.count : 0
                }
            } else {
                _current = {
                    "name": k.name,
                    "value": k.count ? k.count : 0,
                    "children": [_current]
                }
            }

        })


        _data.push(_current)

    })


    /*以上是数据的操作,为了组成树形结构数据,可以忽略*/


    //每条流程高度100px  动态设置画布高度
    $('#processFlow').css('height', 100 * _data.length);


    var myChart = echarts.init(document.getElementById('processFlow'));

    var data = {
        "name": '流程',
        "value": 16,
        "children": _data
    };

    var option = {
        backgroundColor: '#cc2693',
        tooltip: {
            show: false,
            trigger: 'item',
            triggerOn: 'mousemove'
        },
        series: [
            {
                type: 'tree',
                id: 0,
                name: 'tree1',
                data: [data],
                layout: 'orthogonal',

                top: '10%',
                left: '8%',
                bottom: '22%',
                right: '20%',


                symbolSize: 7,

                edgeShape: 'polyline',
                edgeForkPosition: '63%',
                initialTreeDepth: -1,//初始展开的层级(深度)

                //小圆点
                itemStyle: {
                    color: '#C9924B',
                    borderColor: '#C9924B',
                },

                lineStyle: {
                    curveness: 0.5,//线的曲度
                    width: 2//线宽
                },

                label: {
                    backgroundColor: '#f2f2f2',
                    position: 'inside',
                    verticalAlign: 'middle',
                    align: 'center',
                    borderColor: '#e6e6e6',
                    borderWidth: 2,
                    borderRadius: 5,
                    padding: 5,
                    height: 40,
                    formatter: function (data) {
                        return ['{name| ' + data.name + ' }', '{value| ' + data.value + ' }'].join('\n');
                    },
                    rich: {//给不同的数据应用不同的样式
                        name: {
                            color: '#000',
                            fontSize: 14,
                            lineHeight: 20,
                        },
                        value: {
                            color: '#000',
                            fontSize: 14,
                            lineHeight: 20,
                            fontWeight: 'bold',
                        },
                    }
                },

                leaves: {
                    label: {
                        position: 'inside',
                        verticalAlign: 'middle',
                        align: 'center'
                    }
                },

                expandAndCollapse: false,
                animationDuration: 550,
                animationDurationUpdate: 750,
                roam: true,//是否开启鼠标缩放和平移漫游    如果版本太低的话  这里是不生效的   我用的是4.2.1
            }
        ]
    };


    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);



    window.onresize = function () {

        myChart.resize();

    }

</script>
</html>

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
echarts 怎么点击图例显示该折线,隐藏其他折线
PHP MySQL Echarts绘图实例
ECharts数据可视化:从0到1的蜕变(内部技术分享总结)
pyecharts和echarts的混合使用
事半功倍之Javascript [2]
PHP HTML JavaScript MySQL代码如何互相传值的方法分享
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服