Skip to content

Commit

Permalink
force加入label
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Jul 2, 2013
1 parent b23619f commit 9a17b7a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/example/force.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
{
value : 300, //孤立点
category : 1,
name : "Daemon",
itemStyle : {
normal : {
color : '#b10101'
Expand Down
19 changes: 19 additions & 0 deletions src/chart/force.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,25 @@ define(function(require) {
__force_index__ : i
};

// Label
if (self.deepQuery([forceSerie], 'itemStyle.normal.label.show')) {
shape.style.text = node.name;
shape.style.textPosition = 'specific';
shape.style.textColor = self.deepQuery([forceSerie], 'itemStyle.normal.label.textStyle.color') || '#fff';
shape.style.textAlign = self.deepQuery([forceSerie], 'itemStyle.normal.label.textStyle.align') || 'center';
shape.style.textBaseLine = self.deepQuery([forceSerie], 'itemStyle.normal.label.textStyle.baseline') || 'middle';
shape.style.textFont = self.getFont(self.deepQuery([forceSerie], 'itemStyle.normal.label.textStyle'));
}

if (self.deepQuery([forceSerie], 'itemStyle.emphasis.label.show')) {
shape.highlightStyle.text = node.name;
shape.highlightStyle.textPosition = 'specific';
shape.highlightStyle.textColor = self.deepQuery([forceSerie], 'itemStyle.emphasis.label.textStyle.color') || '#fff';
shape.highlightStyle.textAlign = self.deepQuery([forceSerie], 'itemStyle.emphasis.label.textStyle.align') || 'center';
shape.highlightStyle.textBaseLine = self.deepQuery([forceSerie], 'itemStyle.emphasis.label.textStyle.baseline') || 'middle';
shape.highlightStyle.textFont = self.getFont(self.deepQuery([forceSerie], 'itemStyle.emphasis.label.textStyle'));
}

// 优先级 node.style > category.style > defaultStyle
zrUtil.merge(shape.style, nodeStyle);
zrUtil.merge(shape.highlightStyle, nodeEmphasisStyle);
Expand Down
3 changes: 0 additions & 3 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ define(function() {
// color: 各异,
label: {
show: true,
position: 'outer'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
},
nodeStyle : {
Expand All @@ -464,8 +463,6 @@ define(function() {
emphasis: {
// color: 各异,
label: {
show: false,
position: 'outer'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
},
nodeStyle : {
Expand Down

0 comments on commit 9a17b7a

Please sign in to comment.