在vue-lic里面显示多个Echarts图表

Love The Way You Lie 2022-03-09 19:46 364阅读 0赞

直接看源码代码:

  1. <template>
  2. <div>
  3. <div id="main" :style="{width: '600px',height:'400px'}"></div>
  4. <div id="dimensionality" :style="{width: '600px',height:'400px'}"></div>
  5. </div>
  6. </template>
  7. <script>
  8. let echarts = require("echarts/lib/echarts");
  9. // 引入柱状图
  10. require("echarts/lib/chart/bar");
  11. require("echarts/lib/component/tooltip");
  12. require("echarts/lib/component/title");
  13. export default {
  14. name: 'HelloWorld',
  15. data () {
  16. return {}
  17. },
  18. mounted(){
  19. this.initCharts();
  20. },
  21. methods: {
  22. initCharts(){
  23. this.chart = echarts.init(document.getElementById('main'));
  24. this.dimensionality = echarts.init(document.getElementById('dimensionality'));
  25. this.setOptions();
  26. this.setOptions_xyz();
  27. },
  28. setOptions(){
  29. this.chart.setOption({
  30. title: {
  31. text: '折线图堆叠'
  32. },
  33. tooltip: {
  34. trigger: 'axis'
  35. },
  36. grid: {
  37. left: '3%',
  38. right: '4%',
  39. bottom: '3%',
  40. containLabel: true
  41. },
  42. toolbox: {
  43. feature: {
  44. saveAsImage: {}
  45. }
  46. },
  47. xAxis: {
  48. type: 'category',
  49. boundaryGap: false,
  50. data: ['4-5', '4-6', '4-7', '4-8', '4-9']
  51. },
  52. yAxis: {
  53. type: 'value',
  54. min:60,
  55. max:180
  56. },
  57. series: [
  58. {
  59. name: '学',
  60. type: 'line',
  61. data: [160, 132, 101, 120, 140]
  62. },
  63. {
  64. name: '习',
  65. type: 'line',
  66. data: [100, 102, 141, 154, 100]
  67. },
  68. {
  69. name: '能',
  70. type: 'line',
  71. data: [150, 122, 101, 134, 90]
  72. }
  73. ]
  74. })
  75. },
  76. setOptions_xyz(){
  77. this.dimensionality.setOption({
  78. title: {
  79. text: '基础雷达图'
  80. },
  81. tooltip: {},
  82. legend: {
  83. data: ['预算分配(Allocated Budget)', '实际开销(Actual Spending)']
  84. },
  85. radar: {
  86. // shape: 'circle',
  87. name: {
  88. textStyle: {
  89. color: '#fff',
  90. backgroundColor: '#999',
  91. borderRadius: 3,
  92. padding: [3, 5]
  93. }
  94. },
  95. indicator: [
  96. { name: '销售(sales)', max: 6500},
  97. { name: '管理(Administration)', max: 16000},
  98. { name: '信息技术(Information Techology)', max: 30000},
  99. { name: '客服(Customer Support)', max: 38000},
  100. { name: '研发(Development)', max: 52000},
  101. { name: '市场(Marketing)', max: 25000}
  102. ]
  103. },
  104. series: [{
  105. name: '预算 vs 开销(Budget vs spending)',
  106. type: 'radar',
  107. // areaStyle: {normal: {}},
  108. data : [
  109. {
  110. value : [4300, 10000, 28000, 35000, 50000, 19000],
  111. name : '预算分配(Allocated Budget)'
  112. },
  113. {
  114. value : [5000, 14000, 28000, 31000, 42000, 21000],
  115. name : '实际开销(Actual Spending)'
  116. }
  117. ]
  118. }]
  119. })
  120. }
  121. }
  122. }
  123. </script>
  124. <!-- Add "scoped" attribute to limit CSS to this component only -->
  125. <style scoped>
  126. </style>

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0pFRkZfbHV5aWR1YW4_size_16_color_FFFFFF_t_70

发表评论

表情:
评论列表 (有 0 条评论,364人围观)

还没有评论,来说两句吧...

相关阅读