index2.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div style="position: relative">
  3. <div v-for="map in maps">
  4. <div style="position: absolute;right: 0;z-index: 100">
  5. <el-button icon="el-icon-camera-solid" size="mini" @click="handleScreenshot(map.name, map.name)">截图</el-button>
  6. </div>
  7. <el-tabs v-model="active[map.name]">
  8. <el-tab-pane :label="map.name" :name="map.name">
  9. <div :id="map.name" :style="{ width: width, height: height }"></div>
  10. </el-tab-pane>
  11. </el-tabs>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import { chartOption } from "@/views/analyse/custom/mixins";
  17. export default {
  18. mixins: [chartOption],
  19. name: "CMap2",
  20. data() {
  21. return {
  22. maps: [],
  23. active: {}
  24. }
  25. },
  26. async mounted() {
  27. await Promise.all(this.selected.x.map(async (item) => {
  28. const { data } = await this.$api.getMapData({ path: `/map/${item}.json` })
  29. this.maps.push({
  30. name: item,
  31. map: data
  32. })
  33. this.$set(this.active, item, item)
  34. this.$echarts.registerMap(item, data)
  35. }))
  36. this.maps.map(item => {
  37. this.initChart(item.name, this.getOption(this.getDataCount(item.name), item.name))
  38. })
  39. },
  40. methods: {
  41. getOption(count, name) {
  42. let max = 1, x = Object.keys(count || {}), data = [], nameMap = {}
  43. for (let i = 0; i < x.length; i++) {
  44. data.push({
  45. name: x[i],
  46. value: count[x[i]]
  47. })
  48. if (count[x[i]] > max) {
  49. max = count[x[i]]
  50. }
  51. }
  52. return {
  53. visualMap: {
  54. min: 0,
  55. max: max,
  56. calculable: true,
  57. orient: 'horizontal',
  58. left: 'center',
  59. show: false,
  60. },
  61. series: [
  62. {
  63. name: '',
  64. type: 'map',
  65. map: name,
  66. roam: true,
  67. label: this.getDataLabel(),
  68. itemStyle: {
  69. borderWidth: 0
  70. },
  71. data: data,
  72. nameMap: nameMap
  73. }
  74. ]
  75. }
  76. },
  77. }
  78. }
  79. </script>