MADE A PIE 之动态树形图

news2024/11/18 17:20:09

MADE A PIE api地址

他那个api里的代码可以直接拿过来用,只是他没有写怎么使用

使用时我发现如果节点太多会导致节点名称重叠,所以我在他这个基础之上加了一个放大缩小和随意拖动(dragstart,dragend,flTop,flLeft),如果对拖拽有需求可以看我之前文章

 <div
      class="app-wrapper"
      id="myChart"
      style="position: absolute;"
      :style="'width:' + flWidth + 'px;height:' + flHeight + 'px;top:' + flTop + 'px;left:' + flLeft + 'px'"
      draggable="true"
      @dragstart="dragstart1($event)"
      @dragend.stop="dragend($event)"
    >
    </div>

通过获取id使用

      var chartDom = document.getElementById('myChart');
      myChart = that.$echarts.init(chartDom);
      myChart.setOption(option);

在官方文档里使用的逻辑直接复制就可以正常使用了(option是初始化canvas数据)

下面是我是用的整个代码:

我在传了两个值(如果不需要直接改成固定值)

1.basicstateheight:画布高度

2.basicstateWidth:画布宽度

画布使用属性:(字段都是代码里的,可以直接搜索)

1.symbolSize:图标宽高

2.colork:线的颜色

3.source:标题内容

4.textStyle:标题样式

5.target:对应连线的点,和下一级的名字对应

6.links:包括线的颜色,流水线的颜色(link,line)

<template>
  <div
    ref="body"
    style="width: 100%;height: 100%;"
  >

    
    <div
      class="app-wrapper"
      id="myChart"
      style="position: absolute;"
      :style="'width:' + flWidth + 'px;height:' + flHeight + 'px;top:' + flTop + 'px;left:' + flLeft + 'px'"
      draggable="true"
      @dragstart="dragstart1($event)"
      @dragend.stop="dragend($event)"
    >
    </div>

  </div>
</template>

<script>
var option
var myChart
export default {
  name: 'ats',
  components: {},
  props: {
    basicstateheight: {
      type: Number,
      default: 500,
    },
    basicstateWidth: {
      type: Number,
      default: 1920,
    },
  },
  data() {
    return {
      flWidth: 1920,
      flHeight: 500,
      flLeft: 0,
      flTop: 0,
      left: 0,
      top: 0,
    }
  },
  computed: {
  },
  mounted() {
    // this.flHeight = this.dbodyheight
    var returninfo = initCharts(jsons);
    option = {
      backgroundColor: 'transparent',
      grid: {
      },
      xAxis: {
        show: false,
        type: 'value',
        max: returninfo.len[0] - 100,
        min: returninfo.len[1],
      },
      yAxis: {
        show: false,
        type: 'value',
        max: returninfo.leny[0],
        min: returninfo.leny[1],
      },
      tooltip: {},
      series: [
        {
          type: 'graph',
          zlevel: 5,
          draggable: false,
          coordinateSystem: 'cartesian2d', //使用二维的直角坐标系(也称笛卡尔坐标系)
          label: {
            show: true,
            color: '#fff',
            position: 'bottom',
          },
          data: returninfo.data,
          links: returninfo.links,
          lineStyle: {
            opacity: 1,
            width: 2,
          },
        },
        {
          type: 'lines',
          coordinateSystem: 'cartesian2d',
          zlevel: 1,
          animation: false,
          effect: {
            show: true,
            period: 10,
            trailLength: 0.01,
            symbolSize: 12,
            symbol: 'pin',
            loop: true,
          },
          data: returninfo.lines,
          lineStyle: {
            width: 0,
          },
        },


      ],
    };
    var that = this;
    setTimeout(function () {
    that.flHeight = that.basicstateheight
    that.flWidth = that.basicstateWidth
    console.log(that.flHeight, that.flWidth)
    }, 500)
    setTimeout(function () {
    console.log(that.basicstateheight)
      var chartDom = document.getElementById('myChart');
      myChart = that.$echarts.init(chartDom);
      myChart.setOption(option);
    }, 1000)
  },

  methods: {
    getData() {
  
    },
    btnjia() {
      this.flWidth = this.flWidth + 100
      this.flHeight = this.flHeight + 100
      console.log(this.flWidth)
      var chartDom = document.getElementById('myChart');
      myChart.dispose();
      myChart = this.$echarts.init(chartDom);
      myChart.setOption(option);
    },
    btnjian() {
      if (this.flHeight <= 100) return
      this.flWidth = this.flWidth - 100
      this.flHeight = this.flHeight - 100
      console.log(this.flWidth)
      var chartDom = document.getElementById('myChart');
      myChart.dispose();
      myChart = this.$echarts.init(chartDom);
      myChart.setOption(option);
    },
    dragstart1(e, item, index) {
      this.left = e.clientX * 1
      this.top = e.clientY * 1
    },
    // 停止拖拽位置
    dragend(e, item, index) {
      this.flLeft = this.flLeft + e.clientX - this.left
      this.flTop = this.flTop + e.clientY - this.top

    },
  }
}

