ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
设置提示窗 ~~~ case "treemap": var serieData = option.series[0].data; option.tooltip.position = function (p) { return [0, p[1]] }; break; ~~~ 数据方法 ~~~ 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) } }; ~~~ refreshChartView 函数里加 ~~~ case "treemap": internalRefreshTreemapModelData(); break; ~~~ scope.$on(event_chartDimensionValueChange, function (s, event) { 里写 ~~~ 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; ~~~ 4780行添加----只加 case "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 } ~~~