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

相关推荐
渣渣xiong25 分钟前
从零开始:前端转型AI agent直到就业第五天-第十一天
前端·人工智能
布局呆星32 分钟前
Vue3 | 组件通信学习小结
前端·vue.js
C澒35 分钟前
IntelliPro 企业级产研协作平台:前端智能生产模块设计与落地
前端·ai编程
OpenTiny社区2 小时前
重磅预告|OpenTiny 亮相 QCon 北京,共话生成式 UI 最新技术思考
前端·开源·ai编程
前端老实人灬2 小时前
web前端面试题
前端
Moment2 小时前
AI 全栈指南:NestJs 中的 Service Provider 和 Module
前端·后端·面试
IT_陈寒2 小时前
为什么我的JavaScript异步回调总是乱序执行?
前端·人工智能·后端
Moment2 小时前
AI全栈入门指南:NestJs 中的 DTO 和数据校验
前端·后端·面试
小码哥_常2 小时前
告别RecyclerView卡顿!8个优化技巧让列表丝滑如德芙
前端
小村儿2 小时前
Harness Engineering:为什么你用 AI 越用越累?
前端·后端·ai编程