Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
d6eca3a5
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,发现更多精彩内容 >>
提交
d6eca3a5
编写于
2月 23, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix that appendData cause series color changed if series name not specified.
上级
2b9b7dac
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
131 addition
and
46 deletion
+131
-46
src/component/legend/LegendModel.js
src/component/legend/LegendModel.js
+6
-6
src/model/Series.js
src/model/Series.js
+2
-3
src/model/mixin/colorPalette.js
src/model/mixin/colorPalette.js
+7
-0
src/util/model.js
src/util/model.js
+13
-5
src/visual/seriesColor.js
src/visual/seriesColor.js
+1
-1
test/appendData.html
test/appendData.html
+101
-30
test/lib/testHelper.js
test/lib/testHelper.js
+1
-1
未找到文件。
src/component/legend/LegendModel.js
浏览文件 @
d6eca3a5
import
*
as
echarts
from
'
../../echarts
'
;
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
Model
from
'
../../model/Model
'
;
import
{
DEFAULT_COMPONENT_NAME
}
from
'
../../util/model
'
;
import
{
isNameSpecified
}
from
'
../../util/model
'
;
var
LegendModel
=
echarts
.
extendComponentModel
({
...
...
@@ -61,7 +61,7 @@ var LegendModel = echarts.extendComponentModel({
ecModel
.
eachRawSeries
(
function
(
seriesModel
)
{
var
seriesName
=
seriesModel
.
name
;
availableNames
.
push
(
seriesName
);
var
potentialSeriesName
;
var
isPotential
;
if
(
seriesModel
.
legendDataProvider
)
{
var
data
=
seriesModel
.
legendDataProvider
();
...
...
@@ -75,15 +75,15 @@ var LegendModel = echarts.extendComponentModel({
potentialData
=
potentialData
.
concat
(
names
);
}
else
{
potentialSeriesName
=
seriesNam
e
;
isPotential
=
tru
e
;
}
}
else
{
potentialSeriesName
=
seriesNam
e
;
isPotential
=
tru
e
;
}
if
(
potentialSeriesName
&&
potentialSeriesName
!==
DEFAULT_COMPONENT_NAME
)
{
potentialData
.
push
(
potentialSeriesN
ame
);
if
(
isPotential
&&
isNameSpecified
(
seriesModel
)
)
{
potentialData
.
push
(
seriesModel
.
n
ame
);
}
});
...
...
src/model/Series.js
浏览文件 @
d6eca3a5
...
...
@@ -357,8 +357,7 @@ var SeriesModel = ComponentModel.extend({
var
name
=
data
.
getName
(
dataIndex
);
var
seriesName
=
this
.
name
;
if
(
seriesName
===
modelUtil
.
DEFAULT_COMPONENT_NAME
)
{
// Not show '-'
if
(
!
modelUtil
.
isNameSpecified
(
this
))
{
seriesName
=
''
;
}
seriesName
=
seriesName
...
...
@@ -481,7 +480,7 @@ function autoSeriesName(seriesModel) {
// User specified name has higher priority, otherwise it may cause
// series can not be queried unexpectedly.
var
name
=
seriesModel
.
name
;
if
(
modelUtil
.
DEFAULT_COMPONENT_NAME
===
name
)
{
if
(
!
modelUtil
.
isNameSpecified
(
seriesModel
)
)
{
seriesModel
.
name
=
getSeriesAutoName
(
seriesModel
)
||
name
;
}
}
...
...
src/model/mixin/colorPalette.js
浏览文件 @
d6eca3a5
...
...
@@ -19,6 +19,13 @@ export default {
inner
(
this
).
colorNameMap
=
{};
},
/**
* @param {string} name MUST NOT be null/undefined. Otherwise call this function
* twise with the same parameters will get different result.
* @param {Object} [scope=this]
* @param {Object} [requestColorNum]
* @return {string} color string.
*/
getColorFromPalette
:
function
(
name
,
scope
,
requestColorNum
)
{
scope
=
scope
||
this
;
var
scopeFields
=
inner
(
scope
);
...
...
src/util/model.js
浏览文件 @
d6eca3a5
...
...
@@ -5,11 +5,11 @@ var isObject = zrUtil.isObject;
var
isArray
=
zrUtil
.
isArray
;
/**
*
name may be displayed on screen, so use '-'.
*
But we should make sure it is not duplicated
*
with user
specified name, so use '\0';
*
Make the name displayable. But we should
*
make sure it is not duplicated with user
* specified name, so use '\0';
*/
export
var
DEFAULT_COMPONENT_NAME
=
'
\
0-
'
;
var
DUMMY_COMPONENT_NAME_PREFIX
=
'
series
\
0
'
;
/**
* If value is not array, then translate it to array.
...
...
@@ -248,7 +248,9 @@ export function makeIdAndName(mapResult) {
?
opt
.
name
+
''
:
existCpt
?
existCpt
.
name
:
DEFAULT_COMPONENT_NAME
;
// Avoid diffferent series has the same name,
// because name may be used like in color pallet.
:
DUMMY_COMPONENT_NAME_PREFIX
+
index
;
if
(
existCpt
)
{
keyInfo
.
id
=
existCpt
.
id
;
...
...
@@ -273,6 +275,12 @@ export function makeIdAndName(mapResult) {
});
}
export
function
isNameSpecified
(
componentModel
)
{
var
name
=
componentModel
.
name
;
// Is specified when `indexOf` get -1 or > 0.
return
!!
(
name
&&
name
.
indexOf
(
DUMMY_COMPONENT_NAME_PREFIX
));
}
/**
* @public
* @param {Object} cptOption
...
...
src/visual/seriesColor.js
浏览文件 @
d6eca3a5
...
...
@@ -9,7 +9,7 @@ export default {
var
color
=
seriesModel
.
get
(
colorAccessPath
)
// Set in itemStyle
||
seriesModel
.
getColorFromPalette
(
// TODO series count changed.
seriesModel
.
get
(
'
name
'
)
,
null
,
ecModel
.
getSeriesCount
()
seriesModel
.
name
,
null
,
ecModel
.
getSeriesCount
()
);
// Default color
// FIXME Set color function or use the platte color
...
...
test/appendData.html
浏览文件 @
d6eca3a5
...
...
@@ -20,7 +20,8 @@
<div
id=
"main0"
></div>
<!-- <div id="main1"></div> -->
<div
id=
"main1"
></div>
<div
id=
"main2"
></div>
<script>
...
...
@@ -31,54 +32,59 @@
<script>
var
chart
;
var
myChart
;
var
option
;
<script>
require
([
'
echarts
'
/*, 'map/js/china' */
],
function
(
echarts
)
{
// Thanks to
<
https
:
//github.com/Truantboy>, see: #7718.
option
=
{
var
option
=
{
animation
:
true
,
tooltip
:
{},
xAxis
:
{},
yAxis
:
{},
legend
:
{},
series
:
[{
type
:
'
scatter
'
,
name
:
'
data
'
,
data
:
[[
0
,
0
],
[
2005
,
2005
]],
progressiveThreshold
:
2000
,
symbolSize
:
function
(
val
)
{
return
Math
.
random
()
*
30
+
10
;
}
// name: 'data',
data
:
[[
0
,
0
],
[
3005
,
3005
]],
progressiveThreshold
:
3000
,
symbol
:
'
triangle
'
,
symbolSize
:
20
}]
};
chart
=
myChart
=
testHelper
.
create
(
echarts
,
'
main0
'
,
{
var
yBase
=
500
;
var
appendCount
=
2990
;
var
myChart
=
testHelper
.
create
(
echarts
,
'
main0
'
,
{
title
:
[
'
(1) AppendData less than limit, should render thousands of points normally.
'
,
'
(2) Test click lengend, should be normal.
'
'
Click btn to appendData less than limit, should render thousands of points normally.
'
,
'
Click again, should appendData normally.
'
,
'
Check hover (emphasis), should scale normally.
'
],
option
:
option
,
info
:
option
.
series
,
infoKey
:
'
series
'
,
button
:
{
text
:
'
Click to appendData
'
,
text
:
'
Click to appendData
'
+
appendCount
+
'
points
'
,
onClick
:
function
()
{
var
tp
=
[]
var
appendCount
=
1997
;
for
(
var
i
=
1
;
i
<
appendCount
;
i
++
)
{
tp
[
i
]
=
[
i
,
1
];
tp
[
i
]
=
[
i
,
yBase
];
}
myChart
.
appendData
({
seriesIndex
:
0
,
data
:
tp
});
yBase
+=
1000
;
}
}
});
...
...
@@ -94,17 +100,77 @@
<script>
var
chart
;
var
myChart
;
var
option
;
require
([
'
echarts
'
/*, 'map/js/china' */
],
function
(
echarts
)
{
// Thanks to
<
https
:
//github.com/Truantboy>, see: #7718.
var
option
=
{
animation
:
true
,
tooltip
:
{},
xAxis
:
{},
yAxis
:
{},
legend
:
{},
series
:
[{
type
:
'
scatter
'
,
name
:
'
data
'
,
data
:
[[
0
,
0
],
[
3005
,
3005
]],
progressiveThreshold
:
3000
,
symbol
:
'
triangle
'
,
symbolSize
:
20
}]
};
var
yBase
=
500
;
var
appendCount
=
4000
;
var
myChart
=
testHelper
.
create
(
echarts
,
'
main1
'
,
{
title
:
[
'
(1) Click btn to appendData over limit, should render successfully.
'
,
'
(2) Then test click lengend, should be normal.
'
,
'
(3) Check that grid intent should be correct.
'
],
option
:
option
,
info
:
option
.
series
,
infoKey
:
'
series
'
,
button
:
{
text
:
'
Click to appendData
'
+
appendCount
+
'
points
'
,
onClick
:
function
()
{
var
tp
=
[]
for
(
var
i
=
1
;
i
<
appendCount
;
i
++
)
{
tp
[
i
]
=
[
i
,
yBase
];
}
myChart
.
appendData
({
seriesIndex
:
0
,
data
:
tp
});
yBase
+=
1000
;
}
}
});
});
</script>
<script>
require
([
'
echarts
'
],
function
(
echarts
)
{
option
=
{
var
option
=
{
animation
:
true
,
tooltip
:
{},
xAxis
:
{},
...
...
@@ -113,22 +179,27 @@
type
:
'
scatter
'
,
data
:
[[
0
,
0
],
[
2005
,
2005
]],
progressiveThreshold
:
2000
,
symbolSize
:
function
(
val
)
{
return
Math
.
random
()
*
30
+
10
;
}
symbolSize
:
20
},
{
type
:
'
scatter
'
,
data
:
[[
100
,
1000
],
[
300
,
1005
]]
}]
};
var
chart
=
testHelper
.
create
(
echarts
,
'
main1
'
,
{
var
appendCount
=
1998
;
var
chart
=
testHelper
.
create
(
echarts
,
'
main2
'
,
{
title
:
[
'
Click to appendData, color should be the same.
'
'
Click to appendData over limit, color should be the same.
'
,
'
Check hover (emphasis), should scale normally.
'
].
join
(
'
\n
'
),
option
:
option
,
info
:
option
.
series
,
infoKey
:
'
series
'
,
button
:
{
text
:
'
Click to appendData
'
,
text
:
'
Click to appendData
'
+
appendCount
+
'
points
'
,
onClick
:
function
()
{
var
tp
=
[]
var
appendCount
=
1998
;
for
(
var
i
=
1
;
i
<
appendCount
;
i
++
)
{
tp
[
i
]
=
[
i
,
1
];
...
...
test/lib/testHelper.js
浏览文件 @
d6eca3a5
...
...
@@ -78,7 +78,7 @@
optTitle
=
optTitle
.
join
(
'
\n
'
);
}
title
.
innerHTML
=
'
<div class="test-title-inner">
'
+
testHelper
.
encodeHTML
(
optTitle
).
replace
(
'
\n
'
,
'
<br>
'
)
+
testHelper
.
encodeHTML
(
optTitle
).
replace
(
/
\n
/g
,
'
<br>
'
)
+
'
</div>
'
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录