var data = {
  children: [
    {
      children: [
        {
          code: '2',
          ifend: '11',
          name: '节点二21',
        },
        {
          ifend: '12',
          name: '节点二12',
        },
        {
          code: '2',
          ifend: '13',
          name: '节点二13',
        },
        {
          code: '2',
          name: '节点二14',
        }
      ],
      ifend: '1',
      name: '节点一1',
    },
    {
      children: [
        {
          code: '2',
          ifend: '21',
          name: '节点二21',
        },
        {
          ifend: '22',
          name: '节点二22',
        },
        {
          code: '2',
          ifend: '23',
          name: '节点二23',
        },
        {
          code: '2',
          name: '节点二24',
        }
      ],
      ifend: '2',
      name: '节点一2',
    },
    {
      children: [
        {
          code: '2',
          ifend: '31',
          name: '节点二31',
        },
        {
          ifend: '32',
          name: '节点二32',
        },
        {
          code: '2',
          ifend: '33',
          name: '节点二33',
        },
        {
          code: '2',
          name: '节点二34',
        }
      ],
      ifend: '3',
      name: '节点一3',
    },
    {
      children: [
        {
          code: '2',
          ifend: '41',
          name: '节点二41',
        },
        {
          ifend: '42',
          name: '节点二42',
        },
        {
          code: '2',
          ifend: '43',
          name: '节点二43',
        },
        {
          code: '2',
          name: '节点二44',
        }
      ],
      ifend: '4',
      name: '节点一4',
    },
    {
      children: [
        {
          code: '2',
          ifend: '51',
          name: '节点二51',
        },
        {
          ifend: '52',
          name: '节点二52',
        },
        {
          code: '2',
          ifend: '53',
          name: '节点二53',
        },
        {
          code: '2',
          name: '节点二54',
        }
      ],
      ifend: '5',
      name: '节点一5',
    },
    {
      children: [
        {
          code: '2',
          ifend: '61',
          name: '节点二61',
        },
        {
          ifend: '62',
          name: '节点二62',
        },
        {
          code: '2',
          ifend: '63',
          name: '节点二63',
        },
        {
          code: '2',
          name: '节点二64',
        }
      ],
      ifend: '6',
      name: '节点一6',
    },
    {
      children: [
        {
          code: '2',
          ifend: '71',
          name: '节点二71',
        },
        {
          ifend: '72',
          name: '节点二72',
        },
        {
          code: '2',
          ifend: '73',
          name: '节点二73',
        },
        {
          code: '2',
          name: '节点二74',
        }
      ],
      ifend: '7',
      name: '节点一7',
    }, {
      children: [
        {
          code: '2',
          ifend: '81',
          name: '节点二81',
        },
        {
          ifend: '82',
          name: '节点二82',
        },
        {
          code: '2',
          ifend: '83',
          name: '节点二83',
        },
        {
          code: '2',
          name: '节点二84',
        }
      ],
      ifend: '8',
      name: '节点一8',
    }, {
      children: [
        {
          code: '2',
          ifend: '91',
          name: '节点二91',
        },
        {
          ifend: '92',
          name: '节点二92',
        },
        {
          code: '2',
          ifend: '93',
          name: '节点二93',
        },
        {
          code: '2',
          name: '节点二94',
        }
      ],
      ifend: '9',
      name: '节点一9',
    }, {
      children: [
        {
          code: '2',
          ifend: '101',
          name: '节点二101',
        },
        {
          ifend: '102',
          name: '节点二102',
        },
        {
          code: '2',
          ifend: '103',
          name: '节点二103',
        },
        {
          code: '2',
          name: '节点二104',
        }
      ],
      ifend: '10',
      name: '节点一10',
    }, {
      children: [
        {
          code: '2',
          ifend: '111',
          name: '节点二111',
        },
        {
          ifend: '112',
          name: '节点二113',
        },
        {
          code: '2',
          ifend: '114',
          name: '节点二115',
        },
        {
          code: '2',
          name: '节点二116',
        }
      ],
      ifend: '111111',
      name: '节点一11',
    }
  ],
  name: '10号线控制中心',
  ifend: '0',
};
var jsons = format(data);
jsons = format2(jsons);

