Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
bc0cc601
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,发现更多精彩内容 >>
提交
bc0cc601
编写于
5月 06, 2016
作者:
P
pah100
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/ecomfe/echarts
上级
db5ab7c1
6a087b7e
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
245 addition
and
202 deletion
+245
-202
src/chart/graph/GraphSeries.js
src/chart/graph/GraphSeries.js
+73
-5
src/chart/graph/GraphView.js
src/chart/graph/GraphView.js
+3
-21
src/chart/helper/EffectLine.js
src/chart/helper/EffectLine.js
+6
-6
src/chart/helper/Line.js
src/chart/helper/Line.js
+79
-73
src/chart/helper/LineDraw.js
src/chart/helper/LineDraw.js
+4
-8
src/chart/helper/LinePath.js
src/chart/helper/LinePath.js
+15
-4
src/chart/radar/RadarSeries.js
src/chart/radar/RadarSeries.js
+4
-6
src/chart/sankey/SankeyView.js
src/chart/sankey/SankeyView.js
+1
-2
src/component/marker/MarkLineModel.js
src/component/marker/MarkLineModel.js
+4
-16
src/component/marker/MarkLineView.js
src/component/marker/MarkLineView.js
+11
-7
src/component/marker/MarkPointModel.js
src/component/marker/MarkPointModel.js
+4
-19
src/component/timeline/SliderTimelineView.js
src/component/timeline/SliderTimelineView.js
+1
-1
src/data/List.js
src/data/List.js
+9
-7
src/echarts.js
src/echarts.js
+1
-0
src/model/Model.js
src/model/Model.js
+4
-0
src/model/Series.js
src/model/Series.js
+10
-11
src/util/model.js
src/util/model.js
+16
-16
未找到文件。
src/chart/graph/GraphSeries.js
浏览文件 @
bc0cc601
...
...
@@ -4,6 +4,8 @@ define(function (require) {
var
List
=
require
(
'
../../data/List
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
modelUtil
=
require
(
'
../../util/model
'
);
var
Model
=
require
(
'
../../model/Model
'
);
var
createGraphFromNodeEdge
=
require
(
'
../helper/createGraphFromNodeEdge
'
);
...
...
@@ -19,24 +21,37 @@ define(function (require) {
return
this
.
_categoriesData
;
};
this
.
fillDataTextStyle
(
option
.
edges
||
option
.
links
);
this
.
_updateCategoriesData
();
this
.
_updateEdgeDataModel
();
},
mergeOption
:
function
(
option
)
{
GraphSeries
.
superApply
(
this
,
'
mergeOption
'
,
arguments
);
this
.
fillDataTextStyle
(
option
.
edges
||
option
.
links
);
this
.
_updateCategoriesData
();
this
.
_updateEdgeDataModel
();
},
mergeDefaultAndTheme
:
function
(
option
)
{
GraphSeries
.
superApply
(
this
,
'
mergeDefaultAndTheme
'
,
arguments
);
modelUtil
.
defaultEmphasis
(
option
.
edgeLabel
,
modelUtil
.
LABEL_OPTIONS
);
},
getInitialData
:
function
(
option
,
ecModel
)
{
var
edges
=
option
.
edges
||
option
.
links
;
var
nodes
=
option
.
data
||
option
.
nodes
;
if
(
nodes
&&
edges
)
{
var
graph
=
createGraphFromNodeEdge
(
nodes
,
edges
,
this
,
true
);
var
list
=
graph
.
data
;
var
nodeData
=
graph
.
data
;
var
edgeData
=
graph
.
edgeData
;
var
self
=
this
;
// Overwrite
list
.getItemModel to
list
.
wrapMethod
(
'
getItemModel
'
,
function
(
model
)
{
// Overwrite
nodeData
.getItemModel to
nodeData
.
wrapMethod
(
'
getItemModel
'
,
function
(
model
)
{
var
categoriesModels
=
self
.
_categoriesModels
;
var
categoryIdx
=
model
.
getShallow
(
'
category
'
);
var
categoryModel
=
categoriesModels
[
categoryIdx
];
...
...
@@ -46,7 +61,29 @@ define(function (require) {
}
return
model
;
});
return
list
;
var
edgeLabelModel
=
this
.
getModel
(
'
edgeLabel
'
);
var
wrappedGetEdgeModel
=
function
(
path
,
parentModel
)
{
var
pathArr
=
(
path
||
''
).
split
(
'
.
'
);
if
(
pathArr
[
0
]
===
'
label
'
)
{
parentModel
=
parentModel
||
edgeLabelModel
.
getModel
(
pathArr
.
slice
(
1
));
}
var
model
=
Model
.
prototype
.
getModel
.
call
(
this
,
pathArr
,
parentModel
);
model
.
getModel
=
wrappedGetEdgeModel
;
return
model
;
};
edgeData
.
wrapMethod
(
'
getItemModel
'
,
function
(
model
)
{
// FIXME Wrap get method ?
model
.
getModel
=
wrappedGetEdgeModel
;
return
model
;
});
// Set edge data again to ensure the backup data has the wrapped method
// FIXME
graph
.
setEdgeData
(
edgeData
);
return
nodeData
;
}
},
...
...
@@ -69,6 +106,10 @@ define(function (require) {
return
this
.
getGraph
().
edgeData
;
},
getEdgeDataModel
:
function
()
{
return
this
.
_edgeDataModel
;
},
/**
* @return {module:echarts/data/List}
*/
...
...
@@ -76,6 +117,25 @@ define(function (require) {
return
this
.
_categoriesData
;
},
_updateEdgeDataModel
:
function
()
{
var
graph
=
this
.
getGraph
();
var
edgeData
=
this
.
getEdgeData
();
var
data
=
this
.
getData
();
this
.
_edgeDataModel
=
modelUtil
.
createDataFormatModel
(
edgeData
,
this
);
this
.
_edgeDataModel
.
formatTooltip
=
function
(
dataIndex
)
{
var
params
=
this
.
getDataParams
(
dataIndex
);
var
edge
=
graph
.
getEdgeByIndex
(
dataIndex
);
var
sourceName
=
data
.
getName
(
edge
.
node1
.
dataIndex
);
var
targetName
=
data
.
getName
(
edge
.
node2
.
dataIndex
);
var
html
=
sourceName
+
'
>
'
+
targetName
;
if
(
params
.
value
)
{
html
+=
'
:
'
+
params
.
value
;
}
return
html
;
};
},
_updateCategoriesData
:
function
()
{
var
categories
=
zrUtil
.
map
(
this
.
option
.
categories
||
[],
function
(
category
)
{
// Data must has value
...
...
@@ -136,6 +196,13 @@ define(function (require) {
symbol
:
'
circle
'
,
symbolSize
:
10
,
edgeSymbol
:
[
'
none
'
,
'
none
'
],
edgeSymbolSize
:
10
,
edgeLabel
:
{
normal
:
{},
emphasis
:
{}
},
draggable
:
false
,
roam
:
false
,
...
...
@@ -159,7 +226,8 @@ define(function (require) {
label
:
{
normal
:
{
show
:
false
show
:
false
,
formatter
:
'
{b}
'
},
emphasis
:
{
show
:
true
...
...
src/chart/graph/GraphView.js
浏览文件 @
bc0cc601
...
...
@@ -44,32 +44,15 @@ define(function (require) {
symbolDraw
.
updateData
(
data
);
var
edgeData
=
data
.
graph
.
edgeData
;
var
formatModel
=
modelUtil
.
createDataFormatModel
(
seriesModel
,
edgeData
);
formatModel
.
formatTooltip
=
function
(
dataIndex
)
{
var
params
=
this
.
getDataParams
(
dataIndex
);
var
edge
=
data
.
graph
.
getEdgeByIndex
(
dataIndex
);
var
sourceName
=
data
.
getName
(
edge
.
node1
.
dataIndex
);
var
targetName
=
data
.
getName
(
edge
.
node2
.
dataIndex
);
var
html
=
sourceName
+
'
>
'
+
targetName
;
if
(
params
.
value
)
{
html
+=
'
:
'
+
params
.
value
;
}
return
html
;
};
var
edgeData
=
seriesModel
.
getEdgeData
();
lineDraw
.
updateData
(
edgeData
,
null
,
null
);
lineDraw
.
updateData
(
edgeData
);
edgeData
.
eachItemGraphicEl
(
function
(
el
)
{
el
.
traverse
(
function
(
child
)
{
child
.
dataModel
=
formatModel
;
child
.
dataModel
=
seriesModel
.
getEdgeDataModel
()
;
});
});
// Save the original lineWidth
// data.graph.eachEdge(function (edge) {
// edge.__lineWidth = edge.getModel('lineStyle.normal').get('width');
// });
var
group
=
this
.
group
;
var
groupNewProp
=
{
position
:
coordSys
.
position
,
...
...
@@ -186,7 +169,6 @@ define(function (require) {
var
nodeScale
=
(
roamZoom
-
1
)
*
nodeScaleRatio
+
1
;
var
invScale
=
[
// nodeScale / roamZoom / (groupZoom / roamZoom)
nodeScale
/
groupZoom
,
nodeScale
/
groupZoom
];
...
...
src/chart/helper/EffectLine.js
浏览文件 @
bc0cc601
...
...
@@ -15,10 +15,10 @@ define(function (require) {
* @extends {module:zrender/graphic/Group}
* @alias {module:echarts/chart/helper/Line}
*/
function
EffectLine
(
lineData
,
fromData
,
toData
,
idx
)
{
function
EffectLine
(
lineData
,
idx
)
{
graphic
.
Group
.
call
(
this
);
var
line
=
new
Line
(
lineData
,
fromData
,
toData
,
idx
);
var
line
=
new
Line
(
lineData
,
idx
);
this
.
add
(
line
);
this
.
_updateEffectSymbol
(
lineData
,
idx
);
...
...
@@ -98,13 +98,13 @@ define(function (require) {
symbol
.
attr
(
'
scale
'
,
size
);
};
effectLineProto
.
updateData
=
function
(
lineData
,
fromData
,
toData
,
idx
)
{
this
.
childAt
(
0
).
updateData
(
lineData
,
fromData
,
toData
,
idx
);
effectLineProto
.
updateData
=
function
(
lineData
,
idx
)
{
this
.
childAt
(
0
).
updateData
(
lineData
,
idx
);
this
.
_updateEffectSymbol
(
lineData
,
idx
);
};
effectLineProto
.
updateLayout
=
function
(
lineData
,
fromData
,
toData
,
idx
)
{
this
.
childAt
(
0
).
updateLayout
(
lineData
,
fromData
,
toData
,
idx
);
effectLineProto
.
updateLayout
=
function
(
lineData
,
idx
)
{
this
.
childAt
(
0
).
updateLayout
(
lineData
,
idx
);
var
symbol
=
this
.
childAt
(
1
);
var
points
=
lineData
.
getItemLayout
(
idx
);
setAnimationPoints
(
symbol
,
points
);
...
...
src/chart/helper/Line.js
浏览文件 @
bc0cc601
...
...
@@ -5,20 +5,25 @@ define(function (require) {
var
symbolUtil
=
require
(
'
../../util/symbol
'
);
var
vector
=
require
(
'
zrender/core/vector
'
);
var
matrix
=
require
(
'
zrender/core/matrix
'
);
var
LinePath
=
require
(
'
./LinePath
'
);
var
graphic
=
require
(
'
../../util/graphic
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
numberUtil
=
require
(
'
../../util/number
'
);
var
SYMBOL_CATEGORIES
=
[
'
fromSymbol
'
,
'
toSymbol
'
];
function
makeSymbolTypeKey
(
symbolCategory
)
{
return
'
_
'
+
symbolCategory
+
'
Type
'
;
}
/**
* @inner
*/
function
createSymbol
(
name
,
d
ata
,
idx
)
{
var
color
=
d
ata
.
getItemVisual
(
idx
,
'
color
'
);
var
symbolType
=
data
.
getItemVisual
(
idx
,
'
symbol
'
);
var
symbolSize
=
data
.
getItemVisual
(
idx
,
'
symbol
Size
'
);
function
createSymbol
(
name
,
lineD
ata
,
idx
)
{
var
color
=
lineD
ata
.
getItemVisual
(
idx
,
'
color
'
);
var
symbolType
=
lineData
.
getItemVisual
(
idx
,
name
);
var
symbolSize
=
lineData
.
getItemVisual
(
idx
,
name
+
'
Size
'
);
if
(
symbolType
===
'
none
'
)
{
if
(
!
symbolType
||
symbolType
===
'
none
'
)
{
return
;
}
...
...
@@ -58,6 +63,21 @@ define(function (require) {
}
}
function
lineAfterUpdate
()
{
// Ignore scale
var
m
=
this
.
transform
;
if
(
m
)
{
var
sx
=
Math
.
sqrt
(
m
[
0
]
*
m
[
0
]
+
m
[
1
]
*
m
[
1
]);
var
sy
=
Math
.
sqrt
(
m
[
2
]
*
m
[
2
]
+
m
[
3
]
*
m
[
3
]);
m
[
0
]
/=
sx
;
m
[
1
]
/=
sx
;
m
[
2
]
/=
sy
;
m
[
3
]
/=
sy
;
matrix
.
invert
(
this
.
invTransform
,
m
);
}
}
// function isSymbolArrow(symbol) {
// return symbol.type === 'symbol' && symbol.shape.symbolType === 'arrow';
// }
...
...
@@ -72,6 +92,7 @@ define(function (require) {
var
symbolFrom
=
lineGroup
.
childOfName
(
'
fromSymbol
'
);
var
symbolTo
=
lineGroup
.
childOfName
(
'
toSymbol
'
);
var
label
=
lineGroup
.
childOfName
(
'
label
'
);
var
fromPos
=
line
.
pointAt
(
0
);
var
toPos
=
line
.
pointAt
(
line
.
shape
.
percent
);
...
...
@@ -80,17 +101,17 @@ define(function (require) {
if
(
symbolFrom
)
{
symbolFrom
.
attr
(
'
position
'
,
fromPos
);
// Rotate the arrow
// FIXME Hard coded ?
// if (isSymbolArrow(symbolFrom)) {
symbolFrom
.
attr
(
'
rotation
'
,
tangentRotation
(
toPos
,
fromPos
));
// }
var
tangent
=
line
.
tangentAt
(
0
);
symbolFrom
.
attr
(
'
rotation
'
,
-
Math
.
PI
/
2
-
Math
.
atan2
(
tangent
[
1
],
tangent
[
0
]
));
}
if
(
symbolTo
)
{
symbolTo
.
attr
(
'
position
'
,
toPos
);
// if (isSymbolArrow(symbolTo)) {
symbolTo
.
attr
(
'
rotation
'
,
tangentRotation
(
fromPos
,
toPos
));
// }
var
tangent
=
line
.
tangentAt
(
1
);
symbolTo
.
attr
(
'
rotation
'
,
-
Math
.
PI
/
2
-
Math
.
atan2
(
tangent
[
1
],
tangent
[
0
]
));
}
label
.
attr
(
'
position
'
,
toPos
);
...
...
@@ -98,25 +119,35 @@ define(function (require) {
var
textPosition
;
var
textAlign
;
var
textVerticalAlign
;
var
distance
=
5
;
var
parentNode
=
this
.
parent
;
while
(
parentNode
)
{
if
(
parentNode
.
scale
)
{
distance
/=
parentNode
.
scale
[
0
];
}
parentNode
=
parentNode
.
parent
;
}
// End
if
(
label
.
__position
===
'
end
'
)
{
textPosition
=
[
d
[
0
]
*
5
+
toPos
[
0
],
d
[
1
]
*
5
+
toPos
[
1
]];
textPosition
=
[
d
[
0
]
*
distance
+
toPos
[
0
],
d
[
1
]
*
distance
+
toPos
[
1
]];
textAlign
=
d
[
0
]
>
0.8
?
'
left
'
:
(
d
[
0
]
<
-
0.8
?
'
right
'
:
'
center
'
);
textVerticalAlign
=
d
[
1
]
>
0.8
?
'
top
'
:
(
d
[
1
]
<
-
0.8
?
'
bottom
'
:
'
middle
'
);
}
// Middle
else
if
(
label
.
__position
===
'
middle
'
)
{
var
n
=
[
d
[
1
],
-
d
[
0
]];
var
halfPercent
=
line
.
shape
.
percent
/
2
;
var
tangent
=
line
.
tangentAt
(
halfPercent
);
var
n
=
[
tangent
[
1
],
-
tangent
[
0
]];
var
cp
=
line
.
pointAt
(
halfPercent
);
if
(
n
[
1
]
>
0
)
{
n
[
0
]
=
-
n
[
0
];
n
[
1
]
=
-
n
[
1
];
}
textPosition
=
[
(
toPos
[
0
]
+
fromPos
[
0
])
/
2
+
n
[
0
]
*
5
,
(
toPos
[
1
]
+
fromPos
[
1
])
/
2
+
n
[
1
]
*
5
];
textPosition
=
[
cp
[
0
]
+
n
[
0
]
*
distance
,
cp
[
1
]
+
n
[
1
]
*
distance
];
textAlign
=
'
center
'
;
textVerticalAlign
=
'
bottom
'
;
var
rotation
=
-
Math
.
atan2
(
toPos
[
1
]
-
fromPos
[
1
],
toPos
[
0
]
-
fromPos
[
0
]
);
var
rotation
=
-
Math
.
atan2
(
tangent
[
1
],
tangent
[
0
]);
if
(
toPos
[
0
]
<
fromPos
[
0
])
{
rotation
=
Math
.
PI
+
rotation
;
}
...
...
@@ -124,7 +155,7 @@ define(function (require) {
}
// Start
else
{
textPosition
=
[
-
d
[
0
]
*
5
+
fromPos
[
0
],
-
d
[
1
]
*
5
+
fromPos
[
1
]];
textPosition
=
[
-
d
[
0
]
*
distance
+
fromPos
[
0
],
-
d
[
1
]
*
distance
+
fromPos
[
1
]];
textAlign
=
d
[
0
]
>
0.8
?
'
right
'
:
(
d
[
0
]
<
-
0.8
?
'
left
'
:
'
center
'
);
textVerticalAlign
=
d
[
1
]
>
0.8
?
'
bottom
'
:
(
d
[
1
]
<
-
0.8
?
'
top
'
:
'
middle
'
);
}
...
...
@@ -138,21 +169,15 @@ define(function (require) {
});
}
function
tangentRotation
(
p1
,
p2
)
{
return
-
Math
.
PI
/
2
-
Math
.
atan2
(
p2
[
1
]
-
p1
[
1
],
p2
[
0
]
-
p1
[
0
]
);
}
/**
* @constructor
* @extends {module:zrender/graphic/Group}
* @alias {module:echarts/chart/helper/Line}
*/
function
Line
(
lineData
,
fromData
,
toData
,
idx
)
{
function
Line
(
lineData
,
idx
)
{
graphic
.
Group
.
call
(
this
);
this
.
_createLine
(
lineData
,
fromData
,
toData
,
idx
);
this
.
_createLine
(
lineData
,
idx
);
}
var
lineProto
=
Line
.
prototype
;
...
...
@@ -160,7 +185,7 @@ define(function (require) {
// Update symbol position and rotation
lineProto
.
beforeUpdate
=
updateSymbolBeforeLineUpdate
;
lineProto
.
_createLine
=
function
(
lineData
,
fromData
,
toData
,
idx
)
{
lineProto
.
_createLine
=
function
(
lineData
,
idx
)
{
var
seriesModel
=
lineData
.
hostModel
;
var
linePoints
=
lineData
.
getItemLayout
(
idx
);
...
...
@@ -179,26 +204,19 @@ define(function (require) {
});
this
.
add
(
label
);
if
(
fromData
)
{
var
symbol
From
=
createSymbol
(
'
fromSymbol
'
,
from
Data
,
idx
);
zrUtil
.
each
(
SYMBOL_CATEGORIES
,
function
(
symbolCategory
)
{
var
symbol
=
createSymbol
(
symbolCategory
,
line
Data
,
idx
);
// symbols must added after line to make sure
// it will be updated after line#update.
// Or symbol position and rotation update in line#beforeUpdate will be one frame slow
this
.
add
(
symbolFrom
);
this
.
_fromSymbolType
=
fromData
.
getItemVisual
(
idx
,
'
symbol
'
);
}
if
(
toData
)
{
var
symbolTo
=
createSymbol
(
'
toSymbol
'
,
toData
,
idx
);
this
.
add
(
symbolTo
);
this
.
_toSymbolType
=
toData
.
getItemVisual
(
idx
,
'
symbol
'
);
}
this
.
add
(
symbol
);
this
[
makeSymbolTypeKey
(
symbolCategory
)]
=
lineData
.
getItemVisual
(
idx
,
symbolCategory
);
},
this
);
this
.
_updateCommonStl
(
lineData
,
fromData
,
toData
,
idx
);
this
.
_updateCommonStl
(
lineData
,
idx
);
};
lineProto
.
updateData
=
function
(
lineData
,
fromData
,
toData
,
idx
)
{
lineProto
.
updateData
=
function
(
lineData
,
idx
)
{
var
seriesModel
=
lineData
.
hostModel
;
var
line
=
this
.
childOfName
(
'
line
'
);
...
...
@@ -209,31 +227,22 @@ define(function (require) {
setLinePoints
(
target
.
shape
,
linePoints
);
graphic
.
updateProps
(
line
,
target
,
seriesModel
);
// Symbol changed
if
(
fromData
)
{
var
fromSymbolType
=
fromData
.
getItemVisual
(
idx
,
'
symbol
'
);
if
(
this
.
_fromSymbolType
!==
fromSymbolType
)
{
var
symbolFrom
=
createSymbol
(
'
fromSymbol
'
,
fromData
,
idx
);
this
.
remove
(
this
.
childOfName
(
'
fromSymbol
'
));
this
.
add
(
symbolFrom
);
}
this
.
_fromSymbolType
=
fromSymbolType
;
}
if
(
toData
)
{
var
toSymbolType
=
toData
.
getItemVisual
(
idx
,
'
symbol
'
);
zrUtil
.
each
(
SYMBOL_CATEGORIES
,
function
(
symbolCategory
)
{
var
symbolType
=
lineData
.
getItemVisual
(
idx
,
symbolCategory
);
var
key
=
makeSymbolTypeKey
(
symbolCategory
);
// Symbol changed
if
(
t
oSymbolType
!==
this
.
_toS
ymbolType
)
{
var
symbol
To
=
createSymbol
(
'
toSymbol
'
,
to
Data
,
idx
);
this
.
remove
(
this
.
childOfName
(
'
toSymbol
'
));
this
.
add
(
symbol
To
);
if
(
t
his
[
key
]
!==
s
ymbolType
)
{
var
symbol
=
createSymbol
(
symbolCategory
,
line
Data
,
idx
);
this
.
remove
(
this
.
childOfName
(
symbolCategory
));
this
.
add
(
symbol
);
}
this
.
_toSymbolType
=
toS
ymbolType
;
}
this
[
key
]
=
s
ymbolType
;
}
,
this
);
this
.
_updateCommonStl
(
lineData
,
fromData
,
toData
,
idx
);
this
.
_updateCommonStl
(
lineData
,
idx
);
};
lineProto
.
_updateCommonStl
=
function
(
lineData
,
fromData
,
toData
,
idx
)
{
lineProto
.
_updateCommonStl
=
function
(
lineData
,
idx
)
{
var
seriesModel
=
lineData
.
hostModel
;
var
line
=
this
.
childOfName
(
'
line
'
);
...
...
@@ -257,27 +266,28 @@ define(function (require) {
},
itemModel
.
getModel
(
'
lineStyle.normal
'
).
getLineStyle
()
));
var
defaultColor
=
lineData
.
getItemVisual
(
idx
,
'
color
'
)
||
'
#000
'
;
var
label
=
this
.
childOfName
(
'
label
'
);
label
.
afterUpdate
=
lineAfterUpdate
;
label
.
setStyle
({
text
:
labelModel
.
get
(
'
show
'
)
?
zrUtil
.
retrieve
(
seriesModel
.
getFormattedLabel
(
idx
,
'
normal
'
),
seriesModel
.
getFormattedLabel
(
idx
,
'
normal
'
,
lineData
),
defaultText
)
:
''
,
textFont
:
textStyleModel
.
getFont
(),
fill
:
textStyleModel
.
getTextColor
()
||
lineData
.
getItemVisual
(
idx
,
'
color
'
)
fill
:
textStyleModel
.
getTextColor
()
||
defaultColor
});
label
.
hoverStyle
=
{
text
:
labelHoverModel
.
get
(
'
show
'
)
?
zrUtil
.
retrieve
(
seriesModel
.
getFormattedLabel
(
idx
,
'
emphasis
'
),
seriesModel
.
getFormattedLabel
(
idx
,
'
emphasis
'
,
lineData
),
defaultText
)
:
''
,
textFont
:
textStyleHoverModel
.
getFont
(),
fill
:
textStyleHoverModel
.
getTextColor
()
fill
:
textStyleHoverModel
.
getTextColor
()
||
defaultColor
};
label
.
__textAlign
=
textStyleModel
.
get
(
'
align
'
);
label
.
__verticalAlign
=
textStyleModel
.
get
(
'
baseline
'
);
...
...
@@ -288,15 +298,11 @@ define(function (require) {
);
};
lineProto
.
updateLayout
=
function
(
lineData
,
fromData
,
toData
,
idx
)
{
lineProto
.
updateLayout
=
function
(
lineData
,
idx
)
{
var
points
=
lineData
.
getItemLayout
(
idx
);
var
linePath
=
this
.
childOfName
(
'
line
'
);
setLinePoints
(
linePath
.
shape
,
points
);
linePath
.
dirty
(
true
);
// var fromEl = fromData && fromData.getItemGraphicEl(idx);
// var toEl = toData && toData.getItemGraphicEl(idx);
// fromEl && fromEl.attr('position', points[0]);
// toEl && toEl.attr('position', points[1]);
};
zrUtil
.
inherits
(
Line
,
graphic
.
Group
);
...
...
src/chart/helper/LineDraw.js
浏览文件 @
bc0cc601
...
...
@@ -19,10 +19,8 @@ define(function (require) {
/**
* @param {module:echarts/data/List} lineData
* @param {module:echarts/data/List} [fromData]
* @param {module:echarts/data/List} [toData]
*/
lineDrawProto
.
updateData
=
function
(
lineData
,
fromData
,
toData
)
{
lineDrawProto
.
updateData
=
function
(
lineData
)
{
var
oldLineData
=
this
.
_lineData
;
var
group
=
this
.
group
;
...
...
@@ -30,7 +28,7 @@ define(function (require) {
lineData
.
diff
(
oldLineData
)
.
add
(
function
(
idx
)
{
var
lineGroup
=
new
LineCtor
(
lineData
,
fromData
,
toData
,
idx
);
var
lineGroup
=
new
LineCtor
(
lineData
,
idx
);
lineData
.
setItemGraphicEl
(
idx
,
lineGroup
);
...
...
@@ -38,7 +36,7 @@ define(function (require) {
})
.
update
(
function
(
newIdx
,
oldIdx
)
{
var
lineGroup
=
oldLineData
.
getItemGraphicEl
(
oldIdx
);
lineGroup
.
updateData
(
lineData
,
fromData
,
toData
,
newIdx
);
lineGroup
.
updateData
(
lineData
,
newIdx
);
lineData
.
setItemGraphicEl
(
newIdx
,
lineGroup
);
...
...
@@ -50,14 +48,12 @@ define(function (require) {
.
execute
();
this
.
_lineData
=
lineData
;
this
.
_fromData
=
fromData
;
this
.
_toData
=
toData
;
};
lineDrawProto
.
updateLayout
=
function
()
{
var
lineData
=
this
.
_lineData
;
lineData
.
eachItemGraphicEl
(
function
(
el
,
idx
)
{
el
.
updateLayout
(
lineData
,
this
.
_fromData
,
this
.
_toData
,
idx
);
el
.
updateLayout
(
lineData
,
idx
);
},
this
);
};
...
...
src/chart/helper/LinePath.js
浏览文件 @
bc0cc601
...
...
@@ -3,10 +3,15 @@
*/
define
(
function
(
require
)
{
var
graphic
=
require
(
'
../../util/graphic
'
);
var
vec2
=
require
(
'
zrender/core/vector
'
);
var
straightLineProto
=
graphic
.
Line
.
prototype
;
var
bezierCurveProto
=
graphic
.
BezierCurve
.
prototype
;
function
isLine
(
shape
)
{
return
shape
.
cpx1
==
null
||
shape
.
cpy1
==
null
;
}
return
graphic
.
extendShape
({
type
:
'
ec-line
'
,
...
...
@@ -27,15 +32,21 @@ define(function (require) {
},
buildPath
:
function
(
ctx
,
shape
)
{
(
shape
.
cpx1
==
null
||
shape
.
cpy1
==
null
?
straightLineProto
:
bezierCurveProto
).
buildPath
(
ctx
,
shape
);
(
isLine
(
shape
)
?
straightLineProto
:
bezierCurveProto
).
buildPath
(
ctx
,
shape
);
},
pointAt
:
function
(
t
)
{
var
shape
=
this
.
shape
;
return
shape
.
cpx1
==
null
||
shape
.
cpy1
==
null
return
isLine
(
this
.
shape
)
?
straightLineProto
.
pointAt
.
call
(
this
,
t
)
:
bezierCurveProto
.
pointAt
.
call
(
this
,
t
);
},
tangentAt
:
function
(
t
)
{
var
shape
=
this
.
shape
;
var
p
=
isLine
(
shape
)
?
[
shape
.
x2
-
shape
.
x1
,
shape
.
y2
-
shape
.
y1
]
:
bezierCurveProto
.
tangentAt
.
call
(
this
,
t
);
return
vec2
.
normalize
(
p
,
p
);
}
});
});
\ No newline at end of file
src/chart/radar/RadarSeries.js
浏览文件 @
bc0cc601
...
...
@@ -46,15 +46,13 @@ define(function(require) {
}).
join
(
'
<br />
'
);
},
getFormattedLabel
:
function
(
dataIndex
,
status
,
formatter
,
indicatorIndex
)
{
getFormattedLabel
:
function
(
dataIndex
,
status
,
otherData
,
indicatorIndex
)
{
status
=
status
||
'
normal
'
;
var
data
=
this
.
getData
();
var
data
=
otherData
||
this
.
getData
();
var
itemModel
=
data
.
getItemModel
(
dataIndex
);
var
params
=
this
.
getDataParams
(
dataIndex
);
if
(
formatter
==
null
)
{
formatter
=
itemModel
.
get
([
'
label
'
,
status
,
'
formatter
'
]);
}
var
params
=
this
.
getDataParams
(
dataIndex
,
otherData
);
var
formatter
=
itemModel
.
get
([
'
label
'
,
status
,
'
formatter
'
]);
// Get value of specified indicator
params
.
value
=
params
.
value
[
indicatorIndex
||
0
];
if
(
typeof
formatter
===
'
function
'
)
{
...
...
src/chart/sankey/SankeyView.js
浏览文件 @
bc0cc601
...
...
@@ -54,8 +54,7 @@ define(function (require) {
group
.
position
=
[
layoutInfo
.
x
,
layoutInfo
.
y
];
var
edgeData
=
graph
.
edgeData
;
var
rawOption
=
seriesModel
.
option
;
var
formatModel
=
modelUtil
.
createDataFormatModel
(
seriesModel
,
edgeData
);
var
formatModel
=
modelUtil
.
createDataFormatModel
(
edgeData
,
seriesModel
);
formatModel
.
formatTooltip
=
function
(
dataIndex
)
{
var
params
=
this
.
getDataParams
(
dataIndex
);
...
...
src/component/marker/MarkLineModel.js
浏览文件 @
bc0cc601
...
...
@@ -68,13 +68,12 @@ define(function (require) {
defaultOption
:
{
zlevel
:
0
,
z
:
5
,
// 标线起始和结束的symbol介绍类型,如果都一样,可以直接传string
symbol
:
[
'
circle
'
,
'
arrow
'
],
// 标线起始和结束的symbol大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
symbolSize
:
[
8
,
16
],
// 标线起始和结束的symbol旋转控制
//symbolRotate:
null
,
//smooth: false,
//symbolRotate:
0
,
precision
:
2
,
tooltip
:
{
trigger
:
'
item
'
...
...
@@ -82,12 +81,7 @@ define(function (require) {
label
:
{
normal
:
{
show
:
true
,
// 标签文本格式器,同Tooltip.formatter,不支持回调
// formatter: null,
// 可选为 'start'|'end'|'left'|'right'|'top'|'bottom'
position
:
'
end
'
// 默认使用全局文本样式,详见TEXTSTYLE
// textStyle: null
},
emphasis
:
{
show
:
true
...
...
@@ -95,13 +89,7 @@ define(function (require) {
},
lineStyle
:
{
normal
:
{
// color
// width
type
:
'
dashed
'
// shadowColor: 'rgba(0,0,0,0)',
// shadowBlur: 0,
// shadowOffsetX: 0,
// shadowOffsetY: 0
},
emphasis
:
{
width
:
3
...
...
src/component/marker/MarkLineView.js
浏览文件 @
bc0cc601
...
...
@@ -255,9 +255,16 @@ define(function (require) {
fromData
.
getItemLayout
(
idx
),
toData
.
getItemLayout
(
idx
)
]);
lineData
.
setItemVisual
(
idx
,
{
'
fromSymbolSize
'
:
fromData
.
getItemVisual
(
idx
,
'
symbolSize
'
),
'
fromSymbol
'
:
fromData
.
getItemVisual
(
idx
,
'
symbol
'
),
'
toSymbolSize
'
:
toData
.
getItemVisual
(
idx
,
'
symbolSize
'
),
'
toSymbol
'
:
toData
.
getItemVisual
(
idx
,
'
symbol
'
)
});
});
lineDraw
.
updateData
(
lineData
,
fromData
,
toData
);
lineDraw
.
updateData
(
lineData
);
// Set host model for tooltip
// FIXME
...
...
@@ -275,12 +282,9 @@ define(function (require) {
);
data
.
setItemVisual
(
idx
,
{
symbolSize
:
itemModel
.
get
(
'
symbolSize
'
)
||
symbolSize
[
isFrom
?
0
:
1
],
symbol
:
itemModel
.
get
(
'
symbol
'
,
true
)
||
symbolType
[
isFrom
?
0
:
1
],
color
:
itemModel
.
get
(
'
itemStyle.normal.color
'
)
||
seriesData
.
getVisual
(
'
color
'
)
symbolSize
:
itemModel
.
get
(
'
symbolSize
'
)
||
symbolSize
[
isFrom
?
0
:
1
],
symbol
:
itemModel
.
get
(
'
symbol
'
,
true
)
||
symbolType
[
isFrom
?
0
:
1
],
color
:
itemModel
.
get
(
'
itemStyle.normal.color
'
)
||
seriesData
.
getVisual
(
'
color
'
)
});
}
...
...
src/component/marker/MarkPointModel.js
浏览文件 @
bc0cc601
...
...
@@ -59,40 +59,25 @@ define(function (require) {
defaultOption
:
{
zlevel
:
0
,
z
:
5
,
symbol
:
'
pin
'
,
// 标注类型
symbolSize
:
50
,
// 标注大小
// symbolRotate: null, // 标注旋转控制
symbol
:
'
pin
'
,
symbolSize
:
50
,
//symbolRotate: 0,
//symbolOffset: [0, 0]
tooltip
:
{
trigger
:
'
item
'
},
label
:
{
normal
:
{
show
:
true
,
// 标签文本格式器,同Tooltip.formatter,不支持回调
// formatter: null,
// 可选为'left'|'right'|'top'|'bottom'
position
:
'
inside
'
// 默认使用全局文本样式,详见TEXTSTYLE
// textStyle: null
},
emphasis
:
{
show
:
true
// 标签文本格式器,同Tooltip.formatter,不支持回调
// formatter: null,
// position: 'inside' // 'left'|'right'|'top'|'bottom'
// textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
}
},
itemStyle
:
{
normal
:
{
// color: 各异,
// 标注边线颜色,优先于color
// borderColor: 各异,
// 标注边线线宽,单位px,默认为1
borderWidth
:
2
},
emphasis
:
{
// color: 各异
}
}
}
...
...
src/component/timeline/SliderTimelineView.js
浏览文件 @
bc0cc601
...
...
@@ -382,7 +382,7 @@ define(function (require) {
*/
_prepareTooltipHostModel
:
function
(
data
,
timelineModel
)
{
var
tooltipHostModel
=
modelUtil
.
createDataFormatModel
(
{
mainType
:
'
timeline
'
,
subType
:
'
slider
'
},
data
data
,
{
mainType
:
'
timeline
'
,
subType
:
'
slider
'
}
);
var
me
=
this
;
...
...
src/data/List.js
浏览文件 @
bc0cc601
...
...
@@ -31,12 +31,14 @@ define(function (require) {
'
stackedOn
'
,
'
_nameList
'
,
'
_idList
'
,
'
_rawData
'
];
var
transferImmuProperties
=
function
(
a
,
b
,
wrappedMethod
)
{
zrUtil
.
each
(
IMMUTABLE_PROPERTIES
.
concat
(
wrappedMethod
||
[]),
function
(
propName
)
{
var
transferImmuProperties
=
function
(
a
,
b
)
{
zrUtil
.
each
(
IMMUTABLE_PROPERTIES
.
concat
(
b
.
__wrappedMethods
||
[]),
function
(
propName
)
{
if
(
b
.
hasOwnProperty
(
propName
))
{
a
[
propName
]
=
b
[
propName
];
}
});
a
.
__wrappedMethods
=
b
.
__wrappedMethods
;
};
/**
...
...
@@ -527,7 +529,7 @@ define(function (require) {
* @return {number}
*/
listProto
.
getRawDataItem
=
function
(
idx
)
{
return
(
this
.
_rawData
||
[])
[
this
.
getRawIndex
(
idx
)];
return
this
.
_rawData
[
this
.
getRawIndex
(
idx
)];
};
/**
...
...
@@ -689,7 +691,7 @@ define(function (require) {
original
.
hostModel
);
// FIXME If needs stackedOn, value may already been stacked
transferImmuProperties
(
list
,
original
,
original
.
_wrappedMethods
);
transferImmuProperties
(
list
,
original
);
var
storage
=
list
.
_storage
=
{};
var
originalStorage
=
original
.
_storage
;
...
...
@@ -1006,7 +1008,7 @@ define(function (require) {
// FIXME
list
.
_storage
=
this
.
_storage
;
transferImmuProperties
(
list
,
this
,
this
.
_wrappedMethods
);
transferImmuProperties
(
list
,
this
);
list
.
indices
=
this
.
indices
.
slice
();
...
...
@@ -1023,8 +1025,8 @@ define(function (require) {
if
(
typeof
originalMethod
!==
'
function
'
)
{
return
;
}
this
.
_
wrappedMethods
=
this
.
_wrappedMethods
||
[];
this
.
_wrappedMethods
.
push
(
methodName
);
this
.
_
_wrappedMethods
=
this
.
_
_wrappedMethods
||
[];
this
.
_
_
wrappedMethods
.
push
(
methodName
);
this
[
methodName
]
=
function
()
{
var
res
=
originalMethod
.
apply
(
this
,
arguments
);
return
injectFunction
.
call
(
this
,
res
);
...
...
src/echarts.js
浏览文件 @
bc0cc601
...
...
@@ -367,6 +367,7 @@ define(function (require) {
return
;
}
// Fixme First time update ?
ecModel
.
restoreData
();
// TODO
...
...
src/model/Model.js
浏览文件 @
bc0cc601
...
...
@@ -78,6 +78,10 @@ define(function (require) {
var
obj
=
this
.
option
;
var
parentModel
=
this
.
parentModel
;
for
(
var
i
=
0
;
i
<
path
.
length
;
i
++
)
{
// Ignore empty
if
(
!
path
[
i
])
{
continue
;
}
// obj could be number/string/... (like 0)
obj
=
(
obj
&&
typeof
obj
===
'
object
'
)
?
obj
[
path
[
i
]]
:
null
;
if
(
obj
==
null
)
{
...
...
src/model/Series.js
浏览文件 @
bc0cc601
...
...
@@ -70,19 +70,16 @@ define(function(require) {
zrUtil
.
merge
(
option
,
this
.
getDefaultOption
());
// Default label emphasis `position` and `show`
// FIXME Set label in merge
// FIXME Set label in merge
Option
modelUtil
.
defaultEmphasis
(
option
.
label
,
modelUtil
.
LABEL_OPTIONS
);
if
(
option
.
data
)
{
this
.
_fillDataTextStyle
(
option
.
data
);
}
this
.
fillDataTextStyle
(
option
.
data
);
},
mergeOption
:
function
(
newSeriesOption
,
ecModel
)
{
newSeriesOption
=
zrUtil
.
merge
(
this
.
option
,
newSeriesOption
,
true
);
if
(
newSeriesOption
.
data
)
{
this
.
_fillDataTextStyle
(
newSeriesOption
.
data
);
}
this
.
fillDataTextStyle
(
newSeriesOption
.
data
);
var
data
=
this
.
getInitialData
(
newSeriesOption
,
ecModel
);
// TODO Merge data?
if
(
data
)
{
...
...
@@ -91,13 +88,15 @@ define(function(require) {
}
},
_
fillDataTextStyle
:
function
(
data
)
{
fillDataTextStyle
:
function
(
data
)
{
// Default data label emphasis `position` and `show`
// FIXME Tree structure data ?
// FIXME Performance ?
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
data
[
i
]
&&
data
[
i
].
label
)
{
modelUtil
.
defaultEmphasis
(
data
[
i
].
label
,
modelUtil
.
LABEL_OPTIONS
);
if
(
data
)
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
data
[
i
]
&&
data
[
i
].
label
)
{
modelUtil
.
defaultEmphasis
(
data
[
i
].
label
,
modelUtil
.
LABEL_OPTIONS
);
}
}
}
},
...
...
src/util/model.js
浏览文件 @
bc0cc601
...
...
@@ -180,14 +180,14 @@ define(function(require) {
/**
* Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data.
* @param {(Object|module:echarts/model/Series)} opt
* @param {module:echarts/data/List} data
* @param {Object} opt
* @param {string} [opt.seriesIndex]
* @param {Object} [opt.name]
* @param {Object} [opt.mainType]
* @param {Object} [opt.subType]
* @param {module:echarts/data/List} data
*/
modelUtil
.
createDataFormatModel
=
function
(
opt
,
data
)
{
modelUtil
.
createDataFormatModel
=
function
(
data
,
opt
)
{
var
model
=
new
Model
();
zrUtil
.
mixin
(
model
,
modelUtil
.
dataFormatMixin
);
model
.
seriesIndex
=
opt
.
seriesIndex
;
...
...
@@ -239,10 +239,11 @@ define(function(require) {
/**
* Get params for formatter
* @param {number} dataIndex
* @param {module:echarts/data/List} [otherData]
* @return {Object}
*/
getDataParams
:
function
(
dataIndex
)
{
var
data
=
this
.
getData
();
getDataParams
:
function
(
dataIndex
,
otherData
)
{
var
data
=
otherData
||
this
.
getData
();
var
seriesIndex
=
this
.
seriesIndex
;
var
seriesName
=
this
.
name
;
...
...
@@ -273,18 +274,16 @@ define(function(require) {
* Format label
* @param {number} dataIndex
* @param {string} [status='normal'] 'normal' or 'emphasis'
* @param {
Function|string} [formatter] Default use the `itemStyle[status].label.formatter`
* @param {
module:echarts/data/List} [otherData]
* @return {string}
*/
getFormattedLabel
:
function
(
dataIndex
,
status
,
formatter
)
{
getFormattedLabel
:
function
(
dataIndex
,
status
,
otherData
)
{
status
=
status
||
'
normal
'
;
var
data
=
this
.
getData
();
var
data
=
otherData
||
this
.
getData
();
var
itemModel
=
data
.
getItemModel
(
dataIndex
);
var
params
=
this
.
getDataParams
(
dataIndex
);
if
(
formatter
==
null
)
{
formatter
=
itemModel
.
get
([
'
label
'
,
status
,
'
formatter
'
]);
}
var
params
=
this
.
getDataParams
(
dataIndex
,
otherData
);
var
formatter
=
itemModel
.
get
([
'
label
'
,
status
,
'
formatter
'
]);
if
(
typeof
formatter
===
'
function
'
)
{
params
.
status
=
status
;
...
...
@@ -298,12 +297,13 @@ define(function(require) {
/**
* Get raw value in option
* @param {number} idx
* @param {module:echarts/data/List} [otherData]
* @return {Object}
*/
getRawValue
:
function
(
idx
)
{
var
itemModel
=
this
.
getData
().
getItemModel
(
idx
);
if
(
itemModel
&&
itemModel
.
option
!=
null
)
{
var
dataItem
=
itemModel
.
option
;
getRawValue
:
function
(
idx
,
otherData
)
{
var
data
=
otherData
||
this
.
getData
(
);
var
dataItem
=
data
.
getRawDataItem
(
idx
);
if
(
dataItem
!=
null
)
{
return
(
zrUtil
.
isObject
(
dataItem
)
&&
!
zrUtil
.
isArray
(
dataItem
))
?
dataItem
.
value
:
dataItem
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录