Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
6b2ec74a
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,发现更多精彩内容 >>
提交
6b2ec74a
编写于
2月 26, 2020
作者:
1
100pah
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add axis model creator type
上级
786ae682
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
89 addition
and
87 deletion
+89
-87
src/component/gridSimple.ts
src/component/gridSimple.ts
+1
-0
src/component/legend.ts
src/component/legend.ts
+2
-2
src/component/tooltip/TooltipHTMLContent.ts
src/component/tooltip/TooltipHTMLContent.ts
+3
-1
src/component/visualMap/typeDefaulter.ts
src/component/visualMap/typeDefaulter.ts
+2
-2
src/coord/CoordinateSystem.ts
src/coord/CoordinateSystem.ts
+1
-1
src/coord/axisCommonTypes.ts
src/coord/axisCommonTypes.ts
+3
-1
src/coord/axisDefault.ts
src/coord/axisDefault.ts
+4
-4
src/coord/axisModelCreator.ts
src/coord/axisModelCreator.ts
+49
-46
src/coord/cartesian/AxisModel.ts
src/coord/cartesian/AxisModel.ts
+2
-8
src/coord/cartesian/GridModel.ts
src/coord/cartesian/GridModel.ts
+5
-2
src/coord/parallel/AxisModel.ts
src/coord/parallel/AxisModel.ts
+1
-5
src/coord/polar/AxisModel.ts
src/coord/polar/AxisModel.ts
+2
-7
src/coord/radar/RadarModel.ts
src/coord/radar/RadarModel.ts
+1
-1
src/coord/single/AxisModel.ts
src/coord/single/AxisModel.ts
+1
-5
src/helper.ts
src/helper.ts
+10
-2
src/model/Component.ts
src/model/Component.ts
+2
-0
未找到文件。
src/component/gridSimple.ts
浏览文件 @
6b2ec74a
...
...
@@ -24,6 +24,7 @@ import * as zrUtil from 'zrender/src/core/util';
import
*
as
graphic
from
'
../util/graphic
'
;
import
'
../coord/cartesian/Grid
'
;
import
'
../coord/cartesian/GridModel
'
;
import
'
./axis
'
;
// Grid view
...
...
src/component/legend.ts
浏览文件 @
6b2ec74a
...
...
@@ -26,12 +26,12 @@ import './legend/legendAction';
import
'
./legend/LegendView
'
;
import
legendFilter
from
'
./legend/legendFilter
'
;
import
Component
,
{
ComponentModelConstructor
}
from
'
../model/Component
'
;
import
Component
from
'
../model/Component
'
;
// Series Filter
echarts
.
registerProcessor
(
echarts
.
PRIORITY
.
PROCESSOR
.
SERIES_FILTER
,
legendFilter
);
(
Component
as
ComponentModelConstructor
)
.
registerSubTypeDefaulter
(
'
legend
'
,
function
()
{
Component
.
registerSubTypeDefaulter
(
'
legend
'
,
function
()
{
// Default 'plain' when no type specified.
return
'
plain
'
;
});
src/component/tooltip/TooltipHTMLContent.ts
浏览文件 @
6b2ec74a
...
...
@@ -28,6 +28,8 @@ import { ZRenderType } from 'zrender/src/zrender';
import
{
TooltipOption
}
from
'
./TooltipModel
'
;
import
Model
from
'
../../model/Model
'
;
import
{
ZRRawEvent
}
from
'
zrender/src/core/types
'
;
import
CanvasPainter
from
'
zrender/src/canvas/Painter
'
;
import
SVGPainter
from
'
zrender/src/svg/Painter
'
;
var
each
=
zrUtil
.
each
;
var
toCamelCase
=
formatUtil
.
toCamelCase
;
...
...
@@ -134,7 +136,7 @@ function makeStyleCoord(out: number[], zr: ZRenderType, appendToBody: boolean, z
// xy should be based on canvas root. But tooltipContent is
// the sibling of canvas root. So padding of ec container
// should be considered here.
var
viewportRootOffset
=
zrPainter
&&
zrPainter
.
getViewportRootOffset
();
var
viewportRootOffset
=
zrPainter
&&
(
zrPainter
as
CanvasPainter
|
SVGPainter
)
.
getViewportRootOffset
();
if
(
viewportRootOffset
)
{
out
[
0
]
+=
viewportRootOffset
.
offsetLeft
;
out
[
1
]
+=
viewportRootOffset
.
offsetTop
;
...
...
src/component/visualMap/typeDefaulter.ts
浏览文件 @
6b2ec74a
...
...
@@ -17,12 +17,12 @@
* under the License.
*/
import
Component
,
{
ComponentModelConstructor
}
from
'
../../model/Component
'
;
import
Component
from
'
../../model/Component
'
;
import
{
VisualMapOption
}
from
'
./VisualMapModel
'
;
import
{
PiecewiseVisualMapOption
}
from
'
./PiecewiseModel
'
;
import
{
ContinousVisualMapOption
}
from
'
./ContinuousModel
'
;
(
Component
as
ComponentModelConstructor
)
.
registerSubTypeDefaulter
(
Component
.
registerSubTypeDefaulter
(
'
visualMap
'
,
function
(
option
:
VisualMapOption
)
{
// Compatible with ec2, when splitNumber === 0, continuous visualMap will be used.
return
(
...
...
src/coord/CoordinateSystem.ts
浏览文件 @
6b2ec74a
...
...
@@ -52,7 +52,7 @@ export interface CoordinateSystemMaster {
model
?:
Model
;
update
(
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
):
void
;
update
?:
(
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
)
=>
void
;
// This methods is also responsible for determine whether this
// coodinate system is applicable to the given `finder`.
...
...
src/coord/axisCommonTypes.ts
浏览文件 @
6b2ec74a
...
...
@@ -24,7 +24,9 @@ import {
import
{
Dictionary
}
from
'
zrender/src/core/types
'
;
export
type
OptionAxisType
=
'
category
'
|
'
value
'
|
'
time
'
|
'
log
'
;
export
var
AXIS_TYPES
=
{
value
:
1
,
category
:
1
,
time
:
1
,
log
:
1
}
as
const
;
export
type
OptionAxisType
=
keyof
typeof
AXIS_TYPES
;
export
interface
AxisBaseOption
extends
ComponentOption
{
type
?:
OptionAxisType
;
...
...
src/coord/axisDefault.ts
浏览文件 @
6b2ec74a
...
...
@@ -174,8 +174,8 @@ var logAxis: AxisBaseOption = zrUtil.defaults({
export
default
{
category
Axis
:
categoryAxis
,
value
Axis
:
valueAxis
,
time
Axis
:
timeAxis
,
log
Axis
:
logAxis
category
:
categoryAxis
,
value
:
valueAxis
,
time
:
timeAxis
,
log
:
logAxis
};
src/coord/axisModelCreator.ts
浏览文件 @
6b2ec74a
...
...
@@ -17,8 +17,6 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
axisDefault
from
'
./axisDefault
'
;
import
ComponentModel
from
'
../model/Component
'
;
...
...
@@ -28,95 +26,100 @@ import {
fetchLayoutMode
}
from
'
../util/layout
'
;
import
OrdinalMeta
from
'
../data/OrdinalMeta
'
;
import
{
DimensionName
,
ComponentOption
}
from
'
../util/types
'
;
import
{
OptionAxisType
}
from
'
./axisCommonTypes
'
;
import
{
DimensionName
,
BoxLayoutOptionMixin
,
OrdinalRawValue
}
from
'
../util/types
'
;
import
{
AxisBaseOption
,
AXIS_TYPES
}
from
'
./axisCommonTypes
'
;
import
GlobalModel
from
'
../model/Global
'
;
// FIXME axisType is fixed ?
var
AXIS_TYPES
=
[
'
value
'
,
'
category
'
,
'
time
'
,
'
log
'
];
type
Constructor
<
T
>
=
new
(...
args
:
any
[])
=>
T
;
/**
* Generate sub axis model class
* @param axisName 'x' 'y' 'radius' 'angle' 'parallel'
* @param {module:echarts/model/Component} BaseAxisModelClass
* @param {Function} axisTypeDefaulter
* @param {Object} [extraDefaultOption]
* @param axisName 'x' 'y' 'radius' 'angle' 'parallel' ...
*/
export
default
function
(
export
default
function
<
AxisOptionT
extends
AxisBaseOption
,
AxisModelCtor
extends
Constructor
<
ComponentModel
<
AxisOptionT
>>
>
(
axisName
:
DimensionName
,
BaseAxisModelClass
,
axisTypeDefaulter
:
(
axisDim
:
DimensionName
,
option
:
ComponentOption
)
=>
OptionAxisType
,
extraDefaultOption
?:
ComponentOption
BaseAxisModelClass
:
AxisModelCtor
,
extraDefaultOption
?:
AxisOptionT
)
{
zrUtil
.
each
(
AXIS_TYPES
,
function
(
axisType
)
{
zrUtil
.
each
(
AXIS_TYPES
,
function
(
v
,
axisType
)
{
BaseAxisModelClass
.
extend
({
var
defaultOption
=
zrUtil
.
merge
(
zrUtil
.
merge
({},
axisDefault
[
axisType
],
true
),
extraDefaultOption
,
true
);
/**
* @readOnly
*/
type
:
axisName
+
'
Axis.
'
+
axisType
,
class
AxisModel
extends
BaseAxisModelClass
{
static
type
=
axisName
+
'
Axis.
'
+
axisType
;
type
=
axisName
+
'
Axis.
'
+
axisType
;
static
defaultOption
=
defaultOption
;
private
__ordinalMeta
:
OrdinalMeta
;
mergeDefaultAndTheme
:
function
(
option
,
ecModel
)
{
constructor
(...
args
:
any
[])
{
super
(...
args
);
}
mergeDefaultAndTheme
(
option
:
AxisOptionT
,
ecModel
:
GlobalModel
):
void
{
var
layoutMode
=
fetchLayoutMode
(
this
);
var
inputPositionParams
=
layoutMode
?
getLayoutParams
(
option
)
:
{};
?
getLayoutParams
(
option
as
BoxLayoutOptionMixin
)
:
{};
var
themeModel
=
ecModel
.
getTheme
();
zrUtil
.
merge
(
option
,
themeModel
.
get
(
axisType
+
'
Axis
'
));
zrUtil
.
merge
(
option
,
this
.
getDefaultOption
());
option
.
type
=
axisTypeDefaulter
(
axisName
,
option
);
option
.
type
=
getAxisType
(
option
);
if
(
layoutMode
)
{
mergeLayoutParam
(
option
,
inputPositionParams
,
layoutMode
);
mergeLayoutParam
(
option
as
BoxLayoutOptionMixin
,
inputPositionParams
,
layoutMode
);
}
}
,
}
/**
* @override
*/
optionUpdated
:
function
()
{
optionUpdated
():
void
{
var
thisOption
=
this
.
option
;
if
(
thisOption
.
type
===
'
category
'
)
{
this
.
__ordinalMeta
=
OrdinalMeta
.
createByAxisModel
(
this
);
}
}
,
}
/**
* Should not be called before all of 'getInitailData' finished.
* Because categories are collected during initializing data.
*/
getCategories
:
function
(
rawData
)
{
getCategories
(
rawData
:
boolean
):
OrdinalRawValue
[]
|
AxisBaseOption
[
'
data
'
]
{
var
option
=
this
.
option
;
// FIXME
// warning if called before all of 'getInitailData' finished.
if
(
option
.
type
===
'
category
'
)
{
if
(
rawData
)
{
return
option
.
data
;
return
option
.
data
as
AxisBaseOption
[
'
data
'
]
;
}
return
this
.
__ordinalMeta
.
categories
;
}
}
,
}
getOrdinalMeta
:
function
()
{
getOrdinalMeta
():
OrdinalMeta
{
return
this
.
__ordinalMeta
;
},
defaultOption
:
zrUtil
.
mergeAll
(
[
{},
axisDefault
[
axisType
+
'
Axis
'
],
extraDefaultOption
],
true
)
});
}
}
ComponentModel
.
registerClass
(
AxisModel
);
});
ComponentModel
.
registerSubTypeDefaulter
(
axisName
+
'
Axis
'
,
zrUtil
.
curry
(
axisTypeDefaulter
,
axisName
)
getAxisType
);
}
function
getAxisType
(
option
:
AxisBaseOption
)
{
// Default axis with data is category axis
return
option
.
type
||
(
option
.
data
?
'
category
'
:
'
value
'
);
}
src/coord/cartesian/AxisModel.ts
浏览文件 @
6b2ec74a
...
...
@@ -22,7 +22,6 @@ import ComponentModel from '../../model/Component';
import
axisModelCreator
from
'
../axisModelCreator
'
;
import
{
AxisModelCommonMixin
}
from
'
../axisModelCommonMixin
'
;
import
Axis2D
from
'
./Axis2D
'
;
import
{
DimensionName
}
from
'
../../util/types
'
;
import
{
AxisBaseOption
}
from
'
../axisCommonTypes
'
;
import
GridModel
from
'
./GridModel
'
;
...
...
@@ -69,11 +68,6 @@ class AxisModel extends ComponentModel<CartesianAxisOption> {
ComponentModel
.
registerClass
(
AxisModel
);
function
getAxisType
(
axisDim
:
DimensionName
,
option
:
CartesianAxisOption
)
{
// Default axis with data is category axis
return
option
.
type
||
(
option
.
data
?
'
category
'
:
'
value
'
);
}
interface
AxisModel
extends
AxisModelCommonMixin
<
CartesianAxisOption
>
{}
zrUtil
.
mixin
(
AxisModel
,
AxisModelCommonMixin
);
...
...
@@ -83,7 +77,7 @@ var extraOption: CartesianAxisOption = {
offset
:
0
};
axisModelCreator
(
'
x
'
,
AxisModel
,
getAxisType
,
extraOption
);
axisModelCreator
(
'
y
'
,
AxisModel
,
getAxisType
,
extraOption
);
axisModelCreator
<
CartesianAxisOption
,
typeof
AxisModel
>
(
'
x
'
,
AxisModel
,
extraOption
);
axisModelCreator
<
CartesianAxisOption
,
typeof
AxisModel
>
(
'
y
'
,
AxisModel
,
extraOption
);
export
default
AxisModel
;
src/coord/cartesian/GridModel.ts
浏览文件 @
6b2ec74a
...
...
@@ -37,7 +37,7 @@ interface GridOption extends ComponentOption, BoxLayoutOptionMixin, ShadowOption
tooltop
?:
any
;
// FIXME:TS add this tooltip type
}
export
default
class
extends
ComponentModel
<
GridOption
>
implements
CoordinateSystemHostModel
{
class
GridModel
extends
ComponentModel
<
GridOption
>
implements
CoordinateSystemHostModel
{
static
type
=
'
grid
'
;
...
...
@@ -63,5 +63,8 @@ export default class extends ComponentModel<GridOption> implements CoordinateSys
borderWidth
:
1
,
borderColor
:
'
#ccc
'
}
}
ComponentModel
.
registerClass
(
GridModel
);
}
\ No newline at end of file
export
default
GridModel
;
src/coord/parallel/AxisModel.ts
浏览文件 @
6b2ec74a
...
...
@@ -142,10 +142,6 @@ var defaultOption = {
zrUtil
.
mixin
(
AxisModel
,
AxisModelCommonMixin
);
function
getAxisType
(
axisName
,
option
)
{
return
option
.
type
||
(
option
.
data
?
'
category
'
:
'
value
'
);
}
axisModelCreator
(
'
parallel
'
,
AxisModel
,
getAxisType
,
defaultOption
);
axisModelCreator
(
'
parallel
'
,
AxisModel
,
defaultOption
);
export
default
AxisModel
;
\ No newline at end of file
src/coord/polar/AxisModel.ts
浏览文件 @
6b2ec74a
...
...
@@ -71,10 +71,5 @@ var polarAxisDefaultExtendedOption = {
}
};
function
getAxisType
(
axisDim
,
option
)
{
// Default axis with data is category axis
return
option
.
type
||
(
option
.
data
?
'
category
'
:
'
value
'
);
}
axisModelCreator
(
'
angle
'
,
PolarAxisModel
,
getAxisType
,
polarAxisDefaultExtendedOption
.
angle
);
axisModelCreator
(
'
radius
'
,
PolarAxisModel
,
getAxisType
,
polarAxisDefaultExtendedOption
.
radius
);
axisModelCreator
(
'
angle
'
,
PolarAxisModel
,
polarAxisDefaultExtendedOption
.
angle
);
axisModelCreator
(
'
radius
'
,
PolarAxisModel
,
polarAxisDefaultExtendedOption
.
radius
);
src/coord/radar/RadarModel.ts
浏览文件 @
6b2ec74a
...
...
@@ -25,7 +25,7 @@ import axisDefault from '../axisDefault';
import
Model
from
'
../../model/Model
'
;
import
{
AxisModelCommonMixin
}
from
'
../axisModelCommonMixin
'
;
var
valueAxisDefault
=
axisDefault
.
value
Axis
;
var
valueAxisDefault
=
axisDefault
.
value
;
function
defaultsShow
(
opt
,
show
)
{
return
zrUtil
.
defaults
({
...
...
src/coord/single/AxisModel.ts
浏览文件 @
6b2ec74a
...
...
@@ -99,12 +99,8 @@ var defaultOption = {
}
};
function
getAxisType
(
axisName
,
option
)
{
return
option
.
type
||
(
option
.
data
?
'
category
'
:
'
value
'
);
}
zrUtil
.
mixin
(
AxisModel
,
{
AxisModelCommonMixin
});
axisModelCreator
(
'
single
'
,
AxisModel
,
getAxisType
,
defaultOption
);
axisModelCreator
(
'
single
'
,
AxisModel
,
defaultOption
);
export
default
AxisModel
;
\ No newline at end of file
src/helper.ts
浏览文件 @
6b2ec74a
...
...
@@ -76,13 +76,21 @@ export {createSymbol} from './util/symbol';
/**
* Create scale
* @param {Array.<number>} dataExtent
* @param {Object|module:echarts/Model} option
* @param {Object|module:echarts/Model} option If `optoin.type`
* is secified, it can only be `'value'` currently.
*/
export
function
createScale
(
dataExtent
,
option
)
{
var
axisModel
=
option
;
if
(
!
Model
.
isInstance
(
option
))
{
axisModel
=
new
Model
(
option
);
zrUtil
.
mixin
(
axisModel
,
AxisModelCommonMixin
);
// FIXME
// Currently AxisModelCommonMixin has nothing to do with the
// the requirements of `axisHelper.createScaleByModel`. For
// example the method `getCategories` and `getOrdinalMeta`
// are required for `'category'` axis, and ecModel are required
// for `'time'` axis. But occationally echarts-gl happened
// to only use `'value'` axis.
// zrUtil.mixin(axisModel, AxisModelCommonMixin);
}
var
scale
=
axisHelper
.
createScaleByModel
(
axisModel
);
...
...
src/model/Component.ts
浏览文件 @
6b2ec74a
...
...
@@ -286,6 +286,8 @@ class ComponentModel<Opt extends ComponentOption = ComponentOption> extends Mode
}
static
registerClass
:
ClassManager
[
'
registerClass
'
];
static
registerSubTypeDefaulter
:
componentUtil
.
SubTypeDefaulterManager
[
'
registerSubTypeDefaulter
'
];
}
// Reset ComponentModel.extend, add preConstruct.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录