function format(data) {
  data.x = 0;
  data.y = 0;
  if (!data.hasOwnProperty('children')) {
    data.len = [1, -1];
    data.leny = [1, 9];
    return data;
  }
  var l2 = data.children;
  var hi = parseInt(l2.length / 2);
  var xi = l2.length - hi;
  var his = getSum(l2, 0, hi);
  var xis = getSum(l2, xi - 1, l2.length);
  l2 = sortData(l2, hi, xi);
  data.children = l2;
  var jhi = hi > 9 || his === 0 ? 300 : 200;
  var jxi = xi > 9 || xis === 0 ? 300 : 200;
  var maxmin = [-100000, 100000];
  var maxminy = [-100000, 100000];
  for (var i = 0; i < l2.length; i++) {
    if (i < hi) {
      l2[i].x = getLoction(hi, data.x, i + 1);
      l2[i].y = data.y + jhi;
      l2[i].fx = getFX(hi, i, false);
    } else {
      l2[i].x = getLoction(xi, data.x, i - hi + 1);
      l2[i].y = data.y - jxi;
      l2[i].fx = getFX(xi, i - hi, true);
    }
    getMaxMin(maxmin, l2[i].x);
    getMaxMin(maxminy, l2[i].y);
    if (!l2[i].hasOwnProperty('children')) {
      continue;
    }
    var l3 = l2[i].children;
    for (var j = 0; j < l3.length; j++) {
      if (i < hi) {
        l3[j].x = getLoction(l3.length, l2[i].x, j + 1);
        l3[j].y = l2[i].y + 200;
        l3[j].fx = getFX(l3.length, j, false);
      } else {
        l3[j].x = getLoction(l3.length, l2[i].x, j + 1);
        l3[j].y = l2[i].y - 200;
        l3[j].fx = getFX(l3.length, j, true);
      }
      getMaxMin(maxmin, l3[j].x);
      getMaxMin(maxminy, l3[j].y);
    }
  }
  var c;
  if (hi % 2 === 0) {
    c = hi / 2;
    if (l2[c].hasOwnProperty('children')) {
      if (l2[c - 1].hasOwnProperty('children') && l2[c].children[0].x < l2[c].x - 50) {
        var tem = 50 - l2[c].children[0].x;
        for (var j = 0; j < l2[c].children.length; j++) {
          l2[c].children[j].x = l2[c].children[j].x + tem;
          getMaxMin(maxmin, l2[c].children[j].x);
        }
        l2[c].x = getLoction2(l2[c].children);
      }
    }
  } else {
    c = parseInt(hi / 2);
  }
  for (var i = c + 1; i < hi; i++) {
    if (l2[i].hasOwnProperty('children')) {
      if (
        l2[i - 1].hasOwnProperty('children') &&
        l2[i - 1].children[l2[i - 1].children.length - 1].x - l2[i].children[0].x > -100
      ) {
        var tem = l2[i - 1].children[l2[i - 1].children.length - 1].x + 100 - l2[i].children[0].x;
        for (var j = 0; j < l2[i].children.length; j++) {
          l2[i].children[j].x = l2[i].children[j].x + tem;
          getMaxMin(maxmin, l2[i].children[j].x);
        }
        l2[i].x = getLoction2(l2[i].children);
      }
    }
  }
  for (var i = c - 1; i >= 0; i--) {
    if (l2[i].hasOwnProperty('children')) {
      if (
        l2[i + 1].hasOwnProperty('children') &&
        l2[i + 1].children[0].x - l2[i].children[l2[i].children.length - 1].x < 100
      ) {
        var tem = l2[i].children[l2[i].children.length - 1].x - (l2[i + 1].children[0].x - 100);
        for (var j = 0; j < l2[i].children.length; j++) {
          l2[i].children[j].x = l2[i].children[j].x - tem;
          getMaxMin(maxmin, l2[i].children[j].x);
        }
        l2[i].x = getLoction2(l2[i].children);
      }
    }
  }

  if (xi % 2 === 0) {
    c = xi / 2 + hi;
    if (l2[c].hasOwnProperty('children')) {
      if (l2[c - 1].hasOwnProperty('children') && l2[c].children[0].x < l2[c].x - 50) {
        var tem = 50 - l2[c].children[0].x;
        for (var j = 0; j < l2[c].children.length; j++) {
          l2[c].children[j].x = l2[c].children[j].x + tem;
          getMaxMin(maxmin, l2[c].children[j].x);
        }
        l2[c].x = getLoction2(l2[c].children);
      }
    }
  } else {
    c = parseInt(xi / 2) + hi;
  }
  for (var i = c + 1; i < l2.length; i++) {
    if (l2[i].hasOwnProperty('children')) {
      if (
        l2[i - 1].hasOwnProperty('children') &&
        l2[i - 1].children[l2[i - 1].children.length - 1].x - l2[i].children[0].x > -100
      ) {
        var tem = l2[i - 1].children[l2[i - 1].children.length - 1].x + 100 - l2[i].children[0].x;
        for (var j = 0; j < l2[i].children.length; j++) {
          l2[i].children[j].x = l2[i].children[j].x + tem;
          getMaxMin(maxmin, l2[i].children[j].x);
        }
        l2[i].x = getLoction2(l2[i].children);
      }
    }
  }
  for (var i = c - 1; i >= hi; i--) {
    if (l2[i].hasOwnProperty('children')) {
      if (
        l2[i + 1].hasOwnProperty('children') &&
        l2[i + 1].children[0].x - l2[i].children[l2[i].children.length - 1].x < 100
      ) {
        var tem = l2[i].children[l2[i].children.length - 1].x - (l2[i + 1].children[0].x - 100);
        for (var j = 0; j < l2[i].children.length; j++) {
          l2[i].children[j].x = l2[i].children[j].x - tem;
          getMaxMin(maxmin, l2[i].children[j].x);
        }
        l2[i].x = getLoction2(l2[i].children);
      }
    }
  }
  // data.x = (maxmin[0] - maxmin[1]) / 2 + maxmin[1];
  if (maxmin[0] - maxmin[1] <= 400) {
    maxmin[0] = maxmin[0] + 100;
    maxmin[1] = maxmin[1] - 100;
  }
  data.len = maxmin;
  data.leny = maxminy;
  return data;
}

