<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                :-: echarts組件添加--數形圖 #### 一.添加echarts數圖選擇對象 ~~~ { // 新增樹圖 name: "", type: "treemap", coverImage: contextPath + "/images/componenttypes/" + locale + "/echarts/pie.png", coverImageWidth: a, tip: "樹圖" } ~~~ ps(type:"treemap" 重要--------) * * * * * 二.設置樹圖的初始數據 `var treemapdata=[{"value":17.6,"name":"保險"},{"value":16.5,"name":"知識產權"},{"value":16.5,"name":"出版"},{"value":15.5,"name":"輕工業"},{"value":14.8,"name":"金融"},{"value":13.7,"name":"化工"},{"value":13.6,"name":"科技"},{"value":13.4,"name":"教育"},{"value":13.1,"name":"對外經貿合作"},{"value":12.6,"name":"節能"},{"value":12.6,"name":"電力"},{"value":12.6,"name":"資源綜合利用"},{"value":12.4,"name":"能源"},{"value":12.2,"name":"礦產"},{"value":12,"name":"信息產業"},{"value":12,"name":"基礎設施"},{"value":11.7,"name":"物流"},{"value":11.6,"name":"環境保護"},{"value":11.6,"name":"國家安全"},{"value":11.6,"name":"水運"}]` ps(每一個代數據的圖形都需要初始化數據) * * * * * 三.添加樹圖echarts組件基礎對象 ~~~ // 樹圖對象 var treemapOptionTemplate = { // backgroundColor: "#000", // 標題 title: { show: false }, // 提示框 tooltip: { show: true, trigger: "item", // 提示框里的數據 formatter: "{a} <br/>{b} : {c}", axisPointer: { type: "line" }, position: function (p) { console.log([p[1], p[1]]) return [0, p[1]] } }, series: [{ name: vsLang.sample_growth_rate, type: 'treemap', visibleMin: 300, leafDepth: 2, roam: false, //是否開啟拖拽漫游(移動和縮放) nodeClick: false, //點擊節點后的行為,false無反應 breadcrumb: { show: false }, label: { //描述了每個矩形中,文本標簽的樣式。 normal: { show: true, textStyle: { color: '#fff', fontSize: 12, }, align: 'center', position: 'center' } }, itemStyle: { normal: { borderWidth: 1, gapWidth: 2, label: { show: true, distance: 0.5, position:"bottom", textStyle: { fontSize: 12 }, formatter: "{b}" }, labelLine: { show: true, length: 1 } }, emphasis: { label: { show: false, position: "center", textStyle: { fontSize: "30", fontWeight: "bold" } } } }, // 數據 data: treemapdata }] }; // end ~~~ 四.在factory大對象里面添加新組件的判斷 ~~~ // 是否顯示行為 isShowEventCategory: function (scope) { switch (scope.component.type) { case "column": case "mixed": case "pie": case "treemap": case "bar": case "line": return true } return false }, // 樹圖顯示行為所以添加樹圖的屬性 ~~~ * * * * * ~~~ // 聯動里面的指標聯動 supportReceiveMeasureLink: function (scope) { switch (scope.component.type) { case "column": case "pie": case "treemap": case "bar": case "line": case "chinaAreaMap": return true } return false }, // 樹圖需要聯動所以添加樹圖的屬性 ~~~ * * * * * internalInit在這個函數里添加判斷--條件屬性(type="treemap") ~~~ case "treemap": // 組件需要的數據 var serieData = option.series[0].data; 提示框的位置 option.tooltip.position = function (p) { return [0, p[1]] }; break; ~~~ [教程](https://www.cnblogs.com/cupsuccess/p/6483284.html) * * * * * 添加internalRefreshTreeMapModelData這個函數 重要 重要 重要。 ~~~ var internalRefreshTreeMapModelData = function () { // 綜合數據 var option = component.config.chartConfig; // 維度 var dimensions = component.config.datasourceConfig.dimensions; // 度量 var measures = component.config.datasourceConfig.measures; console.log(measures) var data = component.context.data; // 判斷data是不是null if (data == null) { return } // 判斷度量選擇了幾個 if (measures.length>2) { alert('請選擇一項指標') return } // 初始化度量索引為0 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 } } } // 數據初始化為0 var serieData = []; for (var i = 0; i < data.length; i++) { var dimValue = data[i][dimensions[dimensions.length - 1].name]; // 函數在vs-utils.js if (VSUtils.isEmpty(dimValue)) { continue } // datapush進去每一個度量里的key 和 value serieData.push({ name: dimValue, value: data[i][measures[measureIdx].name] }); } console.log(serieData) // 判斷如果數據沒有那么就為空數組 if (serieData.length == 0) { serieData = [""]; } // 數據賦值給echarts對象里面的data option.series[0].data = serieData; option.series[0].name = measures[measureIdx].label; option.series[0].seriesIndex = measureIdx; if (component.config["measureAlias_" + measureIdx] != null && component.config["measureAlias_" + measureIdx].length > 0) { option.series[0].name = component.config["measureAlias_" + measureIdx] } // 處理提示框的數據 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[1], p, VSUtils) } catch (e) { console.log(e) } } console.log(component.config["unit_" + seriesIndex]) var unit = component.config["unit_" + seriesIndex]; if (unit == null) { unit = "" } var displayValue = $vsUtils.processValue(p[2], component.config["digit_" + seriesIndex]); console.log(displayValue) console.log(p[1] + "<br/>" + p[0] + ": " + $vsUtils.comdifyValue(displayValue) + "" + unit + "(" + p[3] + "%)") // 提示框里顯示的每一個指標的數據 return p[1] + "<br/>" + p[0] + ": " + $vsUtils.comdifyValue(displayValue); }; rebuildPieChart(scope, element, option); if (component.config.hideOnFirstShow && !component.context.firstShowTooltip) { component.context.firstShowTooltip = true; return } }; ~~~ * * * * * 在所有組件data函數的下面加一個switch判斷 ~~~ case "treemap": internalRefreshTreeMapModelData(); break; ~~~ * * * * * buildDataDescription在這個數據綁定函數里<br> ~~~ scope.$on(event_chartDimensionValueChange, function (s, event) { // 添加內容 switch (component.type) { case "treemap": // 判斷提示框是顯示 還是隱藏或者禁用 if (!component.config.chartConfig.tooltip.show) { component.context.chart.component.tooltip.hideTip(); return } var dataIndex = -1; for (var i = 0; i < component.config.chartConfig.series[0].data.length; i++) { if ("" + component.config.chartConfig.series[0].data[i].name === "" + event.source.value) { dataIndex = i; break } } if (dataIndex < 0) { component.context.chart.component.tooltip.hideTip(); return } if (dataIndex > -1) { component.context.chart.component.tooltip.showTip({ // name: event.source.value, // seriesIndex: 0 dataIndex: dataIndex, seriesIndex: 0 }) } break; } }) ~~~ ps(里面 已經有判斷了 我們只需要添加單獨的判斷條件和邏輯代碼即可) * * * * * refreshMeasureCategoryDescription在這個函數里添加 * * * * * ~~~ case "treemap": watchers.push(scope.$watch("component.config.measureAlias" + identifier, function (newValue) { if (newValue != null) { scope.$broadcast(event_refreshChartView, {}) } })); watchers.push(scope.$watch("component.config.unit" + identifier, function (newValue) { if (newValue != null) { scope.$broadcast(event_refreshChartView, {}) } })); break; ~~~ * * * * * 在已有的判斷里添加樹形圖 這里是判斷基本并監聽基本屬性改變值 * * * * * ~~~ switch (component.type) { case "bar": case "line": case "area": case "pie": case "treemap": case "mixed": case "column": scope.$watch("component.config.legendItemHeight", function (newValue, oldValue) { if (newValue != null && oldValue != null) { var option = component.config.chartConfig; option.legend.itemHeight = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendItemWidth", function (newValue, oldValue) { if (newValue != null && oldValue != null) { var option = component.config.chartConfig; option.legend.itemWidth = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.showLegend", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; if (option.legend == null) { option.legend = { show: false, orient: "horizontal", x: "right", y: "top", data: [vsLang.sample_revenue], textStyle: { color: "#999", fontSize: 12 } }; option.legend.show = newValue === "show"; scope.$broadcast(event_refreshChartView, {}) } else { option.legend.show = newValue === "show"; scope.component.context.chart.setOption(option, true) } } }); scope.$watch("component.config.legendSelectedModeObj", function (newValue) { if (newValue != null) { component.config.legendSelectedMode = newValue.value; var option = component.config.chartConfig; option.legend.selectedMode = newValue.value; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendOrient", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.legend.orient = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendPosY", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.legend.y = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendOffsetY", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.legend.y = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendPosX", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.legend.x = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendFontColor", function (newValue) { if (isValidColorValue(newValue)) { var option = component.config.chartConfig; if (option.legend.textStyle == null) { option.legend.textStyle = {} } option.legend.textStyle.color = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendFontSize", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; if (option.legend.textStyle == null) { option.legend.textStyle = {} } option.legend.textStyle.fontSize = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendItemGap", function (newValue) { var option = component.config.chartConfig; if (newValue != null) { option.legend.itemGap = parseInt(newValue) } else { if (option.legend != null) { delete option.legend.itemGap } } scope.component.context.chart.setOption(option, true) }); break } ~~~ * * * * * 在buildChartWatchers函數里添加 ~~~ case "treemap": scope.$watchCollection("component.config.colorSeries", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.color = newValue; rebuildPieChart(scope, element, option) } }); scope.$watch("component.config.pieSize", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; if (component.config.pieInnerSize == null) { component.config.pieInnerSize = 0 } option.series[0].radius = [component.config.pieInnerSize + "%", newValue + "%"]; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.pieInnerSize", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; if (component.config.pieSize == null) { component.config.pieSize = parseInt(option.series[0].radius) } option.series[0].radius = [newValue + "%", component.config.pieSize + "%"]; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.showEmphasis", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; if (option.series[0].itemStyle.emphasis == null) { option.series[0].itemStyle.emphasis = { label: { show: false, position: "center", textStyle: { fontSize: "30", fontWeight: "bold" } } } } option.series[0].itemStyle.emphasis.label.show = newValue === "show"; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.emphasisFontSize", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; if (option.series[0].itemStyle.emphasis == null) { option.series[0].itemStyle.emphasis = { label: { show: false, position: "center", textStyle: { fontSize: "30", fontWeight: "bold" } } } } option.series[0].itemStyle.emphasis.label.textStyle.fontSize = newValue + ""; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.itemStyleType", function (newValue) { console.log(component.config) if (newValue != null) { var option = component.config.chartConfig; console.log() option.series[0].itemStyle.normal.show = newValue === "show"; option.series[0].itemStyle.normal.show = newValue === "show"; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.showLegend", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.legend.show = newValue === "show"; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendOrient", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.legend.orient = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendPosY", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.legend.y = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendPosX", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; option.legend.x = newValue; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.pieCenterY", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; if (component.config.pieCenterX == null) { component.config.pieCenterX = parseInt(option.series[0].center[0]) } option.series[0].center = [component.config.pieCenterX + "%", newValue + "%"]; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.pieCenterX", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; if (component.config.pieCenterY == null) { component.config.pieCenterY = parseInt(option.series[0].center[1]) } option.series[0].center = [newValue + "%", component.config.pieCenterY + "%"]; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendValueType", function (newValue) { if (newValue != null) { var option = component.config.chartConfig; scope.component.context.chart.setOption(option, true) } }); scope.$watch("component.config.legendSelectedModeObj", function (newValue) { if (newValue != null) { component.config.legendSelectedMode = newValue.value; var option = component.config.chartConfig; option.legend.selectedMode = newValue.value; scope.component.context.chart.setOption(option, true) } }); break; ~~~ * * * * * 在buildChartOption函數里的switch判斷力添加 * * * * * ~~~ case "treemap": option = angular.copy(treemapOptionTemplate); break; ~~~ * * * * * #### 五.在design.js里添加新組件對應的判斷和邏輯 在internalBuildEChartsComponent函數里添加 ~~~ case "treemap": var serieData = option.series[0].data; option.tooltip.position = function (p) { return [0, p[1]] }; break; ~~~ * * * * * 同樣添加internalRefreshTreemapModelData函數 ~~~ var internalRefreshTreemapModelData = function () { var option = component.config.chartConfig; var dimensions = component.config.datasourceConfig.dimensions; var measures = component.config.datasourceConfig.measures; var data = component.context.data; 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 serieData = []; var legendData = []; for (var i = 0; i < data.length; i++) { var dimValue = data[i][dimensions[dimensions.length - 1].name]; if (VSUtils.isEmpty(dimValue)) { continue } serieData.push({ name: dimValue, value: data[i][measures[measureIdx].name] }); legendData.push(dimValue) } console.log(serieData) if (serieData.length == 0) { serieData = [""]; legendData = [""] } option.series[0].data = serieData; option.series[0].name = measures[measureIdx].label; option.series[0].seriesIndex = measureIdx; if (component.config["measureAlias_" + measureIdx] != null && component.config["measureAlias_" + measureIdx].length > 0) { option.series[0].name = component.config["measureAlias_" + measureIdx] } 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[1], p, VSUtils) } catch (e) { console.log(e) } } var unit = component.config["unit_" + seriesIndex]; if (unit == null) { unit = "" } var displayValue = $vsUtils.processValue(p[2], component.config["digit_" + seriesIndex]); // console.log(p[1] + "<br/>" + p[0] + ": " + $vsUtils.comdifyValue(displayValue) + "" + unit + "(" + p[3] + "%)") return p[1] + "<br/>" + p[0] + ": " + $vsUtils.comdifyValue(displayValue); }; console.log(legendData) console.log(option) option.data = legendData; rebuildPieChart(scope, element, option); if (component.config.hideOnFirstShow && !component.context.firstShowTooltip) { component.context.firstShowTooltip = true; return } if (component.config.chartConfig.tooltip.show) { $timeout(function () { var cachedSelectedValue = scope.getCachedDimensionValue(dimensions[dimensions.length - 1].name); if (cachedSelectedValue != null) { component.context.chart.component.tooltip.showTip({ name: cachedSelectedValue, seriesIndex: 0 }) } }, 800) } }; ~~~ * * * * * ps:和設置頁的data函數一樣 * * * * * 在refreshChartView函數里添加 ~~~ case "treemap": internalRefreshTreemapModelData(); break; ~~~ * * * * * 在已有的switch里添加一個判斷 (這里是判斷提示框的顯示隱藏禁用) ~~~ scope.$on(event_chartDimensionValueChange, function (s, event) { switch (component.type) { case "treemap": if (!component.config.chartConfig.tooltip.show) { return } var dataIndex = -1; for (var i = 0; i < component.config.chartConfig.series[0].data.length; i++) { if ("" + component.config.chartConfig.series[0].data[i].name === "" + event.source.value) { dataIndex = i; break } } if (dataIndex < 0) { component.context.chart.component.tooltip.hideTip(); return } if (dataIndex > -1) { component.context.chart.component.tooltip.showTip({ name: event.source.value, seriesIndex: 0 }) } break; } }) ~~~ 因為樹圖折現圖和餅圖基礎部分一樣 在已有的判斷力加上treemap屬性 ~~~ switch (scope.component.type) { case "mixed": case "bar": case "line": case "treemap": case "line": case "column": component.context.chart.on(echarts.config.EVENT.CLICK, function (param) { var paramName = param.name; if (component.context.originalYAxisLabels != null && component.context.originalYAxisLabels.length > param.dataIndex) { paramName = component.context.originalYAxisLabels[param.dataIndex] } if (component.context.originalXAxisLabels != null && component.context.originalXAxisLabels.length > param.dataIndex) { paramName = component.context.originalXAxisLabels[param.dataIndex] } if (!VSUtils.isEmpty(component.context.tooltipDataValue) && "" + component.context.tooltipDataValue === "" + paramName) { scope.onComponentClickEvent(component, true) } }); break } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看