Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
1fb92ccd
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,发现更多精彩内容 >>
提交
1fb92ccd
编写于
2月 26, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ts: add types for polar coord
上级
bed19deb
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
256 addition
and
270 deletion
+256
-270
src/component/tooltip/TooltipRichContent.ts
src/component/tooltip/TooltipRichContent.ts
+1
-1
src/coord/Axis.ts
src/coord/Axis.ts
+1
-1
src/coord/CoordinateSystem.ts
src/coord/CoordinateSystem.ts
+5
-3
src/coord/axisModelCreator.ts
src/coord/axisModelCreator.ts
+1
-1
src/coord/polar/AngleAxis.ts
src/coord/polar/AngleAxis.ts
+32
-37
src/coord/polar/AxisModel.ts
src/coord/polar/AxisModel.ts
+58
-28
src/coord/polar/Polar.ts
src/coord/polar/Polar.ts
+69
-115
src/coord/polar/PolarModel.ts
src/coord/polar/PolarModel.ts
+22
-20
src/coord/polar/RadiusAxis.ts
src/coord/polar/RadiusAxis.ts
+21
-28
src/coord/polar/polarCreator.ts
src/coord/polar/polarCreator.ts
+32
-25
src/coord/polar/prepareCustom.ts
src/coord/polar/prepareCustom.ts
+14
-11
未找到文件。
src/component/tooltip/TooltipRichContent.ts
浏览文件 @
1fb92ccd
...
...
@@ -22,7 +22,7 @@ import * as zrUtil from 'zrender/src/core/util';
import
Text
from
'
zrender/src/graphic/Text
'
;
import
ExtensionAPI
from
'
../../ExtensionAPI
'
;
import
{
ZRenderType
}
from
'
zrender/src/zrender
'
;
import
TooltipModel
,
{
TooltipOption
}
from
'
./TooltipModel
'
;
import
{
TooltipOption
}
from
'
./TooltipModel
'
;
import
*
as
graphic
from
'
../../util/graphic
'
;
import
{
Dictionary
}
from
'
zrender/src/core/types
'
;
import
{
ColorString
}
from
'
../../util/types
'
;
...
...
src/coord/Axis.ts
浏览文件 @
1fb92ccd
...
...
@@ -47,7 +47,7 @@ class Axis {
readonly
dim
:
DimensionName
;
// Axis scale
readonly
scale
:
Scale
;
scale
:
Scale
;
private
_extent
:
[
number
,
number
];
...
...
src/coord/CoordinateSystem.ts
浏览文件 @
1fb92ccd
...
...
@@ -83,8 +83,8 @@ export interface CoordinateSystemMaster {
}
/**
* For example: cartesian is CoordinateSystem
Executive
.
* series.coordinateSystem is CoordinateSystem
Executive
.
* For example: cartesian is CoordinateSystem.
* series.coordinateSystem is CoordinateSystem.
*/
export
interface
CoordinateSystem
{
...
...
@@ -128,7 +128,9 @@ export interface CoordinateSystem {
getRoamTransform
?:
()
=>
MatrixArray
;
getArea
?:
()
=>
BoundingRect
;
getArea
?:
()
=>
{
contain
(
x
:
number
,
y
:
number
):
boolean
};
// Only `coord/View.js` implements `getBoundingRect`.
// But if other coord sys implement it, should follow this signature.
...
...
src/coord/axisModelCreator.ts
浏览文件 @
1fb92ccd
...
...
@@ -40,7 +40,7 @@ type Constructor<T> = new (...args: any[]) => T;
export
default
function
<
AxisOptionT
extends
AxisBaseOption
,
AxisModelCtor
extends
Constructor
<
ComponentModel
<
AxisOptionT
>>
>
(
>
(
axisName
:
DimensionName
,
BaseAxisModelClass
:
AxisModelCtor
,
extraDefaultOption
?:
AxisOptionT
...
...
src/coord/polar/AngleAxis.ts
浏览文件 @
1fb92ccd
...
...
@@ -17,46 +17,38 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
*
as
textContain
from
'
zrender/src/contain/text
'
;
import
Axis
from
'
../Axis
'
;
import
{
makeInner
}
from
'
../../util/model
'
;
var
inner
=
makeInner
();
function
AngleAxis
(
scale
,
angleExtent
)
{
angleExtent
=
angleExtent
||
[
0
,
360
];
Axis
.
call
(
this
,
'
angle
'
,
scale
,
angleExtent
);
/**
* Axis type
* - 'category'
* - 'value'
* - 'time'
* - 'log'
* @type {string}
*/
this
.
type
=
'
category
'
;
import
{
OptionAxisType
}
from
'
../axisCommonTypes
'
;
import
Scale
from
'
../../scale/Scale
'
;
import
OrdinalScale
from
'
../../scale/Ordinal
'
;
import
Polar
from
'
./Polar
'
;
import
{
AngleAxisModel
}
from
'
./AxisModel
'
;
var
inner
=
makeInner
<
{
lastAutoInterval
:
number
lastTickCount
:
number
}
>
();
interface
AngleAxis
{
dataToAngle
:
Axis
[
'
dataToCoord
'
]
angleToData
:
Axis
[
'
coordToData
'
]
}
class
AngleAxis
extends
Axis
{
type
:
OptionAxisType
AngleAxis
.
prototype
=
{
polar
:
Polar
constructor
:
AngleAxis
,
model
:
AngleAxisModel
/**
* @override
*/
pointToData
:
function
(
point
,
clamp
)
{
return
this
.
polar
.
pointToData
(
point
,
clamp
)[
this
.
dim
===
'
radius
'
?
0
:
1
];
},
dataToAngle
:
Axis
.
prototype
.
dataToCoord
,
constructor
(
scale
?:
Scale
,
angleExtent
?:
[
number
,
number
])
{
super
(
'
angle
'
,
scale
,
angleExtent
||
[
0
,
360
]);
}
angleToData
:
Axis
.
prototype
.
coordToData
,
pointToData
(
point
:
number
[],
clamp
?:
boolean
)
{
return
this
.
polar
.
pointToData
(
point
,
clamp
)[
this
.
dim
===
'
radius
'
?
0
:
1
];
}
/**
* Only be called in category axis.
...
...
@@ -65,11 +57,11 @@ AngleAxis.prototype = {
* @override
* @return {number} Auto interval for cateogry axis tick and label
*/
calculateCategoryInterval
:
function
()
{
calculateCategoryInterval
()
{
var
axis
=
this
;
var
labelModel
=
axis
.
getLabelModel
();
var
ordinalScale
=
axis
.
scale
;
var
ordinalScale
=
axis
.
scale
as
OrdinalScale
;
var
ordinalExtent
=
ordinalScale
.
getExtent
();
// Providing this method is for optimization:
// avoid generating a long array by `getTicks`
...
...
@@ -87,7 +79,7 @@ AngleAxis.prototype = {
// Not precise, just use height as text width
// and each distance from axis line yet.
var
rect
=
textContain
.
getBoundingRect
(
tickValue
,
labelModel
.
getFont
(),
'
center
'
,
'
top
'
tickValue
+
''
,
labelModel
.
getFont
(),
'
center
'
,
'
top
'
);
var
maxH
=
Math
.
max
(
rect
.
height
,
7
);
...
...
@@ -122,8 +114,11 @@ AngleAxis.prototype = {
return
interval
;
}
};
}
AngleAxis
.
prototype
.
dataToAngle
=
Axis
.
prototype
.
dataToCoord
;
AngleAxis
.
prototype
.
angleToData
=
Axis
.
prototype
.
coordToData
;
zrUtil
.
inherits
(
AngleAxis
,
Axis
);
export
default
AngleAxis
;
\ No newline at end of file
src/coord/polar/AxisModel.ts
浏览文件 @
1fb92ccd
...
...
@@ -17,59 +17,89 @@
* 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
{
AxisBaseOption
}
from
'
../axisCommonTypes
'
;
import
AngleAxis
from
'
./AngleAxis
'
;
import
RadiusAxis
from
'
./RadiusAxis
'
;
var
PolarAxisModel
=
ComponentModel
.
extend
({
export
interface
AngleAxisOption
extends
AxisBaseOption
{
/**
* Index of host polar component
*/
polarIndex
?:
number
/**
* Id of host polar component
*/
polarId
?:
string
type
:
'
polarAxis
'
,
startAngle
?:
number
clockwise
?:
boolean
splitNumber
?:
number
axisLabel
?:
Omit
<
AxisBaseOption
[
'
axisLabel
'
],
'
rotate
'
>
&
{
rotate
?:
AxisBaseOption
[
'
axisLabel
'
][
'
rotate
'
]
|
false
}
}
export
interface
RadiusAxisOption
extends
AxisBaseOption
{
/**
*
@type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
*
Index of host polar component
*/
axis
:
null
,
polarIndex
?:
number
/**
*
@override
*
Id of host polar component
*/
getCoordSysModel
:
function
()
{
polarId
?:
string
}
type
PolarAxisOption
=
AngleAxisOption
|
RadiusAxisOption
;
class
PolarAxisModel
<
T
extends
PolarAxisOption
=
PolarAxisOption
>
extends
ComponentModel
<
T
>
{
static
type
=
'
polarAxis
'
getCoordSysModel
():
ComponentModel
{
return
this
.
ecModel
.
queryComponents
({
mainType
:
'
polar
'
,
index
:
this
.
option
.
polarIndex
,
id
:
this
.
option
.
polarId
})[
0
];
}
}
});
interface
PolarAxisModel
<
T
extends
PolarAxisOption
=
PolarAxisOption
>
extends
AxisModelCommonMixin
<
T
>
{}
zrUtil
.
mixin
(
PolarAxisModel
,
AxisModelCommonMixin
);
var
polarAxisDefaultExtendedOption
=
{
angle
:
{
// polarIndex: 0,
// polarId: '',
export
{
PolarAxisModel
};
startAngle
:
90
,
export
class
AngleAxisModel
extends
PolarAxisModel
<
AngleAxisOption
>
{
axis
:
AngleAxis
}
export
class
RadiusAxisModel
extends
PolarAxisModel
<
RadiusAxisOption
>
{
axis
:
RadiusAxis
}
clockwise
:
true
,
ComponentModel
.
registerClass
(
PolarAxisModel
);
splitNumber
:
12
,
const
angleAxisExtraOption
:
AngleAxisOption
=
{
startAngle
:
90
,
axisLabel
:
{
rotate
:
false
}
},
radius
:
{
// polarIndex: 0,
// polarId: '',
clockwise
:
true
,
splitNumber
:
5
splitNumber
:
12
,
axisLabel
:
{
rotate
:
false
}
};
axisModelCreator
(
'
angle
'
,
PolarAxisModel
,
polarAxisDefaultExtendedOption
.
angle
);
axisModelCreator
(
'
radius
'
,
PolarAxisModel
,
polarAxisDefaultExtendedOption
.
radius
);
const
radiusAxisExtraOption
:
RadiusAxisOption
=
{
splitNumber
:
5
};
axisModelCreator
(
'
angle
'
,
AngleAxisModel
,
angleAxisExtraOption
);
axisModelCreator
(
'
radius
'
,
RadiusAxisModel
,
radiusAxisExtraOption
);
src/coord/polar/Polar.ts
浏览文件 @
1fb92ccd
...
...
@@ -17,115 +17,84 @@
* under the License.
*/
// @ts-nocheck
/**
* @module echarts/coord/polar/Polar
*/
import
RadiusAxis
from
'
./RadiusAxis
'
;
import
AngleAxis
from
'
./AngleAxis
'
;
import
PolarModel
from
'
./PolarModel
'
;
import
{
CoordinateSystem
,
CoordinateSystemMaster
}
from
'
../CoordinateSystem
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
{
ParsedModelFinder
}
from
'
../../util/model
'
;
import
{
ScaleDataValue
}
from
'
../../util/types
'
;
import
ExtensionAPI
from
'
../../ExtensionAPI
'
;
/**
* @alias {module:echarts/coord/polar/Polar}
* @constructor
* @param {string} name
*/
var
Polar
=
function
(
name
)
{
interface
Polar
{
update
(
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
):
void
}
class
Polar
implements
CoordinateSystem
,
CoordinateSystemMaster
{
/**
* @type {string}
*/
this
.
name
=
name
||
''
;
readonly
name
:
string
;
/**
* x of polar center
* @type {number}
*/
this
.
cx
=
0
;
readonly
dimensions
=
[
'
radius
'
,
'
angle
'
]
/**
* y of polar center
* @type {number}
*/
this
.
cy
=
0
;
readonly
type
=
'
polar
'
/**
* @type {module:echarts/coord/polar/RadiusAxis}
* @private
* x of polar center
*/
this
.
_radiusAxis
=
new
RadiusAxis
()
;
cx
=
0
;
/**
* @type {module:echarts/coord/polar/AngleAxis}
* @private
* y of polar center
*/
this
.
_angleAxis
=
new
AngleAxis
();
this
.
_radiusAxis
.
polar
=
this
.
_angleAxis
.
polar
=
this
;
};
cy
=
0
;
Polar
.
prototype
=
{
private
_radiusAxis
=
new
RadiusAxis
();
type
:
'
polar
'
,
private
_angleAxis
=
new
AngleAxis
();
axisPointerEnabled
:
true
,
axisPointerEnabled
=
true
constructor
:
Polar
,
model
:
PolarModel
/**
* @param {Array.<string>}
* @readOnly
*/
dimensions
:
[
'
radius
'
,
'
angle
'
],
constructor
(
name
:
string
)
{
this
.
name
=
name
||
''
;
/**
* @type {module:echarts/coord/PolarModel}
*/
model
:
null
,
this
.
_radiusAxis
.
polar
=
this
.
_angleAxis
.
polar
=
this
;
}
/**
* If contain coord
* @param {Array.<number>} point
* @return {boolean}
*/
containPoint
:
function
(
point
)
{
containPoint
(
point
:
number
[]
)
{
var
coord
=
this
.
pointToCoord
(
point
);
return
this
.
_radiusAxis
.
contain
(
coord
[
0
])
&&
this
.
_angleAxis
.
contain
(
coord
[
1
]);
}
,
}
/**
* If contain data
* @param {Array.<number>} data
* @return {boolean}
*/
containData
:
function
(
data
)
{
containData
(
data
:
number
[]
)
{
return
this
.
_radiusAxis
.
containData
(
data
[
0
])
&&
this
.
_angleAxis
.
containData
(
data
[
1
]);
}
,
}
/**
* @param {string} dim
* @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
*/
getAxis
:
function
(
dim
)
{
return
this
[
'
_
'
+
dim
+
'
Axis
'
];
},
getAxis
(
dim
:
'
radius
'
|
'
angle
'
)
{
const
key
=
(
'
_
'
+
dim
+
'
Axis
'
)
as
'
_radiusAxis
'
|
'
_angleAxis
'
;
return
this
[
key
];
}
/**
* @return {Array.<module:echarts/coord/Axis>}
*/
getAxes
:
function
()
{
getAxes
()
{
return
[
this
.
_radiusAxis
,
this
.
_angleAxis
];
}
,
}
/**
* Get axes by type of scale
* @param {string} scaleType
* @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
*/
getAxesByScale
:
function
(
scaleType
)
{
getAxesByScale
(
scaleType
:
'
ordinal
'
|
'
interval
'
|
'
time
'
|
'
log
'
)
{
var
axes
=
[];
var
angleAxis
=
this
.
_angleAxis
;
var
radiusAxis
=
this
.
_radiusAxis
;
...
...
@@ -133,89 +102,66 @@ Polar.prototype = {
radiusAxis
.
scale
.
type
===
scaleType
&&
axes
.
push
(
radiusAxis
);
return
axes
;
}
,
}
/**
* @return {module:echarts/coord/polar/AngleAxis}
*/
getAngleAxis
:
function
()
{
getAngleAxis
()
{
return
this
.
_angleAxis
;
}
,
}
/**
* @return {module:echarts/coord/polar/RadiusAxis}
*/
getRadiusAxis
:
function
()
{
getRadiusAxis
()
{
return
this
.
_radiusAxis
;
}
,
}
/**
* @param {module:echarts/coord/polar/Axis}
* @return {module:echarts/coord/polar/Axis}
*/
getOtherAxis
:
function
(
axis
)
{
getOtherAxis
(
axis
:
AngleAxis
|
RadiusAxis
):
AngleAxis
|
RadiusAxis
{
var
angleAxis
=
this
.
_angleAxis
;
return
axis
===
angleAxis
?
this
.
_radiusAxis
:
angleAxis
;
}
,
}
/**
* Base axis will be used on stacking.
*
* @return {module:echarts/coord/polar/Axis}
*/
getBaseAxis
:
function
()
{
getBaseAxis
()
{
return
this
.
getAxesByScale
(
'
ordinal
'
)[
0
]
||
this
.
getAxesByScale
(
'
time
'
)[
0
]
||
this
.
getAngleAxis
();
}
,
}
/**
* @param {string} [dim] 'radius' or 'angle' or 'auto' or null/undefined
* @return {Object} {baseAxes: [], otherAxes: []}
*/
getTooltipAxes
:
function
(
dim
)
{
getTooltipAxes
(
dim
:
'
radius
'
|
'
angle
'
|
'
auto
'
)
{
var
baseAxis
=
(
dim
!=
null
&&
dim
!==
'
auto
'
)
?
this
.
getAxis
(
dim
)
:
this
.
getBaseAxis
();
return
{
baseAxes
:
[
baseAxis
],
otherAxes
:
[
this
.
getOtherAxis
(
baseAxis
)]
};
}
,
}
/**
* Convert a single data item to (x, y) point.
* Parameter data is an array which the first element is radius and the second is angle
* @param {Array.<number>} data
* @param {boolean} [clamp=false]
* @return {Array.<number>}
*/
dataToPoint
:
function
(
data
,
clamp
)
{
dataToPoint
(
data
:
ScaleDataValue
[],
clamp
?:
boolean
)
{
return
this
.
coordToPoint
([
this
.
_radiusAxis
.
dataToRadius
(
data
[
0
],
clamp
),
this
.
_angleAxis
.
dataToAngle
(
data
[
1
],
clamp
)
]);
}
,
}
/**
* Convert a (x, y) point to data
* @param {Array.<number>} point
* @param {boolean} [clamp=false]
* @return {Array.<number>}
*/
pointToData
:
function
(
point
,
clamp
)
{
pointToData
(
point
:
number
[],
clamp
?:
boolean
)
{
var
coord
=
this
.
pointToCoord
(
point
);
return
[
this
.
_radiusAxis
.
radiusToData
(
coord
[
0
],
clamp
),
this
.
_angleAxis
.
angleToData
(
coord
[
1
],
clamp
)
];
}
,
}
/**
* Convert a (x, y) point to (radius, angle) coord
* @param {Array.<number>} point
* @return {Array.<number>}
*/
pointToCoord
:
function
(
point
)
{
pointToCoord
(
point
:
number
[]
)
{
var
dx
=
point
[
0
]
-
this
.
cx
;
var
dy
=
point
[
1
]
-
this
.
cy
;
var
angleAxis
=
this
.
getAngleAxis
();
...
...
@@ -241,14 +187,12 @@ Polar.prototype = {
}
return
[
radius
,
radian
];
}
,
}
/**
* Convert a (radius, angle) coord to (x, y) point
* @param {Array.<number>} coord
* @return {Array.<number>}
*/
coordToPoint
:
function
(
coord
)
{
coordToPoint
(
coord
:
number
[]
)
{
var
radius
=
coord
[
0
];
var
radian
=
coord
[
1
]
/
180
*
Math
.
PI
;
var
x
=
Math
.
cos
(
radian
)
*
radius
+
this
.
cx
;
...
...
@@ -256,14 +200,13 @@ Polar.prototype = {
var
y
=
-
Math
.
sin
(
radian
)
*
radius
+
this
.
cy
;
return
[
x
,
y
];
}
,
}
/**
* Get ring area of cartesian.
* Area will have a contain function to determine if a point is in the coordinate system.
* @return {Ring}
*/
getArea
:
function
()
{
getArea
()
{
var
angleAxis
=
this
.
getAngleAxis
();
var
radiusAxis
=
this
.
getRadiusAxis
();
...
...
@@ -282,7 +225,7 @@ Polar.prototype = {
startAngle
:
-
angleExtent
[
0
]
*
RADIAN
,
endAngle
:
-
angleExtent
[
1
]
*
RADIAN
,
clockwise
:
angleAxis
.
inverse
,
contain
:
function
(
x
,
y
)
{
contain
(
x
:
number
,
y
:
number
)
{
// It's a ring shape.
// Start angle and end angle don't matter
var
dx
=
x
-
this
.
cx
;
...
...
@@ -296,6 +239,17 @@ Polar.prototype = {
};
}
};
convertToPixel
(
ecModel
:
GlobalModel
,
finder
:
ParsedModelFinder
,
value
:
ScaleDataValue
[])
{
const
seriesModel
=
finder
.
seriesModel
;
const
coordSys
=
seriesModel
?
seriesModel
.
coordinateSystem
:
null
;
return
coordSys
===
this
?
this
.
dataToPoint
(
value
)
:
null
;
}
convertFromPixel
(
ecModel
:
GlobalModel
,
finder
:
ParsedModelFinder
,
pixel
:
number
[])
{
const
seriesModel
=
finder
.
seriesModel
;
const
coordSys
=
seriesModel
?
seriesModel
.
coordinateSystem
:
null
;
return
coordSys
===
this
?
this
.
pointToData
(
pixel
)
:
null
;
}
}
export
default
Polar
;
\ No newline at end of file
src/coord/polar/PolarModel.ts
浏览文件 @
1fb92ccd
...
...
@@ -17,39 +17,37 @@
* under the License.
*/
// @ts-nocheck
import
{
ComponentOption
,
CircleLayoutOptionMixin
}
from
'
../../util/types
'
;
import
ComponentModel
from
'
../../model/Component
'
;
import
Polar
from
'
./Polar
'
;
import
{
AngleAxisModel
,
RadiusAxisModel
}
from
'
./AxisModel
'
;
import
*
as
echarts
from
'
../../echarts
'
;
import
'
./AxisModel
'
;
export
interface
PolarOption
extends
ComponentOption
,
CircleLayoutOptionMixin
{
}
export
default
echarts
.
extendComponentModel
({
class
PolarModel
extends
ComponentModel
<
PolarOption
>
{
static
type
=
'
polar
'
as
const
type
=
PolarModel
.
type
type
:
'
polar
'
,
static
dependencies
=
[
'
radiusAxis
'
,
'
angleAxis
'
]
dependencies
:
[
'
polarAxis
'
,
'
angleAxis
'
],
coordinateSystem
:
Polar
/**
* @type {module:echarts/coord/polar/Polar}
*/
coordinateSystem
:
null
,
/**
* @param {string} axisType
* @return {module:echarts/coord/polar/AxisModel}
*/
findAxisModel
:
function
(
axisType
)
{
findAxisModel
(
axisType
:
'
angleAxis
'
):
AngleAxisModel
findAxisModel
(
axisType
:
'
radiusAxis
'
):
RadiusAxisModel
findAxisModel
(
axisType
:
'
angleAxis
'
|
'
radiusAxis
'
):
AngleAxisModel
|
RadiusAxisModel
{
var
foundAxisModel
;
var
ecModel
=
this
.
ecModel
;
ecModel
.
eachComponent
(
axisType
,
function
(
a
xisModel
)
{
ecModel
.
eachComponent
(
axisType
,
function
(
this
:
PolarModel
,
axisModel
:
AngleAxisModel
|
RadiusA
xisModel
)
{
if
(
axisModel
.
getCoordSysModel
()
===
this
)
{
foundAxisModel
=
axisModel
;
}
},
this
);
return
foundAxisModel
;
}
,
}
defaultOption
:
{
static
defaultOption
:
PolarOption
=
{
zlevel
:
0
,
...
...
@@ -59,4 +57,8 @@ export default echarts.extendComponentModel({
radius
:
'
80%
'
}
});
\ No newline at end of file
}
ComponentModel
.
registerClass
(
PolarModel
);
export
default
PolarModel
;
\ No newline at end of file
src/coord/polar/RadiusAxis.ts
浏览文件 @
1fb92ccd
...
...
@@ -17,42 +17,35 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
Axis
from
'
../Axis
'
;
import
{
OptionAxisType
}
from
'
../axisCommonTypes
'
;
import
Scale
from
'
../../scale/Scale
'
;
import
Polar
from
'
./Polar
'
;
import
{
RadiusAxisModel
}
from
'
./AxisModel
'
;
interface
RadiusAxis
{
dataToRadius
:
Axis
[
'
dataToCoord
'
]
radiusToData
:
Axis
[
'
coordToData
'
]
}
function
RadiusAxis
(
scale
,
radiusExtent
)
{
Axis
.
call
(
this
,
'
radius
'
,
scale
,
radiusExtent
);
class
RadiusAxis
extends
Axis
{
type
:
OptionAxisType
/**
* Axis type
* - 'category'
* - 'value'
* - 'time'
* - 'log'
* @type {string}
*/
this
.
type
=
'
category
'
;
}
polar
:
Polar
RadiusAxis
.
prototype
=
{
model
:
RadiusAxisModel
constructor
:
RadiusAxis
,
constructor
(
scale
?:
Scale
,
radiusExtent
?:
[
number
,
number
])
{
super
(
'
radius
'
,
scale
,
radiusExtent
);
}
/**
* @override
*/
pointToData
:
function
(
point
,
clamp
)
{
pointToData
(
point
:
number
[],
clamp
?:
boolean
)
{
return
this
.
polar
.
pointToData
(
point
,
clamp
)[
this
.
dim
===
'
radius
'
?
0
:
1
];
},
dataToRadius
:
Axis
.
prototype
.
dataToCoord
,
}
}
radiusToData
:
Axis
.
prototype
.
coordToData
};
RadiusAxis
.
prototype
.
dataToRadius
=
Axis
.
prototype
.
dataToCoord
;
zrUtil
.
inherits
(
RadiusAxis
,
Axis
)
;
RadiusAxis
.
prototype
.
radiusToData
=
Axis
.
prototype
.
coordToData
;
export
default
RadiusAxis
;
\ No newline at end of file
src/coord/polar/polarCreator.ts
浏览文件 @
1fb92ccd
...
...
@@ -17,8 +17,6 @@
* under the License.
*/
// @ts-nocheck
// TODO Axis scale
import
{
__DEV__
}
from
'
../../config
'
;
...
...
@@ -32,14 +30,20 @@ import {
import
CoordinateSystem
from
'
../../CoordinateSystem
'
;
import
{
getStackedDimension
}
from
'
../../data/helper/dataStackHelper
'
;
import
'
./PolarModel
'
;
import
PolarModel
from
'
./PolarModel
'
;
import
ExtensionAPI
from
'
../../ExtensionAPI
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
OrdinalScale
from
'
../../scale/Ordinal
'
;
import
RadiusAxis
from
'
./RadiusAxis
'
;
import
AngleAxis
from
'
./AngleAxis
'
;
import
{
PolarAxisModel
,
AngleAxisModel
,
RadiusAxisModel
}
from
'
./AxisModel
'
;
import
SeriesModel
from
'
../../model/Series
'
;
import
{
SeriesOption
}
from
'
../../util/types
'
;
/**
* Resize method bound to the polar
* @param {module:echarts/coord/polar/PolarModel} polarModel
* @param {module:echarts/ExtensionAPI} api
*/
function
resizePolar
(
polar
,
polarModel
,
api
)
{
function
resizePolar
(
polar
:
Polar
,
polarModel
:
PolarModel
,
api
:
ExtensionAPI
)
{
var
center
=
polarModel
.
get
(
'
center
'
);
var
width
=
api
.
getWidth
();
var
height
=
api
.
getHeight
();
...
...
@@ -58,20 +62,20 @@ function resizePolar(polar, polarModel, api) {
// r0 = 0
radius
=
[
0
,
radius
];
}
r
adius
=
[
const
parsedR
adius
=
[
parsePercent
(
radius
[
0
],
size
),
parsePercent
(
radius
[
1
],
size
)
];
radiusAxis
.
inverse
?
radiusAxis
.
setExtent
(
radius
[
1
],
r
adius
[
0
])
:
radiusAxis
.
setExtent
(
radius
[
0
],
r
adius
[
1
]);
?
radiusAxis
.
setExtent
(
parsedRadius
[
1
],
parsedR
adius
[
0
])
:
radiusAxis
.
setExtent
(
parsedRadius
[
0
],
parsedR
adius
[
1
]);
}
/**
* Update polar
*/
function
updatePolarScale
(
ecModel
,
api
)
{
function
updatePolarScale
(
this
:
Polar
,
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
)
{
var
polar
=
this
;
var
angleAxis
=
polar
.
getAngleAxis
();
var
radiusAxis
=
polar
.
getRadiusAxis
();
...
...
@@ -101,33 +105,33 @@ function updatePolarScale(ecModel, api) {
// Fix extent of category angle axis
if
(
angleAxis
.
type
===
'
category
'
&&
!
angleAxis
.
onBand
)
{
var
extent
=
angleAxis
.
getExtent
();
var
diff
=
360
/
angleAxis
.
scale
.
count
();
var
diff
=
360
/
(
angleAxis
.
scale
as
OrdinalScale
)
.
count
();
angleAxis
.
inverse
?
(
extent
[
1
]
+=
diff
)
:
(
extent
[
1
]
-=
diff
);
angleAxis
.
setExtent
(
extent
[
0
],
extent
[
1
]);
}
}
function
isAngleAxisModel
(
axisModel
:
AngleAxisModel
|
PolarAxisModel
):
axisModel
is
AngleAxisModel
{
return
axisModel
.
mainType
===
'
angleAxis
'
;
}
/**
* Set common axis properties
* @param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
* @param {module:echarts/coord/polar/AxisModel}
* @inner
*/
function
setAxis
(
axis
,
a
xisModel
)
{
function
setAxis
(
axis
:
RadiusAxis
|
AngleAxis
,
axisModel
:
PolarA
xisModel
)
{
axis
.
type
=
axisModel
.
get
(
'
type
'
);
axis
.
scale
=
createScaleByModel
(
axisModel
);
axis
.
onBand
=
axisModel
.
get
(
'
boundaryGap
'
)
&&
axis
.
type
===
'
category
'
;
axis
.
inverse
=
axisModel
.
get
(
'
inverse
'
);
if
(
axisModel
.
mainType
===
'
angleAxis
'
)
{
axis
.
inverse
^
=
axisModel
.
get
(
'
clockwise
'
);
if
(
isAngleAxisModel
(
axisModel
)
)
{
axis
.
inverse
=
axis
.
inverse
!=
=
axisModel
.
get
(
'
clockwise
'
);
var
startAngle
=
axisModel
.
get
(
'
startAngle
'
);
axis
.
setExtent
(
startAngle
,
startAngle
+
(
axis
.
inverse
?
-
360
:
360
));
}
// Inject axis instance
axisModel
.
axis
=
axis
;
axis
.
model
=
axisModel
;
axis
.
model
=
axisModel
as
AngleAxisModel
|
RadiusAxisModel
;
}
...
...
@@ -135,10 +139,10 @@ var polarCreator = {
dimensions
:
Polar
.
prototype
.
dimensions
,
create
:
function
(
ecModel
,
api
)
{
var
polarList
=
[];
ecModel
.
eachComponent
(
'
polar
'
,
function
(
polarModel
,
idx
)
{
var
polar
=
new
Polar
(
idx
);
create
:
function
(
ecModel
:
GlobalModel
,
api
:
ExtensionAPI
)
{
var
polarList
:
Polar
[]
=
[];
ecModel
.
eachComponent
(
'
polar
'
,
function
(
polarModel
:
PolarModel
,
idx
:
number
)
{
var
polar
=
new
Polar
(
idx
+
''
);
// Inject resize and update method
polar
.
update
=
updatePolarScale
;
...
...
@@ -159,18 +163,21 @@ var polarCreator = {
polar
.
model
=
polarModel
;
});
// Inject coordinateSystem to series
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
ecModel
.
eachSeries
(
function
(
seriesModel
:
SeriesModel
<
SeriesOption
&
{
polarIndex
?:
number
polarId
?:
string
}
>
)
{
if
(
seriesModel
.
get
(
'
coordinateSystem
'
)
===
'
polar
'
)
{
var
polarModel
=
ecModel
.
queryComponents
({
mainType
:
'
polar
'
,
index
:
seriesModel
.
get
(
'
polarIndex
'
),
id
:
seriesModel
.
get
(
'
polarId
'
)
})[
0
];
})[
0
]
as
PolarModel
;
if
(
__DEV__
)
{
if
(
!
polarModel
)
{
throw
new
Error
(
'
Polar "
'
+
zrUtil
.
retrieve
(
'
Polar "
'
+
zrUtil
.
retrieve
<
number
|
string
>
(
seriesModel
.
get
(
'
polarIndex
'
),
seriesModel
.
get
(
'
polarId
'
),
0
...
...
src/coord/polar/prepareCustom.ts
浏览文件 @
1fb92ccd
...
...
@@ -17,21 +17,24 @@
* under the License.
*/
// @ts-nocheck
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
Polar
from
'
./Polar
'
;
import
RadiusAxis
from
'
./RadiusAxis
'
;
import
AngleAxis
from
'
./AngleAxis
'
;
function
dataToCoordSize
(
dataSize
,
dataItem
)
{
function
dataToCoordSize
(
this
:
Polar
,
dataSize
:
number
[],
dataItem
:
number
[]
)
{
// dataItem is necessary in log axis.
return
zrUtil
.
map
([
'
Radius
'
,
'
Angle
'
],
function
(
dim
,
dimIdx
)
{
var
axis
=
this
[
'
get
'
+
dim
+
'
Axis
'
]();
var
val
=
dataItem
[
dimIdx
];
var
halfSize
=
dataSize
[
dimIdx
]
/
2
;
var
method
=
'
dataTo
'
+
dim
;
const
getterName
=
'
get
'
+
dim
+
'
Axis
'
as
'
getAngleAxis
'
|
'
getRadiusAxis
'
;
// TODO: TYPE Check Angle Axis
const
axis
=
this
[
getterName
]()
as
RadiusAxis
;
const
val
=
dataItem
[
dimIdx
];
const
halfSize
=
dataSize
[
dimIdx
]
/
2
;
const
converterName
=
'
dataTo
'
+
dim
as
'
dataToRadius
'
;
var
result
=
axis
.
type
===
'
category
'
?
axis
.
getBandWidth
()
:
Math
.
abs
(
axis
[
method
](
val
-
halfSize
)
-
axis
[
method
](
val
+
halfSize
));
:
Math
.
abs
(
axis
[
converterName
](
val
-
halfSize
)
-
axis
[
converterName
](
val
+
halfSize
));
if
(
dim
===
'
Angle
'
)
{
result
=
result
*
Math
.
PI
/
180
;
...
...
@@ -42,7 +45,7 @@ function dataToCoordSize(dataSize, dataItem) {
},
this
);
}
export
default
function
(
coordSys
)
{
export
default
function
(
coordSys
:
Polar
)
{
var
radiusAxis
=
coordSys
.
getRadiusAxis
();
var
angleAxis
=
coordSys
.
getAngleAxis
();
var
radius
=
radiusAxis
.
getExtent
();
...
...
@@ -57,13 +60,13 @@ export default function (coordSys) {
r0
:
radius
[
0
]
},
api
:
{
coord
:
zrUtil
.
bind
(
function
(
data
)
{
coord
:
function
(
data
:
number
[]
)
{
var
radius
=
radiusAxis
.
dataToRadius
(
data
[
0
]);
var
angle
=
angleAxis
.
dataToAngle
(
data
[
1
]);
var
coord
=
coordSys
.
coordToPoint
([
radius
,
angle
]);
coord
.
push
(
radius
,
angle
*
Math
.
PI
/
180
);
return
coord
;
}
)
,
},
size
:
zrUtil
.
bind
(
dataToCoordSize
,
coordSys
)
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录