IndexBarChart.vue 1.2 KB

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