Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alon@wen
echarts
提交
a4718851
E
echarts
项目概览
alon@wen
/
echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a4718851
编写于
11月 02, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Graph category filtering
上级
1882405b
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
129 addition
and
88 deletion
+129
-88
src/chart/graph/GraphSeries.js
src/chart/graph/GraphSeries.js
+53
-36
src/chart/graph/GraphView.js
src/chart/graph/GraphView.js
+2
-4
src/chart/graph/categoryFilter.js
src/chart/graph/categoryFilter.js
+2
-2
src/chart/graph/createView.js
src/chart/graph/createView.js
+5
-0
src/chart/graph/simpleLayout.js
src/chart/graph/simpleLayout.js
+1
-1
src/chart/helper/LineDraw.js
src/chart/helper/LineDraw.js
+17
-28
src/chart/helper/SymbolDraw.js
src/chart/helper/SymbolDraw.js
+7
-5
src/chart/helper/createGraphFromNodeEdge.js
src/chart/helper/createGraphFromNodeEdge.js
+1
-1
src/component/legend/LegendModel.js
src/component/legend/LegendModel.js
+6
-5
src/component/legend/LegendView.js
src/component/legend/LegendView.js
+1
-1
src/data/DataDiffer.js
src/data/DataDiffer.js
+2
-2
src/data/Graph.js
src/data/Graph.js
+32
-3
未找到文件。
src/chart/graph/GraphSeries.js
浏览文件 @
a4718851
...
...
@@ -17,21 +17,56 @@ define(function (require) {
init
:
function
(
option
)
{
seriesModelProto
.
init
.
apply
(
this
,
arguments
);
this
.
_udpateCategoriesData
();
// Provide data for legend select
this
.
legendDataProvider
=
function
()
{
return
this
.
_categoriesData
;
};
this
.
_updateCategoriesData
();
},
mergeOption
:
function
(
option
)
{
seriesModelProto
.
mergeOption
.
apply
(
this
,
arguments
);
this
.
_udpateCategoriesData
();
this
.
_updateCategoriesData
();
},
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
);
return
graph
.
data
;
}
},
restoreData
:
function
()
{
seriesModelProto
.
restoreData
.
apply
(
this
,
arguments
);
this
.
getGraph
().
restoreData
();
},
_udpateCategoriesData
:
function
()
{
/**
* @return {module:echarts/data/Graph}
*/
getGraph
:
function
()
{
return
this
.
getData
().
graph
;
},
/**
* @return {module:echarts/data/List}
*/
getEdgeData
:
function
()
{
return
this
.
getGraph
().
edgeData
;
},
/**
* @return {module:echarts/data/List}
*/
getCategoriesData
:
function
()
{
return
this
.
_categoriesData
;
},
_updateCategoriesData
:
function
()
{
var
categories
=
zrUtil
.
map
(
this
.
option
.
categories
||
[],
function
(
category
)
{
// Data must has value
return
category
.
value
!=
null
?
category
:
zrUtil
.
extend
({
value
:
0
},
category
);
...
...
@@ -42,22 +77,24 @@ define(function (require) {
this
.
_categoriesData
=
categoriesData
;
},
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
);
return
graph
.
data
;
}
/**
* @param {number} zoom
*/
setRoamZoom
:
function
(
zoom
)
{
var
roamDetail
=
this
.
option
.
roamDetail
;
roamDetail
&&
(
roamDetail
.
zoom
=
zoom
);
},
/**
* Get category model by index
* @param {number} id Category index
* @return {module:echarts/model/Model}
* @param {number} x
* @param {number} y
*/
getCategoriesData
:
function
()
{
return
this
.
_categoriesData
;
setRoamPan
:
function
(
x
,
y
)
{
var
roamDetail
=
this
.
option
.
roamDetail
;
if
(
roamDetail
)
{
roamDetail
.
x
=
x
;
roamDetail
.
y
=
y
;
}
},
defaultOption
:
{
...
...
@@ -125,26 +162,6 @@ define(function (require) {
},
emphasis
:
{}
}
},
/**
* @param {number} zoom
*/
setRoamZoom
:
function
(
zoom
)
{
var
roamDetail
=
this
.
option
.
roamDetail
;
roamDetail
&&
(
roamDetail
.
zoom
=
zoom
);
},
/**
* @param {number} x
* @param {number} y
*/
setRoamPan
:
function
(
x
,
y
)
{
var
roamDetail
=
this
.
option
.
roamDetail
;
if
(
roamDetail
)
{
roamDetail
.
x
=
x
;
roamDetail
.
y
=
y
;
}
}
});
...
...
src/chart/graph/GraphView.js
浏览文件 @
a4718851
define
(
function
(
require
)
{
var
SymbolDraw
=
require
(
'
../helper/SymbolDraw
'
);
...
...
@@ -42,10 +43,7 @@ define(function (require) {
lineDraw
.
updateData
(
data
.
graph
.
edgeData
,
seriesModel
,
api
,
false
,
function
(
idx
)
{
return
data
.
graph
.
edges
[
idx
].
dataIndex
>=
0
;
}
seriesModel
,
api
,
false
);
// Save the original lineWidth
...
...
src/chart/graph/categoryFilter.js
浏览文件 @
a4718851
...
...
@@ -7,7 +7,8 @@ define(function (require) {
}
ecModel
.
eachSeriesByType
(
'
graph
'
,
function
(
graphSeries
)
{
var
categoriesData
=
graphSeries
.
getCategoriesData
();
var
data
=
graphSeries
.
getData
();
var
graph
=
graphSeries
.
getGraph
();
var
data
=
graph
.
data
;
var
categoryNames
=
categoriesData
.
mapArray
(
categoriesData
.
getName
);
...
...
@@ -22,7 +23,6 @@ define(function (require) {
}
return
true
;
});
},
this
);
};
});
\ No newline at end of file
src/chart/graph/createView.js
浏览文件 @
a4718851
...
...
@@ -35,6 +35,11 @@ define(function (require) {
var
max
=
[];
bbox
.
fromPoints
(
positions
,
min
,
max
);
// Position may be NaN, use view rect instead
if
(
isNaN
(
min
[
0
])
||
isNaN
(
min
[
1
]))
{
min
=
[
viewRect
.
x
,
viewRect
.
y
];
max
=
[
viewRect
.
x
+
viewRect
.
width
,
viewRect
.
y
+
viewRect
.
height
];
}
var
bbWidth
=
max
[
0
]
-
min
[
0
];
var
bbHeight
=
max
[
1
]
-
min
[
1
];
...
...
src/chart/graph/simpleLayout.js
浏览文件 @
a4718851
...
...
@@ -9,7 +9,7 @@ define(function (require) {
if
(
coordSys
&&
coordSys
.
type
!==
'
view
'
)
{
return
;
}
var
graph
=
seriesModel
.
get
Data
().
graph
;
var
graph
=
seriesModel
.
get
Graph
()
;
graph
.
eachNode
(
function
(
node
)
{
var
model
=
node
.
getModel
();
...
...
src/chart/helper/LineDraw.js
浏览文件 @
a4718851
...
...
@@ -24,42 +24,29 @@ define(function (require) {
data
.
diff
(
oldData
)
.
add
(
function
(
idx
)
{
var
shape
=
data
.
getItemLayout
(
idx
);
if
(
!
(
isIgnore
&&
isIgnore
[
idx
]))
{
var
line
=
new
graphic
[
shape
.
cpx1
!=
null
?
'
BezierCurve
'
:
'
Line
'
]({
shape
:
shape
});
var
line
=
new
graphic
[
shape
.
cpx1
!=
null
?
'
BezierCurve
'
:
'
Line
'
]({
shape
:
shape
});
data
.
setItemGraphicEl
(
idx
,
line
);
group
.
add
(
line
);
}
data
.
setItemGraphicEl
(
idx
,
line
);
group
.
add
(
line
);
})
.
update
(
function
(
newIdx
,
oldIdx
)
{
var
line
=
oldData
.
getItemGraphicEl
(
oldIdx
);
var
shape
=
data
.
getItemLayout
(
newIdx
);
if
(
!
(
isIgnore
&&
isIgnore
(
newIdx
)))
{
group
.
remove
(
line
);
return
;
}
if
(
!
line
)
{
line
=
new
graphic
[
shape
.
cpx1
!=
null
?
'
BezierCurve
'
:
'
Line
'
]({
shape
:
shape
if
(
shape
.
cpx1
!=
null
&&
line
.
type
===
'
line
'
)
{
var
oldShape
=
line
.
shape
;
line
=
new
graphic
.
BezierCurve
({
shape
:
oldShape
});
}
else
{
if
(
shape
.
cpx1
!=
null
&&
line
.
type
===
'
line
'
)
{
var
oldShape
=
line
.
shape
;
line
=
new
graphic
.
BezierCurve
({
shape
:
oldShape
});
line
.
setShape
({
cpx1
:
(
oldShape
.
x1
+
oldShape
.
x2
)
/
2
,
cpy1
:
(
oldShape
.
y1
+
oldShape
.
y2
)
/
2
});
}
api
.
updateGraphicEl
(
line
,
{
shape
:
shape
line
.
setShape
({
cpx1
:
(
oldShape
.
x1
+
oldShape
.
x2
)
/
2
,
cpy1
:
(
oldShape
.
y1
+
oldShape
.
y2
)
/
2
});
}
api
.
updateGraphicEl
(
line
,
{
shape
:
shape
});
data
.
setItemGraphicEl
(
newIdx
,
line
);
group
.
add
(
line
);
...
...
@@ -95,7 +82,9 @@ define(function (require) {
});
};
lineDrawProto
.
remove
=
function
()
{
};
return
LineDraw
;
});
\ No newline at end of file
src/chart/helper/SymbolDraw.js
浏览文件 @
a4718851
...
...
@@ -42,14 +42,16 @@ define(function (require) {
});
if
(
enableAnimation
)
{
symbolEl
.
scale
=
[
0
,
0
];
// FIXME Use scale to improve performance
var
zeroShape
=
symbolUtil
.
getSymbolShape
(
symbolType
,
0
,
0
,
0
,
0
).
shape
;
var
normalShape
=
symbolEl
.
shape
;
symbolEl
.
shape
=
zeroShape
;
symbolEl
.
animateTo
({
s
cale
:
[
1
,
1
]
s
hape
:
normalShape
},
500
);
}
else
{
symbolEl
.
scale
=
[
1
,
1
];
}
return
symbolEl
;
}
...
...
src/chart/helper/createGraphFromNodeEdge.js
浏览文件 @
a4718851
...
...
@@ -28,7 +28,7 @@ define(function (require) {
nodeData
.
initData
(
nodes
);
edgeData
.
initData
(
edges
,
linkNameList
,
'
weight
'
);
graph
.
edgeData
=
edgeData
;
graph
.
setEdgeData
(
edgeData
)
;
linkList
.
linkToGraph
(
nodeData
,
graph
);
...
...
src/component/legend/LegendModel.js
浏览文件 @
a4718851
...
...
@@ -16,7 +16,7 @@ define(function(require) {
option
.
selected
=
option
.
selected
||
{};
this
.
_d
ata
=
zrUtil
.
map
(
option
.
data
,
function
(
dataItem
)
{
var
legendD
ata
=
zrUtil
.
map
(
option
.
data
,
function
(
dataItem
)
{
if
(
typeof
dataItem
===
'
string
'
)
{
dataItem
=
{
name
:
dataItem
...
...
@@ -24,6 +24,7 @@ define(function(require) {
}
return
new
Model
(
dataItem
,
this
);
},
this
);
this
.
_data
=
legendData
;
var
availableNames
=
zrUtil
.
map
(
ecModel
.
getSeries
(),
function
(
series
)
{
return
series
.
name
;
...
...
@@ -41,7 +42,7 @@ define(function(require) {
this
.
_availableNames
=
availableNames
;
// Try select the first if selectedMode is single
this
.
select
(
availableNames
[
0
]
);
legendData
[
0
]
&&
this
.
select
(
legendData
[
0
].
get
(
'
name
'
)
);
},
/**
...
...
@@ -58,9 +59,9 @@ define(function(require) {
var
selected
=
this
.
option
.
selected
;
var
selectedMode
=
this
.
get
(
'
selectedMode
'
);
if
(
selectedMode
===
'
single
'
)
{
var
availableNames
=
this
.
_availableNames
;
zrUtil
.
each
(
availableNames
,
function
(
name
)
{
selected
[
name
]
=
false
;
var
data
=
this
.
_data
;
zrUtil
.
each
(
data
,
function
(
dataItem
)
{
selected
[
dataItem
.
get
(
'
name
'
)
]
=
false
;
});
}
selected
[
name
]
=
true
;
...
...
src/component/legend/LegendView.js
浏览文件 @
a4718851
...
...
@@ -96,7 +96,7 @@ define(function (require) {
);
},
this
);
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
ecModel
.
eachSeries
All
(
function
(
seriesModel
)
{
if
(
seriesModel
.
legendDataProvider
)
{
var
data
=
seriesModel
.
legendDataProvider
();
data
.
each
(
function
(
idx
)
{
...
...
src/data/DataDiffer.js
浏览文件 @
a4718851
...
...
@@ -55,7 +55,7 @@ define(function(require) {
// Travel by inverted order to make sure order consistency
// when duplicate keys exists (consider newDataIndex.pop() below).
// For performance consideration, these code below do not look neat.
for
(
i
=
oldArr
.
length
-
1
;
i
>=
0
;
i
--
)
{
for
(
i
=
0
;
i
<
oldArr
.
length
;
i
++
)
{
var
key
=
keyGetter
(
oldArr
[
i
]);
var
idx
=
newDataIndexMap
[
key
];
...
...
@@ -66,7 +66,7 @@ define(function(require) {
var
len
=
idx
.
length
;
if
(
len
)
{
len
===
1
&&
(
newDataIndexMap
[
key
]
=
null
);
idx
=
idx
.
pop
();
idx
=
idx
.
unshift
();
}
else
{
newDataIndexMap
[
key
]
=
null
;
...
...
src/data/Graph.js
浏览文件 @
a4718851
...
...
@@ -46,6 +46,18 @@ define(function(require) {
* @private
*/
this
.
_edgesMap
=
{};
/**
* @type {module:echarts/data/List}
* @readOnly
*/
this
.
data
;
/**
* @type {module:echarts/data/List}
* @readOnly
*/
this
.
edgeData
;
};
var
graphProto
=
Graph
.
prototype
;
...
...
@@ -249,6 +261,7 @@ define(function(require) {
};
// Filter update
graphProto
.
update
=
function
()
{
var
data
=
this
.
data
;
var
edgeData
=
this
.
edgeData
;
...
...
@@ -262,17 +275,33 @@ define(function(require) {
nodes
[
data
.
getRawIndex
(
i
)].
dataIndex
=
i
;
}
edgeData
.
filterSelf
(
function
(
idx
)
{
var
edge
=
edges
[
edgeData
.
getRawIndex
(
idx
)];
return
edge
.
node1
.
dataIndex
>=
0
&&
edge
.
node2
.
dataIndex
>=
0
;
});
// Update edge
for
(
var
i
=
0
,
len
=
edges
.
length
;
i
<
len
;
i
++
)
{
edges
[
i
].
dataIndex
=
-
1
;
}
for
(
var
i
=
0
,
len
=
edgeData
.
count
();
i
<
len
;
i
++
)
{
if
(
edges
[
i
].
node1
.
dataIndex
>=
0
&&
edges
[
i
].
node2
.
dataIndex
>=
0
)
{
edges
[
edgeData
.
getRawIndex
(
i
)].
dataIndex
=
i
;
}
edges
[
edgeData
.
getRawIndex
(
i
)].
dataIndex
=
i
;
}
};
/**
* Set edge data
* @param {module:echarts/data/List} edgeData
*/
graphProto
.
setEdgeData
=
function
(
edgeData
)
{
this
.
edgeData
=
edgeData
;
this
.
_edgeDataSaved
=
edgeData
.
cloneShallow
();
};
graphProto
.
restoreData
=
function
()
{
this
.
edgeData
=
this
.
_edgeDataSaved
.
cloneShallow
();
};
/**
* @return {module:echarts/data/Graph}
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录