效果图
源代码
<!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;
var item1 = {
color: '#F54F4A'
};
var item2 = {
color: '#FF8C75'
};
var item3 = {
color: '#FFB499'
};
var data = [{
children: [{
value: 5,
children: [{
value: 1,
itemStyle: item1
}, {
value: 2,
children: [{
value: 1,
itemStyle: item2
}]
}, {
children: [{
value: 1
}]
}],
itemStyle: item1
}, {
value: 10,
children: [{
value: 6,
children: [{
value: 1,
itemStyle: item1
}, {
value: 1
}, {
value: 1,
itemStyle: item2
}, {
value: 1
}],
itemStyle: item3
}, {
value: 2,
children: [{
value: 1
}],
itemStyle: item3
}, {
children: [{
value: 1,
itemStyle: item2
}]
}],
itemStyle: item1
}],
itemStyle: item1
}, {
value: 9,
children: [{
value: 4,
children: [{
value: 2,
itemStyle: item2
}, {
children: [{
value: 1,
itemStyle: item1
}]
}],
itemStyle: item1
}, {
children: [{
value: 3,
children: [{
value: 1
}, {
value: 1,
itemStyle: item2
}]
}],
itemStyle: item3
}],
itemStyle: item2
}, {
value: 7,
children: [{
children: [{
value: 1,
itemStyle: item3
}, {
value: 3,
children: [{
value: 1,
itemStyle: item2
}, {
value: 1
}],
itemStyle: item2
}, {
value: 2,
children: [{
value: 1
}, {
value: 1,
itemStyle: item1
}],
itemStyle: item1
}],
itemStyle: item3
}],
itemStyle: item1
}, {
children: [{
value: 6,
children: [{
value: 1,
itemStyle: item2
}, {
value: 2,
children: [{
value: 2,
itemStyle: item2
}],
itemStyle: item1
}, {
value: 1,
itemStyle: item3
}],
itemStyle: item3
}, {
value: 3,
children: [{
value: 1,
}, {
children: [{
value: 1,
itemStyle: item2
}]
}, {
value: 1
}],
itemStyle: item3
}],
itemStyle: item1
}];
option = {
series: {
radius: ['15%', '80%'],
type: 'sunburst',
sort: null,
highlightPolicy: 'ancestor',
data: data,
label: {
rotate: 'radial'
},
levels: [],
itemStyle: {
color: '#ddd',
borderWidth: 2
}
}
};
myChart.setOption(option);
</script>
</body>
</html>