hisChart.vue 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div class="his-chart">
  3. <div id="his" class="his"></div>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. data: [22, 23, 24, 25, 22, 23, 23, 24],
  11. dates: ['杭州牧场', '宁波牧场', '温州牧场', '绍兴牧场', '嘉兴牧场', '台州牧场', '金华牧场', '湖州牧场']
  12. }
  13. },
  14. methods: {
  15. drawLine () {
  16. const hisChart = this.$echarts.init(document.getElementById('his'))
  17. const option = {
  18. xAxis: {
  19. type: 'category',
  20. data: this.dates
  21. },
  22. yAxis: {
  23. type: 'value'
  24. },
  25. series: [
  26. {
  27. data: this.data,
  28. type: 'bar',
  29. showBackground: true,
  30. backgroundStyle: {
  31. color: 'rgba(180, 180, 180, 0.2)'
  32. }
  33. }
  34. ]
  35. }
  36. hisChart.setOption(option)
  37. }
  38. },
  39. mounted () {
  40. this.drawLine()
  41. }
  42. }
  43. </script>
  44. <style scoped>
  45. .his {
  46. min-height: 250px;
  47. }
  48. </style>