Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alon@wen
echarts
提交
2932c30a
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,发现更多精彩内容 >>
提交
2932c30a
编写于
8月 25, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Model.getModel, axisTick draw
上级
b26b022d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
113 addition
and
27 deletion
+113
-27
src/component/axis.js
src/component/axis.js
+98
-10
src/coord/cartesian/AxisModel.js
src/coord/cartesian/AxisModel.js
+2
-2
src/model/Model.js
src/model/Model.js
+11
-13
test/bar.html
test/bar.html
+2
-2
未找到文件。
src/component/axis.js
浏览文件 @
2932c30a
...
...
@@ -9,29 +9,38 @@ define(function(require) {
render
:
function
(
axisModel
,
ecModel
,
api
)
{
if
(
axisModel
.
get
(
'
axisLine.show
'
))
{
this
.
_renderAxisLine
(
axisModel
,
api
);
this
.
_renderAxisLine
(
axisModel
,
ecModel
,
api
);
}
if
(
axisModel
.
get
(
'
axisTick.show
'
))
{
this
.
_renderAxisTick
(
axisModel
,
ecModel
,
api
);
}
},
_renderAxisLine
:
function
(
axisModel
,
api
)
{
_renderAxisLine
:
function
(
axisModel
,
ecModel
,
api
)
{
var
axis
=
axisModel
.
axis
;
var
p1
=
[];
var
p2
=
[];
var
lineWidth
=
axisModel
.
get
(
'
axisLine.lineStyle.width
'
);
var
lineColor
=
axisModel
.
get
(
'
axisLine.lineStyle.color
'
);
var
lineStyleModel
=
axisModel
.
getModel
(
'
axisLine.lineStyle
'
);
var
lineWidth
=
lineStyleModel
.
get
(
'
width
'
);
var
lineColor
=
lineStyleModel
.
get
(
'
color
'
);
var
lineType
=
lineStyleModel
.
get
(
'
type
'
);
var
gridModel
=
ecModel
.
getComponent
(
'
grid
'
,
axisModel
.
get
(
'
gridIndex
'
)
);
var
rect
=
gridModel
.
coordinateSystem
.
getRect
();
var
otherCoord
=
axis
.
otherCoord
;
var
coordExtent
=
axis
.
getCoordExtent
();
if
(
axis
.
isHorizontal
())
{
p1
[
0
]
=
coordExtent
[
0
]
;
p2
[
0
]
=
coordExtent
[
1
]
;
p1
[
0
]
=
rect
.
x
;
p2
[
0
]
=
rect
.
x
+
rect
.
width
;
p1
[
1
]
=
p2
[
1
]
=
otherCoord
;
}
else
{
p1
[
1
]
=
coordExtent
[
0
]
;
p2
[
1
]
=
coordExtent
[
1
]
;
p1
[
1
]
=
rect
.
y
;
p2
[
1
]
=
rect
.
y
+
rect
.
height
;
p1
[
0
]
=
p2
[
0
]
=
otherCoord
;
}
...
...
@@ -46,10 +55,89 @@ define(function(require) {
},
style
:
{
stroke
:
lineColor
,
lineWidth
:
lineWidth
lineWidth
:
lineWidth
,
lineCap
:
'
round
'
,
lineType
:
lineType
},
z
:
axisModel
.
get
(
'
z
'
)
}));
},
_renderAxisTick
:
function
(
axisModel
,
ecModel
,
api
)
{
var
axis
=
axisModel
.
axis
;
var
tickModel
=
axisModel
.
getModel
(
'
axisTick
'
);
var
lineStyleModel
=
tickModel
.
getModel
(
'
lineStyle
'
);
var
tickLen
=
tickModel
.
get
(
'
length
'
);
var
tickColor
=
lineStyleModel
.
get
(
'
color
'
);
var
tickLineWidth
=
lineStyleModel
.
get
(
'
width
'
);
var
tickInterval
=
tickModel
.
get
(
'
interval
'
)
||
0
;
var
isTickIntervalFunction
=
typeof
tickInterval
===
'
function
'
;
// PENDING Axis tick don't have the situation that don't have enough space to place
if
(
tickInterval
===
'
auto
'
)
{
tickInterval
=
0
;
}
var
isOrdinalAxis
=
axis
.
scale
.
type
===
'
ordinal
'
;
var
axisPosition
=
axis
.
position
;
var
ticksCoords
=
isOrdinalAxis
&&
axis
.
boundaryGap
?
axis
.
getBandsCoords
(
true
)
:
axis
.
getTicksCoords
();
for
(
var
i
=
0
;
i
<
ticksCoords
.
length
;
i
++
)
{
// Only ordinal scale support tick interval
if
(
isOrdinalAxis
)
{
if
(
isTickIntervalFunction
)
{
if
(
!
tickInterval
(
i
,
axis
.
scale
.
getItem
(
i
)))
{
continue
;
}
}
else
{
if
(
i
%
(
tickInterval
+
1
))
{
continue
;
}
}
}
var
tickCoord
=
ticksCoords
[
i
];
var
x
;
var
y
;
var
offX
=
0
;
var
offY
=
0
;
if
(
axis
.
isHorizontal
())
{
x
=
tickCoord
;
y
=
axis
.
otherCoord
;
offY
=
axisPosition
===
'
top
'
?
-
tickLen
:
tickLen
;
}
else
{
x
=
axis
.
otherCoord
;
y
=
tickCoord
;
offX
=
axisPosition
===
'
left
'
?
-
tickLen
:
tickLen
;
}
if
(
tickModel
.
get
(
'
inside
'
))
{
offX
=
-
offX
;
offY
=
-
offY
;
}
var
p1
=
[
x
,
y
];
var
p2
=
[
x
+
offX
,
y
+
offY
];
api
.
subPixelOptimizeLine
(
p1
,
p2
,
tickLineWidth
);
// Tick line
var
tickLine
=
new
api
.
Line
({
shape
:
{
x1
:
p1
[
0
],
y1
:
p1
[
1
],
x2
:
p2
[
0
],
y2
:
p2
[
1
]
},
style
:
{
stroke
:
tickColor
,
lineWidth
:
tickLineWidth
}
});
this
.
group
.
add
(
tickLine
);
}
}
});
...
...
src/coord/cartesian/AxisModel.js
浏览文件 @
2932c30a
...
...
@@ -7,7 +7,7 @@ define(function(require) {
valueAxis
:
{
show
:
true
,
zlevel
:
0
,
// 一级层叠
z
:
0
,
// 二级层叠
z
:
1
0
,
// 二级层叠
gridIndex
:
0
,
position
:
'
left
'
,
// 位置
name
:
''
,
// 坐标轴名字,默认为空
...
...
@@ -65,7 +65,7 @@ define(function(require) {
categoryAxis
:
{
show
:
true
,
zlevel
:
0
,
// 一级层叠
z
:
0
,
// 二级层叠
z
:
1
0
,
// 二级层叠
gridIndex
:
0
,
position
:
'
bottom
'
,
// 位置
name
:
''
,
// 坐标轴名字,默认为空
...
...
src/model/Model.js
浏览文件 @
2932c30a
...
...
@@ -30,8 +30,6 @@ define(function (require) {
constructor
:
Model
,
_prefix
:
''
,
/**
* visual properties after visual coding
* @type {Object}
...
...
@@ -52,24 +50,19 @@ define(function (require) {
zrUtil
.
merge
(
this
.
option
,
option
);
},
/**
* Set getter path prefix
* @param {string} prefix
*/
withPrefix
:
function
(
prefix
)
{
this
.
_prefix
=
prefix
||
''
;
return
this
;
},
/**
* @param {string} path
* @return {*}
*/
get
:
function
(
path
)
{
get
:
function
(
path
,
parentModel
)
{
if
(
typeof
path
==
'
string
'
)
{
path
=
this
.
_prefix
+
path
;
//
path = this._prefix + path;
path
=
path
.
split
(
'
.
'
);
}
if
(
this
.
option
==
null
)
{
return
;
}
var
obj
=
this
.
option
;
for
(
var
i
=
0
;
i
<
path
.
length
;
i
++
)
{
obj
=
obj
[
path
[
i
]];
...
...
@@ -83,6 +76,11 @@ define(function (require) {
return
obj
;
},
getModel
:
function
(
path
,
parentModel
)
{
var
obj
=
this
.
get
(
path
);
return
new
Model
(
obj
,
parentModel
);
},
/**
* Get visual property.
*/
...
...
test/bar.html
浏览文件 @
2932c30a
...
...
@@ -38,7 +38,7 @@
data3
.
push
(
Math
.
random
());
}
console
.
profil
e
(
'
setOption
'
);
console
.
tim
e
(
'
setOption
'
);
chart
.
setOption
({
legend
:
{
// TODO First bar unclickable
...
...
@@ -77,7 +77,7 @@
data
:
data3
}]
});
console
.
profil
eEnd
(
'
setOption
'
);
console
.
tim
eEnd
(
'
setOption
'
);
})
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录