Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
d2c4c9ab
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,体验更适合开发者的 AI 搜索 >>
提交
d2c4c9ab
编写于
5月 22, 2015
作者:
L
loutongbing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tree图
上级
332f6764
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
909 addition
and
57 deletion
+909
-57
build/dist/echarts.js
build/dist/echarts.js
+0
-15
build/source/echarts-all.js
build/source/echarts-all.js
+2
-0
doc/asset/js/echartsExample.js
doc/asset/js/echartsExample.js
+1
-0
doc/example/tree.html
doc/example/tree.html
+199
-0
doc/example/tree1.html
doc/example/tree1.html
+228
-0
doc/example/treemap2.html
doc/example/treemap2.html
+6
-2
src/chart/base.js
src/chart/base.js
+1
-0
src/chart/tree.js
src/chart/tree.js
+467
-0
src/chart/treemap.js
src/chart/treemap.js
+1
-1
src/component/legend.js
src/component/legend.js
+1
-0
src/component/tooltip.js
src/component/tooltip.js
+0
-39
src/config.js
src/config.js
+1
-0
test/allchart/all.js
test/allchart/all.js
+1
-0
test/performance/p.js
test/performance/p.js
+1
-0
未找到文件。
build/dist/echarts.js
浏览文件 @
d2c4c9ab
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
build/source/echarts-all.js
浏览文件 @
d2c4c9ab
...
...
@@ -47827,6 +47827,8 @@ require("echarts/chart/venn");
require("echarts/chart/treemap");
require("echarts/chart/tree");
_global['echarts'] = echarts;
_global['zrender'] = zrender;
doc/asset/js/echartsExample.js
浏览文件 @
d2c4c9ab
...
...
@@ -212,6 +212,7 @@ function launchExample() {
'
echarts/chart/eventRiver
'
,
'
echarts/chart/venn
'
,
'
echarts/chart/treemap
'
,
'
echarts/chart/tree
'
,
needMap
()
?
'
echarts/chart/map
'
:
'
echarts
'
],
requireCallback
...
...
doc/example/tree.html
0 → 100644
浏览文件 @
d2c4c9ab
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"description"
content=
"ECharts"
>
<meta
name=
"author"
content=
"kener.linfeng@gmail.com"
>
<title>
ECharts · Example
</title>
<link
rel=
"shortcut icon"
href=
"../asset/ico/favicon.png"
>
<link
href=
"../asset/css/font-awesome.min.css"
rel=
"stylesheet"
>
<link
href=
"../asset/css/bootstrap.css"
rel=
"stylesheet"
>
<link
href=
"../asset/css/carousel.css"
rel=
"stylesheet"
>
<link
href=
"../asset/css/echartsHome.css"
rel=
"stylesheet"
>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script
src=
"./www/js/echarts.js"
></script>
<script
src=
"../asset/js/codemirror.js"
></script>
<script
src=
"../asset/js/javascript.js"
></script>
<link
href=
"../asset/css/codemirror.css"
rel=
"stylesheet"
>
<link
href=
"../asset/css/monokai.css"
rel=
"stylesheet"
>
</head>
<body>
<!-- Fixed navbar -->
<div
class=
"navbar navbar-default navbar-fixed-top"
role=
"navigation"
id=
"head"
></div>
<div
class=
"container-fluid"
>
<div
class=
"row-fluid example"
>
<div
id=
"sidebar-code"
class=
"col-md-4"
>
<div
class=
"well sidebar-nav"
>
<div
class=
"nav-header"
><a
href=
"#"
onclick=
"autoResize()"
class=
"glyphicon glyphicon-resize-full"
id =
"icon-resize"
></a>
option
</div>
<textarea
id=
"code"
name=
"code"
>
option = {
title : {
text: '手机占有率',
subtext: '虚构数据'
},
tooltip : {
trigger: 'item',
formatter: "{b}: {c}"
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
restore : {show: true},
saveAsImage : {show: true}
}
},
calculable : false,
series : [
{
name:'树图',
type:'tree',
orient: 'vertical', // vertical horizontal
rootLocation: {x: 'center',y: 10}, // 根节点位置 {x: 100, y: 'center'}
nodePadding: 1,
itemStyle: {
normal: {
label: {
show: false,
formatter: "{b}"
},
lineStyle: {
color: '#48b',
//shadowColor: '#000',
//shadowBlur: 3,
//shadowOffsetX: 3,
//shadowOffsetY: 5,
type: 'curve' // 'curve'|'broken'|'solid'|'dotted'|'dashed'
}
},
emphasis: {
label: {
show: true
}
}
},
data: [
{
name: '手机',
value: 6,
children: [
{
name: '小米',
value: 4,
symbolSize: 40,
children: [
{
name: '小米1',
value: 4
},
{
name: '小米2',
value: 4
},
{
name: '小米3',
value: 2
},
{
name: '小米4',
value: 2
},
{
name: '小米5',
value: 4
},
{
name: '小米6',
value: 4
},
{
name: '小米7',
value: 2
},
{
name: '小米8',
value: 2
},
{
name: '小米9',
value: 4
},
{
name: '小米10',
value: 4
},
{
name: '小米11',
value: 2
},
{
name: '小米12',
value: 2
}
]
},
{
name: '苹果',
value: 4
},
{
name: '华为',
value: 2
},
{
name: '联想',
value: 2
},
{
name: '魅族',
value: 1
}
]
}
]
}
]
};
</textarea>
</div>
<!--/.well -->
</div>
<!--/span-->
<div
id=
"graphic"
class=
"col-md-8"
>
<div
id=
"main"
class=
"main"
></div>
<div>
<button
type=
"button"
class=
"btn btn-sm btn-success"
onclick=
"refresh(true)"
>
刷 新
</button>
<span
class=
"text-primary"
>
切换主题
</span>
<select
id=
"theme-select"
></select>
<span
id=
'wrong-message'
style=
"color:red"
></span>
</div>
</div>
<!--/span-->
</div>
<!--/row-->
</div>
<!--/.fluid-container-->
<footer
id=
"footer"
></footer>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script
src=
"../asset/js/jquery.min.js"
></script>
<script
type=
"text/javascript"
src=
"../asset/js/echartsHome.js"
></script>
<script
src=
"../asset/js/bootstrap.min.js"
></script>
<script
src=
"../asset/js/echartsExample.js"
></script>
</body>
</html>
doc/example/tree1.html
0 → 100644
浏览文件 @
d2c4c9ab
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"description"
content=
"ECharts"
>
<meta
name=
"author"
content=
"kener.linfeng@gmail.com"
>
<title>
ECharts · Example
</title>
<link
rel=
"shortcut icon"
href=
"../asset/ico/favicon.png"
>
<link
href=
"../asset/css/font-awesome.min.css"
rel=
"stylesheet"
>
<link
href=
"../asset/css/bootstrap.css"
rel=
"stylesheet"
>
<link
href=
"../asset/css/carousel.css"
rel=
"stylesheet"
>
<link
href=
"../asset/css/echartsHome.css"
rel=
"stylesheet"
>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script
src=
"./www/js/echarts.js"
></script>
<script
src=
"../asset/js/codemirror.js"
></script>
<script
src=
"../asset/js/javascript.js"
></script>
<link
href=
"../asset/css/codemirror.css"
rel=
"stylesheet"
>
<link
href=
"../asset/css/monokai.css"
rel=
"stylesheet"
>
</head>
<body>
<!-- Fixed navbar -->
<div
class=
"navbar navbar-default navbar-fixed-top"
role=
"navigation"
id=
"head"
></div>
<div
class=
"container-fluid"
>
<div
class=
"row-fluid example"
>
<div
id=
"sidebar-code"
class=
"col-md-4"
>
<div
class=
"well sidebar-nav"
>
<div
class=
"nav-header"
><a
href=
"#"
onclick=
"autoResize()"
class=
"glyphicon glyphicon-resize-full"
id =
"icon-resize"
></a>
option
</div>
<textarea
id=
"code"
name=
"code"
>
option = {
title : {
text: '手机占有率',
subtext: '虚构数据'
},
tooltip : {
trigger: 'item',
formatter: "{b}: {c}"
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
restore : {show: true},
saveAsImage : {show: true}
}
},
calculable : false,
series : [
{
name:'树图',
type:'tree',
orient: 'horizontal', // vertical horizontal
rootLocation: {x: 100, y: '60%'}, // 根节点位置 {x: 'center',y: 10}
nodePadding: 20,
symbol: 'circle',
symbolSize: 40,
itemStyle: {
normal: {
label: {
show: true,
position: 'inside',
textStyle: {
color: '#3d9ce5',
fontSize: 15,
fontWeight: 'bolder'
}
},
lineStyle: {
color: '#48b',
width: 2,
//shadowColor: '#000',
//shadowBlur: 3,
//shadowOffsetX: 3,
//shadowOffsetY: 5,
type: 'curve' // 'curve'|'broken'|'solid'|'dotted'|'dashed'
}
},
emphasis: {
label: {
show: true
}
}
},
data: [
{
name: '手机',
value: 6,
symbol: 'image://http://www.damndigital.com/wp-content/uploads/2010/12/steve-jobs.jpg',
children: [
{
name: '小米',
value: 4,
symbol: 'rectangle',
symbolSize: [40, 30],
children: [
{
name: '小米1',
symbol: 'rectangle',
symbolSize: [20, 20],
value: 4,
itemStyle: {
normal: {
label: {
show: true,
position: 'right',
textStyle: {
color: '#50ac0d',
fontSize: 20,
fontStyle: 'italic',
fontWeight: 'bolder'
}
},
},
emphasis: {
label: {
show: true
},
color: '#fa6900',
borderWidth: 0
}
}
},
{
name: '小米2',
value: 4,
symbol: 'triangle',
symbolSize: 20,
itemStyle: {
normal: {
label: {
show: true,
formatter: "{b}"
},
color: '#99dd99',
borderWidth: 2,
borderColor: '#cc66ff'
},
emphasis: {
label: {
show: false
},
color: '#ff66cc',
borderWidth: 0
}
}
},
{
name: '小米3',
value: 2,
itemStyle: {
normal: {
brushType: 'stroke',
borderWidth: 1,
borderColor: '#ff66cc',
}
}
},
{
name: '小米4',
value: 2
}
]
},
{
name: '苹果',
value: 4
},
{
name: '华为',
value: 2
},
{
name: '联想',
value: 2
},
{
name: '魅族',
value: 1
}
]
}
]
}
]
};
</textarea>
</div>
<!--/.well -->
</div>
<!--/span-->
<div
id=
"graphic"
class=
"col-md-8"
>
<div
id=
"main"
class=
"main"
></div>
<div>
<button
type=
"button"
class=
"btn btn-sm btn-success"
onclick=
"refresh(true)"
>
刷 新
</button>
<span
class=
"text-primary"
>
切换主题
</span>
<select
id=
"theme-select"
></select>
<span
id=
'wrong-message'
style=
"color:red"
></span>
</div>
</div>
<!--/span-->
</div>
<!--/row-->
</div>
<!--/.fluid-container-->
<footer
id=
"footer"
></footer>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script
src=
"../asset/js/jquery.min.js"
></script>
<script
type=
"text/javascript"
src=
"../asset/js/echartsHome.js"
></script>
<script
src=
"../asset/js/bootstrap.min.js"
></script>
<script
src=
"../asset/js/echartsExample.js"
></script>
</body>
</html>
doc/example/treemap2.html
浏览文件 @
d2c4c9ab
...
...
@@ -104,7 +104,9 @@ option = {
formatter : "{b}最多",
textStyle: {
color: '#ccc',
fontSize: 16
fontSize: 16,
x: 30,
y: 35
}
},
color: '#ccff99',
...
...
@@ -116,7 +118,9 @@ option = {
formatter : "{b}-{c}",
textStyle: {
color: 'red',
fontSize: 18
fontSize: 18,
x: 60,
y: 65
}
},
color: '#cc9999',
...
...
src/chart/base.js
浏览文件 @
d2c4c9ab
...
...
@@ -1480,6 +1480,7 @@ define(function (require) {
if
(
this
.
type
!=
ecConfig
.
CHART_TYPE_MAP
&&
this
.
type
!=
ecConfig
.
CHART_TYPE_TREEMAP
&&
this
.
type
!=
ecConfig
.
CHART_TYPE_VENN
&&
this
.
type
!=
ecConfig
.
CHART_TYPE_TREE
)
{
return
ecData
.
get
(
shape
,
'
seriesIndex
'
)
+
'
_
'
+
ecData
.
get
(
shape
,
'
dataIndex
'
)
...
...
src/chart/tree.js
0 → 100644
浏览文件 @
d2c4c9ab
/**
* echarts图表类:树图
*
* @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
* @author Loutongbing (娄同兵, loutongbing@126.com)
*/
define
(
function
(
require
)
{
var
ChartBase
=
require
(
'
./base
'
);
var
GOLDEN_SECTION
=
0.618
;
// 图形依赖
var
toolArea
=
require
(
'
zrender/tool/area
'
);
// 图形依赖
var
IconShape
=
require
(
'
../util/shape/Icon
'
);
var
ImageShape
=
require
(
'
zrender/shape/Image
'
);
var
LineShape
=
require
(
'
zrender/shape/Line
'
);
var
BezierCurveShape
=
require
(
'
zrender/shape/BezierCurve
'
);
// 布局依赖
var
TreeMapLayout
=
require
(
'
../layout/TreeMap
'
);
// 布局依赖
var
TreeLayout
=
require
(
'
../layout/Tree
'
);
// 数据依赖
var
TreeData
=
require
(
'
../data/Tree
'
);
var
ecConfig
=
require
(
'
../config
'
);
// 维恩图默认参数
ecConfig
.
tree
=
{
zlevel
:
0
,
// 一级层叠
z
:
1
,
// 二级层叠
calculable
:
false
,
clickable
:
true
,
rootLocation
:
{},
symbol
:
'
circle
'
,
symbolSize
:
20
,
nodePadding
:
30
,
layerPadding
:
100
,
/*rootLocation: {
x: 'center' | 'left' | 'right' | 'x%' | {number},
y: 'center' | 'top' | 'bottom' | 'x%' | {number}
},*/
itemStyle
:
{
normal
:
{
// color: 各异,
label
:
{
show
:
true
},
lineStyle
:
{
width
:
1
,
color
:
'
#777
'
,
type
:
'
curve
'
// curve
}
},
emphasis
:
{
}
}
};
var
ecData
=
require
(
'
../util/ecData
'
);
var
zrConfig
=
require
(
'
zrender/config
'
);
var
zrEvent
=
require
(
'
zrender/tool/event
'
);
var
zrUtil
=
require
(
'
zrender/tool/util
'
);
/**
* 构造函数
* @param {Object} messageCenter echart消息中心
* @param {ZRender} zr zrender实例
* @param {Object} series 数据
* @param {Object} component 组件
* @constructor
* @exports Tree
*/
function
Tree
(
ecTheme
,
messageCenter
,
zr
,
option
,
myChart
)
{
// 图表基类
ChartBase
.
call
(
this
,
ecTheme
,
messageCenter
,
zr
,
option
,
myChart
);
this
.
refresh
(
option
);
}
Tree
.
prototype
=
{
type
:
ecConfig
.
CHART_TYPE_TREEMAP
,
/**
* 构建单个
*
* @param {Object} data 数据
*/
_buildShape
:
function
()
{
var
queryTarget
=
[
this
.
series
[
0
],
ecConfig
.
tree
];
this
.
serie
=
this
.
deepMerge
(
queryTarget
);
var
serie
=
this
.
serie
;
var
data
=
serie
.
data
[
0
];
this
.
tree
=
TreeData
.
fromOptionData
(
data
.
name
,
data
.
children
);
// 添加root的data
this
.
tree
.
root
.
data
=
data
;
// 根据root坐标 方向 对每个节点的坐标进行映射
this
.
_setTreeShape
();
// 递归画出树节点与连接线
this
.
tree
.
traverse
(
function
(
treeNode
)
{
this
.
_buildItem
(
treeNode
,
serie
.
itemStyle
);
// 画连接线
if
(
treeNode
.
children
.
length
>
0
)
{
this
.
_buildLink
(
treeNode
);
}
},
this
);
this
.
addShapeList
();
},
/**
* 构建单个item
*/
_buildItem
:
function
(
treeNode
,
itemStyle
)
{
var
serie
=
this
.
serie
;
var
queryTarget
=
[
treeNode
.
data
,
serie
];
var
symbol
=
this
.
deepQuery
(
queryTarget
,
'
symbol
'
);
// 多级控制
var
normal
=
this
.
deepMerge
(
queryTarget
,
'
itemStyle.normal
'
)
||
{};
var
emphasis
=
this
.
deepMerge
(
queryTarget
,
'
itemStyle.emphasis
'
)
||
{};
var
normalColor
=
normal
.
color
||
this
.
zr
.
getColor
();
var
emphasisColor
=
emphasis
.
color
||
this
.
zr
.
getColor
();
var
shape
=
new
IconShape
({
zlevel
:
this
.
getZlevelBase
(),
z
:
this
.
getZBase
()
+
1
,
style
:
{
x
:
treeNode
.
layout
.
position
[
0
]
-
treeNode
.
layout
.
width
*
0.5
,
y
:
treeNode
.
layout
.
position
[
1
]
-
treeNode
.
layout
.
height
*
0.5
,
width
:
treeNode
.
layout
.
width
,
height
:
treeNode
.
layout
.
height
,
iconType
:
symbol
,
color
:
normalColor
,
brushType
:
'
both
'
,
lineWidth
:
normal
.
borderWidth
,
strokeColor
:
normal
.
borderColor
},
highlightStyle
:
{
color
:
emphasisColor
,
lineWidth
:
emphasis
.
borderWidth
,
strokeColor
:
emphasis
.
borderColor
}
});
if
(
shape
.
style
.
iconType
.
match
(
'
image
'
))
{
shape
.
style
.
image
=
shape
.
style
.
iconType
.
replace
(
new
RegExp
(
'
^image:
\\
/
\\
/
'
),
''
);
shape
=
new
ImageShape
({
style
:
shape
.
style
,
highlightStyle
:
shape
.
highlightStyle
,
clickable
:
shape
.
clickable
,
zlevel
:
this
.
getZlevelBase
(),
z
:
this
.
getZBase
()
});
}
// 节点标签样式
if
(
this
.
deepQuery
(
queryTarget
,
'
itemStyle.normal.label.show
'
))
{
shape
.
style
.
text
=
treeNode
.
data
.
label
==
null
?
treeNode
.
id
:
treeNode
.
data
.
label
;
shape
.
style
.
textPosition
=
this
.
deepQuery
(
queryTarget
,
'
itemStyle.normal.label.position
'
);
shape
.
style
.
textColor
=
this
.
deepQuery
(
queryTarget
,
'
itemStyle.normal.label.textStyle.color
'
);
shape
.
style
.
textFont
=
this
.
getFont
(
this
.
deepQuery
(
queryTarget
,
'
itemStyle.normal.label.textStyle
'
)
||
{});
}
if
(
this
.
deepQuery
(
queryTarget
,
'
itemStyle.emphasis.label.show
'
))
{
shape
.
highlightStyle
.
textPosition
=
this
.
deepQuery
(
queryTarget
,
'
itemStyle.emphasis.label.position
'
);
shape
.
highlightStyle
.
textColor
=
this
.
deepQuery
(
queryTarget
,
'
itemStyle.emphasis.label.textStyle.color
'
);
shape
.
highlightStyle
.
textFont
=
this
.
getFont
(
this
.
deepQuery
(
queryTarget
,
'
itemStyle.emphasis.label.textStyle
'
)
||
{});
}
// todo
ecData
.
pack
(
shape
,
serie
,
0
,
treeNode
.
data
,
0
,
treeNode
.
id
);
this
.
shapeList
.
push
(
shape
);
},
_buildLink
:
function
(
parentNode
)
{
var
lineStyle
=
this
.
serie
.
itemStyle
.
normal
.
lineStyle
;
// 折线另外计算
if
(
lineStyle
.
type
===
'
broken
'
)
{
this
.
_buildBrokenLine
(
parentNode
,
lineStyle
);
return
;
}
for
(
var
i
=
0
;
i
<
parentNode
.
children
.
length
;
i
++
)
{
var
xStart
=
parentNode
.
layout
.
position
[
0
];
var
yStart
=
parentNode
.
layout
.
position
[
1
];
var
xEnd
=
parentNode
.
children
[
i
].
layout
.
position
[
0
];
var
yEnd
=
parentNode
.
children
[
i
].
layout
.
position
[
1
];
switch
(
lineStyle
.
type
)
{
case
'
curve
'
:
this
.
_buildBezierCurve
(
xStart
,
yStart
,
xEnd
,
yEnd
,
lineStyle
);
break
;
// 折线
case
'
broken
'
:
break
;
// default画直线
default
:
var
shape
=
this
.
_getLine
(
xStart
,
yStart
,
xEnd
,
yEnd
,
lineStyle
);
this
.
shapeList
.
push
(
shape
);
}
}
},
_buildBrokenLine
:
function
(
parentNode
,
lineStyle
)
{
// 引用_getLine需要把type改为solid
var
solidLineStyle
=
zrUtil
.
clone
(
lineStyle
);
solidLineStyle
.
type
=
'
solid
'
;
var
shapes
=
[];
var
xStart
=
parentNode
.
layout
.
position
[
0
];
var
yStart
=
parentNode
.
layout
.
position
[
1
];
var
orient
=
this
.
serie
.
orient
;
// 子节点的y
var
yEnd
=
parentNode
.
children
[
0
].
layout
.
position
[
1
];
// 中点x y
var
xMiddle
=
xStart
;
var
yMiddle
=
yStart
+
(
yEnd
-
yStart
)
*
(
1
-
GOLDEN_SECTION
);
// 中线的起始
var
xMiddleStart
=
parentNode
.
children
[
0
].
layout
.
position
[
0
];
var
yMiddleStart
=
yMiddle
;
var
xMiddleEnd
=
parentNode
.
children
[
parentNode
.
children
.
length
-
1
].
layout
.
position
[
0
];
var
yMiddleEnd
=
yMiddle
;
// 水平状态
if
(
orient
===
'
horizontal
'
)
{
var
xEnd
=
parentNode
.
children
[
0
].
layout
.
position
[
0
];
xMiddle
=
xStart
+
(
xEnd
-
xStart
)
*
(
1
-
GOLDEN_SECTION
);
yMiddle
=
yStart
;
xMiddleStart
=
xMiddle
;
yMiddleStart
=
parentNode
.
children
[
0
].
layout
.
position
[
1
];
xMiddleEnd
=
xMiddle
;
yMiddleEnd
=
parentNode
.
children
[
parentNode
.
children
.
length
-
1
].
layout
.
position
[
1
];
}
// 第一条 从根节点垂直向下
shapes
.
push
(
this
.
_getLine
(
xStart
,
yStart
,
xMiddle
,
yMiddle
,
solidLineStyle
)
);
// 第二条 横向
shapes
.
push
(
this
.
_getLine
(
xMiddleStart
,
yMiddleStart
,
xMiddleEnd
,
yMiddleEnd
,
solidLineStyle
)
);
// 第三条 垂直向下到子节点
for
(
var
i
=
0
;
i
<
parentNode
.
children
.
length
;
i
++
)
{
xEnd
=
parentNode
.
children
[
i
].
layout
.
position
[
0
];
yEnd
=
parentNode
.
children
[
i
].
layout
.
position
[
1
];
// 水平状态
if
(
orient
===
'
horizontal
'
)
{
yMiddleStart
=
yEnd
;
}
else
{
xMiddleStart
=
xEnd
;
}
shapes
.
push
(
this
.
_getLine
(
xMiddleStart
,
yMiddleStart
,
xEnd
,
yEnd
,
solidLineStyle
)
);
}
this
.
shapeList
=
this
.
shapeList
.
concat
(
shapes
);
},
_getLine
:
function
(
xStart
,
yStart
,
xEnd
,
yEnd
,
lineStyle
)
{
return
new
LineShape
({
zlevel
:
this
.
getZlevelBase
()
-
1
,
hoverable
:
false
,
style
:
zrUtil
.
merge
(
{
xStart
:
xStart
,
yStart
:
yStart
,
xEnd
:
xEnd
,
yEnd
:
yEnd
,
lineType
:
lineStyle
.
type
,
strokeColor
:
lineStyle
.
color
,
lineWidth
:
lineStyle
.
width
},
lineStyle
,
true
)
});
},
_buildBezierCurve
:
function
(
xStart
,
yStart
,
xEnd
,
yEnd
,
lineStyle
)
{
var
offsetRatio
=
GOLDEN_SECTION
;
var
orient
=
this
.
serie
.
orient
;
var
cpX1
=
xStart
;
var
cpY1
=
(
yEnd
-
yStart
)
*
offsetRatio
+
yStart
;
var
cpX2
=
xEnd
;
var
cpY2
=
(
yEnd
-
yStart
)
*
(
1
-
offsetRatio
)
+
yStart
;
if
(
orient
===
'
horizontal
'
)
{
cpX1
=
(
xEnd
-
xStart
)
*
offsetRatio
+
xStart
;
cpY1
=
yStart
;
cpX2
=
(
xEnd
-
xStart
)
*
(
1
-
offsetRatio
)
+
xStart
;
cpY2
=
yEnd
;
}
var
shape
=
new
BezierCurveShape
({
zlevel
:
this
.
getZlevelBase
()
-
1
,
hoverable
:
false
,
style
:
zrUtil
.
merge
(
{
xStart
:
xStart
,
yStart
:
yStart
,
cpX1
:
cpX1
,
cpY1
:
cpY1
,
cpX2
:
cpX2
,
cpY2
:
cpY2
,
xEnd
:
xEnd
,
yEnd
:
yEnd
,
strokeColor
:
lineStyle
.
color
,
lineWidth
:
lineStyle
.
width
},
lineStyle
,
true
)
});
this
.
shapeList
.
push
(
shape
);
},
_setTreeShape
:
function
()
{
// 跑出来树的layout
var
treeLayout
=
new
TreeLayout
(
{
nodePadding
:
this
.
serie
.
nodePadding
,
layerPadding
:
this
.
serie
.
layerPadding
}
);
this
.
tree
.
traverse
(
function
(
treeNode
)
{
var
queryTarget
=
[
treeNode
.
data
,
this
.
serie
];
var
symbolSize
=
this
.
deepQuery
(
queryTarget
,
'
symbolSize
'
);
if
(
typeof
symbolSize
===
'
number
'
)
{
symbolSize
=
[
symbolSize
,
symbolSize
];
}
treeNode
.
layout
=
{
width
:
symbolSize
[
0
],
// 节点大小
height
:
symbolSize
[
1
]
};
},
this
);
treeLayout
.
run
(
this
.
tree
);
var
serie
=
this
.
serie
;
// 树的方向
var
orient
=
serie
.
orient
;
var
rootX
=
serie
.
rootLocation
.
x
;
var
rootY
=
serie
.
rootLocation
.
y
;
var
zrWidth
=
this
.
zr
.
getWidth
();
var
zrHeight
=
this
.
zr
.
getHeight
();
rootX
=
this
.
parsePercent
(
rootX
,
zrWidth
);
rootY
=
this
.
parsePercent
(
rootY
,
zrHeight
);
// 水平树
if
(
orient
===
'
horizontal
'
)
{
rootX
=
isNaN
(
rootX
)
?
10
:
rootX
;
rootY
=
isNaN
(
rootY
)
?
zrHeight
*
0.5
:
rootY
;
}
// 纵向树
else
{
rootX
=
isNaN
(
rootX
)
?
zrWidth
*
0.5
:
rootX
;
rootY
=
isNaN
(
rootY
)
?
10
:
rootY
;
}
// tree layout自动算出来的root的坐标
var
originRootX
=
this
.
tree
.
root
.
layout
.
position
[
0
];
var
originRootY
=
this
.
tree
.
root
.
layout
.
position
[
1
];
this
.
tree
.
traverse
(
function
(
treeNode
)
{
var
x
=
treeNode
.
layout
.
position
[
0
]
-
originRootX
+
rootX
;
var
y
=
treeNode
.
layout
.
position
[
1
]
-
originRootY
+
rootY
;
if
(
orient
===
'
horizontal
'
)
{
y
=
treeNode
.
layout
.
position
[
0
]
-
originRootX
+
rootY
;
x
=
treeNode
.
layout
.
position
[
1
]
-
originRootY
+
rootX
;
}
treeNode
.
layout
.
position
[
0
]
=
x
;
treeNode
.
layout
.
position
[
1
]
=
y
;
},
this
.
tree
);
},
/*
* 刷新
*/
refresh
:
function
(
newOption
)
{
this
.
clear
();
if
(
newOption
)
{
this
.
option
=
newOption
;
this
.
series
=
newOption
.
series
;
}
this
.
_buildShape
();
}
};
zrUtil
.
inherits
(
Tree
,
ChartBase
);
// 图表注册
require
(
'
../chart
'
).
define
(
'
tree
'
,
Tree
);
return
Tree
;
});
src/chart/treemap.js
浏览文件 @
d2c4c9ab
/**
* echarts图表类:
维恩
图
* echarts图表类:
矩形树
图
*
* @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
* @author Loutongbing (娄同兵, loutongbing@126.com)
...
...
src/component/legend.js
浏览文件 @
d2c4c9ab
...
...
@@ -577,6 +577,7 @@ define(function (require) {
break
;
case
'
radar
'
:
case
'
venn
'
:
case
'
tree
'
:
case
'
treemap
'
:
case
'
scatter
'
:
itemShape
.
highlightStyle
.
lineWidth
=
3
;
...
...
src/component/tooltip.js
浏览文件 @
d2c4c9ab
...
...
@@ -1483,45 +1483,6 @@ define(function (require) {
case
ecConfig
.
CHART_TYPE_LINE
:
case
ecConfig
.
CHART_TYPE_BAR
:
case
ecConfig
.
CHART_TYPE_K
:
case
ecConfig
.
CHART_TYPE_TREEMAP
:
if
(
this
.
component
.
xAxis
==
null
||
this
.
component
.
yAxis
==
null
||
serie
.
data
.
length
<=
dataIndex
)
{
return
;
}
var
xAxisIndex
=
serie
.
xAxisIndex
||
0
;
var
yAxisIndex
=
serie
.
yAxisIndex
||
0
;
if
(
this
.
component
.
xAxis
.
getAxis
(
xAxisIndex
).
type
===
ecConfig
.
COMPONENT_TYPE_AXIS_CATEGORY
)
{
// 横轴是类目
this
.
_event
=
{
zrenderX
:
this
.
component
.
xAxis
.
getAxis
(
xAxisIndex
)
.
getCoordByIndex
(
dataIndex
),
zrenderY
:
this
.
component
.
grid
.
getY
()
+
(
this
.
component
.
grid
.
getYend
()
-
this
.
component
.
grid
.
getY
()
)
/
4
};
}
else
{
// 纵轴是类目
this
.
_event
=
{
zrenderX
:
this
.
component
.
grid
.
getX
()
+
(
this
.
component
.
grid
.
getXend
()
-
this
.
component
.
grid
.
getX
()
)
/
4
,
zrenderY
:
this
.
component
.
yAxis
.
getAxis
(
yAxisIndex
)
.
getCoordByIndex
(
dataIndex
)
};
}
this
.
_showAxisTrigger
(
xAxisIndex
,
yAxisIndex
,
dataIndex
);
break
;
case
ecConfig
.
CHART_TYPE_RADAR
:
if
(
this
.
component
.
polar
==
null
||
serie
.
data
[
0
].
value
.
length
<=
dataIndex
...
...
src/config.js
浏览文件 @
d2c4c9ab
...
...
@@ -16,6 +16,7 @@ define(function() {
CHART_TYPE_RADAR
:
'
radar
'
,
CHART_TYPE_VENN
:
'
venn
'
,
CHART_TYPE_TREEMAP
:
'
treemap
'
,
CHART_TYPE_TREE
:
'
tree
'
,
CHART_TYPE_MAP
:
'
map
'
,
CHART_TYPE_K
:
'
k
'
,
CHART_TYPE_ISLAND
:
'
island
'
,
...
...
test/allchart/all.js
浏览文件 @
d2c4c9ab
...
...
@@ -161,6 +161,7 @@ function launchExample() {
'
echarts/chart/funnel
'
,
'
echarts/chart/venn
'
,
'
echarts/chart/treemap
'
,
'
echarts/chart/tree
'
,
'
echarts/chart/eventRiver
'
],
requireCallback
...
...
test/performance/p.js
浏览文件 @
d2c4c9ab
...
...
@@ -75,6 +75,7 @@ function launchExample() {
'
echarts/chart/funnel
'
,
'
echarts/chart/venn
'
,
'
echarts/chart/treemap
'
,
'
echarts/chart/tree
'
,
'
echarts/chart/eventRiver
'
],
requireCallback
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录