dataQuery.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="charts-box">
  3. <qiun-data-charts type="line" :eopts="opts" :chartData="chartData" :onzoom="true" :ontouch="true"
  4. :echartsH5="true" tooltipFormat="dataQuery" />
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. props: {
  10. service: Array,
  11. serviceTime: Array
  12. },
  13. data() {
  14. return {
  15. chartData: {},
  16. //您可以通过修改 config-ucharts.js 文件中下标为 ['line'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
  17. opts: {
  18. color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
  19. "#ea7ccc"
  20. ],
  21. padding: [15, 10, 0, 15],
  22. enableScroll: true,
  23. legend: {
  24. top: 0
  25. },
  26. grid: {
  27. bottom: '25%'
  28. },
  29. xAxis: {
  30. type: 'category',
  31. axisLabel: {
  32. textStyle: {
  33. color: '#626262',
  34. fontSize: '10',
  35. },
  36. }
  37. },
  38. yAxis: {
  39. gridType: "dash",
  40. dashLength: 2
  41. },
  42. extra: {
  43. line: {
  44. type: "curve",
  45. width: 2,
  46. activeType: "hollow"
  47. }
  48. },
  49. dataZoom: [{
  50. type: 'inside',
  51. start: 0,
  52. end: 10
  53. },
  54. {
  55. start: 0,
  56. end: 10
  57. }
  58. ],
  59. }
  60. };
  61. },
  62. mounted() {
  63. this.getServerData();
  64. },
  65. methods: {
  66. getServerData() {
  67. const time = this.serviceTime.map(item => {
  68. return item.substring(0, 19).replaceAll('-', "")
  69. })
  70. let res = {
  71. categories: time,
  72. series: this.service
  73. };
  74. // this.opts.xAxis.itemCount = this.service[0].data.length
  75. this.chartData = JSON.parse(JSON.stringify(res));
  76. },
  77. }
  78. };
  79. </script>
  80. <style scoped>
  81. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  82. .charts-box {
  83. width: 100%;
  84. height: 300px;
  85. }
  86. </style>