echarts的具体使用

我写的这些直接放到jsp页面上效果显示出来,显示出来就是中间一个园,牵引着四周的几个园,展示的就是这样的效果,需要的朋友可以拿走。不谢!

 

 

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
<!-- <style type="text/css">
        tr{height:30px;}
        td{width:40px;}
    </style>
  <script type="text/javascript" src="easyui/jquery-1.8.3.min.js"></script>
  <script type="text/javascript" src="easyui/jquery.form.js"></script> -->
<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="charts/echarts.js"></script>
</head>

<body>
    <div id="chart-panel" style="height:100%;width:100%;"></div>
    <script>
        var parList = echarts.init(document.getElementById('chart-panel'));
        var shan;//节点name
        var xiaa;//source               
        $(function() {
            var data = [
                   {"jgmc":"邮政","lt_status":"002"},
                   {"jgmc":"韵达 ","lt_status":"001"},
                   {"jgmc":"申通","lt_status":"001"},
                   {"jgmc":"圆通","lt_status":"001"}
                ];
            var dataArr = [];
            var linkArr = [];
            var formatData = function(data) {
                var temp = "本平台";
                /* for(var i=0;i<data.length;i++){
                    if(data[i].lt_status=="002"){
                        temp = data[i].jgmc;
                    }
                } */
                var cen = {
                        name : temp,
                        itemStyle : {
                            normal : {
                                color : '#f90', //圆点的颜色
                                label : {
                                    position : 'bottom',
                                    textStyle : {
                                        color : '#f90'
                                    }
                                }
                            }
                        }};
                dataArr.push(cen);
                for(var j = 0;j<data.length;j++){
                    //if(data[j].lt_status=="001"){
                        var obj = {
                                name : data[j].jgmc,
                                category : 0,
                                draggable : true
                        };
                        var link = {
                                source : temp,
                                target : data[j].jgmc,
                                value : "合作"
                        };
                        dataArr.push(obj);
                        linkArr.push(link);
                  //  }
                }
            }
            
            /* $.ajax({
                        url : '${pageContext.request.contextPath}/jkgl/yxjk/djxtjk/queryJkjgJSON.action',
                        data : {},
                        type : 'post',
                        async : true,
                        dataType : 'json',
                        success : function(da) {
                            shan = da.shang;
                            xiaa = da.xia;
                            alert(shan);}
                    }); */
            //初始化echarts
            var initEcharts = function(){
                option = {
                        tooltip : {
                            show : false
                        },
                        legend : {
                            x : "center",
                            data : [ "合作"]
                        },
                        animation : false,
                        series : [ {
                            categories : [ {
                                name : '合作',
                                itemStyle : {
                                    normal : {
                                        color : "#009800",
                                    }
                                }
                            } ],
                            type : 'graph',
                            layout : 'force',
                            symbol : "circle",
                            symbolSize : 50,
                            roam : true, //禁止用鼠标滚轮缩小放大效果
                            edgeSymbol: ['circle', 'arrow'],
                            edgeSymbolSize : [ 0, 10 ],
                            // 连接线上的文字
                            focusNodeAdjacency : true, //划过只显示对应关系
                            edgeLabel : {
                                normal : {
                                    show : true,
                                    textStyle : {
                                        fontSize : 20
                                    },
                                    formatter : "{c}"
                                }
                            },
                            categories : [ {
                                name : '合作',
                                itemStyle : {
                                    normal : {
                                        color : "#009800",
                                    }
                                }
                            } ],
                            lineStyle : {
                                normal : {
                                    opacity : 1,
                                    width : 2,
                                    curveness : 0
                                }
                            },
                            // 圆圈内的文字
                            label : {
                                normal : {
                                    show : true,
                                    formatter: '{b}'
                                }
                            },
                            force : {
                                repulsion : 5000
                            },
                            data : dataArr,
                            links : linkArr
                        } ]
                    };
                    parList.setOption(option);
                
            }
            //下面这两个放到ajax中就可以了。
            //格式化返回数据
            formatData(data);
            //加载关系图
            initEcharts();
        });
    </script>
</body>
</html>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值