index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="energyFlow-analysis" :loading="loading">
  3. <commonSearch ref="commonSearch" type="daterange" @search="handleSearch"></commonSearch>
  4. <div class="sankey-chart" ref="sankeyChart" style="height:1800px"></div>
  5. </div>
  6. </template>
  7. <script>
  8. import * as echarts from 'echarts';
  9. import commonSearch from '../components/commonSearch.vue'
  10. import { httpAction, getAction } from '@/api/manage'
  11. export default {
  12. name: 'flowAnalysis',
  13. components: {
  14. commonSearch
  15. },
  16. data () {
  17. return {
  18. description: '能流分析页面',
  19. loading: true,
  20. echartsHeight: window.innerHeight - 84 - 60 - 30,
  21. // 每一个数据及当前总数据(可能多条路线的和)
  22. sourceData: [],
  23. linksData: [],
  24. url: {
  25. list: "/emsStatistics/energyflowAnalysis",
  26. },
  27. }
  28. },
  29. created () {
  30. },
  31. mounted() {
  32. this.$nextTick(() => {
  33. this.getEnergyflowAnalysis()
  34. })
  35. },
  36. methods: {
  37. async getEnergyflowAnalysis(){
  38. var _this = this
  39. _this.loading = true
  40. var data = _this.$refs.commonSearch.queryParams
  41. getAction(this.url.list, data).then(response => {
  42. console.log(response)
  43. _this.sourceData = response.result.sourceData
  44. _this.linksData = response.result.linksData
  45. _this.loading = false
  46. })
  47. _this.initEcharts()
  48. },
  49. initEcharts(){
  50. var _this = this
  51. var chartDom = _this.$refs.sankeyChart
  52. var myChart = echarts.init(chartDom);
  53. var option;
  54. var sangjiColor = ['#f7a365', '#44eda1', '#00ffff', '#00baff', '#f8b551', '#7ecef4', '#7ecef4', '#7ecef4'];
  55. var itemStyleSource = [];
  56. for(let d = 0; d < _this.sourceData.length; d++) {
  57. _this.sourceData[d].itemStyle = {
  58. normal: {
  59. color: sangjiColor[d]
  60. }
  61. }
  62. itemStyleSource.push(_this.sourceData[d]);
  63. }
  64. option = {
  65. // backgroundColor:"#013d5a",
  66. toolbox: {
  67. show: true,
  68. feature: {
  69. saveAsImage: {},
  70. }
  71. },
  72. series: [{
  73. type: 'sankey',
  74. layout: 'none',
  75. // top:"12%",
  76. // bottom: '21%',
  77. // left:'3%',
  78. // focusNodeAdjacency: 'allEdges',
  79. // focus: 'adjacency',
  80. // nodeAligh: 'left',
  81. // layoutIterations: 32,
  82. data: itemStyleSource,
  83. links: _this.linksData,
  84. label: {
  85. normal:{
  86. color:"#666",
  87. fontSize:12,
  88. formatter: function(params, i) {
  89. // console.log(params);
  90. return "{white|"+params.data.name +"}"+params.data.nameValue+" "+params.data.valueUnit;
  91. },
  92. rich:{
  93. white:{
  94. fontSize:12,
  95. padding:[10,0,0,0]
  96. }
  97. }
  98. }
  99. },
  100. lineStyle: {
  101. normal: {
  102. color: 'source',
  103. curveness: 0.7
  104. }
  105. },
  106. itemStyle: {
  107. normal: {
  108. borderWidth: 1,
  109. borderColor: 'transparent'
  110. }
  111. }
  112. }]
  113. }
  114. option && myChart.setOption(option);
  115. // window.addEventListener("resize",function (){
  116. // myChart.resize();
  117. // });
  118. },
  119. /** 搜索按钮操作 */
  120. handleSearch(param) {
  121. this.getEnergyflowAnalysis()
  122. }
  123. },
  124. }
  125. </script>
  126. <style lang="less" scoped>
  127. @import '~@/assets/less/uStyle.less';
  128. </style>
  129. <style lang="less" scoped>
  130. .energyFlow-analysis{
  131. min-height: calc(100vh - 84px);
  132. padding: 10px;
  133. .sankey-chart{
  134. // min-height: calc(100vh - 104px);
  135. padding: 10px;
  136. box-shadow: 0 2px 10px rgba(0,0,0,.1);
  137. }
  138. }
  139. </style>