提交 d372555a 编写于 作者: O Ovilia

feat(sunburst): visual mapping

上级 5dc00048
......@@ -286,21 +286,26 @@ export default SunburstPiece;
* @param {module:echarts/model/Global} ecModel echarts defaults
*/
function getNodeColor(node, seriesModel, ecModel) {
if (node.depth === 0) {
var visualColor = node.getVisual('color');
// Self color or level color
var color = node.getModel('itemStyle.normal').get('color');
if (color) {
return color;
}
else if (visualColor) {
// Color mapping
return visualColor;
}
else if (node.depth === 0) {
// Virtual root node
return ecModel.option.color[0];
}
else {
// Self color or level color
var color = node.getModel('itemStyle.normal').get('color');
if (!color) {
// First-generation color
var length = ecModel.option.color.length;
color = ecModel.option.color[getRootId(node) % length];
}
return color;
// First-generation color
var length = ecModel.option.color.length;
color = ecModel.option.color[getRootId(node) % length];
}
return color;
}
/**
......
<html>
<head>
<meta charset="utf-8">
<script src="lib/esl.js"></script>
<script src="lib/config.js"></script>
</head>
<body>
<style>
html, body, #main {
width: 100%;
height: 100%;
/* background-image: url(old_mathematics.png); */
/* background-repeat: repeat; */
}
</style>
<div id="main"></div>
<script>
var chart;
require([
'echarts'
], function (echarts) {
chart = echarts.init(document.getElementById('main'), null, {
// renderer: 'svg'
});
var data = [{
name: 'Grandpa',
children: [{
name: 'Uncle Leo',
value: 15,
children: [{
name: 'Cousin Jack',
value: 2
}, {
name: 'Cousin Mary',
value: 5,
children: [{
name: 'Jackson',
value: 2
}]
}, {
name: 'Cousin Ben',
value: 4
}]
}, {
name: 'Aunt Jane',
children: [{
name: 'Cousin Kate',
value: 4
}]
}, {
name: 'Father',
value: 10,
children: [{
name: 'Me',
value: 5,
itemStyle: {
normal: {
color: 'red'
}
}
}, {
name: 'Brother Peter',
value: 1
}]
}]
}, {
name: 'Mike',
children: [{
name: 'Uncle Dan',
children: [{
name: 'Cousin Lucy',
value: 3
}, {
name: 'Cousin Luck',
value: 4,
children: [{
name: 'Nephew',
value: 2
}]
}]
}]
}, {
name: 'Nancy',
children: [{
name: 'Uncle Nike',
children: [{
name: 'Cousin Betty',
value: 1
}, {
name: 'Cousin Jenny',
value: 2
}]
}]
}];
chart.setOption({
visualMap: {
type: 'continuous',
min: 0,
max: 10,
inRange: {
color: ['#2D5F73', '#538EA6', '#F2D1B3', '#F2B8A2', '#F28C8C']
}
},
series: {
type: 'sunburst',
data: data,
radius: [0, '90%'],
label: {
normal: {
rotate: 'radial'
}
}
}
});
});
</script>
</body>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册