💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
文件路径:D:\ireport365\ireport365.war.bk\js\enduser\designer\vs-component-echarts.js 一 添加桑基图 ``` { name: "", type: "sanKey", coverImage: contextPath + "/images/componenttypes/" + locale + "/echarts/zh\_pictogram.png", coverImageWidth: a, data: true, dimensions: 2, measures: 1, tip: "桑基图" } ``` 二 添加 option对象 搜索dynamicBarOptionTemplate 在下面添加下面代码 ``` // 桑基图 对象 start var SankeysourceData = [{name:'市直归集',value:286.29},{name:'省级回流',value:286.29},{name:'五区归集',value:286.29},{name:'数据中心',value:286.29},{name:'综合治税',value:286.29,},{name:'市场监管',value:286.29},{name:'公共信用',value:286.29},{name:'数据开放',value:286.29}]; var Sankeylinks = [{source:'市直归集',target:'数据中心',value:6},{source:'省级回流',target:'数据中心',value:3},{source:'五区归集',target:'数据中心',value:3},{source:'数据中心',target:'综合治税',value:5},{source:'数据中心',target:'市场监管',value:2},{source:'数据中心',target:'公共信用',value:3},{source:'数据中心',target:'数据开放',value:2}]; var SankeyOptionTemplate = { tooltip: { show: true, trigger: "item", formatter: "{b} : {c}", axisPointer: { type: "shadow" } }, series: [{ type: 'sankey', layout: 'none', top:"12%", bottom: '21%', left:'3%', focusNodeAdjacency: 'allEdges', draggable: false,//禁止拖拽 data: SankeysourceData, links: Sankeylinks, label: { normal:{ color:"#333", fontSize:14, rich:{ white:{ fontSize:12, padding:[10,0,0,0] } } } }, lineStyle: { normal: { color: 'source', curveness: 0.5 } }, itemStyle: { normal: { borderWidth: 1, borderColor: 'transparent' } } }], color:colorValueSeries } // 桑基图 对象 end ``` 三 copy 对象模板 如图位置 ![](https://img.kancloud.cn/01/05/0105d6877ea1bf471fe972ca8afdaca6_1025x301.png) ``` case "sanKey": option = angular.copy(SankeyOptionTemplate); break; ``` 四 搜索 getThresholdCategoryName 和 isShowEventCategory 分别添加下面代码 如图 ![](https://img.kancloud.cn/8f/a4/8fa482b9ed406da9fead03193337554b_674x738.png) ``` case "sanKey": ``` 五 添加数据处理函数 搜索 internalRefreshAnnularModelData 在下面添加下面代码 ``` var internalRefreshSanKeyModelData = function () { var option = component.config.chartConfig; var dimensions = component.config.datasourceConfig.dimensions; var measures = component.config.datasourceConfig.measures; var data = component.context.data; if(data == null || data.length < 1){ return; } var measureIdx = 0; if (component.config.receiveMeasureLink != null && component.config.receiveMeasureLink === true) { var newMeasures = scope.getSelectedLinkMeasure(component, component.config.datasourceConfig.measures); for (var i = 0; i < measures.length; i++) { if (newMeasures[i] != null) { measureIdx = i; break } } } if (dimensions.length >= 2 && measures.length > 0) { var links = new Array(); var dataObj = {}; var dataNames = new Array(); for (var i in data) { var link = { source:data[i][dimensions[dimensions.length - 2].name], target:data[i][dimensions[dimensions.length - 1].name], value:data[i][measures[measures.length - 1].name] }; links.push(link); if (null == dataObj[link.source]) { dataObj[link.source] = 1; dataNames.push({name:link.source}); } if (null == dataObj[link.target]) { dataObj[link.target] = 1; dataNames.push({name:link.target}); } } option.series[0].links = links; option.series[0].data = dataNames; option.series[0].name = measures[measureIdx].label; option.series[0].seriesIndex = measureIdx; } // 重新绘制图形并清除以前的 setTimeout(function () { component.context.chart.setOption(option, true) }) if (component.config["measureAlias_" + measureIdx] != null && component.config["measureAlias_" + measureIdx].length > 0) { option.series[0].name = component.config["measureAlias_" + measureIdx] } // 谷建文 2019.11.19 option.tooltip.formatter = function (p) { if (component.config.tooltipStatus != null && component.config.tooltipStatus === "hide") { return "" } var seriesIndex = option.series[0].seriesIndex; if (!VSUtils.isEmpty(component.config.tooltipValueScript)) { try { var f = eval("(function(name, params, VSUtils){ " + Base64.decode(component.config.tooltipValueScript) + "})"); return f.call(null, p.name, p, VSUtils) } catch (e) { console.log(e) } } var unit = component.config["unit_" + seriesIndex]; if (unit == null) { unit = "" } var displayValue = $vsUtils.processValue(p.value, component.config["digit_" + seriesIndex]); var str = p.name + "<br/>" + p.seriesName + ": " + $vsUtils.comdifyValue(displayValue) + "" + unit; if(displayValue == 0){ str = '' } var measures = scope.component.config.datasourceConfig.measures; var _data = scope.component.context.data; if (_data != null) { for (var m = 1; m < measures.length; m++) { var seriesIdx = m; var value = _data[p.dataIndex][measures[m].name]; var unit = component.config["unit_" + seriesIdx]; if (unit == null) { unit = "" } if (component.config["valueType_" + seriesIdx] != null && component.config["valueType_" + seriesIdx] === "percent") { value = value * 100; unit = "%" } value = $vsUtils.processValue(value, component.config["digit_" + seriesIdx]); var _label = measures[m].label; if (component.config["measureAlias_" + m] != null && component.config["measureAlias_" + m].length > 0) { _label = component.config["measureAlias_" + m] } str += "<br/>" + _label + " : " + $vsUtils.comdifyValue(value) + unit } } return str }; // end rebuildPieChart(scope, element, option); if (component.config.hideOnFirstShow && !component.context.firstShowTooltip) { component.context.firstShowTooltip = true; return } }; ``` 六 添加数据方法调用 如图位置 ![](https://img.kancloud.cn/92/bb/92bbf8545b4e8d8fef30f2106cfddec5_873x238.png) ``` case "sanKey": internalRefreshSanKeyModelData(); break; ``` 七 添加 图形维度数量 搜索 case "dynamicBar": 位置如图 ![](https://img.kancloud.cn/a0/22/a0225b9511536ba25d9465a55ca5bd17_790x211.png) ``` case "sanKey": //控件的图形维度数量 scope.component.config.chartDimensionCount = 2; break; ``` 八 添加 色块配置项 搜索case "dynamicBar": 如图位置 ![](https://img.kancloud.cn/5c/ae/5cae0c1986647a9fd6840fe2a4b3089f_1082x526.png) ``` case "sanKey": extensionCategory = { name: "colorSeries", title: vsLang.color_blocks, groups: [] }; component.description.categories.push(extensionCategory); break; ``` 九 添加配置项 搜索 case "treemap": 在树图的配置项下面添加 如图 ![](https://img.kancloud.cn/33/41/3341d03c4778f9478d6a294067b4a7f0_892x312.png) ``` case "sanKey": chartCategory.groups.push({ title: { text: "基本配置" }, elements: [{ title: "拖动", type: "switch", bind: "draggable", on: vsLang.on, off: vsLang.off },{ title: "字体颜色", type: "colorpicker", bind: "FontColor" }, { title: "字体大小", type: "configSlide", bind: "FontSize", config: { slideEnd: 100 } },{ title: "边框颜色", type: "colorpicker", bind: "borderColor" }, { title: "边框宽度", type: "configSlide", bind: "borderWidth", config: { slideEnd: 100 } }] }); //监听draggabler属性 scope.$watch('component.config.draggable', function(newValue, oldValue){ if(newValue != null && (oldValue == null || oldValue !== newValue)){ var option = component.config.chartConfig; option.series[0].draggable = newValue; scope.component.context.chart.setOption(option, true) } }); //监听FontColor属性 scope.$watch('component.config.FontColor', function(newValue, oldValue){ if(newValue != null && (oldValue == null || oldValue !== newValue)){ var option = component.config.chartConfig; option.series[0].label.normal.color = newValue; scope.component.context.chart.setOption(option, true) } }); //监听FontSize属性 scope.$watch('component.config.FontSize', function(newValue, oldValue){ if(newValue != null && (oldValue == null || oldValue !== newValue)){ var option = component.config.chartConfig; option.series[0].label.normal.fontSize = newValue; scope.component.context.chart.setOption(option, true) } }); //监听borderColor属性 scope.$watch('component.config.borderColor', function(newValue, oldValue){ if(newValue != null && (oldValue == null || oldValue !== newValue)){ var option = component.config.chartConfig; option.series[0].itemStyle.normal.borderColor = newValue; scope.component.context.chart.setOption(option, true) } }); //监听borderWidth属性 scope.$watch('component.config.borderWidth', function(newValue, oldValue){ if(newValue != null && (oldValue == null || oldValue !== newValue)){ var option = component.config.chartConfig; option.series[0].itemStyle.normal.borderWidth = newValue; scope.component.context.chart.setOption(option, true) } }); break; ``` 十 添加提示框 代码 搜索 vsLang.tooltip_window 在上面添加下面代码 如图位置 ![](https://img.kancloud.cn/bf/d4/bfd4c5e11d9c23a182b59884a4ef00cf_745x395.png) ``` case "sanKey": ``` 十一 添加提示框配置的监听 搜索 component.config.tooltipBgColor 在上面添加代码 如图位置 ![](https://img.kancloud.cn/26/67/2667b34acd336f82a3e9449351f22b5d_935x406.png) ``` case "sanKey": ``` 十二 添加 色块 配置项 搜索 case "dynamicBar": 如图位置 ![](https://img.kancloud.cn/4b/77/4b77c1283009383088b056d13017c696_748x624.png) ``` case "sanKey": extensionCategory.groups.push({ title: { text: vsLang.color_series }, elements: [{ title: vsLang.color_series, type: "colorSeries", bind: "colorSeries" }] }); component.config.colorSeries = option.color; break; ``` 十三 添加色块监听 搜索 case "dynamicBar": 在下面添加 位置如图 ![](https://img.kancloud.cn/e6/74/e674aa972f6a523699f2963f18bb1a2a_1095x431.png) ``` case "sanKey": scope.$watchCollection("component.config.colorSeries", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.color = newValue; rebuildPieChart(scope, element, option) } }); break; ``` # **分享页 design.js** 一 搜索 internalRefreshdynamicBarChartModelData 在下面添加代码 ``` var internalRefreshSanKeyModelData = function () { var option = component.config.chartConfig; var dimensions = component.config.datasourceConfig.dimensions; var measures = component.config.datasourceConfig.measures; var data = component.context.data; if(data == null || data.length < 1){ return; } var measureIdx = 0; if (component.config.receiveMeasureLink != null && component.config.receiveMeasureLink === true) { var newMeasures = scope.getSelectedLinkMeasure(component, component.config.datasourceConfig.measures); for (var i = 0; i < measures.length; i++) { if (newMeasures[i] != null) { measureIdx = i; break } } } if (dimensions.length >= 2 && measures.length > 0) { var links = new Array(); var dataObj = {}; var dataNames = new Array(); for (var i in data) { var link = { source:data[i][dimensions[dimensions.length - 2].name], target:data[i][dimensions[dimensions.length - 1].name], value:data[i][measures[measures.length - 1].name] }; links.push(link); if (null == dataObj[link.source]) { dataObj[link.source] = 1; dataNames.push({name:link.source}); } if (null == dataObj[link.target]) { dataObj[link.target] = 1; dataNames.push({name:link.target}); } } option.series[0].links = links; option.series[0].data = dataNames; option.series[0].name = measures[measureIdx].label; option.series[0].seriesIndex = measureIdx; } // 重新绘制图形并清除以前的 setTimeout(function () { component.context.chart.setOption(option, true) }) if (component.config["measureAlias_" + measureIdx] != null && component.config["measureAlias_" + measureIdx].length > 0) { option.series[0].name = component.config["measureAlias_" + measureIdx] } // 谷建文 2019.11.20 option.tooltip.formatter = function (p) { if (component.config.tooltipStatus != null && component.config.tooltipStatus === "hide") { return "" } var seriesIndex = option.series[0].seriesIndex; if (!VSUtils.isEmpty(component.config.tooltipValueScript)) { try { var f = eval("(function(name, params, VSUtils){ " + Base64.decode(component.config.tooltipValueScript) + "})"); return f.call(null, p.name, p, VSUtils) } catch (e) { console.log(e) } } var unit = component.config["unit_" + seriesIndex]; if (unit == null) { unit = "" } var displayValue = $vsUtils.processValue(p.value, component.config["digit_" + seriesIndex]); var str = p.name + "<br/>" + p.seriesName + ": " + $vsUtils.comdifyValue(displayValue) + "" + unit; if(displayValue == 0){ str = '' } var measures = scope.component.config.datasourceConfig.measures; var _data = scope.component.context.data; if (_data != null) { for (var m = 1; m < measures.length; m++) { var seriesIdx = m; var value = _data[p.dataIndex][measures[m].name]; var unit = component.config["unit_" + seriesIdx]; if (unit == null) { unit = "" } if (component.config["valueType_" + seriesIdx] != null && component.config["valueType_" + seriesIdx] === "percent") { value = value * 100; unit = "%" } value = $vsUtils.processValue(value, component.config["digit_" + seriesIdx]); var _label = measures[m].label; if (component.config["measureAlias_" + m] != null && component.config["measureAlias_" + m].length > 0) { _label = component.config["measureAlias_" + m] } str += "<br/>" + _label + " : " + $vsUtils.comdifyValue(value) + unit } } return str }; // end rebuildPieChart(scope, element, option); if (component.config.hideOnFirstShow && !component.context.firstShowTooltip) { component.context.firstShowTooltip = true; return } }; ``` 二 搜索 case "dynamicBar": 在下面添加顶用处理数据的方法 如图位置 ![](https://img.kancloud.cn/67/54/6754e5be6cfd19a2f69aad3509cc7218_889x376.png) ``` case "sanKey": internalRefreshSanKeyModelData(); break; ``` 三 搜索 case "iconbar": 在下面添加下面代码 如图位置 ![](https://img.kancloud.cn/13/a2/13a29669245ffbb738467fd28f334480_1047x744.png) ``` case "sanKey": var dataIndex = -1; var axisLabels = component.config.chartConfig.yAxis.data; if (component.context.originalYAxisLabels != null && component.context.originalYAxisLabels.length > dataIndex) { axisLabels = component.context.originalYAxisLabels } for (var i = 0; i < axisLabels.length; i++) { if ("" + axisLabels[i] === "" + event.source.value) { dataIndex = i; break } } if (dataIndex < 0) { component.context.chart.dispatchAction({ type: "hideTip" }); return } if (dataIndex > -1) { component.context.chart.dispatchAction({ type: "showTip", dataIndex: dataIndex, seriesIndex: 0 }) } break; ``` 四 搜索 case "iconbar": 在下面添加 代码 如图位置 ![](https://img.kancloud.cn/8a/2d/8a2deade3fa84564db4ba4064321dd18_1134x569.png) ``` case "sanKey": component.context.chart.on("highlight", function (param) { var dataIndex = param.batch[0].dataIndex; if (dataIndex < 0 || dataIndex >= component.config.chartConfig.yAxis.data.length) { return } if (component.config.chartPivotType != null) { for (var i = 0; i < component.config.chartConfig.series.length; i++) { var value = component.config.chartConfig.series[i].data[dataIndex]; if (component.config.valueType_0 != null && component.config.valueType_0 === "percent") { value = value * 100 } value = $vsUtils.processValue(value, component.config.digit_0); value = $vsUtils.comdifyValue(value); var name = component.config.chartConfig.series[i].name; scope.cacheDimensionValue(name, value) } } else { for (var i = 0; i < component.config.chartConfig.series.length; i++) { var value = component.config.chartConfig.series[i].data[dataIndex]; if (component.config["valueType_" + i] != null && component.config["valueType_" + i] === "percent") { value = value * 100 } value = $vsUtils.processValue(value, component.config["digit_" + i]); value = $vsUtils.comdifyValue(value); if (component.config.datasourceConfig.measures != null) { var name = component.config.datasourceConfig.measures[0].label; scope.cacheDimensionValue(name, value) } } } var value = component.config.chartConfig.yAxis.data[dataIndex]; if (component.context.originalYAxisLabels != null && component.context.originalYAxisLabels.length > dataIndex) { value = component.context.originalYAxisLabels[dataIndex] } if (component.context.tooltipDataValue != null && "" + component.context.tooltipDataValue === "" + value) { return } component.context.tooltipDataValue = value; scope.notifyDimensionValueChange(null, scope.getLastDimension(), value) }); break; ```