function format2(data) {
  if (!data.hasOwnProperty('children')) {
    return data;
  }
  var l2 = data.children;
  var hi = parseInt(l2.length / 2);
  var xi = l2.length - hi;
  var maxmin = data.len;
  for (var i = 0; i < l2.length; i++) {
    if (!l2[i].hasOwnProperty('children')) {
      if (i > 0 && i != hi && l2[i - 1].hasOwnProperty('children') && l2[i - 1].children.length > 5) {
        var tem = (l2[i - 1].children.length - 5) / 2;
        l2[i].x = l2[i].x + 100 * tem;
        var len,
          flag = false;
        if (i < hi) {
          len = hi;
        } else {
          len = l2.length;
        }
        for (var j = i + 1; j < len; j++) {
          flag = true;
          l2[j].x = l2[j].x + 100 * tem;
          if (l2[j].hasOwnProperty('children')) {
            var children = l2[j].children;
            for (var k = 0; k < children.length; k++) {
              children[k].x = children[k].x + 100 * tem;
              getMaxMin(maxmin, children[k].x);
            }
          }
          getMaxMin(maxmin, l2[j].x);
        }
        if (flag) {
          l2[i].x = l2[i].x > maxmin[0] ? maxmin[0] : l2[i].x;
        }
      } else if (i < l2.length - 1 && l2[i + 1].hasOwnProperty('children') && l2[i + 1].children.length > 5) {
        var tem = (l2[i + 1].children.length - 5) / 2;
        l2[i].x = l2[i].x - 100 * tem;
        var len,
          flag = false;
        if (i < hi) {
          len = 0;
        } else {
          len = hi;
        }
        for (var j = i - 1; j >= len; j--) {
          flag = true;
          l2[j].x = l2[j].x - 100 * tem;
          if (l2[j].hasOwnProperty('children')) {
            var children = l2[j].children;
            for (var k = 0; k < children.length; k++) {
              children[k].x = children[k].x - 100 * tem;
              getMaxMin(maxmin, children[k].x);
            }
          }
          getMaxMin(maxmin, l2[j].x);
        }
        if (flag) {
          l2[i].x = l2[i].x < maxmin[1] ? maxmin[1] : l2[i].x;
        }
      }
    }
  }
  // data.x = (maxmin[0] - maxmin[1]) / 2 + maxmin[1];
  if (maxmin[0] - maxmin[1] <= 400) {
    maxmin[0] = maxmin[0] + 100;
    maxmin[1] = maxmin[1] - 100;
  }
  data.len = maxmin;
  return data;
}

