king
2021-06-04 9e60fb89a8b1c8a1d16b557b20b6d0a509f37983
src/menu/components/chart/antv-bar/index.jsx
@@ -285,11 +285,19 @@
      let colorIndex = 0
      if (plot.colors && plot.colors.length > 0) {
        if (plot.ramp === 'true') {
          plot.colors.forEach(item => {
            if (!colors.has(transfield[item.type])) {
              colors.set(transfield[item.type], `l(0) 0:${item.color} 1:${item.color1}` )
            }
          })
        } else {
        plot.colors.forEach(item => {
          if (!colors.has(transfield[item.type])) {
            colors.set(transfield[item.type], item.color)
          }
        })
        }
      }
  
      let _chart = chart
@@ -309,11 +317,11 @@
      if (plot.colors && plot.colors.length > 0) {
        let limit = chartColors.length
        _chart.color('key', (key) => {
          if (colors.get(key)) {
          if (colors.has(key)) {
            return colors.get(key)
          } else {
            colors.set(key, chartColors[colorIndex % limit])
            colorIndex++
            return chartColors[(colorIndex - 1) % limit]
          }
        })
      } else {
@@ -370,11 +378,29 @@
    let limit = chartColors.length
    if (plot.colors && plot.colors.length > 0) {
      plot.colors.forEach(item => {
        if (!colors.has(item.type)) {
          colors.set(item.type, item.color)
      if (plot.ramp === 'true') {
        let bars = {}
        plot.customs.forEach(item => {
          if (!item.shape || !item.shape[0] || item.shape[0] === 'bar') {
            bars[item.type] = true
        }
      })
        plot.colors.forEach(item => {
          if (!colors.has(transfield[item.type])) {
            if (bars[item.type]) {
              colors.set(transfield[item.type], `l(90) 0:${item.color} 1:${item.color1}` )
            } else {
              colors.set(transfield[item.type], `l(0) 0:${item.color} 1:${item.color1}` )
            }
          }
        })
      } else {
        plot.colors.forEach(item => {
          if (!colors.has(transfield[item.type])) {
            colors.set(transfield[item.type], item.color)
          }
        })
      }
    }
    let axisIndex = 0
@@ -385,8 +411,8 @@
      item.chartType = item.shape ? (item.shape[0] || 'bar') : 'bar'
      item.shape = item.shape ? (item.shape[1] || '') : ''
      if (colors.get(item.type)) {
        item.color = colors.get(item.type)
      if (colors.has(item.name)) {
        item.color = colors.get(item.name)
      } else {
        item.color = chartColors[colorIndex % limit]
        colorIndex++
@@ -517,17 +543,6 @@
  
      view1.legend(false)
      let colors = new Map()
      let colorIndex = 0
      if (plot.colors && plot.colors.length > 0) {
        plot.colors.forEach(item => {
          if (!colors.has(transfield[item.type])) {
            colors.set(transfield[item.type], item.color)
          }
        })
      }
      if (plot.mutilBar !== 'stack') {
        let _chart = view1
          .interval()
@@ -552,11 +567,12 @@
        if (plot.colors && plot.colors.length > 0) {
          let limit = chartColors.length
          _chart.color('key', (key) => {
            if (colors.get(key)) {
            // return 'l(90) 0:#1890ff 1:#70cdd0'
            if (colors.has(key)) {
              return colors.get(key)
            } else {
              colors.set(key, chartColors[colorIndex % limit])
              colorIndex++
              return chartColors[(colorIndex - 1) % limit]
            }
          })
        } else {
@@ -601,11 +617,11 @@
        if (plot.colors && plot.colors.length > 0) {
          let limit = chartColors.length
          _chart.color('key', (key) => {
            if (colors.get(key)) {
            if (colors.has(key)) {
              return colors.get(key)
            } else {
              colors.set(key, chartColors[colorIndex % limit])
              colorIndex++
              return chartColors[(colorIndex - 1) % limit]
            }
          })
        } else {
@@ -833,11 +849,19 @@
      let colorIndex = 0
      if (plot.colors && plot.colors.length > 0) {
        if (plot.ramp === 'true') {
          plot.colors.forEach(item => {
            if (!colors.has(transfield[item.type])) {
              colors.set(transfield[item.type], `l(90) 0:${item.color} 1:${item.color1}` )
            }
          })
        } else {
        plot.colors.forEach(item => {
          if (!colors.has(transfield[item.type])) {
            colors.set(transfield[item.type], item.color)
          }
        })
        }
      }
  
      if (plot.adjust !== 'stack') {
@@ -864,11 +888,11 @@
        if (plot.colors && plot.colors.length > 0) {
          let limit = chartColors.length
          _chart.color('key', (key) => {
            if (colors.get(key)) {
            if (colors.has(key)) {
              return colors.get(key)
            } else {
              colors.set(key, chartColors[colorIndex % limit])
              colorIndex++
              return chartColors[(colorIndex - 1) % limit]
            }
          })
        } else {
@@ -913,11 +937,11 @@
        if (plot.colors && plot.colors.length > 0) {
          let limit = chartColors.length
          _chart.color('key', (key) => {
            if (colors.get(key)) {
            if (colors.has(key)) {
              return colors.get(key)
            } else {
              colors.set(key, chartColors[colorIndex % limit])
              colorIndex++
              return chartColors[(colorIndex - 1) % limit]
            }
          })
        } else {