a8155e6cc909af7cc894d117aa691ad183f31ff4.svn-base 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!-- 格式
  2. allData: {
  3. title: "下载名称",
  4. legend: [],
  5. xAxis: {},
  6. yAxis: {},
  7. series: [],
  8. formatter: '浮层'
  9. }
  10. -->
  11. <template>
  12. <v-chart
  13. @click="clickEvent"
  14. :options="chartData"
  15. />
  16. </template>
  17. <script>
  18. import ECharts from "vue-echarts";
  19. // import "echarts/lib/chart/bar"; // 柱状图
  20. // import "echarts/lib/component/legend"; // 图例
  21. // import "echarts/lib/component/tooltip"; // 浮层显示
  22. // import "echarts/lib/component/toolbox"; // 下载工具等
  23. export default {
  24. props: ["allData"],
  25. components: {
  26. "v-chart": ECharts
  27. },
  28. data() {
  29. return {
  30. show: false,
  31. color: [
  32. "#1890ff",
  33. "#2fc25b",
  34. "#facc14",
  35. "#223273",
  36. "#8543e0",
  37. "#13c2c2",
  38. "#3436c7",
  39. "#f04864",
  40. "#4212af",
  41. "#ffda00",
  42. "#ff1e00",
  43. "#00bf32",
  44. "#ffe340",
  45. "#ffeb73",
  46. "#ff5640",
  47. "#ff8373",
  48. "#248f40",
  49. "#007c21",
  50. "#462b83",
  51. "#270672",
  52. "#bfaa30",
  53. "#a68e00",
  54. "#bf4030",
  55. "#a61300",
  56. "#38df64",
  57. "#64df85",
  58. "#7247d7",
  59. "#8d6dd7"
  60. ]
  61. };
  62. },
  63. computed: {
  64. chartData() {
  65. let data = {
  66. color: this.color,
  67. tooltip: {
  68. trigger: "axis",
  69. axisPointer: {
  70. type: "shadow"
  71. },
  72. formatter: this.allData.formatter ? this.allData.formatter : {}
  73. },
  74. series: this.allData.series,
  75. xAxis: this.allData.xAxis,
  76. yAxis: this.allData.yAxis
  77. };
  78. if (this.allData.legend) {
  79. data.legend = this.allData.legend;
  80. }
  81. if (this.allData.grid) {
  82. data.grid = this.allData.grid;
  83. }
  84. if (this.allData.dataZoom) {
  85. data.dataZoom = this.allData.dataZoom;
  86. }
  87. if (this.allData.toolbox) {
  88. data.toolbox = this.allData.toolbox;
  89. } else if (this.allData.toolbox != false) {
  90. data.toolbox = {
  91. show: true,
  92. right: 20,
  93. top: 5,
  94. feature: {
  95. saveAsImage: {
  96. name: this.allData.title
  97. ? this.allData.title
  98. : this.getNowFormatDate()
  99. }
  100. }
  101. };
  102. }
  103. return data;
  104. }
  105. },
  106. methods: {
  107. clickEvent(data) {
  108. this.$emit("showInfo", data);
  109. },
  110. getNowFormatDate() {
  111. var date = new Date();
  112. var seperator1 = "-";
  113. var year = date.getFullYear();
  114. var month = date.getMonth() + 1;
  115. var strDate = date.getDate();
  116. if (month >= 1 && month <= 9) {
  117. month = "0" + month;
  118. }
  119. if (strDate >= 0 && strDate <= 9) {
  120. strDate = "0" + strDate;
  121. }
  122. if (this.allData.backgroundColor) {
  123. data.backgroundColor = this.allData.backgroundColor;
  124. }
  125. var currentdate = year + seperator1 + month + seperator1 + strDate;
  126. return currentdate;
  127. }
  128. }
  129. };
  130. </script>