function getLoction(num, x, index) {
  if (num % 2 === 0) {
    var c = num / 2 - index;
    x = x - 50 - 100 * c;
  } else {
    var c = parseInt(num / 2 + 1) - index;
    x = x - 100 * c;
  }
  return x;
}

function getLoction2(data) {
  var len = data.length;
  var x;
  if (len % 2 === 0) {
    var c = len / 2;
    x = data[c - 1].x + 50;
  } else {
    var c = parseInt(len / 2 + 1);
    x = data[c - 1].x;
  }
  return x;
}

function getFX(len, index, fx) {
  var x, c;
  if (len < 1) {
    return 1;
  }
  c = len % 2 === 0 ? len / 2 : parseInt(len / 2) + 1;
  x = index < c ? 1 : -1;
  if (fx) {
    x = -x;
  }
  return x;
}

function getSum(data, st, ed) {
  if (ed > data.length) {
    ed = data.length;
  }
  var count = 0;
  for (var i = st; i < ed; i++) {
    if (!data[i].hasOwnProperty('children')) {
      continue;
    }
    var l3 = data[i].children;
    count = count + l3.length;
  }
  return count;
}

function sortData(data, hi, xi) {
  var res = [];
  var len = hi - 1;
  var pos = 0;
  for (var i = 0; i < hi - 1; i++) {
    var flag = 1;
    for (var j = 0; j < len; j++) {
      var dx = !data[j].hasOwnProperty('children') ? 0 : data[j].children.length,
        dx1 = !data[j + 1].hasOwnProperty('children') ? 0 : data[j + 1].children.length;
      if (dx > dx1) {
        var tem = data[j];
        data[j] = data[j + 1];
        data[j + 1] = tem;
        flag = 0;
        pos = j;
      }
    }
    len = pos;
    if (flag === 1) {
      break;
    }
  }
  for (var i = 0; i < hi; i++) {
    if (i % 2 === 0) {
      res[i / 2] = data[i];
    } else {
      res[hi - (i + 1) / 2] = data[i];
    }
  }

  len = data.length - 1;
  pos = 0;
  for (var i = hi; i < data.length - 1; i++) {
    var flag = 1;
    for (var j = hi; j < len; j++) {
      var dx = !data[j].hasOwnProperty('children') ? 0 : data[j].children.length,
        dx1 = !data[j + 1].hasOwnProperty('children') ? 0 : data[j + 1].children.length;
      if (dx > dx1) {
        var tem = data[j];
        data[j] = data[j + 1];
        data[j + 1] = tem;
        flag = 0;
        pos = j;
      }
    }
    len = pos;
    if (flag === 1) {
      break;
    }
  }
  for (var i = 0; i < xi; i++) {
    if (i % 2 === 0) {
      res[i / 2 + hi] = data[i + hi];
    } else {
      res[xi - (i + 1) / 2 + hi] = data[i + hi];
    }
  }
  return res;
}

