Legend.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="legend">
  3. <MenuCard
  4. :menuData="{
  5. type: 'legend',
  6. title: '图例',
  7. ifChange: false,
  8. boxWidth: legendData.boxWidth,
  9. boxHeight: legendData.boxHeight,
  10. menuIndex: legendData.menuIndex,
  11. subMenuIndex: legendData.subMenuIndex ? legendData.subMenuIndex : '',
  12. }"
  13. >
  14. <div class="legend-container">
  15. <div
  16. class="legend-container-left"
  17. :style="{
  18. width: legendData.leftWidth ? legendData.leftWidth : '50%',
  19. }"
  20. >
  21. <div
  22. class="legend-icon"
  23. v-for="(item, index) in legendData.legendIcon"
  24. :key="index"
  25. :style="{ background: item.background, border: item.border }"
  26. ></div>
  27. </div>
  28. <div
  29. class="legend-container-right"
  30. :style="{
  31. width: legendData.rightWidth ? legendData.rightWidth : '50%',
  32. }"
  33. >
  34. <el-popover
  35. placement="right-start"
  36. width="200"
  37. :content="item.info"
  38. trigger="hover"
  39. v-for="item in legendData.legendTitle"
  40. :key="item.name"
  41. >
  42. <div
  43. slot="reference"
  44. class="legend-title"
  45. :style="{
  46. width:
  47. legendData.rightItemWidth + 'px'
  48. ? legendData.rightItemWidth + 'px'
  49. : '50px',
  50. }"
  51. >
  52. {{ item.name }}
  53. </div>
  54. </el-popover>
  55. <!-- <div
  56. class="legend-title"
  57. v-for="item in legendData.legendTitle"
  58. :key="item"
  59. :style="{
  60. width:
  61. legendData.rightItemWidth + 'px'
  62. ? legendData.rightItemWidth + 'px'
  63. : '50px',
  64. }"
  65. >
  66. {{ item }}
  67. </div> -->
  68. </div>
  69. </div>
  70. </MenuCard>
  71. </div>
  72. </template>
  73. <script>
  74. import MenuCard from "@/components/layout/MenuCard.vue";
  75. /**
  76. * 通用图例
  77. */
  78. export default {
  79. name: "Legend",
  80. components: {
  81. MenuCard,
  82. },
  83. props: ["legendData"],
  84. data() {
  85. return {};
  86. },
  87. mounted() {},
  88. destroy() {},
  89. methods: {},
  90. };
  91. </script>
  92. <style lang="less" scoped>
  93. @commonBorderColor: #00aaff;
  94. .tooltip {
  95. display: block !important;
  96. padding: 4px;
  97. z-index: 10000;
  98. .tooltip-inner {
  99. background: black;
  100. color: white;
  101. border-radius: 16px;
  102. padding: 5px 10px 4px;
  103. }
  104. .tooltip-arrow {
  105. display: none;
  106. }
  107. &[aria-hidden="true"] {
  108. visibility: hidden;
  109. opacity: 0;
  110. transition: opacity 0.15s, visibility 0.15s;
  111. }
  112. &[aria-hidden="false"] {
  113. visibility: visible;
  114. opacity: 1;
  115. transition: opacity 0.15s;
  116. }
  117. }
  118. .legend {
  119. pointer-events: auto;
  120. .legend-container {
  121. width: 100%;
  122. height: 100%;
  123. position: relative;
  124. display: flex;
  125. justify-content: center;
  126. align-items: center;
  127. &-left {
  128. height: 100%;
  129. position: absolute;
  130. left: 0;
  131. top: 0;
  132. display: flex;
  133. flex-direction: column;
  134. justify-content: space-evenly;
  135. .legend-icon {
  136. width: 25px;
  137. height: 15px;
  138. background: @commonBorderColor;
  139. border-radius: 2px;
  140. margin: 0 auto;
  141. }
  142. }
  143. &-right {
  144. height: 100%;
  145. position: absolute;
  146. right: 0;
  147. top: 0;
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. justify-content: space-evenly;
  152. overflow: hidden;
  153. text-overflow: ellipsis;
  154. white-space: nowrap;
  155. .legend-title {
  156. // width: 50px;
  157. height: 20px;
  158. display: flex;
  159. align-items: center;
  160. justify-content: flex-start;
  161. color: white;
  162. pointer-events: auto;
  163. }
  164. }
  165. }
  166. }
  167. </style>