Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
9dad7828
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 搜索 >>
提交
9dad7828
编写于
4月 09, 2015
作者:
L
loutongbing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cr提到的问题
包括rect边框的配置
上级
badd38bc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
58 addition
and
51 deletion
+58
-51
doc/example/treemap.html
doc/example/treemap.html
+10
-1
src/chart/treemap.js
src/chart/treemap.js
+38
-40
src/layout/TreeMap.js
src/layout/TreeMap.js
+10
-10
未找到文件。
doc/example/treemap.html
浏览文件 @
9dad7828
...
...
@@ -65,7 +65,9 @@ option = {
normal: {
label: {
show: true
}
},
borderWidth: 1,
borderColor: '#ccc'
},
emphasis: {
color: '#cc99cc',
...
...
@@ -76,30 +78,37 @@ option = {
data:[
{
name: '魅族',
color: '#ccff99',
value: 6
},
{
name: '小米',
color: '#99ccff',
value: 6
},
{
name: '苹果',
color: '#9999cc',
value: 4
},
{
name: '三星',
color: '#99cccc',
value: 3
},
{
name: '华为',
color: '#ccffcc',
value: 2
},
{
name: '联想',
color: '#ccccff',
value: 2
},
{
name: '中兴',
color: '#ffffcc',
value: 1
}
]
...
...
src/chart/treemap.js
浏览文件 @
9dad7828
...
...
@@ -79,23 +79,23 @@ define(function (require) {
}
var
treeMapLayout
=
new
TreeMapLayout
(
{
area
Arr
:
areaArr
,
area
s
:
areaArr
,
x0
:
this
.
x0
,
y0
:
this
.
y0
,
width0
:
this
.
width0
,
height0
:
this
.
height0
height0
:
this
.
height0
}
);
var
locationArr
=
treeMapLayout
.
rectangleList
var
locationArr
=
treeMapLayout
.
rectangleList
;
for
(
var
k
=
0
;
k
<
locationArr
.
length
;
k
++
)
{
var
item
=
locationArr
[
k
];
var
color
=
this
.
data
[
k
].
color
||
this
.
zr
.
getColor
(
k
);
this
.
_buildItem
(
item
.
x
,
item
.
y
,
item
.
width
,
item
.
height
,
this
.
zr
.
getColor
(
k
)
,
color
,
k
)
};
...
...
@@ -118,7 +118,8 @@ define(function (require) {
y
,
width
,
height
,
color
color
,
this
.
data
[
index
].
name
);
// todo
ecData
.
pack
(
...
...
@@ -128,16 +129,6 @@ define(function (require) {
series
[
0
].
data
[
index
].
name
);
this
.
shapeList
.
push
(
rectangle
);
var
label
=
this
.
getLabel
(
rectangle
.
style
.
height
,
rectangle
.
style
.
width
,
rectangle
.
style
.
x
,
rectangle
.
style
.
y
,
this
.
data
[
index
].
name
);
if
(
label
)
{
this
.
shapeList
.
push
(
label
);
}
},
/**
...
...
@@ -154,7 +145,8 @@ define(function (require) {
y
,
width
,
height
,
color
color
,
text
)
{
var
serie
=
this
.
series
[
0
];
var
data
=
this
.
data
;
...
...
@@ -167,22 +159,32 @@ define(function (require) {
queryTarget
,
'
itemStyle.emphasis
'
)
||
{};
var
textStyle
=
this
.
getLabel
(
x
,
y
,
width
,
height
,
text
);
var
emphasisColor
=
this
.
getItemStyleColor
(
emphasis
.
color
,
0
,
0
,
data
)
||
color
;
var
borderWidth
=
normal
.
borderWidth
||
0
;
var
borderColor
=
normal
.
borderColor
||
color
;
var
rectangleShape
=
{
zlevel
:
1
,
zlevel
:
this
.
getZlevelBase
()
,
z
:
1
,
hoverable
:
true
,
style
:
{
style
:
$
.
extend
(
{
x
:
x
,
y
:
y
,
width
:
width
,
height
:
height
,
brushType
:
'
both
'
,
color
:
color
},
color
:
color
,
lineWidth
:
borderWidth
,
strokeColor
:
borderColor
},
textStyle
),
highlightStyle
:
{
color
:
emphasisColor
,
lineWidth
:
emphasis
.
borderWidth
,
...
...
@@ -194,39 +196,35 @@ define(function (require) {
},
getLabel
:
function
(
rectangleHeight
,
rectangleWidth
,
rectangleX
,
rectangleY
,
rectangleWidth
,
rectangleHeight
,
text
)
{
if
(
!
this
.
series
[
0
].
itemStyle
.
normal
.
label
.
show
)
{
return
false
;
return
{}
;
}
var
marginY
=
12
;
var
marginX
=
5
;
var
fontSize
=
13
;
var
lineWidth
=
text
.
length
*
13
;
var
lineHeight
=
text
.
length
*
13
;
var
lineHeight
=
13
;
if
(
marginX
+
lineWidth
>
rectangleWidth
||
marginY
+
lineHeight
>
rectangleHeight
)
{
return
false
;
return
{}
;
}
var
textShape
=
{
zlevel
:
2
,
hoverable
:
false
,
style
:
{
x
:
rectangleX
+
marginX
,
y
:
rectangleY
+
marginY
,
text
:
text
,
textAlign
:
'
left
'
,
color
:
'
#777
'
,
textFont
:
fontSize
+
'
px Arial
'
}
var
style
=
{
textX
:
rectangleX
+
marginX
,
textY
:
rectangleY
+
marginY
,
text
:
text
,
textPosition
:
'
specific
'
,
textColor
:
'
#777
'
,
textFont
:
fontSize
+
'
px Arial
'
};
return
new
TextShape
(
textShape
)
;
return
style
;
},
/**
* 刷新
*/
...
...
src/layout/TreeMap.js
浏览文件 @
9dad7828
...
...
@@ -9,7 +9,7 @@ define(function (require) {
// 包含子矩形坐标与宽高的数组
this
.
rectangleList
=
[];
/**
* area
Arr
每个子矩形面积
* area
s
每个子矩形面积
* x0 父矩形横坐标
* y0 父矩形横坐标
* width0 父矩形宽
...
...
@@ -22,11 +22,11 @@ define(function (require) {
height
:
opts
.
height0
};
this
.
squarify
(
opts
.
area
Arr
,
opts
.
area
s
,
row
);
}
TreeMapLayout
.
prototype
.
squarify
=
function
(
area
Arr
,
row
)
{
TreeMapLayout
.
prototype
.
squarify
=
function
(
area
s
,
row
)
{
var
layoutDirection
=
'
VERTICAL
'
;
var
width
=
row
.
width
;
var
height
=
row
.
height
;
...
...
@@ -37,7 +37,7 @@ define(function (require) {
}
// 把考虑方向与位置的因素剥离出来,只考虑怎么排列,运行完毕之后再修正
var
shapeArr
=
this
.
getShapeListInAbstractRow
(
area
Arr
,
width
,
height
area
s
,
width
,
height
);
// 首先换算出虚拟的x、y坐标
for
(
var
i
=
0
;
i
<
shapeArr
.
length
;
i
++
)
{
...
...
@@ -86,7 +86,7 @@ define(function (require) {
};
}
// 下一步的矩形数组要剔除已经填充过的矩形
var
nextAreaArr
=
area
Arr
.
slice
(
shapeArr
.
length
);
var
nextAreaArr
=
area
s
.
slice
(
shapeArr
.
length
);
if
(
nextAreaArr
.
length
===
0
)
{
return
;
}
...
...
@@ -98,12 +98,12 @@ define(function (require) {
}
};
TreeMapLayout
.
prototype
.
getShapeListInAbstractRow
=
function
(
area
Arr
,
area
s
,
width
,
height
)
{
// 如果只剩下一个了,直接返回
if
(
area
Arr
.
length
===
1
)
{
if
(
area
s
.
length
===
1
)
{
return
[
{
width
:
width
,
...
...
@@ -113,15 +113,15 @@ define(function (require) {
}
// 填充进入的个数,从填充一个开始到填充所有小矩形,
// 纵横比最优时break并保留结果
for
(
var
count
=
1
;
count
<
area
Arr
.
length
;
count
++
)
{
for
(
var
count
=
1
;
count
<
area
s
.
length
;
count
++
)
{
var
shapeArr0
=
this
.
placeFixedNumberRectangles
(
area
Arr
.
slice
(
0
,
count
),
area
s
.
slice
(
0
,
count
),
width
,
height
);
var
shapeArr1
=
this
.
placeFixedNumberRectangles
(
area
Arr
.
slice
(
0
,
count
+
1
),
area
s
.
slice
(
0
,
count
+
1
),
width
,
height
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录