d3 tree 项目实例一

效果图

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>d3 tree</title>
    <style type="text/css">
        /* svg style */
.node circle {
    fill: #fff;
    stroke: steelblue;
    stroke-width: 3px;
}

.node text {
    font: 12px sans-serif;
}

.link {
    fill: none;
    stroke: #ccc;
    stroke-width: 2px;
}

    </style>
</head>
<body>
<div id="chart"></div>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/d3.min.js"></script> 
<script type="text/javascript" src="js/tree.js"></script>   
</body>
</html>

json

{
    "success": true,
    "data": {
        "1": {
            "id": "1",
            "parent": "0",
            "title": "根节点",
            "url": "NULL",
            "status": "0",
            "shape": "root",
            "product_id": "0",
            "checkIfTrendAvailable": true,
            "checkIfHeatAvailable": false
        },
        "2": {
            "id": "2",
            "parent": "1",
            "title": "一级节点1",
            "url": "NULL",
            "status": "1",
            "shape": "suqare",
            "product_id": "300000001",
            "checkIfTrendAvailable": false,
            "checkIfHeatAvailable": false
        },
        "3": {
            "id": "3",
            "parent": "2",
            "title": "三级节点1",
            "url": "NULL",
            "status": "1",
            "shape": "square",
            "product_id": "0",
            "checkIfTrendAvailable": false,
            "checkIfHeatAvailable": false
        },
        "4": {
            "id": "4",
            "parent": "2",
            "title": "三级节点2",
            "url": "NULL",
            "status": "1",
            "shape": "square",
            "product_id": "0",
            "checkIfTrendAvailable": false,
            "checkIfHeatAvailable": false
        },
        "5": {
            "id": "5",
            "parent": "14",
            "title": "子节点1",
            "url": "NULL",
            "status": 1,
            "shape": "round",
            "product_id": "0",
            "checkIfTrendAvailable": true,
            "checkIfHeatAvailable": false
        },
        "6": {
            "id": "6",
            "parent": "14",
            "title": "子节点2",
            "url": "NULL",
            "status": 0,
            "shape": "round",
            "product_id": "0",
            "checkIfTrendAvailable": true,
            "checkIfHeatAvailable": false
        },
        "7": {
            "id": "7",
            "parent": "14",
            "title": "子节点3",
            "url": "NULL",
            "status": 0,
            "shape": "round",
            "product_id": "0",
            "checkIfTrendAvailable": true,
            "checkIfHeatAvailable": false
        },
        "8": {
            "id": "8",
            "parent": "14",
            "title": "子节点4",
            "url": "NULL",
            "status": 0,
            "shape": "round",
            "product_id": "0",
            "checkIfTrendAvailable": true,
            "checkIfHeatAvailable": false
        },
        "9": {
            "id": "9",
            "parent": "14",
            "title": "子节点5",
            "url": "NULL",
            "status": 0,
            "shape": "round",
            "product_id": "0",
            "checkIfTrendAvailable": true,
            "checkIfHeatAvailable": false
        },
        "10": {
            "id": "10",
            "parent": "14",
            "title": "子节点6",
            "
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值