Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
a245ad82
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
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,发现更多精彩内容 >>
提交
a245ad82
编写于
3月 26, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact: put label as textContent in pie and funnel. fix inside text color issue.
上级
fc26a5f3
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
67 addition
and
54 deletion
+67
-54
src/chart/funnel/FunnelView.ts
src/chart/funnel/FunnelView.ts
+13
-6
src/chart/pie/PieView.ts
src/chart/pie/PieView.ts
+29
-31
src/chart/sunburst/SunburstPiece.ts
src/chart/sunburst/SunburstPiece.ts
+15
-6
src/component/helper/MapDraw.ts
src/component/helper/MapDraw.ts
+1
-2
src/util/graphic.ts
src/util/graphic.ts
+9
-9
未找到文件。
src/chart/funnel/FunnelView.ts
浏览文件 @
a245ad82
...
@@ -46,7 +46,7 @@ class FunnelPiece extends graphic.Group {
...
@@ -46,7 +46,7 @@ class FunnelPiece extends graphic.Group {
let
text
=
new
graphic
.
Text
();
let
text
=
new
graphic
.
Text
();
this
.
add
(
polygon
);
this
.
add
(
polygon
);
this
.
add
(
labelLine
);
this
.
add
(
labelLine
);
this
.
add
(
text
);
polygon
.
setTextContent
(
text
);
this
.
updateData
(
data
,
idx
,
true
);
this
.
updateData
(
data
,
idx
,
true
);
}
}
...
@@ -123,9 +123,9 @@ class FunnelPiece extends graphic.Group {
...
@@ -123,9 +123,9 @@ class FunnelPiece extends graphic.Group {
}
}
_updateLabel
(
data
:
List
,
idx
:
number
)
{
_updateLabel
(
data
:
List
,
idx
:
number
)
{
let
polygon
=
this
.
childAt
(
0
);
let
labelLine
=
this
.
childAt
(
1
)
as
graphic
.
Polyline
;
let
labelLine
=
this
.
childAt
(
1
)
as
graphic
.
Polyline
;
let
labelText
=
this
.
childAt
(
2
)
as
graphic
.
Text
;
let
labelText
=
polygon
.
getTextContent
()
;
let
seriesModel
=
data
.
hostModel
;
let
seriesModel
=
data
.
hostModel
;
let
itemModel
=
data
.
getItemModel
<
FunnelDataItemOption
>
(
idx
);
let
itemModel
=
data
.
getItemModel
<
FunnelDataItemOption
>
(
idx
);
...
@@ -144,9 +144,7 @@ class FunnelPiece extends graphic.Group {
...
@@ -144,9 +144,7 @@ class FunnelPiece extends graphic.Group {
{
{
labelFetcher
:
data
.
hostModel
as
FunnelSeriesModel
,
labelFetcher
:
data
.
hostModel
as
FunnelSeriesModel
,
labelDataIndex
:
idx
,
labelDataIndex
:
idx
,
defaultText
:
data
.
getName
(
idx
),
defaultText
:
data
.
getName
(
idx
)
autoColor
:
visualColor
,
useInsideStyle
:
!!
labelLayout
.
inside
},
},
{
{
align
:
labelLayout
.
textAlign
,
align
:
labelLayout
.
textAlign
,
...
@@ -154,6 +152,14 @@ class FunnelPiece extends graphic.Group {
...
@@ -154,6 +152,14 @@ class FunnelPiece extends graphic.Group {
}
}
);
);
polygon
.
setTextConfig
({
local
:
true
,
inside
:
!!
labelLayout
.
inside
,
insideStroke
:
visualColor
,
insideFill
:
'
auto
'
,
outsideFill
:
visualColor
});
graphic
.
updateProps
(
labelLine
,
{
graphic
.
updateProps
(
labelLine
,
{
shape
:
{
shape
:
{
points
:
labelLayout
.
linePoints
||
labelLayout
.
linePoints
points
:
labelLayout
.
linePoints
||
labelLayout
.
linePoints
...
@@ -168,6 +174,7 @@ class FunnelPiece extends graphic.Group {
...
@@ -168,6 +174,7 @@ class FunnelPiece extends graphic.Group {
y
:
labelLayout
.
y
y
:
labelLayout
.
y
}
}
},
seriesModel
,
idx
);
},
seriesModel
,
idx
);
labelText
.
attr
({
labelText
.
attr
({
rotation
:
labelLayout
.
rotation
,
rotation
:
labelLayout
.
rotation
,
origin
:
[
labelLayout
.
x
,
labelLayout
.
y
],
origin
:
[
labelLayout
.
x
,
labelLayout
.
y
],
...
...
src/chart/pie/PieView.ts
浏览文件 @
a245ad82
...
@@ -29,7 +29,6 @@ import List from '../../data/List';
...
@@ -29,7 +29,6 @@ import List from '../../data/List';
import
PieSeriesModel
,
{
PieDataItemOption
}
from
'
./PieSeries
'
;
import
PieSeriesModel
,
{
PieDataItemOption
}
from
'
./PieSeries
'
;
import
{
Dictionary
}
from
'
zrender/src/core/types
'
;
import
{
Dictionary
}
from
'
zrender/src/core/types
'
;
import
Element
from
'
zrender/src/Element
'
;
import
Element
from
'
zrender/src/Element
'
;
import
Displayable
from
'
zrender/src/graphic/Displayable
'
;
function
updateDataSelected
(
function
updateDataSelected
(
this
:
PiePiece
,
this
:
PiePiece
,
...
@@ -86,11 +85,6 @@ function toggleItemSelected(
...
@@ -86,11 +85,6 @@ function toggleItemSelected(
:
el
.
attr
(
'
position
'
,
position
);
:
el
.
attr
(
'
position
'
,
position
);
}
}
interface
PieceElementExtension
extends
Displayable
{
hoverIgnore
?:
boolean
normalIgnore
?:
boolean
};
/**
/**
* Piece of pie including Sector, Label, LabelLine
* Piece of pie including Sector, Label, LabelLine
*/
*/
...
@@ -107,15 +101,14 @@ class PiePiece extends graphic.Group {
...
@@ -107,15 +101,14 @@ class PiePiece extends graphic.Group {
let
text
=
new
graphic
.
Text
();
let
text
=
new
graphic
.
Text
();
this
.
add
(
sector
);
this
.
add
(
sector
);
this
.
add
(
polyline
);
this
.
add
(
polyline
);
this
.
add
(
text
);
sector
.
setTextContent
(
text
);
this
.
updateData
(
data
,
idx
,
true
);
this
.
updateData
(
data
,
idx
,
true
);
}
}
updateData
(
data
:
List
,
idx
:
number
,
firstCreate
?:
boolean
):
void
{
updateData
(
data
:
List
,
idx
:
number
,
firstCreate
?:
boolean
):
void
{
let
sector
=
this
.
childAt
(
0
)
as
graphic
.
Sector
;
let
sector
=
this
.
childAt
(
0
)
as
graphic
.
Sector
;
let
labelLine
=
this
.
childAt
(
1
)
as
PieceElementExtension
;
let
labelText
=
this
.
childAt
(
2
)
as
PieceElementExtension
;
let
seriesModel
=
data
.
hostModel
as
PieSeriesModel
;
let
seriesModel
=
data
.
hostModel
as
PieSeriesModel
;
let
itemModel
=
data
.
getItemModel
<
PieDataItemOption
>
(
idx
);
let
itemModel
=
data
.
getItemModel
<
PieDataItemOption
>
(
idx
);
...
@@ -197,8 +190,6 @@ class PiePiece extends graphic.Group {
...
@@ -197,8 +190,6 @@ class PiePiece extends graphic.Group {
(
this
as
ECElement
).
highDownOnUpdate
=
(
itemModel
.
get
(
'
hoverAnimation
'
)
&&
seriesModel
.
isAnimationEnabled
())
(
this
as
ECElement
).
highDownOnUpdate
=
(
itemModel
.
get
(
'
hoverAnimation
'
)
&&
seriesModel
.
isAnimationEnabled
())
?
function
(
fromState
:
DisplayState
,
toState
:
DisplayState
):
void
{
?
function
(
fromState
:
DisplayState
,
toState
:
DisplayState
):
void
{
if
(
toState
===
'
emphasis
'
)
{
if
(
toState
===
'
emphasis
'
)
{
labelLine
.
ignore
=
labelLine
.
hoverIgnore
;
labelText
.
ignore
=
labelText
.
hoverIgnore
;
// Sector may has animation of updating data. Force to move to the last frame
// Sector may has animation of updating data. Force to move to the last frame
// Or it may stopped on the wrong shape
// Or it may stopped on the wrong shape
...
@@ -210,9 +201,6 @@ class PiePiece extends graphic.Group {
...
@@ -210,9 +201,6 @@ class PiePiece extends graphic.Group {
},
{
duration
:
300
,
easing
:
'
elasticOut
'
});
},
{
duration
:
300
,
easing
:
'
elasticOut
'
});
}
}
else
{
else
{
labelLine
.
ignore
=
labelLine
.
normalIgnore
;
labelText
.
ignore
=
labelText
.
normalIgnore
;
sector
.
stopAnimation
(
true
);
sector
.
stopAnimation
(
true
);
sector
.
animateTo
({
sector
.
animateTo
({
shape
:
{
shape
:
{
...
@@ -227,19 +215,22 @@ class PiePiece extends graphic.Group {
...
@@ -227,19 +215,22 @@ class PiePiece extends graphic.Group {
}
}
private
_updateLabel
(
data
:
List
,
idx
:
number
,
withAnimation
:
boolean
):
void
{
private
_updateLabel
(
data
:
List
,
idx
:
number
,
withAnimation
:
boolean
):
void
{
const
sector
=
this
.
childAt
(
0
);
let
labelLine
=
this
.
childAt
(
1
)
as
(
PieceElementExtension
&
graphic
.
Polyline
)
;
const
labelLine
=
this
.
childAt
(
1
)
as
graphic
.
Polyline
;
let
labelText
=
this
.
childAt
(
2
)
as
(
PieceElementExtension
&
graphic
.
Text
)
;
const
labelText
=
sector
.
getTextContent
()
as
graphic
.
Text
;
le
t
seriesModel
=
data
.
hostModel
;
cons
t
seriesModel
=
data
.
hostModel
;
le
t
itemModel
=
data
.
getItemModel
<
PieDataItemOption
>
(
idx
);
cons
t
itemModel
=
data
.
getItemModel
<
PieDataItemOption
>
(
idx
);
le
t
layout
=
data
.
getItemLayout
(
idx
);
cons
t
layout
=
data
.
getItemLayout
(
idx
);
le
t
labelLayout
=
layout
.
label
;
cons
t
labelLayout
=
layout
.
label
;
// let visualColor = data.getItemVisual(idx, 'color');
// let visualColor = data.getItemVisual(idx, 'color');
const
labelTextEmphasisState
=
labelText
.
ensureState
(
'
emphasis
'
);
const
labelLineEmphasisState
=
labelLine
.
ensureState
(
'
emphasis
'
);
if
(
!
labelLayout
||
isNaN
(
labelLayout
.
x
)
||
isNaN
(
labelLayout
.
y
))
{
if
(
!
labelLayout
||
isNaN
(
labelLayout
.
x
)
||
isNaN
(
labelLayout
.
y
))
{
labelText
.
ignore
=
labelText
.
normalIgnore
=
labelText
.
hoverIgnore
=
labelText
.
ignore
=
labelText
EmphasisState
.
ignore
=
true
;
labelLine
.
ignore
=
labelLine
.
normalIgnore
=
labelLine
.
hoverI
gnore
=
true
;
labelLine
.
ignore
=
labelLine
EmphasisState
.
i
gnore
=
true
;
return
;
return
;
}
}
...
@@ -263,9 +254,7 @@ class PiePiece extends graphic.Group {
...
@@ -263,9 +254,7 @@ class PiePiece extends graphic.Group {
{
{
labelFetcher
:
data
.
hostModel
as
PieSeriesModel
,
labelFetcher
:
data
.
hostModel
as
PieSeriesModel
,
labelDataIndex
:
idx
,
labelDataIndex
:
idx
,
defaultText
:
labelLayout
.
text
,
defaultText
:
labelLayout
.
text
autoColor
:
visualColor
,
useInsideStyle
:
!!
labelLayout
.
inside
},
},
{
{
align
:
labelLayout
.
textAlign
,
align
:
labelLayout
.
textAlign
,
...
@@ -274,6 +263,15 @@ class PiePiece extends graphic.Group {
...
@@ -274,6 +263,15 @@ class PiePiece extends graphic.Group {
}
}
);
);
// Set textConfig on sector.
sector
.
setTextConfig
({
local
:
true
,
inside
:
!!
labelLayout
.
inside
,
insideStroke
:
visualColor
,
insideFill
:
'
auto
'
,
outsideFill
:
visualColor
});
let
targetTextStyle
=
{
let
targetTextStyle
=
{
x
:
labelLayout
.
x
,
x
:
labelLayout
.
x
,
y
:
labelLayout
.
y
y
:
labelLayout
.
y
...
@@ -304,11 +302,11 @@ class PiePiece extends graphic.Group {
...
@@ -304,11 +302,11 @@ class PiePiece extends graphic.Group {
z2
:
10
z2
:
10
});
});
labelText
.
ignore
=
labelText
.
normalIgnore
=
!
labelModel
.
get
(
'
show
'
);
labelText
.
ignore
=
!
labelModel
.
get
(
'
show
'
);
labelText
.
hoverI
gnore
=
!
labelHoverModel
.
get
(
'
show
'
);
labelText
EmphasisState
.
i
gnore
=
!
labelHoverModel
.
get
(
'
show
'
);
labelLine
.
ignore
=
labelLine
.
normalIgnore
=
!
labelLineModel
.
get
(
'
show
'
);
labelLine
.
ignore
=
!
labelLineModel
.
get
(
'
show
'
);
labelLine
.
hoverI
gnore
=
!
labelLineHoverModel
.
get
(
'
show
'
);
labelLine
EmphasisState
.
i
gnore
=
!
labelLineHoverModel
.
get
(
'
show
'
);
// Default use item visual color
// Default use item visual color
labelLine
.
setStyle
({
labelLine
.
setStyle
({
...
...
src/chart/sunburst/SunburstPiece.ts
浏览文件 @
a245ad82
...
@@ -52,16 +52,19 @@ class SunburstPiece extends graphic.Group {
...
@@ -52,16 +52,19 @@ class SunburstPiece extends graphic.Group {
super
();
super
();
let
sector
=
new
graphic
.
Sector
({
let
sector
=
new
graphic
.
Sector
({
z2
:
DEFAULT_SECTOR_Z
z2
:
DEFAULT_SECTOR_Z
,
textConfig
:
{
inside
:
true
}
});
});
this
.
add
(
sector
);
graphic
.
getECData
(
sector
).
seriesIndex
=
seriesModel
.
seriesIndex
;
graphic
.
getECData
(
sector
).
seriesIndex
=
seriesModel
.
seriesIndex
;
let
text
=
new
graphic
.
Text
({
let
text
=
new
graphic
.
Text
({
z2
:
DEFAULT_TEXT_Z
,
z2
:
DEFAULT_TEXT_Z
,
silent
:
node
.
getModel
<
SunburstSeriesNodeOption
>
().
get
([
'
label
'
,
'
silent
'
])
silent
:
node
.
getModel
<
SunburstSeriesNodeOption
>
().
get
([
'
label
'
,
'
silent
'
])
});
});
this
.
add
(
sector
);
sector
.
setTextContent
(
text
);
this
.
add
(
text
);
this
.
updateData
(
true
,
node
,
'
normal
'
,
seriesModel
,
ecModel
);
this
.
updateData
(
true
,
node
,
'
normal
'
,
seriesModel
,
ecModel
);
...
@@ -238,16 +241,22 @@ class SunburstPiece extends graphic.Group {
...
@@ -238,16 +241,22 @@ class SunburstPiece extends graphic.Group {
text
=
''
;
text
=
''
;
}
}
let
label
=
this
.
childAt
(
1
)
as
graphic
.
Text
;
let
sector
=
this
.
childAt
(
0
);
let
label
=
sector
.
getTextContent
();
graphic
.
setLabelStyle
(
graphic
.
setLabelStyle
(
label
,
normalModel
,
labelHoverModel
,
label
,
normalModel
,
labelHoverModel
,
{
{
defaultText
:
labelModel
.
getShallow
(
'
show
'
)
?
text
:
null
,
defaultText
:
labelModel
.
getShallow
(
'
show
'
)
?
text
:
null
,
autoColor
:
visualColor
,
autoColor
:
visualColor
useInsideStyle
:
true
}
}
);
);
sector
.
setTextConfig
({
inside
:
true
,
insideStroke
:
visualColor
,
insideFill
:
'
auto
'
,
outsideFill
:
visualColor
});
let
midAngle
=
(
layout
.
startAngle
+
layout
.
endAngle
)
/
2
;
let
midAngle
=
(
layout
.
startAngle
+
layout
.
endAngle
)
/
2
;
let
dx
=
Math
.
cos
(
midAngle
);
let
dx
=
Math
.
cos
(
midAngle
);
...
...
src/component/helper/MapDraw.ts
浏览文件 @
a245ad82
...
@@ -274,8 +274,7 @@ class MapDraw {
...
@@ -274,8 +274,7 @@ class MapDraw {
{
{
labelFetcher
:
labelFetcher
,
labelFetcher
:
labelFetcher
,
labelDataIndex
:
query
,
labelDataIndex
:
query
,
defaultText
:
region
.
name
,
defaultText
:
region
.
name
useInsideStyle
:
false
},
},
{
{
align
:
'
center
'
,
align
:
'
center
'
,
...
...
src/util/graphic.ts
浏览文件 @
a245ad82
...
@@ -114,14 +114,6 @@ type TextCommonParams = {
...
@@ -114,14 +114,6 @@ type TextCommonParams = {
* for textFill, textStroke, textBackgroundColor, and textBorderColor. If autoColor specified, it is used as default textFill.
* for textFill, textStroke, textBackgroundColor, and textBorderColor. If autoColor specified, it is used as default textFill.
*/
*/
autoColor
?:
ColorString
autoColor
?:
ColorString
/**
* `true`: Use inside style (textFill, textStroke, textStrokeWidth)
* if `textFill` is not specified.
* `false`: Do not use inside style.
* `null/undefined`: use inside style if `isRectText` is true and
* `textFill` is not specified and textPosition contains `'inside'`.
*/
useInsideStyle
?:
boolean
forceRich
?:
boolean
forceRich
?:
boolean
...
@@ -592,7 +584,7 @@ interface SetLabelStyleOpt<LDI> extends TextCommonParams {
...
@@ -592,7 +584,7 @@ interface SetLabelStyleOpt<LDI> extends TextCommonParams {
* If target is other Element. It will create or reuse RichText which is attached on the target.
* If target is other Element. It will create or reuse RichText which is attached on the target.
* And create a new style object.
* And create a new style object.
*
*
* NOTICE: Because the style on RichText will be replaced with new.
* NOTICE: Because the style on RichText will be replaced with new
(only x, y are keeped)
.
* So please use the style on RichText after use this method.
* So please use the style on RichText after use this method.
*/
*/
export
function
setLabelStyle
<
LDI
>
(
export
function
setLabelStyle
<
LDI
>
(
...
@@ -692,6 +684,14 @@ export function setLabelStyle<LDI>(
...
@@ -692,6 +684,14 @@ export function setLabelStyle<LDI>(
normalStyle
.
text
=
normalStyleText
;
normalStyle
.
text
=
normalStyleText
;
emphasisState
.
style
.
text
=
emphasisStyleText
;
emphasisState
.
style
.
text
=
emphasisStyleText
;
// Keep x and y
if
(
richText
.
style
.
x
!=
null
)
{
normalStyle
.
x
=
richText
.
style
.
x
;
}
if
(
richText
.
style
.
y
!=
null
)
{
normalStyle
.
y
=
richText
.
style
.
y
;
}
// Always create new style.
// Always create new style.
richText
.
useStyle
(
normalStyle
);
richText
.
useStyle
(
normalStyle
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录