Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
missman
incubator-echarts
提交
83224531
I
incubator-echarts
项目概览
missman
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
83224531
编写于
8月 14, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
重写 Model
上级
a08e744d
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
167 addition
and
108 deletion
+167
-108
src/CoordinateSystem.js
src/CoordinateSystem.js
+1
-3
src/component/dataZoom/DataZoomModel.js
src/component/dataZoom/DataZoomModel.js
+22
-0
src/component/dataZoom/LegendModel.js
src/component/dataZoom/LegendModel.js
+26
-0
src/component/legend/LegendModel.js
src/component/legend/LegendModel.js
+6
-21
src/component/legend/LegendView.js
src/component/legend/LegendView.js
+1
-15
src/coord/cartesian/AxisModel.js
src/coord/cartesian/AxisModel.js
+12
-11
src/coord/cartesian/Grid.js
src/coord/cartesian/Grid.js
+37
-32
src/coord/polar/Polar.js
src/coord/polar/Polar.js
+0
-0
src/coord/polar/polarCreator.js
src/coord/polar/polarCreator.js
+0
-0
src/model/Component.js
src/model/Component.js
+9
-1
src/model/Global.js
src/model/Global.js
+46
-20
src/model/Model.js
src/model/Model.js
+7
-5
未找到文件。
src/CoordinateSystem.js
浏览文件 @
83224531
...
...
@@ -28,9 +28,7 @@ define(function(require) {
}
},
resize
:
function
()
{
}
resize
:
function
()
{}
}
CoordinateSystemManager
.
register
=
function
(
type
,
coordinateSystemCreator
)
{
...
...
src/component/dataZoom/DataZoomModel.js
0 → 100644
浏览文件 @
83224531
define
(
function
(
require
)
{
'
use strict
'
;
return
require
(
'
../../model/Model
'
).
extend
({
type
:
'
dataZoom
'
,
setStart
:
function
(
start
)
{
this
.
$option
.
start
=
start
;
},
setEnd
:
function
(
end
)
{
this
.
$option
.
end
=
end
;
},
setRange
:
function
(
start
,
end
)
{
this
.
setStart
(
start
);
this
.
setEnd
(
end
);
}
});
});
\ No newline at end of file
src/component/dataZoom/LegendModel.js
0 → 100644
浏览文件 @
83224531
define
(
function
(
require
)
{
'
use strict
'
;
return
require
(
'
../model/Model
'
).
extend
({
type
:
'
legend
'
,
init
:
function
(
option
)
{
option
.
selected
=
option
.
selected
||
{};
},
select
:
function
(
name
)
{
this
.
$option
.
selected
[
name
]
=
true
;
},
unSelect
:
function
(
name
)
{
this
.
$option
.
selected
[
name
]
=
false
;
},
isSelected
:
function
(
name
)
{
var
selected
=
this
.
$option
.
selected
;
return
!
((
name
in
selected
)
&&
selected
[
name
]);
}
});
});
\ No newline at end of file
src/component/legend/LegendModel.js
浏览文件 @
83224531
...
...
@@ -2,40 +2,25 @@ define(function(require) {
'
use strict
'
;
var
zrUtil
=
require
(
'
zrender/core/util
'
);
return
require
(
'
../model/Model
'
).
extend
({
return
require
(
'
../../model/Model
'
).
extend
({
type
:
'
legend
'
,
init
:
function
(
option
)
{
this
.
_selected
=
{};
this
.
_extendSelected
(
option
.
selected
);
},
mergeOption
:
function
(
option
)
{
zrUtil
.
merge
(
this
.
_option
,
option
);
this
.
_extendSelected
(
option
.
selected
);
},
_extendSelected
:
function
(
newSelected
)
{
if
(
newSelected
)
{
for
(
var
name
in
newSelected
)
{
this
.
_selected
[
name
]
=
!!
newSelected
[
name
];
}
}
option
.
selected
=
option
.
selected
||
{};
},
select
:
function
(
name
)
{
this
.
_
selected
[
name
]
=
true
;
this
.
$option
.
selected
[
name
]
=
true
;
},
unSelect
:
function
(
name
)
{
this
.
_
selected
[
name
]
=
false
;
this
.
$option
.
selected
[
name
]
=
false
;
},
isSelected
:
function
(
name
)
{
return
this
.
_selected
[
name
]
===
true
;
var
selected
=
this
.
$option
.
selected
;
return
!
((
name
in
selected
)
&&
selected
[
name
]);
}
});
});
\ No newline at end of file
src/component/legend/LegendView.js
浏览文件 @
83224531
...
...
@@ -6,21 +6,7 @@ define(function (require) {
type
:
'
legend
'
,
render
:
function
(
option
,
state
,
api
)
{
var
selectedStateGroup
=
state
.
get
(
'
legend.selected
'
);
if
(
selectedStateGroup
)
{
zrUtil
.
each
(
selectedStateGroup
,
function
(
selectedState
)
{
var
selectedMap
=
{};
zrUtil
.
each
(
selectedState
.
selected
,
function
(
name
)
{
selectedMap
[
name
]
=
true
;
});
zrUtil
.
each
(
selectedState
.
all
,
function
(
name
)
{
});
});
}
render
:
function
(
ecModel
,
api
)
{
}
});
});
\ No newline at end of file
src/coord/cartesian/AxisModel.js
浏览文件 @
83224531
...
...
@@ -3,24 +3,25 @@ define(function(require) {
'
use strict
'
;
var
AxisModel
=
require
(
'
../model/Component
'
).
extend
({
type
:
'
axis
'
});
type
:
'
axis
'
,
AxisModel
.
AxisX
=
AxisModel
.
extend
({
mergeOption
:
function
(
option
)
{
},
type
:
'
axisX
'
,
setRange
:
function
(
start
,
end
)
{
this
.
_range
[
0
]
=
start
;
this
.
_range
[
1
]
=
end
;
init
:
function
(
option
)
{
option
.
type
=
option
.
type
||
'
category
'
;
}
});
AxisModel
.
AxisX
=
AxisModel
.
extend
({
type
:
'
axisX
'
});
AxisModel
.
AxisY
=
AxisModel
.
extend
({
type
:
'
axisY
'
type
:
'
axisY
'
,
init
:
function
(
option
)
{
option
.
type
=
option
.
type
||
'
value
'
;
}
});
return
AxisModel
;
...
...
src/coord/cartesian/Grid.js
浏览文件 @
83224531
...
...
@@ -50,11 +50,11 @@ define(function(require, factory) {
/**
* Resize the grid
*/
resize
:
function
(
option
Model
,
api
)
{
resize
:
function
(
ec
Model
,
api
)
{
var
viewportWidth
=
api
.
getWidth
();
var
viewportHeight
=
api
.
getHeight
();
var
grid
=
option
Model
.
get
(
'
grid
'
);
var
grid
=
ec
Model
.
get
(
'
grid
'
);
var
parsePercent
=
numberUtil
.
parsePercent
;
var
gridX
=
parsePercent
(
grid
.
x
,
viewportWidth
);
...
...
@@ -162,10 +162,7 @@ define(function(require, factory) {
* Initialize cartesian coordinate systems
* @private
*/
_initCartesian
:
function
(
option
)
{
var
xAxesList
=
option
.
xAxis
;
var
yAxesList
=
option
.
yAxis
;
_initCartesian
:
function
(
ecModel
)
{
/**
* @inner
*/
...
...
@@ -182,35 +179,43 @@ define(function(require, factory) {
}
};
for
(
var
i
=
0
;
i
<
xAxesList
.
length
;
i
++
)
{
var
xAxisOpt
=
xAxesList
[
i
];
for
(
var
j
=
0
;
j
<
yAxesList
.
length
;
j
++
)
{
var
yAxisOpt
=
yAxesList
[
j
];
var
leftUsed
=
false
;
var
bottomUsed
=
false
;
var
axesList
=
this
.
_axesList
;
ecModel
.
eachComponent
(
'
xAxis
'
,
function
(
xAxisModel
,
i
)
{
ecModel
.
eachComponent
(
'
yAxis
'
,
function
(
yAxisModel
,
j
)
{
var
key
=
'
x
'
+
i
+
'
y
'
+
j
;
var
cartesian
=
new
Cartesian
(
key
);
this
.
_coordsMap
[
key
]
=
cartesian
;
this
.
_coordsList
.
push
(
cartesian
);
var
xAxisType
=
xAxisOpt
.
type
;
// Create x axis
var
xAxisType
=
xAxisModel
.
get
(
'
type
'
);
var
xAxisPosition
=
xAxisModel
.
get
(
'
position
'
)
||
(
bottomUsed
?
'
top
'
:
'
bottom
'
);
bottomUsed
=
xAxisPosition
===
'
bottom
'
;
var
axisX
=
new
Axis2D
(
'
x
'
,
getScaleByOption
(
xAxisType
,
xAxis
Opt
),
'
x
'
,
getScaleByOption
(
xAxisType
,
xAxis
Model
),
[
0
,
0
],
xAxis
Opt
.
type
,
xAxis
Opt
.
p
osition
xAxis
Model
.
get
(
'
type
'
)
,
xAxis
P
osition
);
axisX
.
onZero
=
xAxis
Opt
.
axisLine
.
onZero
;
axisX
.
onZero
=
xAxis
Model
.
get
(
'
axisLine.onZero
'
)
;
cartesian
.
addAxis
(
axisX
);
var
yAxisType
=
yAxisOpt
.
type
;
// Create y axis
var
yAxisType
=
yAxisModel
.
get
(
'
type
'
);
var
yAxisPosition
=
yAxisModel
.
get
(
'
position
'
)
||
(
leftUsed
?
'
right
'
:
'
left
'
);
leftUsed
=
yAxisPosition
===
'
left
'
;
var
axisY
=
new
Axis2D
(
'
y
'
,
getScaleByOption
(
yAxisType
,
yAxis
Opt
),
'
y
'
,
getScaleByOption
(
yAxisType
,
yAxis
Model
),
[
0
,
0
],
yAxis
Opt
.
type
,
yAxis
Opt
.
position
yAxis
Model
.
get
(
'
type
'
)
,
yAxis
Model
.
get
(
'
position
'
)
);
axisY
.
onZero
=
yAxis
Opt
.
axisLine
.
onZero
;
axisY
.
onZero
=
yAxis
Model
.
get
(
'
axisLine.onZero
'
)
;
cartesian
.
addAxis
(
axisY
);
axisX
.
otherAxis
=
axisY
;
...
...
@@ -236,15 +241,15 @@ define(function(require, factory) {
horizontalAxis
.
reverse
();
}
this
.
_
axesList
.
push
(
axisX
);
this
.
_
axesList
.
push
(
axisY
);
}
}
axesList
.
push
(
axisX
);
axesList
.
push
(
axisY
);
}
,
this
);
}
,
this
);
this
.
_updateCartesianFromSeries
(
option
);
this
.
_updateCartesianFromSeries
(
ecModel
);
// Set axis from option
zrUtil
.
each
(
this
.
_
axesList
,
function
(
axis
)
{
zrUtil
.
each
(
axesList
,
function
(
axis
)
{
axis
.
scale
.
niceExtent
();
});
},
...
...
@@ -254,15 +259,15 @@ define(function(require, factory) {
* @param {module:echarts/model/Option} option
* @private
*/
_updateCartesianFromSeries
:
function
(
option
)
{
_updateCartesianFromSeries
:
function
(
ecModel
)
{
var
axisDataMap
=
{};
option
.
eachSeries
(
function
(
series
,
idx
)
{
var
coordinateSystem
=
series
.
get
(
'
coordinateSystem
'
);
ecModel
.
eachSeries
(
function
(
seriesModel
,
idx
)
{
var
coordinateSystem
=
series
Model
.
get
(
'
coordinateSystem
'
);
if
(
coordinateSystem
===
'
cartesian
'
)
{
var
xAxisIndex
=
series
.
get
(
'
xAxisIndex
'
);
var
yAxisIndex
=
series
.
get
(
'
yAxisIndex
'
);
var
xAxisIndex
=
series
Model
.
get
(
'
xAxisIndex
'
);
var
yAxisIndex
=
series
Model
.
get
(
'
yAxisIndex
'
);
var
cartesian
=
this
.
getCartesian
(
xAxisIndex
,
yAxisIndex
);
var
axisData
=
axisDataMap
[
cartesian
.
name
];
...
...
@@ -274,7 +279,7 @@ define(function(require, factory) {
};
}
var
data
=
series
.
getData
();
var
data
=
series
Model
.
getData
();
if
(
data
.
type
===
'
list
'
)
{
var
categoryAxis
=
cartesian
.
getAxisByScale
(
'
ordinal
'
);
if
(
!
categoryAxis
||
categoryAxis
.
dim
===
'
x
'
)
{
...
...
src/coord/Polar.js
→
src/coord/
polar/
Polar.js
浏览文件 @
83224531
文件已移动
src/coord/polarCreator.js
→
src/coord/polar
/polar
Creator.js
浏览文件 @
83224531
文件已移动
src/model/Component.js
浏览文件 @
83224531
...
...
@@ -23,7 +23,15 @@ define(function(require) {
return
SubComponentModel
;
};
ComponentModel
.
create
ComponentModel
.
create
=
function
(
name
,
option
)
{
if
(
componentModelClasses
[
name
])
{
return
new
componentModelClasses
[
name
](
option
);
}
};
ComponentModel
.
has
=
function
(
name
)
{
return
componentModelClasses
[
name
];
};
return
ComponentModel
;
});
\ No newline at end of file
src/model/Global.js
浏览文件 @
83224531
...
...
@@ -18,7 +18,7 @@ define(function (require) {
this
.
_seriesMap
=
{};
this
.
_
option
=
{};
this
.
$
option
=
{};
this
.
mergeOption
(
option
);
},
...
...
@@ -38,38 +38,64 @@ define(function (require) {
},
this
);
// 同步 Option
this
.
_
option
.
series
=
this
.
_series
.
map
(
function
(
seriesModel
)
{
this
.
$
option
.
series
=
this
.
_series
.
map
(
function
(
seriesModel
)
{
return
seriesModel
.
getOption
();
});
var
components
=
this
.
_components
;
for
(
var
name
in
newOption
)
{
if
(
this
.
_components
[
name
])
{
this
.
_components
[
name
].
mergeOption
(
newOption
[
name
]);
var
componentOption
=
newOption
[
name
];
// Normalize
if
(
!
(
componentOption
instanceof
Array
))
{
componentOption
=
[
componentOption
];
}
else
{
var
componentOption
=
newOption
[
name
];
var
componentModel
=
ComponentModel
.
create
(
name
,
componentOption
);
if
(
!
componentModel
)
{
// 如果不存在对应的 model 则直接 merge
if
(
typeof
componentOption
===
'
object
'
)
{
componentOption
=
zrUtil
.
merge
(
this
.
_option
[
name
]
||
{},
componentOption
);
}
this
.
_option
[
name
]
=
componentOption
;
if
(
!
components
[
name
])
{
components
[
name
]
=
[];
}
// 如果不存在对应的 model 则直接 merge
if
(
!
ComponentModel
.
has
(
name
))
{
if
(
typeof
componentOption
[
i
]
===
'
object
'
)
{
componentOption
=
zrUtil
.
merge
(
this
.
$option
[
name
]
||
{},
componentOption
);
}
else
{
this
.
_components
[
name
]
=
componentModel
;
this
.
$option
[
name
]
=
componentOption
;
}
if
(
componentModel
)
{
// 同步 Option
this
.
_option
[
name
]
=
componentModel
.
getOption
();
}
else
{
for
(
var
i
=
0
;
i
<
componentOption
.
length
;
i
++
)
{
var
componentModel
=
components
[
name
][
i
];
if
(
componentModel
)
{
componentModel
.
mergeOption
(
componentOption
[
i
]);
}
else
{
componentModel
=
ComponentModel
.
create
(
name
,
componentOption
[
i
]);
components
[
name
][
i
]
=
componentModel
;
if
(
componentModel
)
{
// 同步 Option
if
(
componentOption
instanceof
Array
)
{
this
.
$option
[
name
][
i
]
=
componentModel
.
getOption
();
}
else
{
this
.
$option
[
name
]
=
componentModel
.
getOption
();
}
}
}
}
}
}
},
getComponent
:
function
(
name
)
{
return
this
.
_components
[
name
];
getComponent
:
function
(
type
,
idx
)
{
var
list
=
this
.
_components
[
type
];
if
(
list
)
{
return
list
[
idx
||
0
];
}
},
eachComponent
:
function
(
type
,
cb
,
context
)
{
zrUtil
.
each
(
this
.
_components
[
type
],
cb
,
context
);
},
getSeriesByName
:
function
(
name
)
{
...
...
src/model/Model.js
浏览文件 @
83224531
...
...
@@ -6,6 +6,8 @@ define(function (require) {
this
.
parent
=
parent
||
null
;
this
.
$option
=
{};
this
.
init
(
option
);
}
...
...
@@ -14,21 +16,21 @@ define(function (require) {
constructor
:
Model
,
init
:
function
(
option
)
{
this
.
_
option
=
option
;
this
.
$
option
=
option
;
},
/**
* 从新的 Option merge
*/
mergeOption
:
function
(
option
)
{
zrUtil
.
merge
(
this
.
_
option
,
option
);
zrUtil
.
merge
(
this
.
$
option
,
option
);
},
get
:
function
(
path
)
{
if
(
typeof
path
==
'
string
'
)
{
path
=
path
.
split
(
'
.
'
);
}
var
obj
=
this
.
_
option
;
var
obj
=
this
.
$
option
;
for
(
var
i
=
0
;
i
<
path
.
length
;
i
++
)
{
obj
=
obj
[
path
[
i
]];
if
(
obj
==
null
)
{
...
...
@@ -42,7 +44,7 @@ define(function (require) {
},
getOption
:
function
()
{
return
this
.
_
option
;
return
this
.
$
option
;
},
restore
:
function
()
{},
...
...
@@ -50,7 +52,7 @@ define(function (require) {
// Pending
clone
:
function
()
{
var
Ctor
=
this
.
constructor
;
return
new
Ctor
(
zrUtil
.
clone
(
this
.
_
option
,
true
));
return
new
Ctor
(
zrUtil
.
clone
(
this
.
$
option
,
true
));
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录