UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

51 lines (50 loc) 1.62 kB
import { each } from "../../../../zrender/lib/core/util.mjs"; import VisualMapping from "../../visual/VisualMapping.mjs"; function sankeyVisual(ecModel) { ecModel.eachSeriesByType("sankey", function(seriesModel) { var graph = seriesModel.getGraph(); var nodes = graph.nodes; var edges = graph.edges; if (nodes.length) { var minValue_1 = Infinity; var maxValue_1 = -Infinity; each(nodes, function(node) { var nodeValue = node.getLayout().value; if (nodeValue < minValue_1) { minValue_1 = nodeValue; } if (nodeValue > maxValue_1) { maxValue_1 = nodeValue; } }); each(nodes, function(node) { var mapping = new VisualMapping({ type: "color", mappingMethod: "linear", dataExtent: [minValue_1, maxValue_1], visual: seriesModel.get("color") }); var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value); var customColor = node.getModel().get(["itemStyle", "color"]); if (customColor != null) { node.setVisual("color", customColor); node.setVisual("style", { fill: customColor }); } else { node.setVisual("color", mapValueToColor); node.setVisual("style", { fill: mapValueToColor }); } }); } if (edges.length) { each(edges, function(edge) { var edgeStyle = edge.getModel().get("lineStyle"); edge.setVisual("style", edgeStyle); }); } }); } export { sankeyVisual as default };