echartsTool_zm_20210420162650.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import * as EC from 'echarts'
  2. const color = ["#00FFF0","#014EB5","#A800FF","#e82edb","#B5454C","#443bff","#e8cb25","#3dffb0","#e8a425","#ff7aab","#e84b1e","#552ce2","#ffae21","#e8861e","#d441ff","#35e8e4","#9c7aff","#e86fd8","#ffee38"];
  3. /*
  4. * 获取 自浮云 - 常用1
  5. * id: 元素ID
  6. * data: [{
  7. name: "发动机卡了", // 值
  8. value: 100, // 权重
  9. textStyle: {
  10. emphasis: {
  11. color: 'red' // 光标移入颜色
  12. }
  13. }
  14. },{
  15. name: "发动了", // 值
  16. value: 20, // 权重
  17. textStyle: {
  18. emphasis: {
  19. color: 'red' // 光标移入颜色
  20. }
  21. }
  22. }]
  23. * name: 提示框name
  24. * */
  25. export function getWordCloud(id, data) {
  26. if(data === undefined){
  27. message.error("没有找到报表数据,请检查!");
  28. return;
  29. }
  30. var myChart = EC.init(document.getElementById(id));
  31. let option = {
  32. tooltip: {},
  33. series: [{
  34. type: 'wordCloud',
  35. gridSize: 2,
  36. sizeRange: [12, 50],
  37. rotationRange: [-90, 90],
  38. shape: 'pentagon',
  39. width: 600,
  40. height: 400,
  41. drawOutOfBound: true,
  42. textStyle: {
  43. normal: {
  44. color: function() {
  45. return 'rgb(' + [
  46. Math.round(Math.random() * 160),
  47. Math.round(Math.random() * 160),
  48. Math.round(Math.random() * 160)
  49. ].join(',') + ')';
  50. }
  51. },
  52. emphasis: {
  53. shadowBlur: 10,
  54. shadowColor: '#333'
  55. }
  56. },
  57. data: data
  58. }]
  59. };
  60. myChart.setOption(option, true);
  61. }