🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
路径D:\ireport365\ireport365.war\WEB-INF\pages\enduser\designer\index.jsp 在这个文件添加2个文件 放到jquery.json.min.js下面吧 _scripts.push({url: "http://www.2xyw.com/cdn/three/three.min.js"}); _scripts.push({url: "http://www.2xyw.com/cdn/gio/gio.min.js"}); 路径D:\ireport365\ireport365.war\js\enduser\designer\vs-component-basic.js 第一步添加组件对象 ``` { name: "", type: "gioChart", coverImage: contextPath + "/images/componenttypes/" + locale + "/basic/zh_timeLine.png", coverImageWidth: "50%", tip: "地球仪" } ``` 第二步默认大小 ``` case "gioChart": a.sizeX = 4; a.sizeY = 24; break; ``` 核心代码 ``` vsPluginComponentModule.factory("$vcPlugin_basic_gioChart", ["$vsPluginRegister", "$timeout", function (a, c) { var b = { showDataCategory: true, showBorderCategory: true, showBasicCategory: true, showFixedCategory: true, showEventCategory: false, showTitleCategory: true, init: function (scope, element, component, $compile) { scope.element = element; scope.component = component; //开启页面过滤 component.config.pageFilter = false; component.config.dimBarOrient = false; if (!component.config.is) { // 将初始国家改成"中国" component.config.setInitCountry = "CN"; //地球表面上 提及国家 比 未提及的国家 更高 component.config.lightenMentioned = true; // 未提到过的国家在3D地球上不可选 false为不开启 component.config.disableUnmentioned = false; // 显示输入线 component.config.showInOnly = true; // 显示输出线 component.config.showOutOnly = true; //3D地球周围显示光晕的颜色 component.config.setHaloColor = "#ff8800"; // 初始化风格 component.config.setStyle = "magic"; // 地球表面颜色 component.config.setSurfaceColor = "#fff"; // 在选中状态下的国家颜色 component.config.setSelectedColor = "#fff"; // 设置输出连接线颜色 component.config.setExportColor = "#ff8800"; // 设置输入连接线颜色 component.config.setImportColor = "#ff8800"; // 设置背景颜色 component.config.setBackgroundColor = "#000"; //海洋高度 component.config.adjustOceanBrightness = 0.5; //设置国家高度 component.config.adjustRelatedBrightness = 0.5; // 提到的国家高度 component.config.adjustMentionedBrightness = 0.5; } }, buildDataDescription: function (e, h, g, d, f) { h.$on(event_refreshBindingData, function (k, l) { d.context.orgData = d.context.data; var i = d.config.datasourceConfig.dimensions; var j = d.config.datasourceConfig.measures; if (i && i.length > 0) { if (!j) { j = [] } h.queryModelData({ eventParam: l, dimensions: i, measures: j, tableKey: d.config.datasourceConfig.metadataConfig.metadataTable.key, onQuerySuccess: function (m) { if (m.data.success) { if (d.context.data == null || d.context.data.length == 0) { return } if (d.context.data != null && d.context.data.length > 0) { // console.log(d.context.data) b.refreshChartView(h, g, d, f) } } else { toaster.error({ body: m.data.message }) } }, onError: function () { toaster.error({ body: vsLang.connection_failed }) } }) } }) }, buildChartDescription: function (j, h, e, g) { var d = { name: "gioChart", title: "配置", groups: [] }; e.description.categories.push(d); if (j.component.config.showTitle == null) { j.component.config.showTitle = false } j.component = e; var f = []; f.push("<div id='gio' style='width:100%;height:100%;'></div>"); var i = g(f.join(""))(j); h.append(i); // console.log($("#"+e.id+" #gio")[0]); // 获取元素dom var gio = $("#" + e.id + " #gio")[0]; // 初始化数据 var gioData = [{ e: "CN", i: "US", v: 100000 }, { e: "CN", i: "RU", v: 3000000 }, { e: "RU", i: "US", v: 1000000 }, { e: "FR", i: "LK", v: 1000000 }, { e: "US", i: "FR", v: 1000000 }, { e: "ES", i: "LB", v: 235358 }, { e: "GI", i: "LT", v: 353123 }, { e: "GI", i: "MV", v: 352323 }, { e: "GT", i: "NE", v: 3215323 }, { e: "GT", i: "NP", v: 30323 }, { e: "GT", i: "PE", v: 135323 }, { e: "JO", i: "MX", v: 354323 }, { e: "KI", i: "MA", v: 35323 }, { e: "LK", i: "IQ", v: 1762131 }, { e: "LR", i: "JE", v: 172358 }, { e: "NE", i: "FI", v: 180132 }, { e: "CN", i: "ES", v: 110120 }, { e: "CN", i: "IT", v: 195313 }, { e: "CN", i: "JM", v: 2525 }, { e: "FI", i: "JO", v: 533413 }, { e: "FI", i: "JP", v: 534335 }, { e: "FI", i: "KI", v: 353535 }, { e: "FI", i: "KW", v: 53538 }, { e: "FI", i: "KY", v: 323512 }, { e: "FI", i: "LK", v: 135323 }, { e: "GI", i: "LR", v: 213123 }, ] // 核心代码start j.component.context.controller = new GIO.Controller(gio); // var controller = new GIO.Controller( gio ); // console.log(controller) // console.log(gioData) var gioInit = function () { // 数据 // console.log(controller) j.component.context.controller.clearData(); // console.log(gioData) j.component.context.controller.addData(gioData); // 设置初始国家 j.component.context.controller.setInitCountry(e.config.setInitCountry); // 开启提到国家的高度 j.component.context.controller.lightenMentioned(e.config.lightenMentioned); // 禁用没有提到的国家 j.component.context.controller.disableUnmentioned(e.config.disableUnmentioned); // 设置光晕颜色 j.component.context.controller.setHaloColor(e.config.lightenMentioned); // 显示输出线 j.component.context.controller.showInOnly(e.config.showOutOnly); // 显示输入线 j.component.context.controller.showOutOnly(e.config.showInOnly); //设置地球风格 j.component.context.controller.setStyle(e.config.setStyle); // 设置地球表面颜色 j.component.context.controller.setSurfaceColor(e.config.setSurfaceColor); // 在选中状态下的国家颜色 j.component.context.controller.setSelectedColor(e.config.setSelectedColor); // 设置输出连接线颜色 j.component.context.controller.setExportColor(e.config.setExportColor); // 设置输入连接线颜色 j.component.context.controller.setImportColor(e.config.setImportColor); // 设置背景颜色 j.component.context.controller.setBackgroundColor(e.config.setBackgroundColor); //海洋高度 j.component.context.controller.adjustOceanBrightness(e.config.adjustOceanBrightness); //设置国家高度 j.component.context.controller.adjustRelatedBrightness(e.config.adjustRelatedBrightness); // 提到的国家高度 j.component.context.controller.adjustMentionedBrightness(e.config.adjustMentionedBrightness); j.component.context.controller.init(); } gioInit(); // 核心代码end // d.groups.push({ // name: "setStyle", // title: { // text: "地球风格" // }, // elements: [{ // title: "地球风格", // type: "select-s", // bind: "fontClass", // items: [{ // name: "magic", // value: "magic" // }, { // name: "blueInk", // value: "blueInk" // }, { // name: "earlySpring", // value: "earlySpring" // }, { // name: "frozenBerry", // value: "frozenBerry" // }, { // name: "gorgeousDream", // value: "gorgeousDream" // }, { // name: "juicyCake", // value: "juicyCake" // }, { // name: "lemonGate", // value: "lemonGate" // }, { // name: "mint", // value: "mint" // }, { // name: "nearMoon", // value: "nearMoon" // }, { // name: "octoberParty", // value: "octoberParty" // }, { // name: "redBlue", // value: "redBlue" // }, { // name: "strawberry", // value: "strawberry" // }, { // name: "sunset", // value: "sunset" // }] // }] // }); d.groups.push({ name: "width", title: { text: "基本配置" }, elements: [{ title: "背景颜色", type: "colorpicker", bind: "setBackgroundColor" }, { title: "国家高度", type: "switch", bind: "lightenMentioned", on: vsLang.on, off: vsLang.off }, { title: "禁用国家", type: "switch", bind: "disableUnmentioned", on: vsLang.on, off: vsLang.off }, { title: "输入线", type: "switch", bind: "showInOnly", on: vsLang.on, off: vsLang.off }, { title: "输入线颜色", type: "colorpicker", bind: "setImportColor" }, { title: "输出线", type: "switch", bind: "showOutOnly", on: vsLang.on, off: vsLang.off }, { title: "输出线颜色", type: "colorpicker", bind: "setExportColor" }, { title: "高度值", type: "configSlide", bind: "adjustMentionedBrightness", config: { slideStart: 0, slideEnd: 10 }, }, { title: "光晕颜色", type: "colorpicker", bind: "setHaloColor" }, { title: "地球表面", type: "colorpicker", bind: "setSurfaceColor" }, { title: "选中国家", type: "colorpicker", bind: "setSelectedColor" }, { title: "海洋高度", type: "configSlide", bind: "adjustOceanBrightness", config: { slideStart: 0, slideEnd: 10 }, }, { title: "国家高度", type: "configSlide", bind: "adjustRelatedBrightness", config: { slideStart: 0, slideEnd: 10 }, }] }); j.$watch("component.config.setBackgroundColor", function (w, u) { var p = e.config; p.is = true; p.setBackgroundColor = w; j.component.context.controller.setBackgroundColor(w); }); j.$watch("component.config.adjustMentionedBrightness", function (w, u) { var p = e.config; p.is = true; p.adjustMentionedBrightness = w; j.component.context.controller.adjustMentionedBrightness(w); }); j.$watch("component.config.disableUnmentioned", function (w, u) { var p = e.config; p.is = true; p.disableUnmentioned = w; j.component.context.controller.disableUnmentioned(w); }); j.$watch("component.config.showInOnly", function (w, u) { var p = e.config; p.is = true; p.showInOnly = w; j.component.context.controller.showInOnly(w); }); j.$watch("component.config.setImportColor", function (w, u) { var p = e.config; p.is = true; p.setImportColor = w; j.component.context.controller.setImportColor(w); }); j.$watch("component.config.showOutOnly", function (w, u) { var p = e.config; p.is = true; p.showOutOnly = w; j.component.context.controller.showOutOnly(w); }); j.$watch("component.config.setExportColor", function (w, u) { var p = e.config; p.is = true; p.setExportColor = w; j.component.context.controller.setExportColor(w); }); j.$watch("component.config.setHaloColor", function (w, u) { var p = e.config; p.is = true; p.setHaloColor = w; j.component.context.controller.setHaloColor(w); }); j.$watch("component.config.setSurfaceColor", function (w, u) { var p = e.config; p.is = true; p.setSurfaceColor = w; j.component.context.controller.setSurfaceColor(w); }); j.$watch("component.config.setSelectedColor", function (w, u) { var p = e.config; p.is = true; p.setSelectedColor = w; j.component.context.controller.setSelectedColor(w); }); j.$watch("component.config.adjustOceanBrightness", function (w, u) { var p = e.config; p.is = true; p.adjustOceanBrightness = w; j.component.context.controller.adjustOceanBrightness(w); }); j.$watch("component.config.adjustRelatedBrightness", function (w, u) { var p = e.config; p.is = true; p.adjustRelatedBrightness = w; j.component.context.controller.adjustRelatedBrightness(w); }); j.$watch("component.config.setStyle", function (w, u) { var p = e.config; p.is = true; p.setStyle = w; console.log(w) j.component.context.controller.setStyle(w); }); }, refreshChartView: function (scope, element, component, $compile) { var processValueObj = function (b, c) { if (b == null || b === 0) { return 0 } var a = parseFloat(b); if (isNaN(a)) { return 0 } if (c == null) { c = 0 } b = Math.round(b * Math.pow(10, c)) / Math.pow(10, c); return a.toFixed(c) }; var processValue = function (d, e) { return processValueObj(d, e) }; var dimensions = component.config.datasourceConfig.dimensions; var measures = component.config.datasourceConfig.measures; // 设置2个维度 component.config.chartDimensionCount = 2 //从context中获得控件数据 var data = component.context.data; var serieData = []; console.log(data) for (var i = 0; i < data.length; i++) { var value = processValue(data[i][measures[0].name], component.config.digit); var dataItem = { e: data[i][dimensions[0].name].toUpperCase(), i: data[i][dimensions[1].name].toUpperCase(), v: parseInt(value) }; serieData.push(dataItem) } if (serieData) { // var gio = $("#"+component.id+" #gio")[0]; // var controller = new GIO.Controller( gio ); component.context.controller.clearData(); component.context.controller.addData(serieData); // console.log(component.context.controller) // gioInit() // controller.init(); } // console.log(serieData) // 处理数据 }, }; a.register("basic", "gioChart", b); return null } ]); ``` 分享页 路径D:\ireport365\ireport365.war\WEB-INF\classes\system-resource\report-template.html 在这个文件里添加js文件 加到echarts-china 下面吧 ``` _scripts.push({url: "http://www.2xyw.com/cdn/three/three.min.js"}); _scripts.push({url: "http://www.2xyw.com/cdn/gio/gio.min.js"}); ``` 路径:D:\ireport365\ireport365.war\WEB-INF\classes\report-resource\design.js ``` case "gioChart": var f = []; f.push("<div class='gio' style='width:100%;height:100%;'></div>"); var i = $compile(f.join(""))(scope); element.html(i); // 获取元素dom var e = scope.component; scope.$on(event_refreshBindingData, function (target, param) { //如果刷新数据事件的发出者是当前控件,不处理本次通知 if(param.component != null && scope.component.id === param.component.id){ return; } // console.log(scope.component.config.datasourceConfig) var dimensions = scope.component.config.datasourceConfig.dimensions; var measures = scope.component.config.datasourceConfig.measures; if(measures == null){ measures = []; } if (dimensions && dimensions.length > 0) { scope.queryModelData({ eventParam: param, dimensions: dimensions, measures: measures, tableKey: scope.component.config.datasourceConfig.metadataConfig.metadataTable.key, onQuerySuccess: function (response) { // console.log(response) if (response.data.success) { // console.log(response.data.success) scope.refreshChartView(scope, element, component, $compile) } else { toaster.error({ body: response.data.message }) } }, onError: function () { toaster.error({ body: vsLang.connection_failed }) } }) } }); // var gio = element.find('#gio')[0]; // var gio = $('#'+component.id+' #gio')[0] // console.log(gio) // scope.component.context.controller = new GIO.Controller(gio); // 初始化数据 var gioData = [{ e: "CN", i: "US", v: 100000 }, { e: "CN", i: "RU", v: 3000000 }, { e: "RU", i: "US", v: 1000000 }, { e: "FR", i: "LK", v: 1000000 }, { e: "US", i: "FR", v: 1000000 }, { e: "ES", i: "LB", v: 235358 }, { e: "GI", i: "LT", v: 353123 }, { e: "GI", i: "MV", v: 352323 }, { e: "GT", i: "NE", v: 3215323 }, { e: "GT", i: "NP", v: 30323 }, { e: "GT", i: "PE", v: 135323 }, { e: "JO", i: "MX", v: 354323 }, { e: "KI", i: "MA", v: 35323 }, { e: "LK", i: "IQ", v: 1762131 }, { e: "LR", i: "JE", v: 172358 }, { e: "NE", i: "FI", v: 180132 }, { e: "CN", i: "ES", v: 110120 }, { e: "CN", i: "IT", v: 195313 }, { e: "CN", i: "JM", v: 2525 }, { e: "FI", i: "JO", v: 533413 }, { e: "FI", i: "JP", v: 534335 }, { e: "FI", i: "KI", v: 353535 }, { e: "FI", i: "KW", v: 53538 }, { e: "FI", i: "KY", v: 323512 }, { e: "FI", i: "LK", v: 135323 }, { e: "GI", i: "LR", v: 213123 }, ] // 核心代码start scope.refreshChartView = function (scope, element, component, $compile) { var processValueObj = function (b, c) { if (b == null || b === 0) { return 0 } var a = parseFloat(b); if (isNaN(a)) { return 0 } if (c == null) { c = 0 } b = Math.round(b * Math.pow(10, c)) / Math.pow(10, c); return a.toFixed(c) }; var processValue = function (d, e) { return processValueObj(d, e) }; var dimensions = component.config.datasourceConfig.dimensions; var measures = component.config.datasourceConfig.measures; //从context中获得控件数据 var data = component.context.data; var serieData = []; for (var i = 0; i < data.length; i++) { var value = processValue(data[i][measures[0].name], component.config.digit); var dataItem = { e: data[i][dimensions[0].name].toUpperCase(), i: data[i][dimensions[1].name].toUpperCase(), v: parseInt(value) }; serieData.push(dataItem) } // if (serieData) { var gio = $('#'+component.id+' .gio')[0] console.log(gio) component.context.controller = new GIO.Controller(gio); var gioInit = function () { // 数据 // console.log(controller) component.context.controller.clearData(); // console.log(gioData) component.context.controller.addData(gioData); // 设置初始国家 component.context.controller.setInitCountry(e.config.setInitCountry); // 开启提到国家的高度 component.context.controller.lightenMentioned(e.config.lightenMentioned); // 禁用没有提到的国家 component.context.controller.disableUnmentioned(e.config.disableUnmentioned); // 设置光晕颜色 component.context.controller.setHaloColor(e.config.lightenMentioned); // 显示输出线 component.context.controller.showInOnly(e.config.showOutOnly); // 显示输入线 component.context.controller.showOutOnly(e.config.showInOnly); //设置地球风格 component.context.controller.setStyle(e.config.setStyle); // 设置地球表面颜色 component.context.controller.setSurfaceColor(e.config.setSurfaceColor); // 在选中状态下的国家颜色 component.context.controller.setSelectedColor(e.config.setSelectedColor); // 设置输出连接线颜色 component.context.controller.setExportColor(e.config.setExportColor); // 设置输入连接线颜色 component.context.controller.setImportColor(e.config.setImportColor); // 设置背景颜色 component.context.controller.setBackgroundColor(e.config.setBackgroundColor); //海洋高度 component.context.controller.adjustOceanBrightness(e.config.adjustOceanBrightness); //设置国家高度 component.context.controller.adjustRelatedBrightness(e.config.adjustRelatedBrightness); // 提到的国家高度 // console.log(e.config.adjustRelatedBrightness) component.context.controller.adjustMentionedBrightness(e.config.adjustMentionedBrightness); } gioInit(); component.context.controller.clearData(); component.context.controller.addData(serieData); component.context.controller.init(); // } }; break; ```