import * as EC from 'echarts'
const color = ["#00FFF0","#014EB5","#A800FF","#e82edb","#B5454C","#443bff","#e8cb25","#3dffb0","#e8a425","#ff7aab","#e84b1e","#552ce2","#ffae21","#e8861e","#d441ff","#35e8e4","#9c7aff","#e86fd8","#ffee38"];

/*
 *  获取 自浮云 - 常用1
 *  id: 元素ID
 *  data: [{
      name: "发动机卡了", // 值
      value: 100, // 权重
      textStyle: {
        emphasis: {
          color: 'red' // 光标移入颜色
        }
      }
    },{
      name: "发动了", // 值
      value: 20, // 权重
      textStyle: {
        emphasis: {
          color: 'red' // 光标移入颜色
        }
      }
    }]
 *  name: 提示框name
 * */
export function getWordCloud(id, data) {
  if(data === undefined){
    message.error("没有找到报表数据，请检查！");
    return;
  }
  var myChart = EC.init(document.getElementById(id));
  let option = {
    tooltip: {},
    series: [{
      type: 'wordCloud',
      gridSize: 2,
      sizeRange: [12, 50],
      rotationRange: [-90, 90],
      shape: 'pentagon',
      width: 600,
      height: 400,
      drawOutOfBound: true,
      textStyle: {
        normal: {
          color: function() {
            return 'rgb(' + [
              Math.round(Math.random() * 160),
              Math.round(Math.random() * 160),
              Math.round(Math.random() * 160)
            ].join(',') + ')';
          }
        },
        emphasis: {
          shadowBlur: 10,
          shadowColor: '#333'
        }
      },
      data: data
    }]
  };
  myChart.setOption(option, true);
}