效果图
源代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<!-- 引入 echarts.js -->
<script src="js/echarts.min.js"></script>
<script src="js/jquery-1.11.0.min.js"></script>
<script src="dist/extension/dataTool.js"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" ></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
var option;
option = {
silent: true,
series: {
radius: ['15%', '80%'],
type: 'sunburst',
sort: null,
highlightPolicy: 'ancestor',
data: [{
value: 8,
children: [{
value: 4,
children: [{
value: 2
}, {
value: 1
}, {
value: 1
}, {
value: 0.5
}]
}, {
value: 2
}]
}, {
value: 4,
children: [{
children: [{
value: 2
}]
}]
}, {
value: 4,
children: [{
children: [{
value: 2
}]
}]
}, {
value: 3,
children: [{
children: [{
value: 1
}]
}]
}],
label: {
color: '#fff',
textBorderColor: '#666',
textBorderWidth: 2,
borderColor: '#999',
borderWidth: 1,
formatter: function (param) {
var depth = param.treePathInfo.length;
if (depth === 2) {
return 'radial';
}
else if (depth === 3) {
return 'tangential';
}
else if (depth === 4) {
return '0';
}
}
},
levels: [{}, {
itemStyle: {
color: 'red'
},
label: {
rotate: 'radial'
}
}, {
itemStyle: {
color: 'orange'
},
label: {
rotate: 'tangential'
}
}, {
itemStyle: {
color: 'yellow'
},
label: {
rotate: 0
}
}]
}
};
myChart.setOption(option);
</script>
</body>
</html>