123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <template>
- <div class="legend">
- <MenuCard
- :menuData="{
- type: 'legend',
- title: '图例',
- ifChange: false,
- boxWidth: legendData.boxWidth,
- boxHeight: legendData.boxHeight,
- menuIndex: legendData.menuIndex,
- subMenuIndex: legendData.subMenuIndex ? legendData.subMenuIndex : '',
- }"
- >
- <div class="legend-container">
- <div
- class="legend-container-left"
- :style="{
- width: legendData.leftWidth ? legendData.leftWidth : '50%',
- }"
- >
- <div
- class="legend-icon"
- v-for="(item, index) in legendData.legendIcon"
- :key="index"
- :style="{ background: item.background, border: item.border }"
- ></div>
- </div>
- <div
- class="legend-container-right"
- :style="{
- width: legendData.rightWidth ? legendData.rightWidth : '50%',
- }"
- >
- <el-popover
- placement="right-start"
- width="200"
- :content="item.info"
- trigger="hover"
- v-for="item in legendData.legendTitle"
- :key="item.name"
- >
- <div
- slot="reference"
- class="legend-title"
- :style="{
- width:
- legendData.rightItemWidth + 'px'
- ? legendData.rightItemWidth + 'px'
- : '50px',
- }"
- >
- {{ item.name }}
- </div>
- </el-popover>
- <!-- <div
- class="legend-title"
- v-for="item in legendData.legendTitle"
- :key="item"
- :style="{
- width:
- legendData.rightItemWidth + 'px'
- ? legendData.rightItemWidth + 'px'
- : '50px',
- }"
- >
- {{ item }}
- </div> -->
- </div>
- </div>
- </MenuCard>
- </div>
- </template>
- <script>
- import MenuCard from "@/components/layout/MenuCard.vue";
- /**
- * 通用图例
- */
- export default {
- name: "Legend",
- components: {
- MenuCard,
- },
- props: ["legendData"],
- data() {
- return {};
- },
- mounted() {},
- destroy() {},
- methods: {},
- };
- </script>
- <style lang="less" scoped>
- @commonBorderColor: #00aaff;
- .tooltip {
- display: block !important;
- padding: 4px;
- z-index: 10000;
- .tooltip-inner {
- background: black;
- color: white;
- border-radius: 16px;
- padding: 5px 10px 4px;
- }
- .tooltip-arrow {
- display: none;
- }
- &[aria-hidden="true"] {
- visibility: hidden;
- opacity: 0;
- transition: opacity 0.15s, visibility 0.15s;
- }
- &[aria-hidden="false"] {
- visibility: visible;
- opacity: 1;
- transition: opacity 0.15s;
- }
- }
- .legend {
- pointer-events: auto;
- .legend-container {
- width: 100%;
- height: 100%;
- position: relative;
- display: flex;
- justify-content: center;
- align-items: center;
- &-left {
- height: 100%;
- position: absolute;
- left: 0;
- top: 0;
- display: flex;
- flex-direction: column;
- justify-content: space-evenly;
- .legend-icon {
- width: 25px;
- height: 15px;
- background: @commonBorderColor;
- border-radius: 2px;
- margin: 0 auto;
- }
- }
- &-right {
- height: 100%;
- position: absolute;
- right: 0;
- top: 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: space-evenly;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- .legend-title {
- // width: 50px;
- height: 20px;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- color: white;
- pointer-events: auto;
- }
- }
- }
- }
- </style>
|