echarts 文字标签云图实现方法
2014-12-09 00:00
633 查看
摘要: 做了个项目,用的百度的Echarts,要用到文字标签云图,发现自带的没这种,但是可以通过改变力导图样式实现。
加载ECHART相关JS
var myChart = echarts.init(document.getElementById('ChartOwnFansTag'));
var option = {
series : [
{
type:'force',
name : "Force tree",
ribbonType: false,
itemStyle: {
normal: {
label: {
show: true,
rotate:false,
textStyle:{ color:'#ffffff',fontSize:12}
},
nodeStyle : {
color:'rgba(0,0,0,0)',//这里是隐藏圆圈
brushType : 'both',
borderWidth : 0
},
linkStyle: {
type: 'line',
strokeColor: 'rgba(0,0,0,0)'//这里是隐藏连接线
}
}
},
minRadius : 5,
maxRadius : 20,
coolDown: 0.995,
nodes : [
{id: 0, name:'adidas', value:3, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[9],fontSize:24}}}}},//这里根据数据量设置【value/圆大小】【color/字颜色】【fontSize/字大小】
{id: 1, name:'品牌', value:2.5, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[8],fontSize:22}}}}},
{id: 2, name:'代言人', value:2, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[7],fontSize:20}}}}},
{id: 3, name:'热话题', value:1.5, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[5],fontSize:14}}}}},
{id: 4, name:'印象', value:1, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[3],fontSize:12}}}}},
{id: 5, name:'公益', value:.5, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[2],fontSize:6}}}}}
],
links: [
//这里注意,source必须全部为0(及上面最大值的ID),这样就实现一圈小圆围着中间一个圆的效果
{source: 0, target: 1},
{source: 0, target: 2},
{source: 0, target: 3},
{source: 0, target: 4},
{source: 0, target: 5}
]
}
]
};
// 为echarts对象加载数据
myChart.setOption(option);
最终效果
加载ECHART相关JS
var myChart = echarts.init(document.getElementById('ChartOwnFansTag'));
var option = {
series : [
{
type:'force',
name : "Force tree",
ribbonType: false,
itemStyle: {
normal: {
label: {
show: true,
rotate:false,
textStyle:{ color:'#ffffff',fontSize:12}
},
nodeStyle : {
color:'rgba(0,0,0,0)',//这里是隐藏圆圈
brushType : 'both',
borderWidth : 0
},
linkStyle: {
type: 'line',
strokeColor: 'rgba(0,0,0,0)'//这里是隐藏连接线
}
}
},
minRadius : 5,
maxRadius : 20,
coolDown: 0.995,
nodes : [
{id: 0, name:'adidas', value:3, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[9],fontSize:24}}}}},//这里根据数据量设置【value/圆大小】【color/字颜色】【fontSize/字大小】
{id: 1, name:'品牌', value:2.5, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[8],fontSize:22}}}}},
{id: 2, name:'代言人', value:2, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[7],fontSize:20}}}}},
{id: 3, name:'热话题', value:1.5, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[5],fontSize:14}}}}},
{id: 4, name:'印象', value:1, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[3],fontSize:12}}}}},
{id: 5, name:'公益', value:.5, itemStyle: {normal: {label: {textStyle:{ color:Rgba.white[2],fontSize:6}}}}}
],
links: [
//这里注意,source必须全部为0(及上面最大值的ID),这样就实现一圈小圆围着中间一个圆的效果
{source: 0, target: 1},
{source: 0, target: 2},
{source: 0, target: 3},
{source: 0, target: 4},
{source: 0, target: 5}
]
}
]
};
// 为echarts对象加载数据
myChart.setOption(option);
最终效果
相关文章推荐
- input 标签实现输入框带提示文字效果(两种方法)
- 用marquee标签实现文字滚动
- 不用ajax实现点击文字即可编辑的方法
- HTML中用div标签包含Marquee实现文字走马灯滚动效果
- 用CSS实现图片替换文字三种方法(Image replacement )
- 实现Div层里的文字垂直居中的方法
- Android之Tab分页标签的实现方法一-----TabActivity和TabHost的结合(三)
- VC中实现文字竖排的简单方法
- 减少代码和语义化标签实现方法
- Android之Tab分页标签的实现方法一-----TabActivity和TabHost的结合(一)
- 在图片上加上文字或水印的方法实现
- 鼠标拖动层(可任意绑定DIV标签)(实现方法一)
- 鼠标拖动层(可任意绑定DIV标签)(实现方法二)
- Opengl 反走样文字实现方法(汉字) :快速将DC环境下的中英文字转到OpenGL下反走样显示(共享我的代码)
- 实现Div层里的文字垂直居中的方法
- 符合WEB标准的滚动文字特效的实现方法
- C# :Word 标签替代文字或图片 (图片浮于文字之上 插入后回车或换行符替换的解决方法)
- 笔记:JS利用正则表达式实现去除Html标签方法
- .NET 实现Eval(文字列表达式计算)的3种实现方法。
- Taglib原理和实现 第六章:标签内常用方法总结