💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
一 添加极坐标图形 ``` { name: "", type: "roseLine", coverImage: contextPath + "/images/componenttypes/" + locale + "/echarts/zh\_pictogram.png", coverImageWidth: a, data: true, dimensions: 1, measures: 1, tip: "极坐标" } ``` 二 添加option对象 搜索pictorialColumnOptionTemplate 在下面添加 ``` // 玫瑰图 start var roseLineOptionTemplate = { color: colorValueSeries, title: { show:false }, tooltip: { show: true, trigger: "item", formatter: "{b} : {c}", axisPointer: { type: "shadow" } }, angleAxis: { type: 'category', data: ["北", "北东北", "东北", "东东北", "东", "东东南", "东南", "南东南", "南", "南西南", "西南", "西西南", "西", "西西北", "西北", "北西北"], boundaryGap: false, axisTick: { show:false, alignWithLabel: false }, axisLine: { show:false, lineStyle: { color: '#ff8800' } }, axisLabel: { show: false, color: '#ff8800', fontSize: 16 }, splitLine: { show: false, lineStyle: { color: "#ff8800", width: 1, type: "solid" } } }, radiusAxis: { axisTick: { show:false }, axisLine: { show: false, lineStyle: { color: "#0B3E5E", width: 1, type: "solid" }, }, axisLabel: { formatter: '{value} %', show: false, padding: [0, 0, 20, 0], color: "#ff8800", fontSize: 16 }, splitLine: { show:false, lineStyle: { color: "#ff8800", width: 2, type: "dashed" } }, z: 10 }, polar: {}, legend: { show: true, right: 0, bottom: 0, type: 'scroll', orient: 'vertical', data: ['<0.5m/s', '0.5-2m/s', '2-4m/s', '4-6m/s', '6-8m/s', '8-10m/s', '>10m/s'] }, series: [{ type: 'bar', data: [6.16, 6.84, 8.49, 8.11, 8.78, 7.13, 5.7, 4.28, 3.79, 4.07, 4.46, 5.76, 7.26, 6.92, 6.92, 5.32], coordinateSystem: 'polar', name: '0.5m/s', stack: 'a' }, { type: 'bar', data: [5.82, 8.0, 12.36, 11.77, 9.38, 6.19, 4.61, 3.87, 3.44, 3.17, 2.45, 3.58, 6.91, 6.47, 6.47, 5.5], coordinateSystem: 'polar', name: '0.5-2m/s', stack: 'a' }, { type: 'bar', data: [3.4, 7.37, 16.29, 12.56, 7.37, 5.04, 1.84, 1.11, 1.89, 2.97, 1.82, 4.11, 10.41, 10.01, 10.01, 3.81], coordinateSystem: 'polar', name: '2-4m/s', stack: 'a' }, { type: 'bar', data: [3.01, 6.22, 14.46, 10.34, 4.45, 4.52, 0.98, 0.59, 0.39, 2.23, 1.37, 4.25, 15.77, 13.94, 13.94, 3.53], coordinateSystem: 'polar', name: '4-6m/s', stack: 'a' }, { type: 'bar', data: [10.28, 14.65, 9.25, 12.34, 1.03, 1.54, 0.26, 0.26, 0.51, 1.03, 1.8, 7.2, 12.34, 11.57, 11.57, 4.37], coordinateSystem: 'polar', name: '6-8m/s', stack: 'a' }, { type: 'bar', data: [6.16, 6.84, 8.49, 8.11, 8.78, 7.13, 5.7, 4.28, 3.79, 4.07, 4.46, 5.76, 7.26, 6.92, 6.92, 5.32], coordinateSystem: 'polar', name: '8-10m/s', stack: 'a' }, { type: 'bar', data: [6.16, 6.84, 8.49, 8.11, 8.78, 7.13, 5.7, 4.28, 3.79, 4.07, 4.46, 5.76, 7.26, 6.92, 6.92, 5.32], coordinateSystem: 'polar', name: '>10m/s', stack: 'a' }] }; // 玫瑰图 end ``` 复制对象 搜索 angular.copy(pictorialColumnOptionTemplate) 如图位置 ![](https://img.kancloud.cn/f5/de/f5def5459cb0722cf7d93ff90e796895_777x1275.png) ``` case "roseLine": option = angular.copy(roseLineOptionTemplate); break; ``` 三 搜索 getThresholdCategoryName 和isShowEventCategory 分别添加 如图 ![](https://img.kancloud.cn/4a/e6/4ae6d7d7d617ca09a7ee1cd2325c530d_928x854.png) ``` case "roseLine": ``` 四 弹窗单位配置 搜case "pictorialColumn": 在这个配置下面写 代码块基本上差不多 稍有改动 ![](https://img.kancloud.cn/3f/e1/3fe1372017602cb3d083fdc1bcbeaea5_702x1279.png) ``` case "roseLine": option.tooltip.confine = true; option.tooltip.formatter = function (params) { // console.log(params) if (component.config.tooltipStatus != null && component.config.tooltipStatus === "hide") { return "" } var res = params.name; if (component.context.originalYAxisLabels != null && component.context.originalYAxisLabels.length > params[0].dataIndex) { res = component.context.originalYAxisLabels[params[0].dataIndex] } if (!VSUtils.isEmpty(component.config.tooltipValueScript)) { try { var f = eval("(function(name, params, VSUtils){ " + Base64.decode(component.config.tooltipValueScript) + "})"); return f.call(null, res, params, VSUtils) } catch (e) { console.log(e) } } if (component.config.chartPivotType != null) { var unit = component.config.unit_0; var value = params[0].value; if (unit == null) { unit = "" } if (component.config.valueType_0 != null && component.config.valueType_0 === "percent") { value = value * 100; unit = "%" } value = $vsUtils.processValue(value, component.config.digit_0); res += "<br/>" + params[0].seriesName + " : " + $vsUtils.comdifyValue(value) + unit } else { var measures = component.config.datasourceConfig.measures; // console.log(params) var seriesIdx = 0; var unit = component.config["unit_" + params.dataIndex]; // console.log(component.config) var value = params.value; if (unit == null) { unit = "" } if (component.config["valueType_" + params.dataIndex] != null && component.config["valueType_" +params.dataIndex] === "percent") { value = value * 100; unit = "%" } value = $vsUtils.processValue(value, component.config["digit_" + params.dataIndex]); res += "<br/>" + params.seriesName + " : " + $vsUtils.comdifyValue(value) + unit } return res }; break; ``` 五:搜索 internalRefreshPictorialColumnChartModelData 在这个下面 写数据处理 如下代码 ``` var internalRefreshroseLineChartModelData = function(){ var option = component.config.chartConfig; var dimensions = component.config.datasourceConfig.dimensions; var measures = component.config.datasourceConfig.measures; var data = component.context.data; // option.chartData = data; if (data == null) { 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 } } } var legendData = []; var newSeries = []; var seriesMap = {}; for (var i = 0; i < data.length; i++) { for (var m = 0; m < measures.length; m++) { var show = component.config["show_" + m]; if (show != null && show === false) { continue } var seriesName = data[i][dimensions[dimensions.length - 1].name]; if (legendData.indexOf(seriesName) < 0) { legendData.push(seriesName) } var series = seriesMap[seriesName]; if (series == null) { series = { name: seriesName, type: 'bar', coordinateSystem: 'polar', stack: 'a', data: [] }; newSeries.push(series); seriesMap[seriesName] = series; series.data = []; } series.data.push(data[i][measures[m].name]) var legendValue = measures[m].label; if (component.config["measureAlias_" + m] != null && component.config["measureAlias_" + m].length > 0) { option.angleAxis.data[m] = component.config["measureAlias_" + m]; legendValue = component.config["measureAlias_" + m] } legendData.push(legendValue); if (option.angleAxis.data[m] == null || option.angleAxis.data.length == 0) { option.angleAxis.data[m] = measures[m].label } option.series[m].seriesIndex = measureIdx; } } // console.log(newSeries) // console.log(legendData) // option.series = newSeries; // option.series[0].seriesIndex = measureIdx; // console.log(option) setTimeout(function () { component.context.chart.setOption(option, true) }) } ``` 六 写调用 数据处理的方法 ![](https://img.kancloud.cn/d0/e1/d0e12c2636d64377123a7c3cee239ac3_680x448.png) ``` case "roseLine": internalRefreshroseLineChartModelData(); break ``` 七:写 联动 弹框显示隐藏 搜索case "pictorialColumn": ![](https://img.kancloud.cn/a3/09/a309a232f87c9d680508b352b76cbed9_706x1156.png) ``` case "roseLine": // console.log(event.source.value) // console.log(component.config.chartConfig) var dataIndex = -1; var option = component.config.chartConfig; for (var i = 0; i < component.config.chartConfig.series.length; i++) { // console.log(component.config.chartConfig.series[i].name) if ("" + component.config.chartConfig.series[i].name === "" + event.source.value) { console.log(i) dataIndex = i; break } } if (dataIndex < 0) { component.context.chart.dispatchAction({ type: "hideTip" }); return } if (dataIndex > -1) { component.context.chart.dispatchAction({ type: "showTip", name: event.source.value, dataIndex:dataIndex, seriesIndex: 0 }) } break; ``` 八搜索 case "pictorialColumn": 写如下代码 ![](https://img.kancloud.cn/cd/dc/cddc1ccec07d3a83ea298d1724c8e35d_704x1563.png) ``` case "roseLine": component.context.chart.on("mouseover", function (param) { var dataIndex = param.dataIndex; console.log(dataIndex) // if (dataIndex < 0 || dataIndex >= component.config.chartConfig.xAxis[0].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.xAxis[0].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; ``` 九 配置色块 搜索 var extensionCategory = null; 如图位置 添加代码 ![](https://img.kancloud.cn/f6/b0/f6b01e479a75b95fb1727a3dddce4780_654x536.png) ``` case "roseLine": ``` 十 图例配置项 如图位置 ![](https://img.kancloud.cn/5a/e1/5ae14575764983c47b71e769aef77861_701x705.png) ``` case "roseLine": ``` 十一 搜索 component.config.pictorialColumnlabelFontSize 在下面添加 配置项 ![](https://img.kancloud.cn/cf/3a/cf3aaaafc821148cebb6af15dd72704c_885x499.png) ``` case "roseLine": chartCategory.groups.push({ title: { text: "边框配置" }, elements: [{ title: "开关", type: "switch", bind: "axisLineShow", on: vsLang.on, off: vsLang.off },{ title: "颜色", type: "colorpicker", bind: "axisLineColor" },{ title: "线宽", type: "configSlide", bind: "axisLineWidth", config: { slideEnd: 50 } },{ title: "线性", type: "radio", bind: "axisLineType", items: [{ name: "实线", value: "solid" }, { name: "虚线", value: "dashed" }] },{ title: "文字", type: "switch", bind: "axisLabelShow", on: vsLang.on, off: vsLang.off },{ title: "文字颜色", type: "colorpicker", bind: "axisLabelColor" },{ title: "文字线宽", type: "configSlide", bind: "axisLabelFontsize", config: { slideEnd: 50 } }] }); chartCategory.groups.push({ title: { text: "纵线配置" }, elements: [{ title: "开关", type: "switch", bind: "splitLineShow", on: vsLang.on, off: vsLang.off },{ title: "颜色", type: "colorpicker", bind: "splitLineColor" },{ title: "线宽", type: "configSlide", bind: "splitLineWidth", config: { slideEnd: 50 } },{ title: "线性", type: "radio", bind: "splitLineType", items: [{ name: "实线", value: "solid" }, { name: "虚线", value: "dashed" }] }] }); chartCategory.groups.push({ title: { text: "轴线配置" }, elements: [{ title: "开关", type: "switch", bind: "radiusAxisLineShow", on: vsLang.on, off: vsLang.off },{ title: "颜色", type: "colorpicker", bind: "radiusAxisLineColor" },{ title: "线宽", type: "configSlide", bind: "radiusAxisLineWidth", config: { slideEnd: 50 } },{ title: "线性", type: "radio", bind: "radiusAxisLineType", items: [{ name: "实线", value: "solid" }, { name: "虚线", value: "dashed" }] },{ title: "文字", type: "switch", bind: "radiusAxisLabelShow", on: vsLang.on, off: vsLang.off },{ title: "文字颜色", type: "colorpicker", bind: "radiusAxisLabelColor" },{ title: "文字大小", type: "configSlide", bind: "radiusAxisLabelFontSize", config: { slideEnd: 50 } },{ title: "文字单位", type: "radio", bind: "radiusAxisLabelFormatter", items: [{ name: "无", value: "" }, { name: "百分比", value: "%" }] }] }); chartCategory.groups.push({ title: { text: "内线配置" }, elements: [{ title: "开关", type: "switch", bind: "radiussplitLineShow", on: vsLang.on, off: vsLang.off },{ title: "颜色", type: "colorpicker", bind: "radiussplitLineColor" },{ title: "线宽", type: "configSlide", bind: "radiussplitLineWidth", config: { slideEnd: 50 } },{ title: "线性", type: "radio", bind: "radiussplitLineType", items: [{ name: "实线", value: "solid" }, { name: "虚线", value: "dashed" }] }] }); scope.$watch("component.config.axisLineShow", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.angleAxis.axisLine.show = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.axisLineColor", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.angleAxis.axisLine.lineStyle.color = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.axisLineWidth", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.angleAxis.axisLine.lineStyle.width = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.axisLineType", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.angleAxis.axisLine.lineStyle.type = newValue; scope.component.context.chart.setOption(option, true) } }); // end scope.$watch("component.config.axisLabelShow", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.angleAxis.axisLabel.show = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.axisLabelColor", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.angleAxis.axisLabel.color = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.axisLabelFontsize", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.angleAxis.axisLabel.fontSize = newValue; scope.component.context.chart.setOption(option, true) } }); // end scope.$watch("component.config.splitLineShow", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.angleAxis.splitLine.show = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.splitLineColor", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.angleAxis.splitLine.lineStyle.color = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.splitLineWidth", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.angleAxis.splitLine.lineStyle.width = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.splitLineType", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.angleAxis.splitLine.lineStyle.type = newValue; scope.component.context.chart.setOption(option, true) } }); // end scope.$watch("component.config.radiusAxisLineShow", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.radiusAxis.axisLine.show = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.radiusAxisLineColor", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.radiusAxis.axisLine.lineStyle.color = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.radiusAxisLineWidth", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.radiusAxis.axisLine.lineStyle.width = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.radiusAxisLineType", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.radiusAxis.axisLine.lineStyle.type = newValue; scope.component.context.chart.setOption(option, true) } }); // end scope.$watch("component.config.radiusAxisLabelShow", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.radiusAxis.axisLabel.show = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.radiusAxisLabelColor", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.radiusAxis.axisLabel.color = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.radiusAxisLabelFontSize", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.radiusAxis.axisLabel.fontSize = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.radiusAxisLabelFormatter", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.radiusAxis.axisLabel.formatter = '{value} '+newValue; scope.component.context.chart.setOption(option, true) } }); // end scope.$watch("component.config.radiussplitLineShow", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.radiusAxis.splitLine.show = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.radiussplitLineColor", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.radiusAxis.splitLine.lineStyle.color = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.radiussplitLineWidth", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.radiusAxis.splitLine.lineStyle.width = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.radiussplitLineType", function(newValue, oldValue) { if (newValue != null && (oldValue == null || oldValue !== newValue)) { var option = component.config.chartConfig; option.radiusAxis.splitLine.lineStyle.type = newValue; scope.component.context.chart.setOption(option, true) } }); break; ``` 十三 添加 提示框配置 ![](https://img.kancloud.cn/d5/f5/d5f578d14b73b81676c2950a82d0a452_596x501.png) ``` case "roseLine": ``` 搜索 component.config.chartConfig.tooltip.textStyle 在上面添加 ![](https://img.kancloud.cn/2a/4a/2a4a5c2088a0340c63c8d441e91afba3_636x213.png) ``` case "roseLine": ``` 搜索 component.config.legendItemHeight 在上面添加 ![](https://img.kancloud.cn/db/57/db5738b05be4b1a328470de486ea5faa_687x343.png) ``` case "roseLine": ``` 搜索 vsLang.color_series 在上面 添加 ![](https://img.kancloud.cn/26/a7/26a7fde7676cb08b0fc310f13ce9661c_667x356.png) ``` case "roseLine": ``` 搜索 case "sanKey": 在如图的位置添加下面代码 ![](https://img.kancloud.cn/75/ed/75ed3dd9143570b7f63d81b87626ba16_702x344.png) ``` case "roseLine": 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; ```