💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
路径 D:\ireport365\ireport365.war\js\enduser\designer\vs-component-echarts.js 数据处理 ``` case "DrillDownChinaMap": // 数据处理 var mapStack = []; var curMap = {}; var option = component.config.chartConfig; var optionNode = component.config; var mapdata = option.series[0].data; option.series[0].data = mapdata; if(optionNode.curlMap){ loadMap1(optionNode.curlMap.mapCode, optionNode.curlMap.mapName); }else{ loadMap1('100000', 'china'); } function loadMap1(mapCode, mapName) { $.ajaxSettings.async = false; $.getJSON(contextPath + '/cdn/1.0/assets-map-json/main-city/' + mapCode + '.json', function(data1) { if (data1) { // console.log(data1) echarts.registerMap(mapName, data1); option.series[0].mapType = mapName // console.log(mapName) scope.component.context.chart.setOption(option, true) curMap = { mapCode: mapCode, mapName: mapName }; // console.log(curMap) } else { alert('无法加载该地图'); } }); } /** 绑定用户切换地图区域事件 cityMap对象存储着地图区域名称和区域的信息(name-code) 当mapCode有值,说明可以切换到下级地图 同时保存上级地图的编号和名称 */ component.context.chart.on("mapselectchanged", function (params) { if (params.dataIndex < 0) { return } // console.log(params) var name = params.batch[0].name; var mapCode = cityMap[name]; if (!mapCode) { //如果地图无法继续下钻,则让点击的区域呈现选中状态 alert('无此区域地图显示') return; } loadMap1(mapCode, name); //将上一级地图信息压入mapStack // console.log(curMap) mapStack.push({ mapCode: curMap.mapCode, mapName: curMap.mapName }); console.log(mapStack) }); // 动态插入div var boarddiv = '<div id = "contextMenu" style = "position: absolute;background:#000;opacity:0.8;cursor: pointer;border-radius: 2px;padding:8px 30px;display:none;color: #fff;font-size:14px;">返回上一级</div>'; $('#'+component.id).append(boarddiv); /** 绑定鼠标右键事件,并加载上一级地图 */ component.context.chart.on('contextmenu', function(params) { $('#'+component.id+'>#contextMenu').css({ left: params.event.offsetX, top: params.event.offsetY }).show(); console.log(mapStack) }); function truncate(arr) { var m = arr.slice(0); m.splice(m.length-1,1); return m; } var maparr = truncate(mapStack) // 返回按钮的点击事件 $('#'+component.id).on('click','#contextMenu', function () { console.log(maparr) var map = maparr.pop(); console.log(map) $(this).hide(); if (!maparr.length && !map) { // alert('已经到达最上一级地图了'); if(optionNode.curlMap){ loadMap1(optionNode.curlMap.mapCode, optionNode.curlMap.mapName); }else{ loadMap1('100000', 'china'); } return; }else{ // alert('1212') loadMap1(map.mapCode, map.mapName); } // scope.component.context.chart.setOption(option, true) }); break ``` 分享页面 ``` case "DrillDownChinaMap": // 数据处理 var mapStack = []; var curMap = {}; var option = component.config.chartConfig; var optionNode = component.config; var mapdata = option.series[0].data; option.series[0].data = mapdata; if(optionNode.curlMap){ loadMap1(optionNode.curlMap.mapCode, optionNode.curlMap.mapName); }else{ loadMap1('100000', 'china'); } function loadMap1(mapCode, mapName) { $.ajaxSettings.async = false; $.getJSON(contextPath + '/cdn/1.0/assets-map-json/main-city/' + mapCode + '.json', function(data1) { if (data1) { console.log(data1) echarts.registerMap(mapName, data1); option.series[0].mapType = mapName // console.log(mapName) scope.component.context.chart.setOption(option, true) curMap = { mapCode: mapCode, mapName: mapName }; // console.log(curMap) } else { alert('无法加载该地图'); } }); } /** 绑定用户切换地图区域事件 cityMap对象存储着地图区域名称和区域的信息(name-code) 当mapCode有值,说明可以切换到下级地图 同时保存上级地图的编号和名称 */ component.context.chart.on("mapselectchanged", function (params) { if (params.dataIndex < 0) { return } // console.log(params) var name = params.batch[0].name; var mapCode = cityMap[name]; if (!mapCode) { //如果地图无法继续下钻,则让点击的区域呈现选中状态 alert('无此区域地图显示') return; } loadMap1(mapCode, name); //将上一级地图信息压入mapStack // console.log(curMap) mapStack.push({ mapCode: curMap.mapCode, mapName: curMap.mapName }); console.log(mapStack) }); // 动态插入div var boarddiv = '<div id = "contextMenu" style = "position: absolute;background:#000;opacity:0.8;cursor: pointer;border-radius: 2px;padding:8px 30px;display:none;color: #fff;font-size:14px;">返回上一级</div>'; $('#'+component.id).append(boarddiv); /** 绑定鼠标右键事件,并加载上一级地图 */ component.context.chart.on('contextmenu', function(params) { $('#'+component.id+'>#contextMenu').css({ left: params.event.offsetX, top: params.event.offsetY }).show(); console.log(mapStack) }); // 返回按钮的点击事件 $('#'+component.id).on('click','#contextMenu', function () { console.log(mapStack) var map = mapStack.pop(); // // var map = mapStack[0]; console.log(map) $(this).hide(); if (!mapStack.length && !map) { // alert('已经到达最上一级地图了'); if(optionNode.curlMap){ loadMap1(optionNode.curlMap.mapCode, optionNode.curlMap.mapName); }else{ loadMap1('100000', 'china'); } return; }else{ // alert('1212') loadMap1(map.mapCode, map.mapName); } // scope.component.context.chart.setOption(option, true) }); break; ```