Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
edd13a26
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,发现更多精彩内容 >>
提交
edd13a26
编写于
2月 26, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ts: add types for singleAxis
上级
1fb92ccd
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
236 addition
and
307 deletion
+236
-307
src/component/toolbox/feature/DataView.ts
src/component/toolbox/feature/DataView.ts
+3
-4
src/coord/cartesian/Axis2D.ts
src/coord/cartesian/Axis2D.ts
+13
-13
src/coord/polar/Polar.ts
src/coord/polar/Polar.ts
+2
-6
src/coord/single/AxisModel.ts
src/coord/single/AxisModel.ts
+71
-69
src/coord/single/Single.ts
src/coord/single/Single.ts
+64
-103
src/coord/single/SingleAxis.ts
src/coord/single/SingleAxis.ts
+40
-75
src/coord/single/prepareCustom.ts
src/coord/single/prepareCustom.ts
+4
-5
src/coord/single/singleAxisHelper.ts
src/coord/single/singleAxisHelper.ts
+26
-21
src/coord/single/singleCreator.ts
src/coord/single/singleCreator.ts
+13
-11
未找到文件。
src/component/toolbox/feature/DataView.ts
浏览文件 @
edd13a26
...
...
@@ -27,6 +27,7 @@ import { ColorString, ECUnitOption, SeriesOption, Payload, Dictionary } from '..
import
ExtensionAPI
from
'
../../../ExtensionAPI
'
;
import
{
addEventListener
}
from
'
zrender/src/core/event
'
;
import
Axis
from
'
../../../coord/Axis
'
;
import
Cartesian2D
from
'
../../../coord/cartesian/Cartesian2D
'
;
var
dataViewLang
=
lang
.
toolbox
.
dataView
;
...
...
@@ -70,10 +71,9 @@ function groupSeries(ecModel: GlobalModel) {
var
coordSys
=
seriesModel
.
coordinateSystem
;
if
(
coordSys
&&
(
coordSys
.
type
===
'
cartesian2d
'
||
coordSys
.
type
===
'
polar
'
))
{
var
baseAxis
=
coordSys
.
getBaseAxis
();
// @ts-ignore TODO Polar
// TODO: TYPE Consider polar? Include polar may increase unecessary bundle size.
var
baseAxis
=
(
coordSys
as
Cartesian2D
).
getBaseAxis
();
if
(
baseAxis
.
type
===
'
category
'
)
{
// @ts-ignore TODO Polar
var
key
=
baseAxis
.
dim
+
'
_
'
+
baseAxis
.
index
;
if
(
!
seriesGroupByCategoryAxis
[
key
])
{
seriesGroupByCategoryAxis
[
key
]
=
{
...
...
@@ -83,7 +83,6 @@ function groupSeries(ecModel: GlobalModel) {
};
meta
.
push
({
axisDim
:
baseAxis
.
dim
,
// @ts-ignore TODO Polar
axisIndex
:
baseAxis
.
index
});
}
...
...
src/coord/cartesian/Axis2D.ts
浏览文件 @
edd13a26
...
...
@@ -25,6 +25,19 @@ import Grid from './Grid';
import
{
OptionAxisType
}
from
'
../axisCommonTypes
'
;
interface
Axis2D
{
/**
* Transform global coord to local coord,
* i.e. var localCoord = axis.toLocalCoord(80);
*/
toLocalCoord
(
coord
:
number
):
number
;
/**
* Transform global coord to local coord,
* i.e. var globalCoord = axis.toLocalCoord(40);
*/
toGlobalCoord
(
coord
:
number
):
number
;
}
class
Axis2D
extends
Axis
{
/**
...
...
@@ -106,19 +119,6 @@ class Axis2D extends Axis {
return
this
.
coordToData
(
this
.
toLocalCoord
(
point
[
this
.
dim
===
'
x
'
?
0
:
1
]),
clamp
);
}
/**
* Transform global coord to local coord,
* i.e. var localCoord = axis.toLocalCoord(80);
* designate by module:echarts/coord/cartesian/Grid.
*/
toLocalCoord
:
(
coord
:
number
)
=>
number
;
/**
* Transform global coord to local coord,
* i.e. var globalCoord = axis.toLocalCoord(40);
* designate by module:echarts/coord/cartesian/Grid.
*/
toGlobalCoord
:
(
coord
:
number
)
=>
number
;
}
...
...
src/coord/polar/Polar.ts
浏览文件 @
edd13a26
...
...
@@ -17,10 +17,6 @@
* under the License.
*/
/**
* @module echarts/coord/polar/Polar
*/
import
RadiusAxis
from
'
./RadiusAxis
'
;
import
AngleAxis
from
'
./AngleAxis
'
;
import
PolarModel
from
'
./PolarModel
'
;
...
...
@@ -241,13 +237,13 @@ class Polar implements CoordinateSystem, CoordinateSystemMaster {
convertToPixel
(
ecModel
:
GlobalModel
,
finder
:
ParsedModelFinder
,
value
:
ScaleDataValue
[])
{
const
seriesModel
=
finder
.
seriesModel
;
const
coordSys
=
seriesModel
?
seriesModel
.
coordinateSystem
:
null
;
const
coordSys
=
seriesModel
&&
seriesModel
.
coordinateSystem
;
return
coordSys
===
this
?
this
.
dataToPoint
(
value
)
:
null
;
}
convertFromPixel
(
ecModel
:
GlobalModel
,
finder
:
ParsedModelFinder
,
pixel
:
number
[])
{
const
seriesModel
=
finder
.
seriesModel
;
const
coordSys
=
seriesModel
?
seriesModel
.
coordinateSystem
:
null
;
const
coordSys
=
seriesModel
&&
seriesModel
.
coordinateSystem
;
return
coordSys
===
this
?
this
.
pointToData
(
pixel
)
:
null
;
}
}
...
...
src/coord/single/AxisModel.ts
浏览文件 @
edd13a26
...
...
@@ -17,90 +17,92 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
ComponentModel
from
'
../../model/Component
'
;
import
axisModelCreator
from
'
../axisModelCreator
'
;
import
{
AxisModelCommonMixin
}
from
'
../axisModelCommonMixin
'
;
import
Single
from
'
./Single
'
;
import
SingleAxis
from
'
./SingleAxis
'
;
import
{
AxisBaseOption
}
from
'
../axisCommonTypes
'
;
import
{
BoxLayoutOptionMixin
,
LayoutOrient
}
from
'
../../util/types
'
;
export
type
SingleAxisPosition
=
'
top
'
|
'
bottom
'
|
'
left
'
|
'
right
'
var
AxisModel
=
ComponentModel
.
extend
({
export
interface
SingleAxisOption
extends
AxisBaseOption
,
BoxLayoutOptionMixin
{
position
?:
SingleAxisPosition
orient
:
LayoutOrient
}
type
:
'
singleAxis
'
,
class
SingleAxisModel
extends
ComponentModel
<
SingleAxisOption
>
{
static
type
=
'
singleAxis
'
type
=
SingleAxisModel
.
type
layoutMode
:
'
box
'
,
static
readonly
layoutMode
=
'
box
'
/**
* @type {module:echarts/coord/single/SingleAxis}
*/
axis
:
null
,
axis
:
SingleAxis
/**
* @type {module:echarts/coord/single/Single}
*/
coordinateSystem
:
null
,
coordinateSystem
:
Single
/**
* @override
*/
getCoordSysModel
:
function
()
{
getCoordSysModel
()
{
return
this
;
}
});
var
defaultOption
=
{
left
:
'
5%
'
,
top
:
'
5%
'
,
right
:
'
5%
'
,
bottom
:
'
5%
'
,
type
:
'
value
'
,
position
:
'
bottom
'
,
orient
:
'
horizontal
'
,
axisLine
:
{
show
:
true
,
lineStyle
:
{
width
:
1
,
type
:
'
solid
'
}
},
// Single coordinate system and single axis is the,
// which is used as the parent tooltip model.
// same model, so we set default tooltip show as true.
tooltip
:
{
show
:
true
},
axisTick
:
{
show
:
true
,
length
:
6
,
lineStyle
:
{
width
:
1
}
},
axisLabel
:
{
show
:
true
,
interval
:
'
auto
'
},
splitLine
:
{
show
:
true
,
lineStyle
:
{
type
:
'
dashed
'
,
opacity
:
0.2
static
defaultOption
:
SingleAxisOption
=
{
left
:
'
5%
'
,
top
:
'
5%
'
,
right
:
'
5%
'
,
bottom
:
'
5%
'
,
type
:
'
value
'
,
position
:
'
bottom
'
,
orient
:
'
horizontal
'
,
axisLine
:
{
show
:
true
,
lineStyle
:
{
width
:
1
,
type
:
'
solid
'
}
},
// Single coordinate system and single axis is the,
// which is used as the parent tooltip model.
// same model, so we set default tooltip show as true.
tooltip
:
{
show
:
true
},
axisTick
:
{
show
:
true
,
length
:
6
,
lineStyle
:
{
width
:
1
}
},
axisLabel
:
{
show
:
true
,
interval
:
'
auto
'
},
splitLine
:
{
show
:
true
,
lineStyle
:
{
type
:
'
dashed
'
,
opacity
:
0.2
}
}
}
};
}
ComponentModel
.
registerClass
(
SingleAxisModel
);
zrUtil
.
mixin
(
AxisModel
,
{
AxisModelCommonMixin
});
interface
SingleAxisModel
extends
AxisModelCommonMixin
<
SingleAxisOption
>
{}
zrUtil
.
mixin
(
SingleAxisModel
,
{
AxisModelCommonMixin
});
axisModelCreator
(
'
single
'
,
AxisModel
,
defaultOption
);
axisModelCreator
(
'
single
'
,
SingleAxisModel
,
SingleAxisModel
.
defaultOption
);
export
default
AxisModel
;
\ No newline at end of file
export
default
SingleAxisModel
;
\ No newline at end of file
src/coord/single/Single.ts
浏览文件 @
edd13a26
...
...
@@ -17,8 +17,6 @@
* under the License.
*/
// @ts-nocheck
/**
* Single coordinates system.
*/
...
...
@@ -27,67 +25,48 @@ import SingleAxis from './SingleAxis';
import
*
as
axisHelper
from
'
../axisHelper
'
;
import
{
getLayoutRect
}
from
'
../../util/layout
'
;
import
{
each
}
from
'
zrender/src/core/util
'
;
import
{
CoordinateSystem
,
CoordinateSystemMaster
}
from
'
../CoordinateSystem
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
ExtensionAPI
from
'
../../ExtensionAPI
'
;
import
BoundingRect
from
'
zrender/src/core/BoundingRect
'
;
import
SingleAxisModel
from
'
./AxisModel
'
;
import
{
ParsedModelFinder
}
from
'
../../util/model
'
;
import
{
ScaleDataValue
}
from
'
../../util/types
'
;
/**
* Create a single coordinates system.
*
* @param {module:echarts/coord/single/AxisModel} axisModel
* @param {module:echarts/model/Global} ecModel
* @param {module:echarts/ExtensionAPI} api
*/
function
Single
(
axisModel
,
ecModel
,
api
)
{
class
Single
implements
CoordinateSystem
,
CoordinateSystemMaster
{
/**
* @type {string}
* @readOnly
*/
this
.
dimension
=
'
single
'
;
readonly
type
=
'
single
'
;
readonly
dimension
=
'
single
'
;
/**
* Add it just for draw tooltip.
*
* @type {Array.<string>}
* @readOnly
*/
this
.
dimensions
=
[
'
single
'
];
readonly
dimensions
=
[
'
single
'
];
/**
* @private
* @type {module:echarts/coord/single/SingleAxis}.
*/
this
.
_axis
=
null
;
name
:
string
/**
* @private
* @type {module:zrender/core/BoundingRect}
*/
this
.
_rect
;
axisPointerEnabled
:
boolean
=
true
this
.
_init
(
axisModel
,
ecModel
,
api
);
model
:
SingleAxisModel
/**
* @type {module:echarts/coord/single/AxisModel}
*/
this
.
model
=
axisModel
;
}
private
_axis
:
SingleAxis
Single
.
prototype
=
{
private
_rect
:
BoundingRect
type
:
'
singleAxis
'
,
constructor
(
axisModel
:
SingleAxisModel
,
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
)
{
axisPointerEnabled
:
true
,
this
.
model
=
axisModel
;
constructor
:
Single
,
this
.
_init
(
axisModel
,
ecModel
,
api
);
}
/**
* Initialize single coordinate system.
*
* @param {module:echarts/coord/single/AxisModel} axisModel
* @param {module:echarts/model/Global} ecModel
* @param {module:echarts/ExtensionAPI} api
* @private
*/
_init
:
function
(
axisModel
,
ecModel
,
api
)
{
_init
(
axisModel
:
SingleAxisModel
,
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
)
{
var
dim
=
this
.
dimension
;
...
...
@@ -108,14 +87,12 @@ Single.prototype = {
axis
.
model
=
axisModel
;
axis
.
coordinateSystem
=
this
;
this
.
_axis
=
axis
;
}
,
}
/**
* Update axis scale after data processed
* @param {module:echarts/model/Global} ecModel
* @param {module:echarts/ExtensionAPI} api
*/
update
:
function
(
ecModel
,
api
)
{
update
(
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
)
{
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
if
(
seriesModel
.
coordinateSystem
===
this
)
{
var
data
=
seriesModel
.
getData
();
...
...
@@ -125,15 +102,12 @@ Single.prototype = {
axisHelper
.
niceScaleExtent
(
this
.
_axis
.
scale
,
this
.
_axis
.
model
);
}
},
this
);
}
,
}
/**
* Resize the single coordinate system.
*
* @param {module:echarts/coord/single/AxisModel} axisModel
* @param {module:echarts/ExtensionAPI} api
*/
resize
:
function
(
axisModel
,
api
)
{
resize
(
axisModel
:
SingleAxisModel
,
api
:
ExtensionAPI
)
{
this
.
_rect
=
getLayoutRect
(
{
left
:
axisModel
.
get
(
'
left
'
),
...
...
@@ -150,19 +124,13 @@ Single.prototype = {
);
this
.
_adjustAxis
();
}
,
}
/**
* @return {module:zrender/core/BoundingRect}
*/
getRect
:
function
()
{
getRect
()
{
return
this
.
_rect
;
}
,
}
/**
* @private
*/
_adjustAxis
:
function
()
{
private
_adjustAxis
()
{
var
rect
=
this
.
_rect
;
var
axis
=
this
.
_axis
;
...
...
@@ -175,13 +143,10 @@ Single.prototype = {
this
.
_updateAxisTransform
(
axis
,
isHorizontal
?
rect
.
x
:
rect
.
y
);
},
}
/**
* @param {module:echarts/coord/single/SingleAxis} axis
* @param {number} coordBase
*/
_updateAxisTransform
:
function
(
axis
,
coordBase
)
{
private
_updateAxisTransform
(
axis
:
SingleAxis
,
coordBase
:
number
)
{
var
axisExtent
=
axis
.
getExtent
();
var
extentSum
=
axisExtent
[
0
]
+
axisExtent
[
1
];
...
...
@@ -202,47 +167,38 @@ Single.prototype = {
:
function
(
coord
)
{
return
extentSum
-
coord
+
coordBase
;
};
}
,
}
/**
* Get axis.
*
* @return {module:echarts/coord/single/SingleAxis}
*/
getAxis
:
function
()
{
getAxis
()
{
return
this
.
_axis
;
}
,
}
/**
* Get axis, add it just for draw tooltip.
*
* @return {[type]} [description]
*/
getBaseAxis
:
function
()
{
getBaseAxis
()
{
return
this
.
_axis
;
}
,
}
/**
* @return {Array.<module:echarts/coord/Axis>}
*/
getAxes
:
function
()
{
getAxes
()
{
return
[
this
.
_axis
];
}
,
}
/**
* @return {Object} {baseAxes: [], otherAxes: []}
*/
getTooltipAxes
:
function
()
{
return
{
baseAxes
:
[
this
.
getAxis
()]};
},
getTooltipAxes
()
{
return
{
baseAxes
:
[
this
.
getAxis
()],
// Empty otherAxes
otherAxes
:
[]
as
SingleAxis
[]
};
}
/**
* If contain point.
*
* @param {Array.<number>} point
* @return {boolean}
*/
containPoint
:
function
(
point
)
{
containPoint
(
point
:
number
[]
)
{
var
rect
=
this
.
getRect
();
var
axis
=
this
.
getAxis
();
var
orient
=
axis
.
orient
;
...
...
@@ -254,26 +210,20 @@ Single.prototype = {
return
axis
.
contain
(
axis
.
toLocalCoord
(
point
[
1
]))
&&
(
point
[
0
]
>=
rect
.
y
&&
point
[
0
]
<=
(
rect
.
y
+
rect
.
height
));
}
}
,
}
/**
* @param {Array.<number>} point
* @return {Array.<number>}
*/
pointToData
:
function
(
point
)
{
pointToData
(
point
:
number
[])
{
var
axis
=
this
.
getAxis
();
return
[
axis
.
coordToData
(
axis
.
toLocalCoord
(
point
[
axis
.
orient
===
'
horizontal
'
?
0
:
1
]
))];
}
,
}
/**
* Convert the series data to concrete point.
*
* @param {number|Array.<number>} val
* @return {Array.<number>}
* Can be [val] | val
*/
dataToPoint
:
function
(
val
)
{
dataToPoint
(
val
:
ScaleDataValue
|
ScaleDataValue
[]
)
{
var
axis
=
this
.
getAxis
();
var
rect
=
this
.
getRect
();
var
pt
=
[];
...
...
@@ -288,6 +238,17 @@ Single.prototype = {
return
pt
;
}
};
convertToPixel
(
ecModel
:
GlobalModel
,
finder
:
ParsedModelFinder
,
value
:
ScaleDataValue
[])
{
const
seriesModel
=
finder
.
seriesModel
;
const
coordSys
=
seriesModel
&&
seriesModel
.
coordinateSystem
;
return
coordSys
===
this
?
this
.
dataToPoint
(
value
)
:
null
;
}
convertFromPixel
(
ecModel
:
GlobalModel
,
finder
:
ParsedModelFinder
,
pixel
:
number
[])
{
const
seriesModel
=
finder
.
seriesModel
;
const
coordSys
=
seriesModel
&&
seriesModel
.
coordinateSystem
;
return
coordSys
===
this
?
this
.
pointToData
(
pixel
)
:
null
;
}
}
export
default
Single
;
src/coord/single/SingleAxis.ts
浏览文件 @
edd13a26
...
...
@@ -17,98 +17,63 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
Axis
from
'
../Axis
'
;
import
Scale
from
'
../../scale/Scale
'
;
import
{
OptionAxisType
}
from
'
../axisCommonTypes
'
;
import
SingleAxisModel
,
{
SingleAxisPosition
}
from
'
./AxisModel
'
;
import
{
LayoutOrient
}
from
'
../../util/types
'
;
import
Single
from
'
./Single
'
;
/**
* @constructor module:echarts/coord/single/SingleAxis
* @extends {module:echarts/coord/Axis}
* @param {string} dim
* @param {*} scale
* @param {Array.<number>} coordExtent
* @param {string} axisType
* @param {string} position
*/
var
SingleAxis
=
function
(
dim
,
scale
,
coordExtent
,
axisType
,
position
)
{
Axis
.
call
(
this
,
dim
,
scale
,
coordExtent
);
interface
SingleAxis
{
/**
* Axis type
* - 'category'
* - 'value'
* - 'time'
* - 'log'
* @type {string}
* Transform global coord to local coord,
* i.e. var localCoord = axis.toLocalCoord(80);
*/
t
his
.
type
=
axisType
||
'
value
'
;
t
oLocalCoord
(
coord
:
number
):
number
;
/**
* Axis position
* - 'top'
* - 'bottom'
* - 'left'
* - 'right'
* @type {string}
* Transform global coord to local coord,
* i.e. var globalCoord = axis.toLocalCoord(40);
*/
this
.
position
=
position
||
'
bottom
'
;
toGlobalCoord
(
coord
:
number
):
number
;
}
class
SingleAxis
extends
Axis
{
/**
* Axis orient
* - 'horizontal'
* - 'vertical'
* @type {[type]}
*/
this
.
orient
=
null
;
type
:
OptionAxisType
};
position
:
SingleAxisPosition
SingleAxis
.
prototype
=
{
orient
:
LayoutOrient
constructor
:
SingleAxis
,
reverse
:
boolean
/**
* Axis model
* @type {module:echarts/coord/single/AxisModel}
*/
model
:
null
,
/**
* Judge the orient of the axis.
* @return {boolean}
*/
isHorizontal
:
function
()
{
var
position
=
this
.
position
;
return
position
===
'
top
'
||
position
===
'
bottom
'
;
coordinateSystem
:
Single
},
model
:
SingleAxisModel
/**
* @override
*/
pointToData
:
function
(
point
,
clamp
)
{
return
this
.
coordinateSystem
.
pointToData
(
point
,
clamp
)[
0
];
},
constructor
(
dim
:
string
,
scale
:
Scale
,
coordExtent
:
[
number
,
number
],
axisType
?:
OptionAxisType
,
position
?:
SingleAxisPosition
)
{
super
(
dim
,
scale
,
coordExtent
);
/**
* Convert the local coord(processed by dataToCoord())
* to global coord(concrete pixel coord).
* designated by module:echarts/coord/single/Single.
* @type {Function}
*/
toGlobalCoord
:
null
,
this
.
type
=
axisType
||
'
value
'
;
this
.
position
=
position
||
'
bottom
'
;
}
/**
* Convert the global coord to local coord.
* designated by module:echarts/coord/single/Single.
* @type {Function}
* Judge the orient of the axis.
*/
toLocalCoord
:
null
};
zrUtil
.
inherits
(
SingleAxis
,
Axis
);
isHorizontal
()
{
var
position
=
this
.
position
;
return
position
===
'
top
'
||
position
===
'
bottom
'
;
}
pointToData
(
point
:
number
[],
clamp
?:
boolean
)
{
// TODO: clamp is not used.
return
this
.
coordinateSystem
.
pointToData
(
point
)[
0
];
}
}
export
default
SingleAxis
;
\ No newline at end of file
src/coord/single/prepareCustom.ts
浏览文件 @
edd13a26
...
...
@@ -17,11 +17,10 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
Single
from
'
./Single
'
;
function
dataToCoordSize
(
dataSize
,
dataItem
)
{
function
dataToCoordSize
(
this
:
Single
,
dataSize
:
number
|
number
[],
dataItem
:
number
|
number
[]
)
{
// dataItem is necessary in log axis.
var
axis
=
this
.
getAxis
();
var
val
=
dataItem
instanceof
Array
?
dataItem
[
0
]
:
dataItem
;
...
...
@@ -31,7 +30,7 @@ function dataToCoordSize(dataSize, dataItem) {
:
Math
.
abs
(
axis
.
dataToCoord
(
val
-
halfSize
)
-
axis
.
dataToCoord
(
val
+
halfSize
));
}
export
default
function
(
coordSys
)
{
export
default
function
(
coordSys
:
Single
)
{
var
rect
=
coordSys
.
getRect
();
return
{
...
...
@@ -43,7 +42,7 @@ export default function (coordSys) {
height
:
rect
.
height
},
api
:
{
coord
:
function
(
val
)
{
coord
:
function
(
val
:
number
)
{
// do not provide "out" param
return
coordSys
.
dataToPoint
(
val
);
},
...
...
src/coord/single/singleAxisHelper.ts
浏览文件 @
edd13a26
...
...
@@ -17,22 +17,27 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
SingleAxisModel
from
'
./AxisModel
'
;
interface
LayoutResult
{
position
:
[
number
,
number
],
rotation
:
number
labelRotation
:
number
labelDirection
:
1
|
-
1
tickDirection
:
1
|
-
1
nameDirection
:
1
|
-
1
z2
:
number
}
/**
* @param {Object} opt {labelInside}
* @return {Object} {
* position, rotation, labelDirection, labelOffset,
* tickDirection, labelRotate, z2
* }
*/
export
function
layout
(
axisModel
,
opt
)
{
export
function
layout
(
axisModel
:
SingleAxisModel
,
opt
?:
{
labelInside
?:
boolean
rotate
?:
number
})
{
opt
=
opt
||
{};
var
single
=
axisModel
.
coordinateSystem
;
var
axis
=
axisModel
.
axis
;
var
layout
=
{};
var
layout
=
{}
as
LayoutResult
;
var
axisPosition
=
axis
.
position
;
var
orient
=
axis
.
orient
;
...
...
@@ -43,35 +48,35 @@ export function layout(axisModel, opt) {
var
positionMap
=
{
horizontal
:
{
top
:
rectBound
[
2
],
bottom
:
rectBound
[
3
]},
vertical
:
{
left
:
rectBound
[
0
],
right
:
rectBound
[
1
]}
};
}
as
const
;
layout
.
position
=
[
orient
===
'
vertical
'
?
positionMap
.
vertical
[
axisPosition
]
?
positionMap
.
vertical
[
axisPosition
as
'
left
'
|
'
right
'
]
:
rectBound
[
0
],
orient
===
'
horizontal
'
?
positionMap
.
horizontal
[
axisPosition
]
?
positionMap
.
horizontal
[
axisPosition
as
'
top
'
|
'
bottom
'
]
:
rectBound
[
3
]
];
]
as
[
number
,
number
]
;
var
r
=
{
horizontal
:
0
,
vertical
:
1
};
layout
.
rotation
=
Math
.
PI
/
2
*
r
[
orient
];
var
directionMap
=
{
top
:
-
1
,
bottom
:
1
,
right
:
1
,
left
:
-
1
}
;
const
directionMap
=
{
top
:
-
1
,
bottom
:
1
,
right
:
1
,
left
:
-
1
}
as
const
;
layout
.
labelDirection
=
layout
.
tickDirection
=
layout
.
nameDirection
=
directionMap
[
axisPosition
];
if
(
axisModel
.
get
(
'
axisTick.inside
'
))
{
layout
.
tickDirection
=
-
layout
.
tickDirection
;
if
(
axisModel
.
get
(
[
'
axisTick
'
,
'
inside
'
]
))
{
layout
.
tickDirection
=
-
layout
.
tickDirection
as
-
1
|
1
;
}
if
(
zrUtil
.
retrieve
(
opt
.
labelInside
,
axisModel
.
get
(
'
axisLabel.inside
'
)))
{
layout
.
labelDirection
=
-
layout
.
labelDirection
;
if
(
zrUtil
.
retrieve
(
opt
.
labelInside
,
axisModel
.
get
(
[
'
axisLabel
'
,
'
inside
'
]
)))
{
layout
.
labelDirection
=
-
layout
.
labelDirection
as
-
1
|
1
;
}
var
labelRotation
=
opt
.
rotate
;
labelRotation
==
null
&&
(
labelRotation
=
axisModel
.
get
(
'
axisLabel.rotate
'
));
labelRotation
==
null
&&
(
labelRotation
=
axisModel
.
get
(
[
'
axisLabel
'
,
'
rotate
'
]
));
layout
.
labelRotation
=
axisPosition
===
'
top
'
?
-
labelRotation
:
labelRotation
;
layout
.
z2
=
1
;
...
...
src/coord/single/singleCreator.ts
浏览文件 @
edd13a26
...
...
@@ -17,26 +17,25 @@
* under the License.
*/
// @ts-nocheck
/**
* Single coordinate system creator.
*/
import
Single
from
'
./Single
'
;
import
CoordinateSystem
from
'
../../CoordinateSystem
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
ExtensionAPI
from
'
../../ExtensionAPI
'
;
import
SingleAxisModel
from
'
./AxisModel
'
;
import
SeriesModel
from
'
../../model/Series
'
;
import
{
SeriesOption
}
from
'
../../util/types
'
;
/**
* Create single coordinate system and inject it into seriesModel.
*
* @param {module:echarts/model/Global} ecModel
* @param {module:echarts/ExtensionAPI} api
* @return {Array.<module:echarts/coord/single/Single>}
*/
function
create
(
ecModel
,
api
)
{
var
singles
=
[];
function
create
(
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
)
{
var
singles
:
Single
[]
=
[];
ecModel
.
eachComponent
(
'
singleAxis
'
,
function
(
axisModel
,
idx
)
{
ecModel
.
eachComponent
(
'
singleAxis
'
,
function
(
axisModel
:
SingleAxisModel
,
idx
:
number
)
{
var
single
=
new
Single
(
axisModel
,
ecModel
,
api
);
single
.
name
=
'
single_
'
+
idx
;
...
...
@@ -46,13 +45,16 @@ function create(ecModel, api) {
});
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
ecModel
.
eachSeries
(
function
(
seriesModel
:
SeriesModel
<
SeriesOption
&
{
singleAxisIndex
?:
number
singleAxisId
?:
string
}
>
)
{
if
(
seriesModel
.
get
(
'
coordinateSystem
'
)
===
'
singleAxis
'
)
{
var
singleAxisModel
=
ecModel
.
queryComponents
({
mainType
:
'
singleAxis
'
,
index
:
seriesModel
.
get
(
'
singleAxisIndex
'
),
id
:
seriesModel
.
get
(
'
singleAxisId
'
)
})[
0
];
})[
0
]
as
SingleAxisModel
;
seriesModel
.
coordinateSystem
=
singleAxisModel
&&
singleAxisModel
.
coordinateSystem
;
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录