echarts树图-树效果展示

echarts树图实现数据以树的结构展示,其效果如下:

代码如下:

javascript 复制代码
const data = {
  name: 'XXX公司',
  itemStyle: {
    color: '#00ADD0'
  },
  children: [
    {
      name: '网络主机',
      itemStyle: {
        color: '#FFA12F'
      },
      children: [
        {
          name: '普通路由器',
          itemStyle: {
            color: '#604BFF'
          },
          children: [
            {
              name: '智能网关',
              itemStyle: {
                color: '#95F300'
              }
            },
            {
              name: '192.168.1.0/24'
            }
          ]
        }
      ]
    },
    {
      name: '企业路由器'
    },
    {
      name: '三级交换机'
    }
  ]
};
option = {
  tooltip: {
    trigger: 'item',
    triggerOn: 'mousemove'
  },
  series: [
    {
      type: 'tree',
      data: [data],
      left: '2%',
      right: '2%',
      top: '8%',
      bottom: '20%',
      symbol: 'square',
      symbolSize: [30, 30],
      edgeShape: 'polyline',
      orient: 'vertical',
      expandAndCollapse: true,
      initialTreeDepth: 3,
      roam: true, //是否开启鼠标缩放和平移漫游。scale/move/true
      label: {
        position: 'top',
        rotate: 0,
        verticalAlign: 'middle',
        align: 'center',
        fontSize: 12,
        distance: 8,
      },
      itemStyle: {
        color: '#00ADD0'
      },
      leaves: {
        label: {
          position: 'bottom',
          rotate: -90,
          verticalAlign: 'middle',
          align: 'left'
        }
      },
      animationDurationUpdate: 150
    }
  ]
};

备注:可以在echarts官网示例中运行:https://echarts.apache.org/examples/zh/editor.html?c=tree-vertical

相关推荐
2601_958492552 小时前
Optimizing Engagement with Freehead Skate - HTML5 Game - Construct 3
前端·html·html5
茉莉玫瑰花茶3 小时前
工作流的常见模式 [ 1 ]
java·服务器·前端
zhangxingchao3 小时前
AI应用开发六:企业知识库
前端·人工智能·后端
山峰哥4 小时前
SQL慢查询调优实战:从全表扫描到索引覆盖的完整复盘
前端·数据库·sql·性能优化
红尘散仙4 小时前
一个 `#[uniffi::export]`,把 Rust 接进 React Native
前端·后端·rust
moshuying4 小时前
AI Coding 最大的 token 黑洞,可能根本不是 prompt
前端
红尘散仙4 小时前
一行 `#[specta::specta]`,让 Tauri IPC 有类型
前端·后端·rust
lichenyang4534 小时前
HarmonyOS HMRouter 接入记录:从普通 Tab Demo 到路由跳转
前端
木斯佳5 小时前
前端八股文面经大全:腾讯WXG暑期前端一面(2026-05-15)·面经深度解析
前端·面试·笔试