123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { lift } from 'zrender/lib/tool/color.js';
- import { extend, isString } from 'zrender/lib/core/util.js';
- export default function sunburstVisual(ecModel) {
- var paletteScope = {};
-
- function pickColor(node, seriesModel, treeHeight) {
-
- var current = node;
- while (current && current.depth > 1) {
- current = current.parentNode;
- }
- var color = seriesModel.getColorFromPalette(current.name || current.dataIndex + '', paletteScope);
- if (node.depth > 1 && isString(color)) {
-
- color = lift(color, (node.depth - 1) / (treeHeight - 1) * 0.5);
- }
- return color;
- }
- ecModel.eachSeriesByType('sunburst', function (seriesModel) {
- var data = seriesModel.getData();
- var tree = data.tree;
- tree.eachNode(function (node) {
- var model = node.getModel();
- var style = model.getModel('itemStyle').getItemStyle();
- if (!style.fill) {
- style.fill = pickColor(node, seriesModel, tree.root.height);
- }
- var existsStyle = data.ensureUniqueItemVisual(node.dataIndex, 'style');
- extend(existsStyle, style);
- });
- });
- }
|