| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <!-- -->
- <template>
- <div class="chart-template">
- <div id="map_Chart" style="height: 100%"></div>
- </div>
- </template>
- <script>
- import "./../../board.scss";
- import * as echarts from "echarts";
- import { getMap } from "@/api/board/cockpit.js";
- import {
- findMaxIndex,
- getChartDOMSize,
- getNextPeriod,
- getPeriodText,
- } from "../../utils.js";
- export default {
- props: ["orgId", "orgName"],
- data() {
- return {
- map: {},
- coordinates: [],
- icon: "image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAUCAYAAABvVQZ0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAF3SURBVDhPvZTBK4RBGIe/z56UklDay+6JkhM3RYo/wVlOrg4uTtyc3JSrg6Lc2CQHp5U7RyVylBBJXD7PO/PO7M43Y3OQp57mfd/fzOz6dlf2LxRFMYLr2hro63io7e/gQI53uKwjA303Cr06CujStcwV1rCHg3Kpgf4E1/CBtsraGTbN4wv24Q0K2/hsy2IFN/FJj6Rhw4zshg2ctGVxodkcfmET+/EVd8zBFISXKH+O1HtSQ92EQD2Bo1rfSggLJmyHoQvNZYK27nKXm3fDGu030I/ZsecDh/DIdCHy9Ti1peceK+6yFGeaLaE8q1UcxllMYR8HxYHtI4IHTO8+oDJvOOA2VfFTpgm2zCagfrejiIZuaaFBhGb+gZfYNYfLEKQeuFDBny7zX50IwvIn1emdTZlDSuq3ua+r41rX8jzL87ypZQyvVLMvGDCoseTuV+EI/kUFEB7bPZ5FjTw6b2dcoxYMGzbznGsUwHzaxp5Hjf6SLPsG2jnZyz2k38wAAAAASUVORK5CYII=",
- };
- },
- components: {},
- computed: {},
- watch: {
- orgId: {
- deep: true,
- handler(val) {
- // this.resetTimer();
- this.getData();
- },
- },
- // map: {
- // deep: true,
- // handler() {
- // this.$nextTick(() => {
- // this.initMap();
- // });
- // },
- // },
- },
- created() {
- // this.types = types;
- // this.maxDisplay = 16;
- // this.refreshTime = 1 * 10 * 1000;
- this.isMouseOver = false;
- },
- async mounted() {
- // console.info(this.fjMap)
- window.addEventListener("resize", this.windowResize);
- },
- beforeDestroy() {
- this.timer && clearInterval(this.timer);
- this.timer = null;
- window.removeEventListener("resize", this.windowResize);
- },
- methods: {
- // handleClick() {
- // this.resetTimer();
- // this.getData();
- // },
- handleMouseEnter() {
- this.isMouseOver = true;
- },
- handleMouseLeave() {
- this.isMouseOver = false;
- },
- async getData() {
- let map = window.boardMap.getMap(this.orgName);
- let coordinates = window.boardMap.getCoord(this.orgName);
- this.map = map;
- this.coordinates = coordinates;
- this.$nextTick(() => {
- this.initMap();
- });
- },
- initMap() {
- this.myChart && this.myChart.dispose();
- // 基于准备好的dom,初始化echarts实例
- this.myChart = echarts.init(document.getElementById("map_Chart"));
- let t = this;
- getMap(this.map).then((data) => {
- echarts.registerMap("map", data);
- let option = {
- tooltip: {
- trigger: "item",
- },
- geo: {
- show: true,
- map: "map",
- zoom: 1.25,
- showLegendSymbol: false, // 存在legend时显示
- label: {
- normal: {
- show: false,
- color: "#c1b496", //控制地图省市文字颜色
- fontSize: 14,
- },
- emphasis: {
- show: false,
- color: "#fff", //悬浮字体颜色
- },
- },
- roam: true,
- selectedMode: "single", //选择模式,单选,只能选中一个地市
- select: {
- //这个就是鼠标点击后,地图想要展示的配置
- disabled: false, //可以被选中
- itemStyle: {
- //相关配置项很多,可以参考echarts官网
- borderWidth: 1, //区域边框宽度
- borderColor: "#2B91B7ff", //区域边框颜色
- areaColor: "#2B91B730", //选中
- },
- label: {
- show: false,
- color: "#fff", //悬浮字体颜色
- },
- },
- itemStyle: {
- normal: {
- borderWidth: 1, //区域边框宽度
- borderColor: "#3fdaffff", //区域边框颜色
- areaColor: "#3fdaff55", //区域颜色"rgba(23,107,221,0.7)",//
- },
- emphasis: {
- borderWidth: 1,
- borderColor: "#fff",
- areaColor: "#2B91B7",
- },
- },
- },
- legend: [
- {
- selectedMode: true, //取消图例上的点击事件
- },
- ],
- series: [
- {
- map: "map",
- type: "effectScatter",
- // silent: true,
- coordinateSystem: "geo",
- // datasetIndex: 0,
- // geoIndex: 0,
- // selectedMode: false,
- // focusNodeAdjacency: false,
- // label: {
- // show: true,
- // width: 13,
- // height: 15,
- // fontSize: 0,
- // color: "#1DF9FC",
- // backgroundColor: {
- // image: iconRQ
- // },
- // },
- label: {
- formatter: (param) => {
- return param.name;
- },
- position: "top",
- fontSize: "10",
- color: "#fff",
- show: true,
- },
- tooltip: {
- show: false,
- },
- // tooltip:{
- // position: "right",
- // textStyle:{
- // // color:'#fff',
- // },
- // // backgroundColor:'rgba(184,189,192,1)',
- // formatter:function(param){
- // return `<div >
- // <div> ${param.data.name} </div>
- // <div>履职总数:85 </div>
- // <div> 已完成:67 </div>
- // </div>`
- // }
- // },
- itemStyle: {
- color: "#ddb926",
- },
- symbol: this.icon, //自定义图标
- symbolSize: [10, 10],
- // encode: {
- // value: 2,
- // },
- // showEffectOn: "emphasis", //关闭涟漪
- // hoverEffectOn: true,
- rippleEffect: {
- brushType: "fill",
- period: 0,
- number: 0,
- },
- data: this.coordinates,
- },
- ],
- };
- if (option && typeof option === "object") {
- this.myChart.setOption(option);
- }
- });
- },
- windowResize() {
- this.myChart && this.myChart.resize();
- },
- resetTimer() {
- this.timer && clearInterval(this.timer);
- this.timer = setInterval(() => {
- if (this.isMouseOver) {
- return;
- }
- this.activeName = getNextPeriod(this.types, this.activeName);
- this.getData();
- }, this.refreshTime);
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .content {
- display: flex;
- margin-bottom: 20px;
- margin-left: 5px;
- margin-right: 5px;
- border: solid 1px #b8bdc088;
- & > span {
- margin-right: 10px;
- padding-top: 5px;
- padding-bottom: 5px;
- height: 30px;
- color: rgb(245, 245, 245);
- font-size: 14px;
- }
- & > span:first-child {
- width: 100px;
- background-color: #b8bdc088;
- text-align: center;
- }
- }
- </style>
|