IndexBarChart.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view>
  3. <uni-ec-canvas
  4. class="uni-ec-canvas"
  5. id="line-chart"
  6. canvas-id="multi-charts-line"
  7. :ec="ec"
  8. ></uni-ec-canvas>
  9. </view>
  10. </template>
  11. <script>
  12. // #ifndef MP-WEIXIN
  13. import uniEcCanvas from '@/components/Echart.vue'
  14. // #endif
  15. // #ifdef MP-WEIXIN
  16. import uniEcCanvas from "./UniEcCanvas.vue";
  17. // #endif
  18. export default {
  19. props: ['data'],
  20. watch: {
  21. 'data.yData': {
  22. handler(val) {
  23. if (val) {
  24. this.ec.option.series[0].data = val;
  25. }
  26. },
  27. deep: true
  28. },
  29. 'data.name': {
  30. handler(val) {
  31. if (val) {
  32. this.ec.option.series[0].name = val;
  33. }
  34. },
  35. deep: true
  36. },
  37. 'data.xData': {
  38. handler(val) {
  39. if (val) {
  40. this.ec.option.xAxis.data = val;
  41. }
  42. },
  43. deep: true
  44. }
  45. },
  46. data() {
  47. return {
  48. ec: {
  49. option : {
  50. legend: {
  51. show: true
  52. },
  53. xAxis: {
  54. type: 'category',
  55. data: [],
  56. axisLabel: {
  57. rotate: -50,
  58. fontSize:10
  59. }
  60. },
  61. yAxis: {
  62. type: 'value'
  63. },
  64. series: [
  65. {
  66. data: [],
  67. type: 'bar',
  68. name: '统计数据',
  69. barWidth: 14,
  70. itemStyle: {
  71. color: '#0080FF'
  72. }
  73. }
  74. ]
  75. }
  76. }
  77. };
  78. },
  79. components: {
  80. uniEcCanvas
  81. }
  82. };
  83. </script>
  84. <style scoped>
  85. .uni-ec-canvas {
  86. width: 100%;
  87. height: 600upx;
  88. display: block;
  89. }
  90. </style>