Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alon@wen
echarts
提交
76922b98
E
echarts
项目概览
alon@wen
/
echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
76922b98
编写于
6月 02, 2016
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Color palette enhancement
上级
802b34ed
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
64 addition
and
14 deletion
+64
-14
src/echarts.js
src/echarts.js
+4
-0
src/model/Global.js
src/model/Global.js
+2
-0
src/model/Series.js
src/model/Series.js
+12
-0
src/model/mixin/colorPalette.js
src/model/mixin/colorPalette.js
+29
-0
src/visual/dataColor.js
src/visual/dataColor.js
+14
-10
src/visual/seriesColor.js
src/visual/seriesColor.js
+3
-4
未找到文件。
src/echarts.js
浏览文件 @
76922b98
...
...
@@ -783,6 +783,10 @@ define(function (require) {
* @private
*/
function
doVisualCoding
(
ecModel
,
payload
)
{
ecModel
.
clearColorPalette
();
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
seriesModel
.
clearColorPalette
();
});
each
(
VISUAL_CODING_STAGES
,
function
(
stage
)
{
each
(
visualCodingFuncs
[
stage
]
||
[],
function
(
visualCoding
)
{
visualCoding
(
ecModel
,
payload
);
...
...
src/model/Global.js
浏览文件 @
76922b98
...
...
@@ -748,5 +748,7 @@ define(function (require) {
}
}
zrUtil
.
mixin
(
GlobalModel
,
require
(
'
./mixin/colorPalette
'
));
return
GlobalModel
;
});
\ No newline at end of file
src/model/Series.js
浏览文件 @
76922b98
...
...
@@ -6,6 +6,7 @@ define(function(require) {
var
formatUtil
=
require
(
'
../util/format
'
);
var
modelUtil
=
require
(
'
../util/model
'
);
var
ComponentModel
=
require
(
'
./Component
'
);
var
colorPaletteMixin
=
require
(
'
./mixin/colorPalette
'
);
var
encodeHTML
=
formatUtil
.
encodeHTML
;
var
addCommas
=
formatUtil
.
addCommas
;
...
...
@@ -219,10 +220,21 @@ define(function(require) {
this
.
_data
=
this
.
_dataBeforeProcessed
.
cloneShallow
();
},
getColorFromPalette
:
function
(
name
,
scope
)
{
var
ecModel
=
this
.
ecModel
;
// PENDING
var
color
=
colorPaletteMixin
.
getColorFromPalette
.
call
(
this
,
name
,
scope
);
if
(
!
color
)
{
color
=
ecModel
.
getColorFromPalette
(
name
,
scope
);
}
return
color
;
},
getAxisTooltipDataIndex
:
null
});
zrUtil
.
mixin
(
SeriesModel
,
modelUtil
.
dataFormatMixin
);
zrUtil
.
mixin
(
SeriesModel
,
colorPaletteMixin
);
return
SeriesModel
;
});
\ No newline at end of file
src/model/mixin/colorPalette.js
0 → 100644
浏览文件 @
76922b98
define
(
function
()
{
return
{
clearColorPalette
:
function
()
{
this
.
_colorIdx
=
0
;
this
.
_colorNameMap
=
{};
},
getColorFromPalette
:
function
(
name
,
scope
)
{
scope
=
scope
||
this
;
var
colorIdx
=
scope
.
_colorIdx
||
0
;
var
colorNameMap
=
scope
.
_colorNameMap
||
(
scope
.
_colorNameMap
=
{});
if
(
colorNameMap
[
name
])
{
return
colorNameMap
[
name
];
}
var
colorPalette
=
this
.
get
(
'
color
'
,
true
)
||
[];
if
(
!
colorPalette
.
length
)
{
return
;
}
var
color
=
colorPalette
[
colorIdx
];
if
(
name
)
{
colorNameMap
[
name
]
=
color
;
}
scope
.
_colorIdx
=
(
colorIdx
+
1
)
%
colorPalette
.
length
;
return
color
;
}
};
});
\ No newline at end of file
src/visual/dataColor.js
浏览文件 @
76922b98
...
...
@@ -2,25 +2,30 @@
define
(
function
(
require
)
{
return
function
(
seriesType
,
ecModel
)
{
var
globalColorList
=
ecModel
.
get
(
'
color
'
);
var
offset
=
0
;
// Pie and funnel may use diferrent scope
var
paletteScope
=
{}
;
ecModel
.
eachRawSeriesByType
(
seriesType
,
function
(
seriesModel
)
{
var
colorList
=
seriesModel
.
get
(
'
color
'
,
true
);
var
dataAll
=
seriesModel
.
getRawData
();
var
idxMap
=
{};
if
(
!
ecModel
.
isSeriesFiltered
(
seriesModel
))
{
var
data
=
seriesModel
.
getData
();
data
.
each
(
function
(
idx
)
{
var
itemModel
=
data
.
getItemModel
(
idx
);
var
rawIdx
=
data
.
getRawIndex
(
idx
);
idxMap
[
rawIdx
]
=
idx
;
});
dataAll
.
each
(
function
(
rawIdx
)
{
// FIXME Performance
var
itemModel
=
dataAll
.
getItemModel
(
rawIdx
);
var
filteredIdx
=
idxMap
[
rawIdx
];
// If series.itemStyle.normal.color is a function. itemVisual may be encoded
var
singleDataColor
=
data
.
getItemVisual
(
idx
,
'
color
'
,
true
);
var
singleDataColor
=
data
.
getItemVisual
(
filteredIdx
,
'
color
'
,
true
);
if
(
!
singleDataColor
)
{
var
paletteColor
=
colorList
?
colorList
[
rawIdx
%
colorList
.
length
]
:
globalColorList
[(
rawIdx
+
offset
)
%
globalColorList
.
length
];
var
color
=
itemModel
.
get
(
'
itemStyle.normal.color
'
)
||
paletteColor
;
var
color
=
itemModel
.
get
(
'
itemStyle.normal.color
'
)
||
seriesModel
.
getColorFromPalette
(
dataAll
.
getName
(
rawIdx
),
paletteScope
);
// Legend may use the visual info in data before processed
dataAll
.
setItemVisual
(
rawIdx
,
'
color
'
,
color
);
data
.
setItemVisual
(
i
dx
,
'
color
'
,
color
);
data
.
setItemVisual
(
filteredI
dx
,
'
color
'
,
color
);
}
else
{
// Set data all color for legend
...
...
@@ -28,7 +33,6 @@ define(function (require) {
}
});
}
offset
+=
dataAll
.
count
();
});
};
});
\ No newline at end of file
src/visual/seriesColor.js
浏览文件 @
76922b98
...
...
@@ -3,10 +3,9 @@ define(function (require) {
return
function
(
seriesType
,
styleType
,
ecModel
)
{
function
encodeColor
(
seriesModel
)
{
var
colorAccessPath
=
[
styleType
,
'
normal
'
,
'
color
'
];
var
colorList
=
ecModel
.
get
(
'
color
'
);
var
data
=
seriesModel
.
getData
();
var
color
=
seriesModel
.
get
(
colorAccessPath
)
// Set in itemStyle
||
colorList
[
seriesModel
.
seriesIndex
%
colorList
.
length
]
;
// Default color
||
seriesModel
.
getColorFromPalette
(
seriesModel
.
get
(
'
name
'
))
;
// Default color
// FIXME Set color function or use the platte color
data
.
setVisual
(
'
color
'
,
color
);
...
...
@@ -30,7 +29,7 @@ define(function (require) {
});
}
}
seriesType
?
ecModel
.
eachSeriesByType
(
seriesType
,
encodeColor
)
:
ecModel
.
eachSeries
(
encodeColor
);
seriesType
?
ecModel
.
each
Raw
SeriesByType
(
seriesType
,
encodeColor
)
:
ecModel
.
each
Raw
Series
(
encodeColor
);
};
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录