配置项如下
data = [
{
name: '河北医科大学第二医院',
level:0,
id:0,
children: [
{
name: '1~10名',
level:0,
id:0,
children: [
{
name: '呼吸内科',
level:1,
id:1,
collapsed: false,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
{
name: '内分泌科',
level:1,
id:2,
collapsed: true,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
{
name: '心内科',
level:1,
id:3,
collapsed: true,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
{
name: '骨科',
level:1,
id:4,
collapsed: true,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
{
name: '普外科',
level:1,
id:5,
collapsed: true,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
{
name: '神经外科',
level:1,
id:6,
collapsed: true,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
{
name: '中医科',
level:1,
id:7,
collapsed: true,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
{
name: '手术室',
level:1,
id:8,
collapsed: true,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
{
name: '妇产科',
level:1,
id:9,
collapsed: true,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
{
name: '肿瘤科',
level:1,
id:10,
collapsed: true,
children: [
{
name: '麻醉',
value: 3322,
},
{
name: '护理',
value: 3322,
},
{
name: '放射',
value: 3322,
},
{
name: '材料',
value: 3322,
},
{
name: '病例',
value: 3322,
},
{
name: '检查',
value: 3322,
},
{
name: '手术',
value: 3322,
},
{
name: '治疗',
value: 3322,
},
{
name: '血费',
value: 3322,
},
{
name: '草药',
value: 3322,
},
{
name: '中成',
value: 3322,
},
{
name: '化验',
value: 3322,
},
{
name: '诊察',
value: 3322,
},
{
name: '西药',
value: 3322,
},
{
name: '其他',
value: 3322,
},
],
},
],
},
{
name: '11~20名',
level:0,
id:0,
collapsed: true,
children: [{}]
},
{
name: '21~30名',
level:0,
id:0,
collapsed: true,
children: [{}]
},
{
name: '31~40名',
level:0,
id:0,
collapsed: true,
children: [{}]
},
]
}];
option = {
tooltip: {
trigger: 'item',
triggerOn: 'mousemove',
},
series: [
{
type: 'tree',
data: data,
top: '1%',
left: '15%',
bottom: '1%',
right: '20%',
symbolSize: 14,
roam: true,
label: {
position: 'left',
verticalAlign: 'middle',
align: 'right',
fontSize: 14,
},
leaves: {
label: {
position: 'right',
verticalAlign: 'middle',
align: 'left',
},
},
emphasis: {
focus: 'descendant',
},
expandAndCollapse: true,
animationDuration: 550,
animationDurationUpdate: 750,
},
],
}
myChart.on("click",function(param){
// param为点击的节点信息
/*var level = param.data.level;
var id = param.data.id;
console.log(param);
for(var i in data){
if(data[i].level == level&&data[i].id == id){
data[i].collapsed = false;
}else if(data[i].level == level){
data[i].collapsed = true;
}
}
console.log(data);
myChart.clear();
myChart.setOption(option);*/
});