Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
b494b002
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,发现更多精彩内容 >>
提交
b494b002
编写于
4月 22, 2014
作者:
K
kener
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
图表重构 calculableBase
上级
69a84151
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
50 deletion
+48
-50
src/chart/calculableBase.js
src/chart/calculableBase.js
+48
-50
未找到文件。
src/chart/calculableBase.js
浏览文件 @
b494b002
/**
* echarts
组件
基类
* echarts
可计算特性
基类
*
* @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
* @author Kener (@Kener-林峰, linzhifeng@baidu.com)
*
*/
define
(
function
(
require
)
{
function
Base
(
zr
,
option
){
var
ecData
=
require
(
'
../util/ecData
'
);
var
accMath
=
require
(
'
../util/accMath
'
);
var
zrUtil
=
require
(
'
zrender/tool/util
'
);
define
(
function
(
require
)
{
var
ecData
=
require
(
'
../util/ecData
'
);
var
accMath
=
require
(
'
../util/accMath
'
);
var
zrUtil
=
require
(
'
zrender/tool/util
'
);
function
Base
(){
var
self
=
this
;
self
.
selectedMap
=
{};
self
.
shapeHandler
=
{
onclick
:
function
()
{
this
.
selectedMap
=
{};
this
.
shapeHandler
=
{
onclick
:
function
()
{
self
.
isClick
=
true
;
},
ondragover
:
function
(
param
)
{
...
...
@@ -27,11 +25,11 @@ define(function(require) {
text
:
''
,
r
:
calculableShape
.
style
.
r
+
5
,
brushType
:
'
stroke
'
,
strokeColor
:
option
.
calculableColor
,
//self.zr.getCalculableColor()
,
strokeColor
:
self
.
ecTheme
.
calculableColor
,
lineWidth
:
(
calculableShape
.
style
.
lineWidth
||
1
)
+
12
};
self
.
zr
.
addHoverShape
(
calculableShape
);
setTimeout
(
function
(){
setTimeout
(
function
(){
calculableShape
.
highlightStyle
=
highlightStyle
;
},
20
);
},
...
...
@@ -46,21 +44,29 @@ define(function(require) {
ondragend
:
function
()
{
self
.
isDragend
=
true
;
}
};
function
setCalculable
(
shape
)
{
shape
.
dragEnableTime
=
option
.
DRAG_ENABLE_TIME
;
shape
.
ondragover
=
self
.
shapeHandler
.
ondragover
;
shape
.
ondragend
=
self
.
shapeHandler
.
ondragend
;
shape
.
ondrop
=
self
.
shapeHandler
.
ondrop
;
return
shape
;
}
}
/**
* 基类方法
*/
Base
.
prototype
=
{
/**
* 图形拖拽特性
*/
setCalculable
:
function
(
shape
)
{
shape
.
dragEnableTime
=
this
.
ecTheme
.
DRAG_ENABLE_TIME
;
shape
.
ondragover
=
this
.
shapeHandler
.
ondragover
;
shape
.
ondragend
=
this
.
shapeHandler
.
ondragend
;
shape
.
ondrop
=
this
.
shapeHandler
.
ondrop
;
return
shape
;
},
/**
* 数据项被拖拽进来
*/
function
ondrop
(
param
,
status
)
{
if
(
!
self
.
isDrop
||
!
param
.
target
)
{
ondrop
:
function
(
param
,
status
)
{
if
(
!
this
.
isDrop
||
!
param
.
target
)
{
// 没有在当前实例上发生拖拽行为则直接返回
return
;
}
...
...
@@ -72,30 +78,30 @@ define(function(require) {
var
dataIndex
=
ecData
.
get
(
target
,
'
dataIndex
'
);
// 落到数据item上,数据被拖拽到某个数据项上,数据修改
var
data
=
option
.
series
[
seriesIndex
].
data
[
dataIndex
]
||
'
-
'
;
var
data
=
this
.
option
.
series
[
seriesIndex
].
data
[
dataIndex
]
||
'
-
'
;
if
(
data
.
value
)
{
if
(
data
.
value
!=
'
-
'
)
{
option
.
series
[
seriesIndex
].
data
[
dataIndex
].
value
=
this
.
option
.
series
[
seriesIndex
].
data
[
dataIndex
].
value
=
accMath
.
accAdd
(
option
.
series
[
seriesIndex
].
data
[
dataIndex
].
value
,
this
.
option
.
series
[
seriesIndex
].
data
[
dataIndex
].
value
,
ecData
.
get
(
dragged
,
'
value
'
)
);
}
else
{
option
.
series
[
seriesIndex
].
data
[
dataIndex
].
value
=
this
.
option
.
series
[
seriesIndex
].
data
[
dataIndex
].
value
=
ecData
.
get
(
dragged
,
'
value
'
);
}
}
else
{
if
(
data
!=
'
-
'
)
{
option
.
series
[
seriesIndex
].
data
[
dataIndex
]
=
this
.
option
.
series
[
seriesIndex
].
data
[
dataIndex
]
=
accMath
.
accAdd
(
option
.
series
[
seriesIndex
].
data
[
dataIndex
],
this
.
option
.
series
[
seriesIndex
].
data
[
dataIndex
],
ecData
.
get
(
dragged
,
'
value
'
)
);
}
else
{
option
.
series
[
seriesIndex
].
data
[
dataIndex
]
=
this
.
option
.
series
[
seriesIndex
].
data
[
dataIndex
]
=
ecData
.
get
(
dragged
,
'
value
'
);
}
}
...
...
@@ -104,16 +110,16 @@ define(function(require) {
status
.
dragIn
=
status
.
dragIn
||
true
;
// 处理完拖拽事件后复位
self
.
isDrop
=
false
;
this
.
isDrop
=
false
;
return
;
}
}
,
/**
* 数据项被拖拽出去
*/
function
ondragend
(
param
,
status
)
{
if
(
!
self
.
isDragend
||
!
param
.
target
)
{
ondragend
:
function
(
param
,
status
)
{
if
(
!
this
.
isDragend
||
!
param
.
target
)
{
// 没有在当前实例上发生拖拽行为则直接返回
return
;
}
...
...
@@ -123,40 +129,32 @@ define(function(require) {
var
dataIndex
=
ecData
.
get
(
target
,
'
dataIndex
'
);
// 被拖拽的图形是折线图bar,删除被拖拽走的数据
option
.
series
[
seriesIndex
].
data
[
dataIndex
]
=
'
-
'
;
this
.
option
.
series
[
seriesIndex
].
data
[
dataIndex
]
=
'
-
'
;
// 别status = {}赋值啊!!
status
.
dragOut
=
true
;
status
.
needRefresh
=
true
;
// 处理完拖拽事件后复位
self
.
isDragend
=
false
;
this
.
isDragend
=
false
;
return
;
}
}
,
/**
* 图例选择
*/
function
onlegendSelected
(
param
,
status
)
{
onlegendSelected
:
function
(
param
,
status
)
{
var
legendSelected
=
param
.
selected
;
for
(
var
itemName
in
self
.
selectedMap
)
{
if
(
self
.
selectedMap
[
itemName
]
!=
legendSelected
[
itemName
])
{
for
(
var
itemName
in
this
.
selectedMap
)
{
if
(
this
.
selectedMap
[
itemName
]
!=
legendSelected
[
itemName
])
{
// 有一项不一致都需要重绘
status
.
needRefresh
=
true
;
}
self
.
selectedMap
[
itemName
]
=
legendSelected
[
itemName
];
this
.
selectedMap
[
itemName
]
=
legendSelected
[
itemName
];
}
return
;
}
/**
* 基类方法
*/
self
.
setCalculable
=
setCalculable
;
self
.
ondrop
=
ondrop
;
self
.
ondragend
=
ondragend
;
self
.
onlegendSelected
=
onlegendSelected
;
}
return
Base
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录