function getMaxMin(maxmin, x) {
  if (maxmin[0] < x) {
    maxmin[0] = x;
  }
  if (maxmin[1] > x) {
    maxmin[1] = x;
  }
  return maxmin;
}
function initCharts(returninfo) {
  var res = {};
  var links = [];
  var lines = [];
  var yiji =
    'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAxhJREFUWEftl9FLFFEUxr+zWghFreFbUZZBBEFeoRcpsnfBtZ3osY1mIF9K+weyfyCtl4LZaITems1ZsOcUq8eughQ9mAb5JrlJgcisN+/OzLa7TbJzp9TQedqduffMj+9895w5hG1+0Tbnwy5g3AztHAWvGLx9DRiViiWA3ucmm4qrntz/VxS8bPAMCQwRISmDCoGCIAy8MJkVFzI2oKbzIRD6Q0EEhu0sG4gDqQyYyvBkYyNGQejyAMQ3CEqVfpJwADro3ca466LXsVhBBVQJMPAbAa0eg5guNlDKeczm5f/UTd7aUBQOgc56zzGv6svIgCU4gVcVfhspuuivVUgq3NCIYSJcC3yZIFyKengiA2o6HwThrp++ATvLhjdKnabzfhCG/PX37CwbjJLqWIC2yerarxlc7AIGaalM8X+hYNljAmU/1t7b0hRrBh8HcBHAhG2yUk2svbdlgOsFblAQMn49/A1Q1j8SsNYbqndyBTb3FNeUizAFq5dsEmBXVSsLEMI8WIXntUI7y6Ql6r7qqmN1R/sHC3cGoP9lI09yuy/ilOtiQvULpjIRsRVMG/y2PM3Bx0PZkgIFeXpzJnsQJ/OxANMGf0pAZiMAAVg5k11XhVQGTN/gKUp4M0hTUwI93Udw5vSBEsfMh2Xkx75gZWXNK39r6M09YY4KpDKgZnAuPSfh7tw6hUP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93TPxqNrFQHwW4Sc/I9OCkBx71+v8B7AXRgDzlSkwAAAAASUVORK5CYII=';
  var data = [
    {
      name: returninfo.name + returninfo.ifend,//对应source: returninfo.name,否则无法连线
      tooltip: {
        formatter: '{b}',
      },
      symbol: yiji,
      symbolSize: [30, 30],
      value: [returninfo.x, returninfo.y],
      spid: returninfo.id,
    },
  ];
  if ('children' in returninfo) {
    var l2 = returninfo.children;
    var curveness, colork, colorn;
    for (var i = 0; i < l2.length; i++) {
      curveness = 0.1;
      colork = l2[i].code === '2' || l2[i].code === 2 ? '#D8D8D8' : '#53D4A8';
      var link = {
        source: returninfo.name + returninfo.ifend,//对应name: returninfo.name,否则无法连线
        target: l2[i].name,
        textStyle: {
          color: '#fff',
        },
        lineStyle: {
          curveness: curveness,
          color: colork,
        },
      };
      links.push(link);
      colorn = l2[i].code === '2' || l2[i].code === 2 ? 'transparent' : '#53D4A8';
      var line = {
        coords: [
          [returninfo.x, returninfo.y],
          [l2[i].x, l2[i].y],
        ],
        lineStyle: {
          curveness: curveness,
          color: colorn,
        },
      };
      lines.push(line);
      var node = {
        name: l2[i].name,
        tooltip: {
          formatter: '{b}',
        },
        symbol: erji,
        symbolSize: [30, 30],
        value: [l2[i].x, l2[i].y],
        ifend: l2[i].ifend,
        spid: l2[i].id,
      };
      data.push(node);
      if ('children' in l2[i]) {
        var l3 = l2[i].children;
        for (var j = 0; j < l3.length; j++) {
          curveness = l3[j].fx === 1 ? 0.1 : -0.1;
          colork = l3[j].code === '2' || l3[j].code === 2 ? '#D8D8D8' : '#53D4A8';
          var link = {
            source: l2[i].name,
            target: l3[j].name + l3[j].ifend,
            lineStyle: {
              curveness: curveness,
              color: colork,
            },
          };
          links.push(link);
          colorn = l3[j].code === '2' || l3[j].code === 2 ? 'transparent' : '#53D4A8';
          var line = {
            coords: [
              [l2[i].x, l2[i].y],
              [l3[j].x, l3[j].y],
            ],
            lineStyle: {
              curveness: curveness,
              color: colorn,
            },
          };
          lines.push(line);
          node = {
            name: l3[j].name + l3[j].ifend,
            tooltip: {
              formatter: '{b}',
            },
            symbol: sanji,
            symbolSize: [30, 30],
            value: [l3[j].x, l3[j].y],
            ifend: l3[j].ifend,
            spid: l3[j].id,
          };
          console.log(node);
          data.push(node);
        }
      }
    }
  }
  res.data = data;
  res.links = links;
  res.lines = lines;
  res.len = returninfo.len;
  res.leny = returninfo.leny;
  return res;
}
</script>

