king
2023-06-19 5b74d645d1f10db0143d5eb23d79253314fe7d5b
2023-06-19
1个文件已修改
85 ■■■■■ 已修改文件
src/tabviews/custom/components/chart/antv-G6/index.jsx 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/chart/antv-G6/index.jsx
@@ -814,6 +814,8 @@
  }
  data = []
  mkgraph = null
  selectedId = ''
  UNSAFE_componentWillMount () {
    const { config, data, initdata } = this.props
@@ -1188,6 +1190,16 @@
    root = this.getTree(root, _options, root)
    root.children = root.children || []
    if (root.selectedItem) {
      let option = {...root.selectedItem}
      setTimeout(() => {
        MKEmitter.emit('resetSelectLine', config.uuid, option.id, option)
      }, 20)
      delete root.selectedItem
    } else {
      this.selectedId = ''
    }
    if (plot.subtype === 'mindmap') {
      root.type = 'dice-mind-map-root'
@@ -1255,6 +1267,12 @@
    options = options.filter(option => {
      if (option.$parentId === parent.id) {
        delete option.$parentId
        if (this.selectedId && option.id === this.selectedId) {
          root.selectedItem = {...option}
          option.selected = true
        }
        parent.children.push(option)
        root.nodeNumber++
@@ -1278,19 +1296,22 @@
  }
  handleData = () => {
    let _element = document.getElementById(this.state.chartId)
    if (_element) {
      _element.innerHTML = ''
    }
    const { config } = this.state
    setTimeout(() => {
    MKEmitter.emit('resetSelectLine', config.uuid, '', '')
    if (this.mkgraph) {
      this.mkgraph.clear()
      this.resetrender()
    } else {
      this.viewrender()
    }, 100)
    }
  }
  viewrender = () => {
    const { plot } = this.state
    this.selectedId = ''
    if (this.data.length === 0) {
      this.setState({empty: true})
    } else {
@@ -1302,6 +1323,44 @@
        this.indentrender()
      } else if (plot.subtype === 'kapmap') {
        this.kapmaprender()
      }
    }
  }
  resetrender = () => {
    const { plot } = this.state
    if (this.data.length === 0) {
      this.setState({empty: true})
      this.selectedId = ''
    } else {
      this.setState({empty: false})
      const data = this.getdata()
      if (plot.subtype === 'mindmap') {
        this.mkgraph.data(data)
        this.mkgraph.render()
        const width = this.wrap.scrollWidth - 30
        if (plot.collapsed === 'true' && plot.dirField) {
          this.mkgraph.zoomTo(1, { x: width / 2, y: plot.height / 2 })
        } else if (plot.collapsed === 'true' || data.nodeNumber < 5) {
          this.mkgraph.zoomTo(1, { x: 0, y: plot.height / 2 })
        }
      } else if (plot.subtype === 'indentTree') {
        this.mkgraph.data(dataIndTransform(data))
        this.mkgraph.render()
      } else if (plot.subtype === 'kapmap') {
        this.mkgraph.data(data)
        this.mkgraph.render()
        this.mkgraph.fitView()
        if (plot.collapsed === 'true' || data.nodeNumber < 5) {
          this.mkgraph.zoomTo(1, { x: 0, y: plot.height / 2 })
        }
      }
    }
  }
@@ -1364,6 +1423,8 @@
    if (plot.collapsed === 'true' || data.nodeNumber < 5) {
      graph.zoomTo(1, { x: 0, y: plot.height / 2 })
    }
    this.mkgraph = graph
  }
  indentrender = () => {
@@ -1425,6 +1486,8 @@
    tree.data(dataIndTransform(data))
    
    tree.render()
    this.mkgraph = tree
  }
  /**
@@ -1487,12 +1550,17 @@
    } else if (plot.collapsed === 'true' || data.nodeNumber < 5) {
      tree.zoomTo(1, { x: 0, y: plot.height / 2 })
    }
    this.mkgraph = tree
  }
  handleClick = (data = null) => {
    const { plot, config } = this.state
    
    if (plot.click && !data) return
    if (plot.click && !data) {
      this.selectedId = ''
      return
    }
    if (plot.click === 'menus') {
      let menu = null
@@ -1555,7 +1623,8 @@
      MKEmitter.emit('modifyTabs', newtab, true)
    } else {
      MKEmitter.emit('resetSelectLine', config.uuid, (data ? data.$$uuid : ''), data)
      this.selectedId = data.$$uuid || ''
      MKEmitter.emit('resetSelectLine', config.uuid, data.$$uuid || '', data)
    }
  }