d3+js横向图

<!doctype html>
<html>
<head>
    <meta charset="utf-8">

    <!-- <link rel="stylesheet" type="text/css" href="gqct.css"> -->
    <title>d3+jQuery横向树图</title>
    <script src="https://cdn.bootcss.com/d3/3.2.7/d3.min.js"></script>
    <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
</head>

<body>
<div class="container" id="treecontainer">
    <div class="menu">
        <div id="product_tree"></div>
    </div>
</div>
</body>
<script type="text/javascript">
    var container;
    var zoom;
    var rootData;
    var depthInfo;
    var rootName;//根节点名称

    jQuery(document).ready(function () {
   
        /* resizeScreen();*/

        //selectChange();
        var child=document.getElementById("product_tree");
        child.innerHTML = '';
        getData();
    });

    var getData =function() {
   
        rootData ={
   
    "downward": {
   
        "orderId": "94970e083e9c4b36a821fc0ebd65cf7b",
        "children": [
            {
   
                "isExpand": true,
                "amount": "物流送往公司",
                "orderId": "94970e083e9c4b36a821fc0ebd65cf7b",
                "children": [
                    {
   
                        "isExpand": true,
                        "amount": "物流送达公司",
                        "orderId": "94970e083e9c4b36a821fc0ebd65cf7b",
                        "children": [
                            {
   
                                "isExpand": true,
                                "amount": "00000021",
                                "orderId": "94970e083e9c4b36a821fc0ebd65cf7b",
                                "children": [
                                    
                                ],
                                "hasChildren": true,
                                "name": "00000021样本指派到实验室",
                                "text": "",
                                "hasHumanholding": true,
                                "ratio": ""
                            },
                            {
   
                                "isExpand": true,
                                "amount": "2020-08-06 09:36:28",
                                "orderId": "94970e083e9c4b36a821fc0ebd65cf7b",
                                "children": [
                                    
                                ],
                                "hasChildren": true,
                                "name": "物流测试账号派送中",
                                "text": "",
                                "hasHumanholding": true,
                                "ratio": "00000021"
                            },
                            {
   
                                "isExpand": true,
                                "amount": "2020-08-06 09:40:09",
                                "orderId": "94970e083e9c4b36a821fc0ebd65cf7b",
                                "children": [
                                    
                                ],
                                "hasChildren": true,
                                "name": "技术员测试账号审核通过",
                                "text": "驻点",
                                "hasHumanholding": true,
                                "ratio": "00000021"
                            },
                            {
   
                                "isExpand": true,
                                "amount": "2020-08-06 10:28:00",
                                "orderId": "94970e083e9c4b36a821fc0ebd65cf7b",
                                "children": [
                                    
                                ],
                                "hasChildren": true,
                                "name": "技术员测试账号质检通过",
                                "text": "",
                                "hasHumanholding": true,
                                "ratio": "00000021"
                            }
                        ],
                        "hasChildren": true,
                        "name": "测试账号签收",
                        "text": "",
                        "hasHumanholding": true,
                        "ratio": "2020-08-06"
                    }
                ],
                "hasChildren": true,
                "name": "物流测试账号签收",
                "text": "22222",
                "hasHumanholding": true,
                "ratio": "12312312312"
            }
        ],
        "name": "origin",
        "direction": "downward"
    }
}
        rootName = '科技有限公司';
        drawing();
    };
    var	drawing = function() {
   
        var _this = this;
        // var rootName = ''; //根节点的名字
        var rootRectWidth = 0; //根节点rect的宽度
        var forUpward = true;

        var treeChart = function(d3Object) {
   
            this.d3 = d3Object;
            this.directions = ['downward'];
        };


        treeChart.prototype.drawChart = function() {
   
            // First get tree data for both directions.
            this.treeData = {
   };
            var self = this;
            self.directions.forEach(function(direction) {
   
                self.treeData[direction] = _this.rootData[direction];
            });
            // rootName = '北京伴学科技有限公司';
            rootRectWidth = _this.rootName.length * 15;
            self.graphTree(self.getTreeConfig());
        };

        treeChart.prototype.getTreeConfig = function() {
   
            var treeConfig = {
   
                'margin': {
   
                    'top': 10,
                    'right': 5,
                    'bottom'
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冒菜-码农

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值