Skip to content

Commit

Permalink
force 加入标签位置配置
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Oct 30, 2014
1 parent 87e1b49 commit 20eb3b5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
9 changes: 6 additions & 3 deletions doc/example/force.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,20 @@
linkSymbol: 'arrow',
steps: 10,
coolDown: 0.9,
preventOverlap: true,
//preventOverlap: true,
nodes:[
{
category:0, name: '乔布斯', value : 10,
symbol: 'image://http://www.cnii.com.cn/hg/zt/2012315zt/content/attachement/jpg/site2/20120217/00137274b1a410a8340f07.jpg',
symbol: 'image://http://www.damndigital.com/wp-content/uploads/2010/12/steve-jobs.jpg',
symbolSize: 30,
draggable: true,
itemStyle: {
normal: {
label: {
show: false
position: 'right',
textStyle: {
color: 'black'
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion doc/example/force1.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
series : [
{
type:'chord',
type:'force',
name : "人物关系",
categories : [
{
Expand Down
19 changes: 8 additions & 11 deletions src/chart/force.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,26 +427,23 @@ define(function (require) {
// 节点标签样式
if (this.deepQuery(queryTarget, 'itemStyle.normal.label.show')) {
shape.style.text = node.data.name;
shape.style.textPosition = 'inside';
var labelStyle = this.deepQuery(
queryTarget, 'itemStyle.normal.label.textStyle'
queryTarget, 'itemStyle.normal.label'
) || {};
shape.style.textColor = labelStyle.color || '#fff';
shape.style.textAlign = labelStyle.align || 'center';
shape.style.textBaseline = labelStyle.baseline || 'middle';
shape.style.textFont = this.getFont(labelStyle);
var textStyle = labelStyle.textStyle || {};
shape.style.textPosition = labelStyle.position;
shape.style.textColor = textStyle.color || '#fff';
shape.style.textFont = this.getFont(textStyle);
}

if (this.deepQuery(queryTarget, 'itemStyle.emphasis.label.show')) {
shape.highlightStyle.text = node.data.name;
shape.highlightStyle.textPosition = 'inside';
var labelStyle = this.deepQuery(
queryTarget, 'itemStyle.emphasis.label.textStyle'
) || {};
shape.highlightStyle.textColor = labelStyle.color || '#fff';
shape.highlightStyle.textAlign = labelStyle.align || 'center';
shape.highlightStyle.textBaseline = labelStyle.baseline || 'middle';
shape.highlightStyle.textFont = this.getFont(labelStyle);
shape.highlightStyle.textPosition = labelStyle.position;
shape.highlightStyle.textColor = textStyle.color || '#fff';
shape.highlightStyle.textFont = this.getFont(textStyle);
}

// 拖拽特性
Expand Down
8 changes: 5 additions & 3 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ define(function() {
borderWidth: 1,
label: {
show: true,
position: 'outer'
position: 'inside'
// formatter: 标签文本格式器,同Tooltip.formatter,不支持回调
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
},
Expand Down Expand Up @@ -877,7 +877,8 @@ define(function() {
normal: {
// color: 各异,
label: {
show: false
show: false,
position: 'inside'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
},
nodeStyle: {
Expand All @@ -886,7 +887,8 @@ define(function() {
},
linkStyle: {
color: '#5182ab',
width: 1
width: 1,
type: 'line'
}
},
emphasis: {
Expand Down

0 comments on commit 20eb3b5

Please sign in to comment.