<script>
import { unique } from '@huntianning/components/src/utils/string'

export default {
  name: 'UiChartBar',
  inject: ['UiChart'],
  props: {
    data: {
      type: Array
    },
    barWidth: {
      type: String,
      default: '12'
    },
    itemStyle: {
      type: Object,
      default() {
        return {
          borderRadius: [6, 6, 6, 6]
        }
      }
    }
  },
  created() {
    this.id = unique()
    this.UiChart.addSeries({
      id: this.id,
      type: 'bar',
      data: this.data,
      barWidth: this.barWidth,
      itemStyle: this.itemStyle
    })
  },
  render() {
    return null
  },
  beforeDestroy() {
    this.UiChart.removeSeries(this.id)
  }
}
</script>
