Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
621c38fb
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
621c38fb
编写于
8月 21, 2017
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
(1) support label color 'auto' (2) add text stroke to inside label by default.
上级
41ab0602
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
74 addition
and
39 deletion
+74
-39
src/chart/funnel/FunnelView.js
src/chart/funnel/FunnelView.js
+5
-3
src/chart/helper/Line.js
src/chart/helper/Line.js
+4
-1
src/chart/pie/PieView.js
src/chart/pie/PieView.js
+5
-3
src/util/graphic.js
src/util/graphic.js
+45
-30
test/graph-grid.html
test/graph-grid.html
+15
-2
未找到文件。
src/chart/funnel/FunnelView.js
浏览文件 @
621c38fb
...
...
@@ -127,15 +127,17 @@ define(function (require) {
var
labelHoverModel
=
itemModel
.
getModel
(
'
label.emphasis
'
);
var
labelLineModel
=
itemModel
.
getModel
(
'
labelLine.normal
'
);
var
labelLineHoverModel
=
itemModel
.
getModel
(
'
labelLine.emphasis
'
);
var
visualColor
=
data
.
getItemVisual
(
idx
,
'
color
'
);
graphic
.
setTextStyle
(
labelText
.
style
,
labelModel
,
{
textAlign
:
labelLayout
.
textAlign
,
textVerticalAlign
:
labelLayout
.
verticalAlign
,
text
:
zrUtil
.
retrieve
(
data
.
hostModel
.
getFormattedLabel
(
idx
,
'
normal
'
),
data
.
getName
(
idx
))
},
{
defaultTextColor
:
data
.
getItemVisual
(
idx
,
'
color
'
),
getDefaultTextColor
:
function
(
model
,
opt
)
{
return
labelLayout
.
inside
?
'
#fff
'
:
opt
.
defaultTextColor
;
defaultTextColor
:
visualColor
,
autoColor
:
visualColor
,
checkInside
:
function
(
model
,
opt
)
{
return
labelLayout
.
inside
;
}
});
...
...
src/chart/helper/Line.js
浏览文件 @
621c38fb
...
...
@@ -316,7 +316,10 @@ define(function (require) {
seriesModel
.
getFormattedLabel
(
idx
,
'
normal
'
,
lineData
.
dataType
),
defaultText
)
},
{
defaultTextColor
:
defaultLabelColor
});
},
{
defaultTextColor
:
defaultLabelColor
,
autoColor
:
defaultLabelColor
});
label
.
__textAlign
=
labelStyle
.
textAlign
;
label
.
__verticalAlign
=
labelStyle
.
textVerticalAlign
;
...
...
src/chart/pie/PieView.js
浏览文件 @
621c38fb
...
...
@@ -229,6 +229,7 @@ define(function (require) {
var
labelHoverModel
=
itemModel
.
getModel
(
'
label.emphasis
'
);
var
labelLineModel
=
itemModel
.
getModel
(
'
labelLine.normal
'
);
var
labelLineHoverModel
=
itemModel
.
getModel
(
'
labelLine.emphasis
'
);
var
visualColor
=
data
.
getItemVisual
(
idx
,
'
color
'
);
graphic
.
setTextStyle
(
labelText
.
style
,
labelModel
,
{
textVerticalAlign
:
labelLayout
.
verticalAlign
,
...
...
@@ -236,9 +237,10 @@ define(function (require) {
opacity
:
data
.
getItemVisual
(
idx
,
'
opacity
'
),
text
:
zrUtil
.
retrieve
(
data
.
hostModel
.
getFormattedLabel
(
idx
,
'
normal
'
),
data
.
getName
(
idx
))
},
{
defaultTextColor
:
data
.
getItemVisual
(
idx
,
'
color
'
),
getDefaultTextColor
:
function
(
model
,
opt
)
{
return
labelLayout
.
inside
?
'
#fff
'
:
opt
.
defaultTextColor
;
defaultTextColor
:
visualColor
,
autoColor
:
visualColor
,
checkInside
:
function
(
model
,
opt
)
{
return
labelLayout
.
inside
;
}
});
...
...
src/util/graphic.js
浏览文件 @
621c38fb
...
...
@@ -443,17 +443,16 @@ define(function(require) {
opt
.
forMerge
=
true
;
}
else
{
opt
.
defaultTextColor
=
defaultColor
;
opt
.
getDefaultTextColor
=
getDefaultTextColorForSetText
;
// Support setting color as 'auto' to get visual color.
opt
.
defaultTextColor
=
opt
.
autoColor
=
defaultColor
;
opt
.
checkInside
=
checkInsideForSetText
;
}
setTextStyleCommon
(
textStyle
,
labelModel
,
opt
);
textStyle
.
host
&&
textStyle
.
host
.
dirty
&&
textStyle
.
host
.
dirty
(
false
);
};
function
getDefaultTextColorForSetText
(
labelModel
,
opt
,
textPosition
)
{
return
(
textPosition
&&
textPosition
.
indexOf
(
'
inside
'
)
>=
0
)
?
'
#fff
'
:
opt
.
defaultTextColor
;
function
checkInsideForSetText
(
labelModel
,
textPosition
)
{
return
textPosition
&&
textPosition
.
indexOf
(
'
inside
'
)
>=
0
;
}
/**
...
...
@@ -463,7 +462,7 @@ define(function(require) {
* autoColor: string, specify a color when color is 'auto',
* for textFill, textStroke, textBackgroundColor, and textBorderColor,
* defaultTextColor: string,
*
getDefaultTextColor
: function, higher priority than `defaultTextColor`.
*
checkInside
: function, higher priority than `defaultTextColor`.
* forceRich: boolean,
* forMerge: boolean
* }
...
...
@@ -510,31 +509,47 @@ define(function(require) {
return
textStyle
;
}
function
setTokenTextStyle
(
textStyle
,
textStyleModel
,
defaultTextStyle
,
opt
,
isBlock
)
{
var
textPosition
=
textStyle
.
textPosition
;
function
setTokenTextStyle
(
textStyle
,
textStyleModel
,
globalTextStyle
,
opt
,
isBlock
)
{
var
forMerge
=
opt
.
forMerge
;
// In merge mode, default value should not be given.
defaultTextStyle
=
!
opt
.
forMerge
&&
defaultTextStyle
||
EMPTY_OBJ
;
textStyle
.
textFill
=
getAutoColor
(
textStyleModel
.
getTextColor
(
opt
.
forMerge
),
opt
)
||
(
opt
.
forMerge
?
null
:
opt
.
getDefaultTextColor
?
opt
.
getDefaultTextColor
(
textStyleModel
,
opt
,
textPosition
)
:
opt
.
defaultTextColor
);
globalTextStyle
=
!
forMerge
&&
globalTextStyle
||
EMPTY_OBJ
;
var
textFill
=
getAutoColor
(
textStyleModel
.
getShallow
(
'
color
'
));
var
textStroke
=
getAutoColor
(
textStyleModel
.
getShallow
(
'
textBorderColor
'
));
var
textLineWidth
=
textStyleModel
.
getShallow
(
'
textBorderWidth
'
);
if
(
!
forMerge
)
{
textFill
==
null
&&
(
textFill
=
globalTextStyle
.
color
);
textStroke
==
null
&&
(
textStroke
=
globalTextStyle
.
textBorderColor
);
textLineWidth
==
null
&&
(
textLineWidth
=
globalTextStyle
.
textBorderWidth
);
if
(
textFill
==
null
&&
opt
.
checkInside
&&
opt
.
checkInside
(
textStyleModel
,
textStyle
.
textPosition
)
)
{
textFill
=
'
#fff
'
;
// Consider text with #fff overflow its container.
if
(
textStroke
==
null
)
{
textStroke
=
opt
.
defaultTextColor
;
textLineWidth
==
null
&&
(
textLineWidth
=
2
);
}
}
textStyle
.
textStroke
=
getAutoColor
(
textStyleModel
.
getShallow
(
'
textBorderColor
'
)
||
defaultTextStyle
.
textBorderColor
);
textStyle
.
textLineWidth
=
textStyleModel
.
getShallow
(
'
textBorderWidth
'
);
textFill
==
null
&&
(
textFill
=
opt
.
defaultTextColor
);
}
textStyle
.
textFill
=
textFill
;
textStyle
.
textStroke
=
textStroke
;
textStyle
.
textLineWidth
=
textLineWidth
;
// Do not use `getFont` here, because merge should be supported, where
// part of these properties may be changed in emphasis style, and the
// others should remain their original value got from normal style.
textStyle
.
fontStyle
=
textStyleModel
.
getShallow
(
'
fontStyle
'
)
||
default
TextStyle
.
fontStyle
;
textStyle
.
fontWeight
=
textStyleModel
.
getShallow
(
'
fontWeight
'
)
||
default
TextStyle
.
fontWeight
;
textStyle
.
fontSize
=
textStyleModel
.
getShallow
(
'
fontSize
'
)
||
default
TextStyle
.
fontSize
;
textStyle
.
fontFamily
=
textStyleModel
.
getShallow
(
'
fontFamily
'
)
||
default
TextStyle
.
fontFamily
;
textStyle
.
fontStyle
=
textStyleModel
.
getShallow
(
'
fontStyle
'
)
||
global
TextStyle
.
fontStyle
;
textStyle
.
fontWeight
=
textStyleModel
.
getShallow
(
'
fontWeight
'
)
||
global
TextStyle
.
fontWeight
;
textStyle
.
fontSize
=
textStyleModel
.
getShallow
(
'
fontSize
'
)
||
global
TextStyle
.
fontSize
;
textStyle
.
fontFamily
=
textStyleModel
.
getShallow
(
'
fontFamily
'
)
||
global
TextStyle
.
fontFamily
;
textStyle
.
textAlign
=
textStyleModel
.
getShallow
(
'
align
'
);
textStyle
.
textVerticalAlign
=
textStyleModel
.
getShallow
(
'
verticalAlign
'
)
...
...
@@ -559,13 +574,13 @@ define(function(require) {
}
textStyle
.
textShadowColor
=
textStyleModel
.
getShallow
(
'
textShadowColor
'
)
||
default
TextStyle
.
textShadowColor
;
||
global
TextStyle
.
textShadowColor
;
textStyle
.
textShadowBlur
=
textStyleModel
.
getShallow
(
'
textShadowBlur
'
)
||
default
TextStyle
.
textShadowBlur
;
||
global
TextStyle
.
textShadowBlur
;
textStyle
.
textShadowOffsetX
=
textStyleModel
.
getShallow
(
'
textShadowOffsetX
'
)
||
default
TextStyle
.
textShadowOffsetX
;
||
global
TextStyle
.
textShadowOffsetX
;
textStyle
.
textShadowOffsetY
=
textStyleModel
.
getShallow
(
'
textShadowOffsetY
'
)
||
default
TextStyle
.
textShadowOffsetY
;
||
global
TextStyle
.
textShadowOffsetY
;
}
function
getAutoColor
(
color
,
opt
)
{
...
...
test/graph-grid.html
浏览文件 @
621c38fb
...
...
@@ -33,9 +33,22 @@
var
chart
=
echarts
.
init
(
document
.
getElementById
(
'
main
'
),
'
vintage
'
);
var
axisData
=
[
'
周一
'
,
'
周二
'
,
'
周三
'
,
'
周四
'
,
'
周五
'
,
'
周六
'
,
'
周日
'
];
var
axisData
=
[
'
周一
'
,
'
周二
'
,
'
周三
'
,
'
很长很长的周四
'
,
'
应为系列色边框(auto)的
周五
'
,
'
周六
'
,
'
周日
'
];
var
data
=
axisData
.
map
(
function
(
item
,
i
)
{
return
Math
.
round
(
Math
.
random
()
*
1000
*
(
i
+
1
));
var
val
=
Math
.
round
(
Math
.
random
()
*
1000
*
(
i
+
1
))
return
i
!==
4
?
val
:
{
value
:
val
,
label
:
{
normal
:
{
borderColor
:
'
auto
'
,
borderWidth
:
1
,
padding
:
5
,
position
:
'
top
'
}
}
};
});
var
links
=
data
.
map
(
function
(
item
,
i
)
{
return
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录