Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
missman
incubator-echarts
提交
cccd60ba
I
incubator-echarts
项目概览
missman
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
cccd60ba
编写于
1月 11, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
(1) Fix getRawValue (2) Some tiny refactor.
上级
7159e0e3
变更
15
显示空白变更内容
内联
并排
Showing
15 changed file
with
227 addition
and
193 deletion
+227
-193
src/chart/helper/createListFromArray.js
src/chart/helper/createListFromArray.js
+1
-1
src/chart/radar/RadarSeries.js
src/chart/radar/RadarSeries.js
+3
-2
src/component/axisPointer/BaseAxisPointer.js
src/component/axisPointer/BaseAxisPointer.js
+9
-9
src/component/axisPointer/axisTrigger.js
src/component/axisPointer/axisTrigger.js
+4
-4
src/component/axisPointer/globalListener.js
src/component/axisPointer/globalListener.js
+9
-9
src/component/marker/MarkerModel.js
src/component/marker/MarkerModel.js
+2
-1
src/component/timeline/SliderTimelineModel.js
src/component/timeline/SliderTimelineModel.js
+2
-2
src/coord/axisHelper.js
src/coord/axisHelper.js
+4
-1
src/coord/axisModelCreator.js
src/coord/axisModelCreator.js
+6
-7
src/data/OrdinalMeta.js
src/data/OrdinalMeta.js
+24
-8
src/data/helper/dataProvider.js
src/data/helper/dataProvider.js
+37
-2
src/model/Series.js
src/model/Series.js
+2
-1
src/model/mixin/dataFormat.js
src/model/mixin/dataFormat.js
+111
-0
src/scale/Ordinal.js
src/scale/Ordinal.js
+7
-0
src/util/model.js
src/util/model.js
+6
-146
未找到文件。
src/chart/helper/createListFromArray.js
浏览文件 @
cccd60ba
...
...
@@ -54,7 +54,7 @@ function createListFromArray(source, seriesModel) {
if
(
firstCategoryDimIndex
==
null
)
{
firstCategoryDimIndex
=
dimIndex
;
}
dimInfo
.
ordinalMeta
=
categoryAxisModel
.
ordinalMeta
;
dimInfo
.
ordinalMeta
=
categoryAxisModel
.
getOrdinalMeta
()
;
}
if
(
dimInfo
.
otherDims
.
itemName
!=
null
)
{
hasNameEncode
=
true
;
...
...
src/chart/radar/RadarSeries.js
浏览文件 @
cccd60ba
...
...
@@ -29,13 +29,14 @@ var RadarSeries = SeriesModel.extend({
},
formatTooltip
:
function
(
dataIndex
)
{
var
value
=
this
.
getRawValue
(
dataIndex
);
var
data
=
this
.
getData
(
);
var
coordSys
=
this
.
coordinateSystem
;
var
indicatorAxes
=
coordSys
.
getIndicatorAxes
();
var
name
=
this
.
getData
().
getName
(
dataIndex
);
return
encodeHTML
(
name
===
''
?
this
.
name
:
name
)
+
'
<br/>
'
+
zrUtil
.
map
(
indicatorAxes
,
function
(
axis
,
idx
)
{
return
encodeHTML
(
axis
.
name
+
'
:
'
+
value
[
idx
]);
var
val
=
data
.
get
(
data
.
mapDimension
(
axis
.
dim
),
dataIndex
);
return
encodeHTML
(
axis
.
name
+
'
:
'
+
val
);
}).
join
(
'
<br />
'
);
},
...
...
src/component/axisPointer/BaseAxisPointer.js
浏览文件 @
cccd60ba
...
...
@@ -4,9 +4,9 @@ import * as graphic from '../../util/graphic';
import
*
as
axisPointerModelHelper
from
'
./modelHelper
'
;
import
*
as
eventTool
from
'
zrender/src/core/event
'
;
import
*
as
throttleUtil
from
'
../../util/throttle
'
;
import
*
as
modelUtil
from
'
../../util/model
'
;
import
{
makeInner
}
from
'
../../util/model
'
;
var
get
=
modelUtil
.
makeGett
er
();
var
inner
=
makeInn
er
();
var
clone
=
zrUtil
.
clone
;
var
bind
=
zrUtil
.
bind
;
...
...
@@ -193,7 +193,7 @@ BaseAxisPointer.prototype = {
createPointerEl
:
function
(
group
,
elOption
,
axisModel
,
axisPointerModel
)
{
var
pointerOption
=
elOption
.
pointer
;
if
(
pointerOption
)
{
var
pointerEl
=
get
(
group
).
pointerEl
=
new
graphic
[
pointerOption
.
type
](
var
pointerEl
=
inner
(
group
).
pointerEl
=
new
graphic
[
pointerOption
.
type
](
clone
(
elOption
.
pointer
)
);
group
.
add
(
pointerEl
);
...
...
@@ -205,7 +205,7 @@ BaseAxisPointer.prototype = {
*/
createLabelEl
:
function
(
group
,
elOption
,
axisModel
,
axisPointerModel
)
{
if
(
elOption
.
label
)
{
var
labelEl
=
get
(
group
).
labelEl
=
new
graphic
.
Rect
(
var
labelEl
=
inner
(
group
).
labelEl
=
new
graphic
.
Rect
(
clone
(
elOption
.
label
)
);
...
...
@@ -218,7 +218,7 @@ BaseAxisPointer.prototype = {
* @protected
*/
updatePointerEl
:
function
(
group
,
elOption
,
updateProps
)
{
var
pointerEl
=
get
(
group
).
pointerEl
;
var
pointerEl
=
inner
(
group
).
pointerEl
;
if
(
pointerEl
)
{
pointerEl
.
setStyle
(
elOption
.
pointer
.
style
);
updateProps
(
pointerEl
,
{
shape
:
elOption
.
pointer
.
shape
});
...
...
@@ -229,7 +229,7 @@ BaseAxisPointer.prototype = {
* @protected
*/
updateLabelEl
:
function
(
group
,
elOption
,
updateProps
,
axisPointerModel
)
{
var
labelEl
=
get
(
group
).
labelEl
;
var
labelEl
=
inner
(
group
).
labelEl
;
if
(
labelEl
)
{
labelEl
.
setStyle
(
elOption
.
label
.
style
);
updateProps
(
labelEl
,
{
...
...
@@ -345,7 +345,7 @@ BaseAxisPointer.prototype = {
handle
.
stopAnimation
();
handle
.
attr
(
getHandleTransProps
(
trans
));
get
(
handle
).
lastProp
=
null
;
inner
(
handle
).
lastProp
=
null
;
this
.
_doDispatchAxisPointer
();
},
...
...
@@ -467,8 +467,8 @@ BaseAxisPointer.prototype.constructor = BaseAxisPointer;
function
updateProps
(
animationModel
,
moveAnimation
,
el
,
props
)
{
// Animation optimize.
if
(
!
propsEqual
(
get
(
el
).
lastProp
,
props
))
{
get
(
el
).
lastProp
=
props
;
if
(
!
propsEqual
(
inner
(
el
).
lastProp
,
props
))
{
inner
(
el
).
lastProp
=
props
;
moveAnimation
?
graphic
.
updateProps
(
el
,
props
,
animationModel
)
:
(
el
.
stopAnimation
(),
el
.
attr
(
props
));
...
...
src/component/axisPointer/axisTrigger.js
浏览文件 @
cccd60ba
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
*
as
modelUtil
from
'
../../util/model
'
;
import
{
makeInner
}
from
'
../../util/model
'
;
import
*
as
modelHelper
from
'
./modelHelper
'
;
import
findPointFromSeries
from
'
./findPointFromSeries
'
;
var
each
=
zrUtil
.
each
;
var
curry
=
zrUtil
.
curry
;
var
get
=
modelUtil
.
makeGett
er
();
var
inner
=
makeInn
er
();
/**
* Basic logic: check all axis, if they do not demand show/highlight,
...
...
@@ -337,8 +337,8 @@ function dispatchHighDownActually(axesInfo, dispatchAction, api) {
var
zr
=
api
.
getZr
();
var
highDownKey
=
'
axisPointerLastHighlights
'
;
var
lastHighlights
=
get
(
zr
)[
highDownKey
]
||
{};
var
newHighlights
=
get
(
zr
)[
highDownKey
]
=
{};
var
lastHighlights
=
inner
(
zr
)[
highDownKey
]
||
{};
var
newHighlights
=
inner
(
zr
)[
highDownKey
]
=
{};
// Update highlight/downplay status according to axisPointer model.
// Build hash map and remove duplicate incidentally.
...
...
src/component/axisPointer/globalListener.js
浏览文件 @
cccd60ba
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
env
from
'
zrender/src/core/env
'
;
import
*
as
modelUtil
from
'
../../util/model
'
;
import
{
makeInner
}
from
'
../../util/model
'
;
var
get
=
modelUtil
.
makeGett
er
();
var
inner
=
makeInn
er
();
var
each
=
zrUtil
.
each
;
/**
...
...
@@ -18,20 +18,20 @@ export function register(key, api, handler) {
}
var
zr
=
api
.
getZr
();
get
(
zr
).
records
||
(
get
(
zr
).
records
=
{});
inner
(
zr
).
records
||
(
inner
(
zr
).
records
=
{});
initGlobalListeners
(
zr
,
api
);
var
record
=
get
(
zr
).
records
[
key
]
||
(
get
(
zr
).
records
[
key
]
=
{});
var
record
=
inner
(
zr
).
records
[
key
]
||
(
inner
(
zr
).
records
[
key
]
=
{});
record
.
handler
=
handler
;
}
function
initGlobalListeners
(
zr
,
api
)
{
if
(
get
(
zr
).
initialized
)
{
if
(
inner
(
zr
).
initialized
)
{
return
;
}
get
(
zr
).
initialized
=
true
;
inner
(
zr
).
initialized
=
true
;
useHandler
(
'
click
'
,
zrUtil
.
curry
(
doEnter
,
'
click
'
));
useHandler
(
'
mousemove
'
,
zrUtil
.
curry
(
doEnter
,
'
mousemove
'
));
...
...
@@ -42,7 +42,7 @@ function initGlobalListeners(zr, api) {
zr
.
on
(
eventType
,
function
(
e
)
{
var
dis
=
makeDispatchAction
(
api
);
each
(
get
(
zr
).
records
,
function
(
record
)
{
each
(
inner
(
zr
).
records
,
function
(
record
)
{
record
&&
cb
(
record
,
e
,
dis
.
dispatchAction
);
});
...
...
@@ -112,8 +112,8 @@ export function unregister(key, api) {
return
;
}
var
zr
=
api
.
getZr
();
var
record
=
(
get
(
zr
).
records
||
{})[
key
];
var
record
=
(
inner
(
zr
).
records
||
{})[
key
];
if
(
record
)
{
get
(
zr
).
records
[
key
]
=
null
;
inner
(
zr
).
records
[
key
]
=
null
;
}
}
src/component/marker/MarkerModel.js
浏览文件 @
cccd60ba
...
...
@@ -4,6 +4,7 @@ import * as zrUtil from 'zrender/src/core/util';
import
env
from
'
zrender/src/core/env
'
;
import
*
as
modelUtil
from
'
../../util/model
'
;
import
*
as
formatUtil
from
'
../../util/format
'
;
import
dataFormatMixin
from
'
../../model/mixin/dataFormat
'
;
var
addCommas
=
formatUtil
.
addCommas
;
var
encodeHTML
=
formatUtil
.
encodeHTML
;
...
...
@@ -125,6 +126,6 @@ var MarkerModel = echarts.extendComponentModel({
}
});
zrUtil
.
mixin
(
MarkerModel
,
modelUtil
.
dataFormatMixin
);
zrUtil
.
mixin
(
MarkerModel
,
dataFormatMixin
);
export
default
MarkerModel
;
\ No newline at end of file
src/component/timeline/SliderTimelineModel.js
浏览文件 @
cccd60ba
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
TimelineModel
from
'
./TimelineModel
'
;
import
*
as
modelUtil
from
'
../../util/model
'
;
import
dataFormatMixin
from
'
../../model/mixin/dataFormat
'
;
var
SliderTimelineModel
=
TimelineModel
.
extend
({
...
...
@@ -98,6 +98,6 @@ var SliderTimelineModel = TimelineModel.extend({
});
zrUtil
.
mixin
(
SliderTimelineModel
,
modelUtil
.
dataFormatMixin
);
zrUtil
.
mixin
(
SliderTimelineModel
,
dataFormatMixin
);
export
default
SliderTimelineModel
;
\ No newline at end of file
src/coord/axisHelper.js
浏览文件 @
cccd60ba
...
...
@@ -220,7 +220,10 @@ export function createScaleByModel(model, axisType) {
// Buildin scale
case
'
category
'
:
return
new
OrdinalScale
(
model
.
ordinalMeta
,
[
Infinity
,
-
Infinity
]
model
.
getOrdinalMeta
?
model
.
getOrdinalMeta
()
:
model
.
getCategories
(),
[
Infinity
,
-
Infinity
]
);
case
'
value
'
:
return
new
IntervalScale
();
...
...
src/coord/axisModelCreator.js
浏览文件 @
cccd60ba
...
...
@@ -29,11 +29,6 @@ export default function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraD
*/
type
:
axisName
+
'
Axis.
'
+
axisType
,
/**
* @readOnly
*/
ordinalMeta
:
null
,
mergeDefaultAndTheme
:
function
(
option
,
ecModel
)
{
var
layoutMode
=
this
.
layoutMode
;
var
inputPositionParams
=
layoutMode
...
...
@@ -56,7 +51,7 @@ export default function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraD
optionUpdated
:
function
()
{
var
thisOption
=
this
.
option
;
if
(
thisOption
.
type
===
'
category
'
)
{
this
.
ordinalMeta
=
new
OrdinalMeta
(
this
);
this
.
__ordinalMeta
=
OrdinalMeta
.
createByAxisModel
(
this
);
}
},
...
...
@@ -68,10 +63,14 @@ export default function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraD
// FIXME
// warning if called before all of 'getInitailData' finished.
if
(
this
.
option
.
type
===
'
category
'
)
{
return
this
.
ordinalMeta
.
categories
;
return
this
.
__
ordinalMeta
.
categories
;
}
},
getOrdinalMeta
:
function
()
{
return
this
.
__ordinalMeta
;
},
defaultOption
:
zrUtil
.
mergeAll
(
[
{},
...
...
src/data/OrdinalMeta.js
浏览文件 @
cccd60ba
...
...
@@ -2,30 +2,30 @@ import {createHashMap, isObject, map} from 'zrender/src/core/util';
/**
* @constructor
* @param {module:echart/model/Model} axisModel
* @param {Object} [opt]
* @param {Object} [opt.categories=[]]
* @param {Object} [opt.needCollect=false]
* @param {Object} [opt.preventDeduplication=false]
*/
function
OrdinalMeta
(
axisModel
)
{
var
data
=
axisModel
.
option
.
data
;
var
categories
=
data
&&
map
(
data
,
getName
);
function
OrdinalMeta
(
opt
)
{
/**
* @readOnly
* @type {Array.<string>}
*/
this
.
categories
=
categories
||
[];
this
.
categories
=
opt
.
categories
||
[];
/**
* @private
* @type {boolean}
*/
this
.
_needCollect
=
!
categories
;
this
.
_needCollect
=
opt
.
needCollect
;
/**
* @private
* @type {boolean}
*/
this
.
_preventDeduplication
=
axisModel
.
get
(
'
dedplication
'
,
true
)
===
false
;
this
.
_preventDeduplication
=
opt
.
preventDeduplication
;
/**
* @private
...
...
@@ -34,6 +34,22 @@ function OrdinalMeta(axisModel) {
this
.
_map
;
}
/**
* @param {module:echarts/model/Model} axisModel
* @return {module:echarts/data/OrdinalMeta}
*/
OrdinalMeta
.
createByAxisModel
=
function
(
axisModel
)
{
var
option
=
axisModel
.
option
;
var
data
=
option
.
data
;
var
categories
=
data
&&
map
(
data
,
getName
);
return
new
OrdinalMeta
({
categories
:
categories
,
needCollect
:
!
categories
,
preventDeduplication
:
option
.
dedplication
===
false
});
};
var
proto
=
OrdinalMeta
.
prototype
;
/**
...
...
src/data/helper/dataProvider.js
浏览文件 @
cccd60ba
...
...
@@ -3,11 +3,16 @@
// merge with defaultDimValueGetter?
import
{
__DEV__
}
from
'
../../config
'
;
import
{
isTypedArray
,
extend
,
assert
,
each
}
from
'
zrender/src/core/util
'
;
import
{
isTypedArray
,
extend
,
assert
,
each
,
isObject
,
isArray
}
from
'
zrender/src/core/util
'
;
import
{
getDataItemValue
,
isDataItemOption
}
from
'
../../util/model
'
;
import
{
parseDate
}
from
'
../../util/number
'
;
import
Source
from
'
../Source
'
;
import
{
SOURCE_FORMAT_TYPED_ARRAY
,
SOURCE_FORMAT_ARRAY_ROWS
}
from
'
./sourceHelper
'
;
import
{
SOURCE_FORMAT_TYPED_ARRAY
,
SOURCE_FORMAT_ARRAY_ROWS
,
SOURCE_FORMAT_ORIGINAL
,
SOURCE_FORMAT_OBJECT_ROWS
}
from
'
./sourceHelper
'
;
/**
* If normal array used, mutable chunk size is supported.
...
...
@@ -250,3 +255,33 @@ function converDataValue(value, dimInfo) {
return
(
value
==
null
||
value
===
''
)
?
NaN
:
+
value
;
// If string (like '-'), using '+' parse to NaN
}
// ??? FIXME can these logic be more neat: getRawValue, getRawDataItem,
// Consider persistent.
/**
* @return {Array.<number>|number} can be null/undefined.
*/
export
function
getRawValueForModel
(
model
,
dataIndex
,
dataType
)
{
var
data
=
model
.
getData
(
dataType
);
// Consider data may be not persistent.
var
dataItem
=
data
.
getRawDataItem
(
dataIndex
);
var
sourceFormat
=
data
.
getProvider
().
getSource
().
sourceFormat
;
if
(
dataItem
==
null
)
{
return
;
}
if
(
sourceFormat
===
SOURCE_FORMAT_ORIGINAL
)
{
return
(
isObject
(
dataItem
)
&&
!
isArray
(
dataItem
))
?
dataItem
.
value
:
dataItem
;
}
else
if
(
sourceFormat
===
SOURCE_FORMAT_OBJECT_ROWS
)
{
var
item
=
[];
var
dims
=
data
.
dimensions
;
for
(
var
i
=
0
;
i
<
dims
.
length
;
i
++
)
{
item
.
push
(
dataItem
[
dims
[
i
]]);
}
return
item
;
}
else
{
return
dataItem
;
}
}
src/model/Series.js
浏览文件 @
cccd60ba
...
...
@@ -10,6 +10,7 @@ import {
import
*
as
modelUtil
from
'
../util/model
'
;
import
ComponentModel
from
'
./Component
'
;
import
colorPaletteMixin
from
'
./mixin/colorPalette
'
;
import
dataFormatMixin
from
'
../model/mixin/dataFormat
'
;
import
{
getLayoutParams
,
mergeLayoutParam
...
...
@@ -409,7 +410,7 @@ var SeriesModel = ComponentModel.extend({
});
zrUtil
.
mixin
(
SeriesModel
,
modelUtil
.
dataFormatMixin
);
zrUtil
.
mixin
(
SeriesModel
,
dataFormatMixin
);
zrUtil
.
mixin
(
SeriesModel
,
colorPaletteMixin
);
/**
...
...
src/model/mixin/dataFormat.js
0 → 100644
浏览文件 @
cccd60ba
import
{
getRawValueForModel
}
from
'
../../data/helper/dataProvider
'
;
import
{
getTooltipMarker
,
formatTpl
}
from
'
../../util/format
'
;
var
DIMENSION_LABEL_REG
=
/
\{
@
(
.+
?)\}
/g
;
// PENDING A little ugly
export
default
{
/**
* Get params for formatter
* @param {number} dataIndex
* @param {string} [dataType]
* @return {Object}
*/
getDataParams
:
function
(
dataIndex
,
dataType
)
{
var
data
=
this
.
getData
(
dataType
);
var
rawValue
=
this
.
getRawValue
(
dataIndex
,
dataType
);
var
rawDataIndex
=
data
.
getRawIndex
(
dataIndex
);
var
name
=
data
.
getName
(
dataIndex
,
true
);
var
itemOpt
=
data
.
getRawDataItem
(
dataIndex
);
var
color
=
data
.
getItemVisual
(
dataIndex
,
'
color
'
);
return
{
componentType
:
this
.
mainType
,
componentSubType
:
this
.
subType
,
seriesType
:
this
.
mainType
===
'
series
'
?
this
.
subType
:
null
,
seriesIndex
:
this
.
seriesIndex
,
seriesId
:
this
.
id
,
seriesName
:
this
.
name
,
name
:
name
,
dataIndex
:
rawDataIndex
,
data
:
itemOpt
,
dataType
:
dataType
,
value
:
rawValue
,
color
:
color
,
marker
:
getTooltipMarker
(
color
),
// Param name list for mapping `a`, `b`, `c`, `d`, `e`
$vars
:
[
'
seriesName
'
,
'
name
'
,
'
value
'
]
};
},
/**
* Format label
* @param {number} dataIndex
* @param {string} [status='normal'] 'normal' or 'emphasis'
* @param {string} [dataType]
* @param {number} [dimIndex]
* @param {string} [labelProp='label']
* @return {string} If not formatter, return null/undefined
*/
getFormattedLabel
:
function
(
dataIndex
,
status
,
dataType
,
dimIndex
,
labelProp
)
{
status
=
status
||
'
normal
'
;
var
data
=
this
.
getData
(
dataType
);
var
itemModel
=
data
.
getItemModel
(
dataIndex
);
var
params
=
this
.
getDataParams
(
dataIndex
,
dataType
);
if
(
dimIndex
!=
null
&&
(
params
.
value
instanceof
Array
))
{
params
.
value
=
params
.
value
[
dimIndex
];
}
var
formatter
=
itemModel
.
get
(
status
===
'
normal
'
?
[
labelProp
||
'
label
'
,
'
formatter
'
]
:
[
status
,
labelProp
||
'
label
'
,
'
formatter
'
]
);
if
(
typeof
formatter
===
'
function
'
)
{
params
.
status
=
status
;
return
formatter
(
params
);
}
else
if
(
typeof
formatter
===
'
string
'
)
{
var
str
=
formatTpl
(
formatter
,
params
);
// Support 'aaa{@[3]}bbb{@product}ccc'.
// Do not support '}' in dim name util have to.
return
str
.
replace
(
DIMENSION_LABEL_REG
,
function
(
origin
,
dimName
)
{
var
len
=
dimName
.
length
;
if
(
dimName
.
charAt
(
0
)
===
'
[
'
&&
dimName
.
charAt
(
len
-
1
)
===
'
]
'
)
{
var
dimIndex
=
+
dimName
.
slice
(
1
,
len
-
1
);
// Also: '[]' => 0
if
(
!
isNaN
(
dimIndex
))
{
dimName
=
data
.
dimensions
[
dimIndex
];
}
}
return
dimName
?
data
.
get
(
dimName
,
dataIndex
,
true
)
:
origin
;
});
}
},
/**
* ??? TODO remove?
* @deprecated
* Get raw value in option
* @param {number} idx
* @param {string} [dataType]
* @return {Array|number|string}
*/
getRawValue
:
function
(
idx
,
dataType
)
{
return
getRawValueForModel
(
this
,
idx
,
dataType
);
},
/**
* Should be implemented.
* @param {number} dataIndex
* @param {boolean} [multipleSeries=false]
* @param {number} [dataType]
* @return {string} tooltip string
*/
formatTooltip
:
function
()
{
// Empty function
}
};
src/scale/Ordinal.js
浏览文件 @
cccd60ba
...
...
@@ -9,6 +9,7 @@
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
Scale
from
'
./Scale
'
;
import
OrdinalMeta
from
'
../data/OrdinalMeta
'
;
var
scaleProto
=
Scale
.
prototype
;
...
...
@@ -16,7 +17,13 @@ var OrdinalScale = Scale.extend({
type
:
'
ordinal
'
,
/**
* @param {module:echarts/data/OrdianlMeta|Array.<string>} ordinalMeta
*/
init
:
function
(
ordinalMeta
,
extent
)
{
if
(
!
(
ordinalMeta
instanceof
OrdinalMeta
))
{
ordinalMeta
=
new
OrdinalMeta
({
categories
:
ordinalMeta
});
}
this
.
_ordinalMeta
=
ordinalMeta
;
this
.
_extent
=
extent
||
[
0
,
ordinalMeta
.
categories
.
length
-
1
];
},
...
...
src/util/model.js
浏览文件 @
cccd60ba
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
*
as
formatUtil
from
'
./format
'
;
var
each
=
zrUtil
.
each
;
var
isObject
=
zrUtil
.
isObject
;
var
DIMENSION_LABEL_REG
=
/
\{
@
(
.+
?)\}
/g
;
/**
* name may be displayed on screen, so use '-'.
* But we should make sure it is not duplicated
...
...
@@ -98,138 +95,6 @@ export function isDataItemOption(dataItem) {
// && !(dataItem[0] && isObject(dataItem[0]) && !(dataItem[0] instanceof Array));
}
// /**
// * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data.
// * @param {module:echarts/data/List} data
// * @param {Object} opt
// * @param {string} [opt.seriesIndex]
// * @param {Object} [opt.name]
// * @param {Object} [opt.mainType]
// * @param {Object} [opt.subType]
// */
// export function createDataFormatModel(data, opt) {
// var model = new Model();
// zrUtil.mixin(model, dataFormatMixin);
// model.seriesIndex = opt.seriesIndex;
// model.name = opt.name || '';
// model.mainType = opt.mainType;
// model.subType = opt.subType;
// model.getData = function () {
// return data;
// };
// return model;
// }
// PENDING A little ugly
export
var
dataFormatMixin
=
{
/**
* Get params for formatter
* @param {number} dataIndex
* @param {string} [dataType]
* @return {Object}
*/
getDataParams
:
function
(
dataIndex
,
dataType
)
{
var
data
=
this
.
getData
(
dataType
);
var
rawValue
=
this
.
getRawValue
(
dataIndex
,
dataType
);
var
rawDataIndex
=
data
.
getRawIndex
(
dataIndex
);
var
name
=
data
.
getName
(
dataIndex
,
true
);
var
itemOpt
=
data
.
getRawDataItem
(
dataIndex
);
var
color
=
data
.
getItemVisual
(
dataIndex
,
'
color
'
);
return
{
componentType
:
this
.
mainType
,
componentSubType
:
this
.
subType
,
seriesType
:
this
.
mainType
===
'
series
'
?
this
.
subType
:
null
,
seriesIndex
:
this
.
seriesIndex
,
seriesId
:
this
.
id
,
seriesName
:
this
.
name
,
name
:
name
,
dataIndex
:
rawDataIndex
,
data
:
itemOpt
,
dataType
:
dataType
,
value
:
rawValue
,
color
:
color
,
marker
:
formatUtil
.
getTooltipMarker
(
color
),
// Param name list for mapping `a`, `b`, `c`, `d`, `e`
$vars
:
[
'
seriesName
'
,
'
name
'
,
'
value
'
]
};
},
/**
* Format label
* @param {number} dataIndex
* @param {string} [status='normal'] 'normal' or 'emphasis'
* @param {string} [dataType]
* @param {number} [dimIndex]
* @param {string} [labelProp='label']
* @return {string} If not formatter, return null/undefined
*/
getFormattedLabel
:
function
(
dataIndex
,
status
,
dataType
,
dimIndex
,
labelProp
)
{
status
=
status
||
'
normal
'
;
var
data
=
this
.
getData
(
dataType
);
var
itemModel
=
data
.
getItemModel
(
dataIndex
);
var
params
=
this
.
getDataParams
(
dataIndex
,
dataType
);
if
(
dimIndex
!=
null
&&
(
params
.
value
instanceof
Array
))
{
params
.
value
=
params
.
value
[
dimIndex
];
}
var
formatter
=
itemModel
.
get
(
status
===
'
normal
'
?
[
labelProp
||
'
label
'
,
'
formatter
'
]
:
[
status
,
labelProp
||
'
label
'
,
'
formatter
'
]
);
if
(
typeof
formatter
===
'
function
'
)
{
params
.
status
=
status
;
return
formatter
(
params
);
}
else
if
(
typeof
formatter
===
'
string
'
)
{
var
str
=
formatUtil
.
formatTpl
(
formatter
,
params
);
// Support 'aaa{@[3]}bbb{@product}ccc'.
// Do not support '}' in dim name util have to.
return
str
.
replace
(
DIMENSION_LABEL_REG
,
function
(
origin
,
dimName
)
{
var
len
=
dimName
.
length
;
if
(
dimName
.
charAt
(
0
)
===
'
[
'
&&
dimName
.
charAt
(
len
-
1
)
===
'
]
'
)
{
var
dimIndex
=
+
dimName
.
slice
(
1
,
len
-
1
);
// Also: '[]' => 0
if
(
!
isNaN
(
dimIndex
))
{
dimName
=
data
.
dimensions
[
dimIndex
];
}
}
return
dimName
?
data
.
get
(
dimName
,
dataIndex
,
true
)
:
origin
;
});
}
},
/**
* Get raw value in option
* @param {number} idx
* @param {string} [dataType]
* @return {Array|number|string}
*/
getRawValue
:
function
(
idx
,
dataType
)
{
var
data
=
this
.
getData
(
dataType
);
var
dataItem
=
data
.
getRawDataItem
(
idx
);
// ??? check: source format.
if
(
dataItem
!=
null
)
{
return
(
isObject
(
dataItem
)
&&
!
(
dataItem
instanceof
Array
))
?
dataItem
.
value
:
dataItem
;
}
},
/**
* Should be implemented.
* @param {number} dataIndex
* @param {boolean} [multipleSeries=false]
* @param {number} [dataType]
* @return {string} tooltip string
*/
formatTooltip
:
zrUtil
.
noop
};
/**
* Mapping to exists for merge.
*
...
...
@@ -516,18 +381,13 @@ export function queryDataIndex(data, payload) {
*
* @return {Function}
*/
export
var
makeInner
=
(
function
()
{
var
index
=
0
;
return
function
()
{
var
key
=
'
__
\
0zr_inner_
'
+
index
++
;
export
function
makeInner
()
{
var
key
=
'
__
\
0ec_inner_
'
+
innerUniqueIndex
++
;
return
function
(
hostObj
)
{
return
hostObj
[
key
]
||
(
hostObj
[
key
]
=
{});
};
};
})();
// ??? remove
export
var
makeGetter
=
makeInner
;
}
var
innerUniqueIndex
=
0
;
/**
* @param {module:echarts/model/Global} ecModel
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录