<template>
  <div :id="id" :style="{ width: width, height: height }"></div>
</template>

<script>
import { chartOptionMixins } from "@/views/analyse/custom/mixins";
import { random } from "@/utils";
export default {
  mixins: [chartOptionMixins],
  name: "CSankey",
  data() {
    return {
      id: 'sankey'
    }
  },
  mounted() {
  },
  methods: {
    getOption() {
      let links = [], x = this.selected.x, y = this.selected.y
      for (let i = 0; i < y.length; i++) {
        for (let j = 0; j < x.length; j++) {
          links.push({
            source: x[j],
            target: y[i],
            value: this.getDataCount(x[j], y[i])
          })
        }
      }
      return {
        series: {
          type: 'sankey',
          layout: 'none',
          emphasis: {
            focus: 'adjacency'
          },
          data: [...x, ...y].map(item => {
            return {
              name: item,
              itemStyle: {
                color: this.getColor(item),
              }
            }
          }),
          links: links
        }
      }
    }
  }
}
</script>
