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

相关推荐
集成显卡1 小时前
PlayWright | 初识微软出品的 WEB 应用自动化测试框架
前端·chrome·测试工具·microsoft·自动化·edge浏览器
前端小趴菜052 小时前
React - 组件通信
前端·react.js·前端框架
Amy_cx2 小时前
在表单输入框按回车页面刷新的问题
前端·elementui
dancing9992 小时前
cocos3.X的oops框架oops-plugin-excel-to-json改进兼容多表单导出功能
前端·javascript·typescript·游戏程序
后海 0_o3 小时前
2025前端微服务 - 无界 的实战应用
前端·微服务·架构
Scabbards_3 小时前
CPT304-2425-S2-Software Engineering II
前端
小满zs3 小时前
Zustand 第二章(状态处理)
前端·react.js
程序猿小D3 小时前
第16节 Node.js 文件系统
linux·服务器·前端·node.js·编辑器·vim
萌萌哒草头将军3 小时前
🚀🚀🚀Prisma 发布无 Rust 引擎预览版,安装和使用更轻量;支持任何 ORM 连接引擎;支持自动备份...
前端·javascript·vue.js
狼性书生3 小时前
uniapp实现的简约美观的星级评分组件
前端·uni-app·vue·组件