analysisChartTopLeft.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div>
  3. <div id="analysisChartTopLeft" style="width:6rem;height:4rem;margin:35px auto;"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import echartMixins from "@/utils/resizeMixins";
  8. export default {
  9. props:['xDataTopLeft','yDataTopLeft'],
  10. data() {
  11. return {
  12. chart: null,
  13. }
  14. },
  15. mixins: [echartMixins],
  16. mounted() {
  17. this.init();
  18. },
  19. methods: {
  20. init() {
  21. this.chart = this.echarts.init(document.getElementById("analysisChartTopLeft"));
  22. let option = {
  23. title: {
  24. text: '设备 1',
  25. fontSize: 20,
  26. textStyle: {
  27. fontWeight: 'bold',
  28. color: '#DCDCDC'
  29. },
  30. x: 'center'
  31. },
  32. tooltip: {
  33. trigger: 'axis',
  34. axisPointer: {
  35. type: 'shadow'
  36. }
  37. },
  38. legend: {},
  39. grid: {
  40. left: '3%',
  41. right: '4%',
  42. bottom: '3%',
  43. containLabel: true
  44. },
  45. xAxis: {
  46. type: 'value',
  47. boundaryGap: [0, 0.01],
  48. axisLabel: {
  49. fontSize: 14,
  50. textStyle: {
  51. fontWeight: 'bold',
  52. color: '#DCDCDC'
  53. }
  54. },
  55. nameTextStyle: {
  56. fontSize: 14,
  57. fontWeight: 'bold',
  58. color: '#DCDCDC'
  59. }
  60. },
  61. yAxis: {
  62. type: 'category',
  63. data: this.yDataTopLeft,
  64. axisLabel: {
  65. fontSize: 14,
  66. textStyle: {
  67. fontWeight: 'bold',
  68. color: '#DCDCDC'
  69. }
  70. },
  71. nameTextStyle: {
  72. fontSize: 14,
  73. fontWeight: 'bold',
  74. color: '#DCDCDC'
  75. }
  76. },
  77. series: [
  78. {
  79. type: 'bar',
  80. data: this.xDataTopLeft,
  81. }
  82. ]
  83. };
  84. this.chart.setOption(option);
  85. }
  86. },
  87. destroyed() {
  88. window.onresize = null;
  89. }
  90. }
  91. </script>
  92. <style>
  93. </style>