1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- var VisualMapping = require("../../visual/VisualMapping");
- var zrUtil = require("zrender/lib/core/util");
- function _default(ecModel, payload) {
- ecModel.eachSeriesByType('sankey', function (seriesModel) {
- var graph = seriesModel.getGraph();
- var nodes = graph.nodes;
- if (nodes.length) {
- var minValue = Infinity;
- var maxValue = -Infinity;
- zrUtil.each(nodes, function (node) {
- var nodeValue = node.getLayout().value;
- if (nodeValue < minValue) {
- minValue = nodeValue;
- }
- if (nodeValue > maxValue) {
- maxValue = nodeValue;
- }
- });
- zrUtil.each(nodes, function (node) {
- var mapping = new VisualMapping({
- type: 'color',
- mappingMethod: 'linear',
- dataExtent: [minValue, maxValue],
- visual: seriesModel.get('color')
- });
- var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value);
- var customColor = node.getModel().get('itemStyle.color');
- customColor != null ? node.setVisual('color', customColor) : node.setVisual('color', mapValueToColor);
- });
- }
- });
- }
- module.exports = _default;
|