king
2023-12-14 0eb129a9beddbb86ae74d7106a8e60823206b8d5
src/menu/components/chart/antv-bar/index.jsx
@@ -87,8 +87,14 @@
      this.updateComponent(_card, true)
    } else {
      let _card = fromJS(card).toJS()
      if (_card.plot.correction) {
        delete _card.plot.correction // 数据修正(已弃用)
        _card.plot.barSize = 35
      }
      this.setState({
        card: fromJS(card).toJS()
        card: _card
      })
    }
  }
@@ -550,7 +556,8 @@
      })
    }
    if (!plot.legend || plot.legend === 'hidden') {
    let noLegend = !plot.legend || plot.legend === 'hidden'
    if (noLegend) {
      chart.legend(false)
    } else {
      chart.legend({
@@ -580,6 +587,29 @@
        fill: '#fff'
      }
    }
    let label = plot.label
    if (Bar_axis.length) {
      if (label === 'false') {
        plot.customs.forEach(item => {
          if (!Bar_axis.includes(item.type)) return
          if (item.label === 'true') {
            label = 'true'
          }
        })
      } else {
        let reset = true
        plot.customs.forEach(item => {
          if (!Bar_axis.includes(item.type)) return
          if (item.label === 'true') {
            reset = false
          }
        })
        if (reset) {
          label = 'false'
        }
      }
    }
    if (plot.label === 'top') {
      lablecfg.offset = -5
@@ -604,6 +634,10 @@
      })
      const dst = new DataSet()
      const dvt = dst.createView().source(data)
      // if (plot.mutilBar === 'stack') {
      //   Bar_axis.reverse()
      // }
  
      dvt.transform({
        type: 'fold',
@@ -643,7 +677,9 @@
      }
      view1.axis('value', yc)
  
      // view1.legend(false)
      if (!noLegend) {
        view1.legend(false)
      }
  
      if (plot.mutilBar !== 'stack') {
        let _chart = view1
@@ -679,13 +715,13 @@
        } else {
          _chart.color('key')
        }
        if (plot.label !== 'false') {
        if (label !== 'false') {
          _chart.label('value*key', (value, key) => {
            if (plot.show === 'percent') {
              value = value + '%'
            }
            if (plot.label === 'true' && plot.labelColor === 'custom' && colors.has(key)) {
            if (label === 'true' && plot.labelColor === 'custom' && colors.has(key)) {
              lablecfg.style.fill = colors.get(key)
            }
            return {
@@ -695,7 +731,7 @@
          })
        }
        if (plot.barSize || plot.correction) {
        if (plot.barSize) {
          _chart.size(plot.barSize || 35)
        }
        if (plot.barRadius) {
@@ -730,13 +766,13 @@
        } else {
          _chart.color('key')
        }
        if (plot.label !== 'false') {
        if (label !== 'false') {
          _chart.label('value*key', (value, key) => {
            if (plot.show === 'percent') {
              value = value + '%'
            }
            if (plot.label === 'true' && plot.labelColor === 'custom' && colors.has(key)) {
            if (label === 'true' && plot.labelColor === 'custom' && colors.has(key)) {
              lablecfg.style.fill = colors.get(key)
            }
@@ -747,7 +783,7 @@
          })
        }
        if (plot.barSize || plot.correction) {
        if (plot.barSize) {
          _chart.size(plot.barSize || 35)
        }
        if (plot.barRadius) {
@@ -770,7 +806,9 @@
    view2.data(dv.rows)
    // view2.legend(false)
    if (!noLegend && Bar_axis.length) {
      view2.legend(false)
    }
    fields.forEach(item => {
      if (item.chartType === 'bar' && !Bar_axis.length) {
@@ -1093,7 +1131,7 @@
          })
        }
        if (plot.barSize || plot.correction) {
        if (plot.barSize) {
          _chart.size(plot.barSize || 35)
        }
        if (plot.selectColor) {
@@ -1153,7 +1191,7 @@
          })
        }
        if (plot.barSize || plot.correction) {
        if (plot.barSize) {
          _chart.size(plot.barSize || 35)
        }
        if (plot.selectColor) {
@@ -1307,6 +1345,21 @@
    this.updateComponent(_card)
  }
  plotchange = (card) => {
    if (card.plot.enabled === 'true' && card.plot.zoomYaxis !== 'custom' && card.plot.customs) {
      card.plot.customs.forEach(item => {
        item.min = ''
        item.max = ''
      })
    }
    if (card.plot.barcolors && (card.plot.enabled === 'true' || card.plot.datatype === 'statistics')) {
      card.plot.barcolors = null
    }
    this.updateComponent(card)
  }
  clickComponent = (e) => {
    if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') {
      e.stopPropagation()
@@ -1331,7 +1384,7 @@
          <div className="mk-popover-control">
            {appType !== 'mob' ? <PlusCircleOutlined className="plus" title="添加搜索" onClick={this.addSearch}/> : null}
            {appType !== 'mob' ? <PlusSquareOutlined className="plus" title="添加按钮" onClick={this.addButton}/> : null}
            <ChartCompileForm config={card} plotchange={this.updateComponent}/>
            <ChartCompileForm config={card} plotchange={this.plotchange}/>
            <CopyComponent type="line" card={card}/>
            <PasteComponent config={card} options={['action', 'search']} updateConfig={this.updateComponent} />
            <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle}/>