Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
6b8f9e52
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,发现更多精彩内容 >>
提交
6b8f9e52
编写于
11月 19, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unshaped log scale
上级
5fc5500e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
205 addition
and
9 deletion
+205
-9
src/coord/axisDefault.js
src/coord/axisDefault.js
+4
-1
src/coord/axisModelCommonMixin.js
src/coord/axisModelCommonMixin.js
+15
-4
src/scale/Interval.js
src/scale/Interval.js
+2
-2
src/scale/Log.js
src/scale/Log.js
+111
-0
src/scale/Time.js
src/scale/Time.js
+2
-2
test/logScale.html
test/logScale.html
+71
-0
未找到文件。
src/coord/axisDefault.js
浏览文件 @
6b8f9e52
...
...
@@ -103,10 +103,13 @@ define(function (require) {
},
defaultOption
);
var
timeAxis
=
zrUtil
.
merge
({},
valueAxis
);
var
logAxis
=
zrUtil
.
merge
({},
valueAxis
);
logAxis
.
scale
=
true
;
return
{
categoryAxis
:
categoryAxis
,
valueAxis
:
valueAxis
,
timeAxis
:
timeAxis
timeAxis
:
timeAxis
,
logAxis
:
logAxis
};
});
\ No newline at end of file
src/coord/axisModelCommonMixin.js
浏览文件 @
6b8f9e52
...
...
@@ -8,6 +8,20 @@ define(function (require) {
return
val
;
}
// function getName(obj) {
// if (typeof obj === 'string') {
// return obj;
// }
// return obj.name;
// }
/**
* Get categories
*/
// function getCategories() {
// return this.get('type') === 'category'
// && zrUtil.map()
// }
/**
* Format labels
* @param {Array.<string>} labels
...
...
@@ -24,10 +38,7 @@ define(function (require) {
case
'
time
'
:
labelFormatter
=
function
(
time
)
{
return
time
;
}
break
;
case
'
log
'
:
// TODO
};
break
;
default
:
labelFormatter
=
function
(
val
)
{
...
...
src/scale/Interval.js
浏览文件 @
6b8f9e52
/**
* Interval scale
* @module echarts/
coord/
scale/Interval
* @module echarts/scale/Interval
*/
define
(
function
(
require
)
{
...
...
@@ -108,7 +108,7 @@ define(function (require) {
* Get interval
*/
getInterval
:
function
()
{
if
(
!
this
.
_interval
)
{
if
(
!
this
.
_interval
)
{
this
.
niceTicks
();
}
return
this
.
_interval
;
...
...
src/scale/Log.js
0 → 100644
浏览文件 @
6b8f9e52
/**
* Log scale
* @module echarts/scale/Log
*/
define
(
function
(
require
)
{
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
IntervalScale
=
require
(
'
./Interval
'
);
var
intervalScaleProto
=
IntervalScale
.
prototype
;
var
numberUtil
=
require
(
'
../util/number
'
);
var
mathFloor
=
Math
.
floor
;
var
mathCeil
=
Math
.
ceil
;
var
LOG_BASE
=
10
;
var
mathLog
=
Math
.
log
;
function
LogScale
(
logBase
)
{
IntervalScale
.
call
(
this
);
}
var
logScaleProto
=
LogScale
.
prototype
;
logScaleProto
.
type
=
'
log
'
;
zrUtil
.
each
([
'
contain
'
,
'
normalize
'
],
function
(
methodName
)
{
logScaleProto
[
methodName
]
=
function
(
val
)
{
val
=
mathLog
(
val
)
/
mathLog
(
LOG_BASE
);
return
intervalScaleProto
[
methodName
].
call
(
this
,
val
);
};
});
logScaleProto
.
getTicks
=
function
()
{
var
ticks
=
intervalScaleProto
.
getTicks
.
call
(
this
);
return
zrUtil
.
map
(
ticks
,
function
(
tick
)
{
return
Math
.
pow
(
LOG_BASE
,
tick
);
});
};
/**
* @param {number} val
* @return {number}
*/
logScaleProto
.
scale
=
function
(
val
)
{
val
=
intervalScaleProto
.
scale
.
call
(
this
,
val
);
return
Math
.
pow
(
LOG_BASE
,
val
);
};
/**
* @param {number} start
* @param {number} end
*/
logScaleProto
.
setExtent
=
function
(
start
,
end
)
{
start
=
mathLog
(
start
)
/
mathLog
(
LOG_BASE
);
end
=
mathLog
(
end
)
/
mathLog
(
LOG_BASE
);
intervalScaleProto
.
setExtent
.
call
(
this
,
start
,
end
);
};
/**
* @return {number} end
*/
logScaleProto
.
getExtent
=
function
()
{
var
extent
=
intervalScaleProto
.
getExtent
.
call
(
this
);
extent
[
0
]
=
Math
.
pow
(
LOG_BASE
,
extent
[
0
]);
extent
[
1
]
=
Math
.
pow
(
LOG_BASE
,
extent
[
1
]);
return
extent
;
};
logScaleProto
.
niceTicks
=
function
(
approxTickNum
)
{
approxTickNum
=
approxTickNum
||
10
;
var
extent
=
this
.
_extent
;
var
span
=
extent
[
1
]
-
extent
[
0
];
if
(
span
===
Infinity
||
span
<=
0
)
{
return
;
}
var
interval
=
Math
.
pow
(
10
,
Math
.
floor
(
Math
.
log
(
span
/
approxTickNum
)
/
Math
.
LN10
));
var
err
=
approxTickNum
/
span
*
interval
;
// Filter ticks to get closer to the desired count.
if
(
err
<=
0.5
)
{
interval
*=
10
;
}
var
niceExtent
=
[
numberUtil
.
round
(
mathCeil
(
extent
[
0
]
/
interval
)
*
interval
),
numberUtil
.
round
(
mathFloor
(
extent
[
1
]
/
interval
)
*
interval
)
];
this
.
_interval
=
interval
;
this
.
_niceExtent
=
niceExtent
;
};
/**
* @param {Array.<number>} extent
*/
logScaleProto
.
unionExtent
=
function
(
extent
)
{
extent
[
0
]
=
mathLog
(
extent
[
0
])
/
mathLog
(
LOG_BASE
);
extent
[
1
]
=
mathLog
(
extent
[
1
])
/
mathLog
(
LOG_BASE
);
intervalScaleProto
.
unionExtent
.
call
(
this
,
extent
);
};
zrUtil
.
inherits
(
LogScale
,
IntervalScale
);
LogScale
.
create
=
function
()
{
return
new
LogScale
();
};
require
(
'
./scale
'
).
register
(
LogScale
);
return
LogScale
;
});
\ No newline at end of file
src/scale/Time.js
浏览文件 @
6b8f9e52
...
...
@@ -90,10 +90,10 @@ define(function (require) {
* @alias module:echarts/coord/scale/Time
* @constructor
*/
var
TimeScale
=
function
()
{
function
TimeScale
()
{
IntervalScale
.
call
(
this
);
}
;
}
TimeScale
.
prototype
=
{
...
...
test/logScale.html
0 → 100644
浏览文件 @
6b8f9e52
<html>
<head>
<meta
charset=
'utf-8'
>
<script
src=
'esl.js'
></script>
<script
src=
'config.js'
></script>
</head>
<body>
<style>
html
,
body
,
#main
{
width
:
100%
;
height
:
100%
;
}
</style>
<div
id=
'main'
></div>
<script>
require
([
'
echarts
'
,
'
echarts/chart/line
'
,
'
echarts/component/legend
'
,
'
echarts/component/grid
'
,
'
echarts/component/tooltip
'
,
'
echarts/component/title
'
,
'
echarts/component/dataZoom
'
,
'
echarts/scale/Log
'
],
function
(
echarts
)
{
var
chart
=
echarts
.
init
(
document
.
getElementById
(
'
main
'
));
chart
.
setOption
({
title
:
{
text
:
'
对数轴示例
'
,
x
:
'
center
'
},
tooltip
:
{
trigger
:
'
item
'
,
formatter
:
'
{a} <br/>{b} : {c}
'
},
legend
:
{
x
:
'
left
'
,
data
:
[
'
2的指数
'
,
'
3的指数
'
]
},
xAxis
:
[{
type
:
'
category
'
,
name
:
'
x
'
,
splitLine
:
{
show
:
false
},
data
:
[
'
一
'
,
'
二
'
,
'
三
'
,
'
四
'
,
'
五
'
,
'
六
'
,
'
七
'
,
'
八
'
,
'
九
'
]
}],
yAxis
:
[{
type
:
'
log
'
,
name
:
'
y
'
}],
calculable
:
true
,
series
:
[
{
name
:
'
3的指数
'
,
type
:
'
line
'
,
data
:
[
1
,
3
,
9
,
27
,
81
,
247
,
741
,
2223
,
6669
]
},
{
name
:
'
2的指数
'
,
type
:
'
line
'
,
data
:
[
1
,
2
,
4
,
8
,
16
,
32
,
64
,
128
,
256
]
}
]
});
});
</script>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录