trafficFlow.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!-- 车流量分析 -->
  2. <template>
  3. <view class="revenue">
  4. <view class="revenue-line">
  5. <LineChart :chartData="chartData" :title="title" :opts="opts"/>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import LineChart from '@/components/lineChart.vue'
  11. export default {
  12. components: {
  13. LineChart
  14. },
  15. props: {
  16. title: {
  17. type: String,
  18. default: ''
  19. },
  20. opts: {
  21. type: Object,
  22. default: () => {
  23. return {
  24. xAxis: {
  25. rotateLabel: false,
  26. labelCount: 6
  27. },
  28. yAxis: {
  29. showTitle: true,
  30. splitNumber: 5,
  31. data: [{
  32. title: '辆',
  33. titleOffsetY: -5
  34. }]
  35. },
  36. legend: {
  37. show: false
  38. },
  39. dataLabel: false,
  40. extra: {
  41. column: {
  42. width: 20
  43. }
  44. }
  45. }
  46. }
  47. }
  48. },
  49. data() {
  50. return {
  51. chartData: {
  52. categories: [],
  53. series: [{
  54. name: '',
  55. data: []
  56. }]
  57. }
  58. }
  59. },
  60. methods: {
  61. getData({ reportType, queryDate }) {
  62. uni.$u.api.operationalAnalysisApi.getTrafficFlowDataApi({ reportType, queryDate }).then(res => {
  63. if (res.code === 200) {
  64. if (res.data.itemList && res.data.itemList.length) {
  65. this.chartData.categories = res.data.itemList.map(item => {
  66. return item.statisTime
  67. })
  68. this.chartData.series[0].data = res.data.itemList.map(item => {
  69. return item.vehicleCount
  70. })
  71. } else {
  72. this.chartData.categories = []
  73. this.chartData.series[0].data = []
  74. }
  75. }
  76. })
  77. }
  78. }
  79. }
  80. </script>