<style lang="scss" scoped>
.app-wrapper {
  height: 500px;
  width: 500px;
}

</style>

demo(WEB,小程序)(放在这是因为我不想干活,又想了解新东西)J1797Y

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2132970.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

收银员权限-收银系统源码

收银系统对于门店来说是收银员每天日常高频使用的软件工具&#xff0c;但很多门店老板不想给收银员开放很多权限&#xff0c;如商品改价、订单打折、会员充值、订单退款等都需要门店给其开通权限或者有权限码才能操作。 1. 收银员交接班 收银系统要支持交接班&#xff0c;收银…

OJ题——迷宫问题

&#x1f36c;个人主页&#xff1a;Yanni.— &#x1f308;数据结构&#xff1a;Data Structure.​​​​​​ &#x1f382;C语言笔记&#xff1a;C Language Notes &#x1f3c0;OJ题分享&#xff1a; Topic Sharing 前言&#xff1a; 在笔试或者竞赛的过程中&#xff0c;经…

剖析 MySQL 数据库连接池(C++版)

目录 ☀️0. 前言 &#x1f324;️1. 数据库连接池概述 ⛅1.1 服务器与数据库交互 ⛅1.2 MySQL 数据库网络模型 ⛅1.3 MySQL 连接驱动安装 ⛅1.4 同步&#xff08;synchronous&#xff09;连接池与异步&#xff08;asynchronous&#xff09;连接池 ⛅1.5 同步连接池和异…

Spring 循环依赖原理及解决方案

一、什么是循环依赖 循环依赖指的是一个实例或多个实例存在相互依赖的关系&#xff08;类之间循环嵌套引用&#xff09;。 举例&#xff1a; Component public class AService {// A中注入了BAutowiredprivate BService bService; }Component public class BService {// B中也…

通信工程学习:什么是PC永久连接、SPC软永久连接

一、PC永久连接 PC&#xff08;Permanent Connection&#xff09;永久连接是一种由网管系统通过网管协议建立的长期稳定的连接方式。在ASON&#xff08;自动交换光网络&#xff09;中&#xff0c;PC永久连接沿袭了传统光网络的连接建立形式&#xff0c;其特点主要包括&#xff…

【Canvas与密铺】正六边形、正方形和正三角形的密铺

【成图】 【代码】 <!DOCTYPE html> <html lang"utf-8"> <meta http-equiv"Content-Type" content"text/html; charsetutf-8"/> <head><title>正六边形正方形和正三角形的密铺1920x1080</title><style t…

SpringSecurity原理解析(四):SpringSecurity初始化过程

1、对 SpringSecurity初始化时的几个疑问 通过对前边一个请求流转的分析&#xff0c;我们知道一个请求要想到达服务端Servlet需要经过n多个 拦截器处理&#xff0c;请求处理流程如下所示&#xff1a; 对于一个请求到来后会通过FilterChainProxy来匹配一个对应的过滤器链来处理该…

PEST分析法包括哪些内容?用在线白板工具轻松绘制,简单好用!

在当今瞬息万变的商业环境中&#xff0c;企业需要一个全面而系统的方法来分析外部环境对其经营的影响。PEST分析模型恰好提供了这样一个强大的工具&#xff0c;帮助企业洞察政治、经济、社会和技术因素对其发展的潜在影响。 然而&#xff0c;如何高效地创建PEST分析模型一直是…

Unity 第一人称游戏的武器被其他物体覆盖解决方案

在第一人称游戏的时候&#xff0c;会出现渲染过程中&#xff0c;主角的手持武器可能会被其他物体挡住。 解决方法 在主摄像机下再创建一个摄像机&#xff0c;负责渲染不同图层 Main Camera的参数&#xff1a;我们这个摄像机不渲染equipable层&#xff08;自定义武器为equipab…

前后端分离项目实现SSE

