Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
463ea55a
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
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,发现更多精彩内容 >>
提交
463ea55a
编写于
2月 10, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #7715 (candlestick encode problem)
上级
f27f50eb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
217 addition
and
15 deletion
+217
-15
src/data/helper/completeDimensions.js
src/data/helper/completeDimensions.js
+16
-13
test/dataset-charts.html
test/dataset-charts.html
+86
-0
test/lib/reset.css
test/lib/reset.css
+5
-1
test/ut/spec/data/completeDimensions.js
test/ut/spec/data/completeDimensions.js
+110
-1
未找到文件。
src/data/helper/completeDimensions.js
浏览文件 @
463ea55a
...
...
@@ -21,7 +21,8 @@ import {OTHER_DIMENSIONS} from './dimensionHelper';
* provides not only dim template, but also default order.
* properties: 'name', 'type', 'displayName'.
* `name` of each item provides default coord name.
* [{dimsDef: [string...]}, ...] can be specified to give names.
* [{dimsDef: [string...]}, ...] dimsDef of sysDim item provides default dim name, and
* provide dims count that the sysDim required.
* [{ordinalMeta}] can be specified.
* @param {module:echarts/data/Source|Array|Object} source or data (for compatibal with pervious)
* @param {Object} [opt]
...
...
@@ -198,18 +199,20 @@ function completeDimensions(sysDims, source, opt) {
// may be visited.
// (2) sometimes user need to calcualte bubble size or use visualMap
// on other dimensions besides coordSys needed.
function
getDimCount
(
source
,
sysDims
,
dimsDef
,
dimCount
)
{
if
(
dimCount
==
null
)
{
dimCount
=
Math
.
max
(
source
.
dimensionsDetectCount
||
1
,
sysDims
.
length
,
dimsDef
.
length
);
each
(
sysDims
,
function
(
sysDimItem
)
{
var
sysDimItemDimsDef
=
sysDimItem
.
dimsDef
;
sysDimItemDimsDef
&&
(
dimCount
=
Math
.
max
(
dimCount
,
sysDimItemDimsDef
.
length
));
});
}
// So, dims that is not used by system, should be shared in storage?
function
getDimCount
(
source
,
sysDims
,
dimsDef
,
optDimCount
)
{
// Note that the result dimCount should not small than columns count
// of data, otherwise `dataDimNameMap` checking will be incorrect.
var
dimCount
=
Math
.
max
(
source
.
dimensionsDetectCount
||
1
,
sysDims
.
length
,
dimsDef
.
length
,
optDimCount
||
0
);
each
(
sysDims
,
function
(
sysDimItem
)
{
var
sysDimItemDimsDef
=
sysDimItem
.
dimsDef
;
sysDimItemDimsDef
&&
(
dimCount
=
Math
.
max
(
dimCount
,
sysDimItemDimsDef
.
length
));
});
return
dimCount
;
}
...
...
test/dataset-charts.html
浏览文件 @
463ea55a
...
...
@@ -32,6 +32,7 @@
<div
id=
"layout5"
></div>
<div
id=
"layout6"
></div>
<div
id=
"layout7"
></div>
<div
id=
"layout7.5"
></div>
<div
id=
"layout8"
></div>
<div
id=
"layout9"
></div>
<div
id=
"layout10"
></div>
...
...
@@ -610,6 +611,91 @@
<script>
require
([
'
echarts
'
],
function
(
echarts
,
source
)
{
// Thanks to
<
https
:
//github.com/OvidiuBuleandra>
option
=
{
tooltip
:
{
trigger
:
'
axis
'
},
xAxis
:
{
type
:
"
category
"
,
scale
:
true
},
yAxis
:
{
type
:
"
value
"
,
scale
:
true
,
boundaryGap
:
[
'
5%
'
,
'
5%
'
]
},
dataZoom
:
[{
type
:
'
slider
'
},
{
type
:
'
inside
'
}],
dataset
:
{
dimensions
:
[
"
date
"
,
"
open
"
,
"
high
"
,
"
low
"
,
"
close
"
,
"
volume
"
,{
name
:
"
haOpen
"
,
displayName
:
'
open
'
},
"
haHigh
"
,
"
haLow
"
,
"
haClose
"
,
"
sma9
"
],
source
:
[
[
"
2018-01-09 14:30:00
"
,
14636.21
,
14682.6
,
14401.0
,
14659.57
,
349.069176
,
14647.89
,
14682.6
,
14401.0
,
14594.845
,
0.0
],
[
"
2018-01-09 15:00:00
"
,
14650.0
,
14700.0
,
14238.99
,
14347.43
,
459.735215
,
14621.3675
,
14700.0
,
14238.99
,
14484.105
,
0.0
],
[
"
2018-01-09 15:30:00
"
,
14374.72
,
14434.2
,
14011.05
,
14041.03
,
697.055035
,
14552.73625
,
14552.73625
,
14011.05
,
14215.25
,
0.0
],
[
"
2018-01-09 16:00:00
"
,
14072.87
,
14497.06
,
14064.13
,
14349.0
,
671.165463
,
14383.993125
,
14497.06
,
14064.13
,
14245.765
,
0.0
],
[
"
2018-01-09 16:30:00
"
,
14369.98
,
14640.99
,
14340.0
,
14560.48
,
416.750768
,
14314.8790625
,
14640.99
,
14314.8790625
,
14477.8625
,
0.0
],
[
"
2018-01-09 17:00:00
"
,
14551.42
,
14800.0
,
14551.41
,
14749.55
,
357.445717
,
14396.37078125
,
14800.0
,
14396.37078125
,
14663.095000000001
,
0.0
],
[
"
2018-01-09 17:30:00
"
,
14745.0
,
14766.2
,
14485.0
,
14654.96
,
306.727704
,
14529.732890625
,
14766.2
,
14485.0
,
14662.789999999999
,
0.0
],
[
"
2018-01-09 18:00:00
"
,
14655.01
,
14829.0
,
14585.01
,
14800.1
,
194.858965
,
14596.261445312499
,
14829.0
,
14585.01
,
14717.28
,
0.0
],
[
"
2018-01-09 18:30:00
"
,
14800.1
,
14998.62
,
14792.03
,
14951.01
,
313.268531
,
14656.770722656249
,
14998.62
,
14656.770722656249
,
14885.44
,
0.0
],
[
"
2018-01-09 19:00:00
"
,
14968.0
,
14982.0
,
14778.47
,
14810.0
,
214.504459
,
14771.105361328126
,
14982.0
,
14771.105361328126
,
14884.6175
,
16213.681111111111
],
[
"
2018-01-09 19:30:00
"
,
14810.0
,
14973.49
,
14799.95
,
14949.98
,
144.830078
,
14827.861430664063
,
14973.49
,
14799.95
,
14883.355
,
16245.94888888889
],
[
"
2018-01-09 20:00:00
"
,
14949.98
,
14990.0
,
14865.49
,
14916.91
,
145.574797
,
14855.608215332031
,
14990.0
,
14855.608215332031
,
14930.595000000001
,
16309.224444444444
],
[
"
2018-01-09 20:30:00
"
,
14914.03
,
14945.01
,
14799.01
,
14803.44
,
146.21296
,
14893.101607666016
,
14945.01
,
14799.01
,
14865.372500000001
,
16393.936666666665
],
[
"
2018-01-09 21:00:00
"
,
14803.46
,
14863.93
,
14700.44
,
14799.0
,
190.167582
,
14879.237053833009
,
14879.237053833009
,
14700.44
,
14791.7075
,
16443.936666666665
],
[
"
2018-01-09 21:30:00
"
,
14798.99
,
14798.99
,
14650.0
,
14717.82
,
209.543776
,
14835.472276916506
,
14835.472276916506
,
14650.0
,
14741.449999999999
,
16461.41888888889
],
[
"
2018-01-09 22:00:00
"
,
14717.82
,
14781.56
,
14600.0
,
14615.9
,
164.859485
,
14788.461138458253
,
14788.461138458253
,
14600.0
,
14678.82
,
16446.568888888887
],
[
"
2018-01-09 22:30:00
"
,
14647.09
,
14861.56
,
14615.4
,
14755.03
,
228.445843
,
14733.640569229126
,
14861.56
,
14615.4
,
14719.77
,
16457.687777777777
],
[
"
2018-01-09 23:00:00
"
,
14755.33
,
14780.0
,
14680.0
,
14702.33
,
150.779654
,
14726.705284614563
,
14780.0
,
14680.0
,
14729.415
,
16446.824444444443
],
[
"
2018-01-09 23:30:00
"
,
14709.49
,
14709.49
,
14420.0
,
14462.81
,
274.752199
,
14728.060142307282
,
14728.060142307282
,
14420.0
,
14575.447499999998
,
16392.579999999998
],
[
"
2018-01-10 00:00:00
"
,
14452.0
,
14536.36
,
14407.77
,
14435.0
,
279.156552
,
14651.753821153641
,
14651.753821153641
,
14407.77
,
14457.782500000001
,
16350.913333333334
],
[
"
2018-01-10 00:30:00
"
,
14435.0
,
14459.94
,
14182.84
,
14254.92
,
435.050575
,
14554.768160576821
,
14554.768160576821
,
14182.84
,
14333.175
,
16273.684444444445
],
[
"
2018-01-10 01:00:00
"
,
14234.7
,
14290.56
,
14125.0
,
14259.98
,
422.926221
,
14443.97158028841
,
14443.97158028841
,
14125.0
,
14227.560000000001
,
16200.692222222224
],
[
"
2018-01-10 01:30:00
"
,
14259.98
,
14454.95
,
14144.13
,
14400.0
,
377.788542
,
14335.765790144205
,
14454.95
,
14144.13
,
14314.765
,
16155.865555555552
],
[
"
2018-01-10 02:00:00
"
,
14401.0
,
14480.0
,
13750.0
,
13972.46
,
582.921859
,
14325.265395072103
,
14480.0
,
13750.0
,
14150.865
,
16064.027777777777
]
]
},
series
:
[{
type
:
"
candlestick
"
,
encode
:
{
x
:
"
date
"
,
// y: ["open", "close", "low", "high"],
y
:
[
"
haOpen
"
,
"
haClose
"
,
"
haLow
"
,
"
haHigh
"
],
tooltip
:
[
"
haOpen
"
,
"
haHigh
"
,
"
haLow
"
,
"
haClose
"
]
}
}]
};
testHelper
.
create
(
echarts
,
'
layout7.5
'
,
{
title
:
'
Check: Y use haOpen, haHigh, haLow, haClose, but display name of "haOpen" is open
'
,
height
:
400
,
option
:
option
,
dataTable
:
option
.
dataset
.
source
,
info
:
{
series
:
option
.
series
}
});
});
</script>
<script>
require
([
'
echarts
'
,
'
data/stock-DJI.json
'
],
function
(
echarts
,
source
)
{
...
...
test/lib/reset.css
浏览文件 @
463ea55a
...
...
@@ -25,7 +25,10 @@ body > .main {
overflow
:
hidden
;
}
.test-chart-block-has-right
.test-chart-block-right
{
float
:
right
;
position
:
absolute
;
right
:
10px
;
background
:
#fff
;
z-index
:
99
;
width
:
300px
;
}
.test-chart-block-has-right
.test-chart-block-left
{
...
...
@@ -33,6 +36,7 @@ body > .main {
}
.test-info
{
border-left
:
1px
solid
#ddd
;
border-bottom
:
1px
solid
#ddd
;
padding-left
:
10px
;
overflow
:
auto
;
}
...
...
test/ut/spec/data/completeDimensions.js
浏览文件 @
463ea55a
describe
(
'
completeDimensions
'
,
function
()
{
var
utHelper
=
window
.
utHelper
;
var
testCase
=
utHelper
.
prepare
([
'
echarts/src/data/helper/completeDimensions
'
]);
var
testCase
=
utHelper
.
prepare
([
'
echarts/src/data/helper/completeDimensions
'
,
'
echarts/src/data/Source
'
,
'
echarts/src/data/sourceType
'
,
]);
...
...
@@ -19,6 +24,110 @@ describe('completeDimensions', function () {
return
result
;
}
testCase
(
'
namesMoreThanDimCount
'
,
function
(
completeDimensions
,
Source
,
sourceType
)
{
var
sysDims
=
[
{
'
name
'
:
'
x
'
,
'
type
'
:
'
ordinal
'
,
'
otherDims
'
:
{
'
tooltip
'
:
false
,
'
itemName
'
:
0
},
'
dimsDef
'
:
[
'
base
'
]
},
{
'
name
'
:
'
y
'
,
'
type
'
:
'
float
'
,
'
dimsDef
'
:
[
'
open
'
,
'
close
'
,
'
lowest
'
,
'
highest
'
]
}
];
var
source
=
new
Source
({
data
:
[],
fromDataset
:
true
,
sourceFormat
:
sourceType
.
SOURCE_FORMAT_ARRAY_ROWS
,
dimensionsDetectCount
:
11
});
var
opt
=
{
'
dimsDef
'
:
[
{
'
name
'
:
'
date
'
,
'
displayName
'
:
'
date
'
},
{
'
name
'
:
'
open
'
,
'
displayName
'
:
'
open
'
},
{
'
name
'
:
'
high
'
,
'
displayName
'
:
'
high
'
},
{
'
name
'
:
'
low
'
,
'
displayName
'
:
'
low
'
},
{
'
name
'
:
'
close
'
,
'
displayName
'
:
'
close
'
},
{
'
name
'
:
'
volume
'
,
'
displayName
'
:
'
volume
'
},
{
'
name
'
:
'
haOpen
'
,
'
displayName
'
:
'
haOpen
'
},
{
'
name
'
:
'
haHigh
'
,
'
displayName
'
:
'
haHigh
'
},
{
'
name
'
:
'
haLow
'
,
'
displayName
'
:
'
haLow
'
},
{
'
name
'
:
'
haClose
'
,
'
displayName
'
:
'
haClose
'
},
{
'
name
'
:
'
sma9
'
,
'
displayName
'
:
'
sma9
'
}
],
'
encodeDef
'
:
{
'
x
'
:
'
date
'
,
'
y
'
:
[
'
haOpen
'
,
'
haClose
'
,
'
haLow
'
,
'
haHigh
'
],
'
tooltip
'
:
[
'
open
'
,
'
high
'
,
'
low
'
,
'
close
'
]
},
'
dimCount
'
:
5
};
var
result
=
[
];
expect
(
doCompleteDimensions
(
completeDimensions
,
sysDims
,
source
,
opt
)).
toEqual
(
result
);
});
testCase
(
'
differentData
'
,
function
(
completeDimensions
)
{
function
doTest
(
sysDims
,
data
,
opt
,
result
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录