Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
8d6ab602
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,发现更多精彩内容 >>
提交
8d6ab602
编写于
11月 04, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Gauge title and detail
上级
2dfede63
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
86 addition
and
17 deletion
+86
-17
src/chart/gauge/GaugeView.js
src/chart/gauge/GaugeView.js
+86
-17
未找到文件。
src/chart/gauge/GaugeView.js
浏览文件 @
8d6ab602
...
...
@@ -5,7 +5,6 @@ define(function (require) {
var
graphic
=
require
(
'
../../util/graphic
'
);
var
numberUtil
=
require
(
'
../../util/number
'
);
var
parsePercent
=
numberUtil
.
parsePercent
;
// var zrUtil = require('zrender/core/util');
function
parsePosition
(
seriesModel
,
api
)
{
var
center
=
seriesModel
.
get
(
'
center
'
);
...
...
@@ -23,6 +22,19 @@ define(function (require) {
};
}
function
formatLabel
(
label
,
labelFormatter
)
{
if
(
labelFormatter
)
{
if
(
typeof
labelFormatter
===
'
string
'
)
{
label
=
labelFormatter
.
replace
(
'
{value}
'
,
label
);
}
else
if
(
typeof
labelFormatter
===
'
function
'
)
{
label
=
labelFormatter
(
label
);
}
}
return
label
;
}
var
PI2
=
Math
.
PI
*
2
;
var
GaugeView
=
require
(
'
../../view/Chart
'
).
extend
({
...
...
@@ -116,7 +128,14 @@ define(function (require) {
this
.
_renderPointer
(
seriesModel
,
ecModel
,
api
,
getColor
,
posInfo
,
startAngle
,
endAngle
,
clockwise
)
);
this
.
_renderTitle
(
seriesModel
,
ecModel
,
api
,
getColor
,
posInfo
);
this
.
_renderDetail
(
seriesModel
,
ecModel
,
api
,
getColor
,
posInfo
);
},
_renderTicks
:
function
(
...
...
@@ -135,8 +154,6 @@ define(function (require) {
var
tickModel
=
seriesModel
.
getModel
(
'
axisTick
'
);
var
labelModel
=
seriesModel
.
getModel
(
'
axisLabel
'
);
var
labelFormatter
=
labelModel
.
get
(
'
formatter
'
);
var
splitNumber
=
seriesModel
.
get
(
'
splitNumber
'
);
var
subSplitNumber
=
tickModel
.
get
(
'
splitNumber
'
);
...
...
@@ -177,15 +194,11 @@ define(function (require) {
// Label
if
(
labelModel
.
get
(
'
show
'
))
{
var
label
=
numberUtil
.
round
(
i
/
splitNumber
*
(
maxVal
-
minVal
)
+
minVal
);
if
(
labelFormatter
)
{
if
(
typeof
labelFormatter
===
'
string
'
)
{
label
=
labelFormatter
.
replace
(
'
{value}
'
,
label
);
}
else
if
(
typeof
labelFormatter
===
'
function
'
)
{
label
=
labelFormatter
(
label
);
}
}
var
label
=
formatLabel
(
numberUtil
.
round
(
i
/
splitNumber
*
(
maxVal
-
minVal
)
+
minVal
),
labelModel
.
get
(
'
formatter
'
)
);
var
text
=
new
graphic
.
Text
({
style
:
{
text
:
label
,
...
...
@@ -320,12 +333,68 @@ define(function (require) {
this
.
_data
=
data
;
},
_renderTitle
:
function
(
seriesModel
,
ecModel
,
api
)
{
_renderTitle
:
function
(
seriesModel
,
ecModel
,
api
,
getColor
,
posInfo
)
{
var
titleModel
=
seriesModel
.
getModel
(
'
title
'
);
if
(
titleModel
.
get
(
'
show
'
))
{
var
textStyleModel
=
titleModel
.
getModel
(
'
textStyle
'
);
var
offsetCenter
=
titleModel
.
get
(
'
offsetCenter
'
);
var
x
=
posInfo
.
cx
+
parsePercent
(
offsetCenter
[
0
],
posInfo
.
r
);
var
y
=
posInfo
.
cy
+
parsePercent
(
offsetCenter
[
1
],
posInfo
.
r
);
var
text
=
new
graphic
.
Text
({
style
:
{
x
:
x
,
y
:
y
,
// FIXME First data name ?
text
:
seriesModel
.
getData
().
getName
(
0
),
fill
:
textStyleModel
.
get
(
'
color
'
),
textFont
:
textStyleModel
.
getFont
(),
textAlign
:
'
center
'
,
textBaseline
:
'
middle
'
}
});
this
.
group
.
add
(
text
);
}
},
_renderDetail
:
function
(
seriesModel
,
ecModel
,
api
)
{
_renderDetail
:
function
(
seriesModel
,
ecModel
,
api
,
getColor
,
posInfo
)
{
var
detailModel
=
seriesModel
.
getModel
(
'
detail
'
);
var
minVal
=
seriesModel
.
get
(
'
min
'
);
var
maxVal
=
seriesModel
.
get
(
'
max
'
);
if
(
detailModel
.
get
(
'
show
'
))
{
var
textStyleModel
=
detailModel
.
getModel
(
'
textStyle
'
);
var
offsetCenter
=
detailModel
.
get
(
'
offsetCenter
'
);
var
x
=
posInfo
.
cx
+
parsePercent
(
offsetCenter
[
0
],
posInfo
.
r
);
var
y
=
posInfo
.
cy
+
parsePercent
(
offsetCenter
[
1
],
posInfo
.
r
);
var
width
=
parsePercent
(
detailModel
.
get
(
'
width
'
),
posInfo
.
r
);
var
height
=
parsePercent
(
detailModel
.
get
(
'
height
'
),
posInfo
.
r
);
var
value
=
seriesModel
.
getData
().
get
(
'
value
'
,
0
);
var
rect
=
new
graphic
.
Rect
({
shape
:
{
x
:
x
-
width
/
2
,
y
:
y
-
height
/
2
,
width
:
width
,
height
:
height
},
style
:
{
text
:
formatLabel
(
// FIXME First data name ?
value
,
detailModel
.
get
(
'
formatter
'
)
),
fill
:
detailModel
.
get
(
'
backgroundColor
'
),
textFill
:
textStyleModel
.
get
(
'
color
'
),
textFont
:
textStyleModel
.
getFont
()
}
});
if
(
rect
.
style
.
textFill
===
'
auto
'
)
{
rect
.
setStyle
(
'
textFill
'
,
getColor
((
value
-
minVal
)
/
(
maxVal
-
minVal
)));
}
rect
.
setStyle
(
detailModel
.
getItemStyle
([
'
color
'
]));
this
.
group
.
add
(
rect
);
}
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录