SSE介绍 在日常web开发中经常会遇到查看数据最新状态的业务场景&#xff0c;例如查看任务状态与日志内容等。比较场景的解决方案是轮循和SSE。 Server-Sent Events (SSE) 是一种允许服务器通过单向通道向客户端推送更新的技术。它基于HTTP协议&#xff0c;客户端使用一个标准…

2024CCPC网络预选赛

vp链接&#xff1a;Dashboard - The 2024 CCPC Online Contest - Codeforces B. 军训 II 序列 a 从小到大排列或者从大到小排列时&#xff0c;不整齐度是最小的。方案数是所有相同数字的个数的排列数的乘积。如果首尾的数字不同的话&#xff0c;还要再乘个 2。 #include <…

Running setup.py install for wxPython did not run successfully.

Running setup.py install for wxPython did not run successfully. 欢迎来到英杰社区https://bbs.csdn.net/topics/617804998 欢迎来到我的主页&#xff0c;我是博主英杰&#xff0c;211科班出身&#xff0c;就职于医疗科技公司&#xff0c;热衷分享知识&#xff0c;武汉城市开…

axure循环介绍

一直在犹豫要不要写关于axure循环方面的介绍&#xff0c;因为循环的场景用其它方法都是可以实现的&#xff0c;今天还是用上次手机号码判断的案例来写一下循坏吧。 1、页面新建元件&#xff0c;手机号码输入框重命名为【手机号码输入框】按钮重命名为【按钮】再在页面拖动上来一…

python学习第八节:爬虫的初级理解

python学习第八节&#xff1a;爬虫的初级理解 爬虫说明&#xff1a;爬虫准备工作&#xff1a;分析网站url分析网页内容 爬虫获取数据&#xff1a;1.使用urllib库发起一个get请求2.使用urllib库发起一个post请求3.网页超时处理4.简单反爬虫绕过5.获取响应参数6.完整请求代码 解析…

【Python机器学习】长短期记忆网络(LSTM)

目录 随时间反向传播 实践 模型的使用 脏数据 “未知”词条的处理 字符级建模&#xff08;英文&#xff09; 生成聊天文章 进一步生成文本 文本生成的问题&#xff1a;内容不受控 其他记忆机制 更深的网络 尽管在序列数据中&#xff0c;循环神经网络为对各种语言关系…

Java项目: 基于SpringBoot+mybatis+maven医院管理系统(含源码+数据库+任务书+开题报告+毕业论文)

一、项目简介 本项目是一套基于SpringBootmybatismaven医院管理系统 包含&#xff1a;项目源码、数据库脚本等&#xff0c;该项目附带全部源码可作为毕设使用。 项目都经过严格调试&#xff0c;eclipse或者idea 确保可以运行&#xff01; 该系统功能完善、界面美观、操作简单、…

强化网络安全:通过802.1X协议保障远程接入设备安全认证

随着远程办公和移动设备的普及&#xff0c;企业网络面临着前所未有的安全挑战。为了确保网络的安全性&#xff0c;同时提供无缝的用户体验&#xff0c;我们的 ASP 身份认证平台引入了先进的 802.1X 认证协议&#xff0c;确保只有经过认证的设备才能接入您的网络。本文档将详细介…

【我的 PWN 学习手札】Fastbin Attack

关于fastbin&#xff0c;有很多攻击利用手法&#xff0c;本篇只是讲述了修改fd指针&#xff0c;分配到fake_chunk&#xff0c;更多利用手法拆分到后面的博客中 目录 前言 一、Fastbin保护检查机制 二、利用手法 &#xff08;1&#xff09;分配到任意地址&#xff08;__mall…

VScode相关问题与解决

1.写c文件时找不到头文件stdio.h 在linux下我们gcc命令来编译c文件时&#xff0c;会遇到找不到头文件的问题 解决方法&#xff1a;我们每写完一个文件记得保存一下文件即可&#xff0c;这样就解决了找不到头文件的问题&#xff01; 参考链接&#xff1a; /usr/bin/ld: /us…

Java实现生成验证码实战

文章目录 需求描述思想思路实现代码实现效果 在实际项目中&#xff0c;管理端的登录&#xff0c;会涉及验证码的校验&#xff0c;简单的数字与字母组合形式&#xff0c;在Java中要如何生成与实现&#xff0c;记录下来&#xff0c;方便备查。 需求描述 生成8位的由数字、大写字…