You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/02/17 14:51:59 UTC
[incubator-echarts] branch typescript updated: ts: remove ts-ignore
caused by zrender type issue
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch typescript
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
The following commit(s) were added to refs/heads/typescript by this push:
new 156fd22 ts: remove ts-ignore caused by zrender type issue
156fd22 is described below
commit 156fd2268d8fc2d7f8059c8358ed3d1d74e4f8db
Author: pissang <bm...@gmail.com>
AuthorDate: Mon Feb 17 22:48:13 2020 +0800
ts: remove ts-ignore caused by zrender type issue
---
src/chart/pie/PieView.ts | 19 ++++---------------
src/model/mixin/itemStyle.ts | 36 ++++++++++++++++++++----------------
2 files changed, 24 insertions(+), 31 deletions(-)
diff --git a/src/chart/pie/PieView.ts b/src/chart/pie/PieView.ts
index 1d9c350..f1e8658 100644
--- a/src/chart/pie/PieView.ts
+++ b/src/chart/pie/PieView.ts
@@ -77,7 +77,6 @@ function toggleItemSelected(
hasAnimation
// animateTo will stop revious animation like update transition
- // @ts-ignore FIXME:TS zr?
? el.animate()
.when(200, {
position: position
@@ -104,7 +103,6 @@ class PiePiece extends graphic.Group {
constructor(data: List, idx: number) {
super();
- // @ts-ignore FIXME:TS modify zr?
var sector = new graphic.Sector({
z2: 2
});
@@ -179,11 +177,9 @@ class PiePiece extends graphic.Group {
itemModel.getModel('itemStyle').getItemStyle()
)
);
- // @ts-ignore FIXME:TS make a type in util/graphic.ts to support `hoverStyle`.
sector.hoverStyle = itemModel.getModel('emphasis.itemStyle').getItemStyle();
var cursorStyle = itemModel.getShallow('cursor');
- // @ts-ignore FIXME:TS update zr.
cursorStyle && sector.attr('cursor', cursorStyle);
// Toggle selected
@@ -212,7 +208,6 @@ class PiePiece extends graphic.Group {
shape: {
r: layout.r + seriesModel.get('hoverOffset')
}
- // @ts-ignore FIXME:TS modify zr
}, 300, 'elasticOut');
}
else {
@@ -224,7 +219,6 @@ class PiePiece extends graphic.Group {
shape: {
r: layout.r
}
- // @ts-ignore FIXME:TS modify zr
}, 300, 'elasticOut');
}
}
@@ -235,7 +229,7 @@ class PiePiece extends graphic.Group {
private _updateLabel(data: List, idx: number, withAnimation: boolean): void {
- var labelLine = this.childAt(1) as (PieceElementExtension & graphic.Line);
+ var labelLine = this.childAt(1) as (PieceElementExtension & graphic.Polyline);
var labelText = this.childAt(2) as (PieceElementExtension & graphic.Text);
var seriesModel = data.hostModel;
@@ -250,7 +244,9 @@ class PiePiece extends graphic.Group {
return;
}
- var targetLineShape = {
+ var targetLineShape: {
+ points: number[][]
+ } = {
points: labelLayout.linePoints || [
[labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y]
]
@@ -270,11 +266,9 @@ class PiePiece extends graphic.Group {
}
else {
labelLine.attr({
- // @ts-ignore FIXME:TS modify zr
shape: targetLineShape
});
labelText.attr({
- // @ts-ignore FIXME:TS modify zr
style: targetTextStyle
});
}
@@ -282,7 +276,6 @@ class PiePiece extends graphic.Group {
labelText.attr({
rotation: labelLayout.rotation,
origin: [labelLayout.x, labelLayout.y],
- // @ts-ignore FIXME:TS modify zr
z2: 10
});
@@ -294,7 +287,6 @@ class PiePiece extends graphic.Group {
graphic.setLabelStyle(
labelText.style,
- // @ts-ignore FIXME:TS make a type in util/graphic.
labelText.hoverStyle = {},
labelModel,
labelHoverModel,
@@ -325,7 +317,6 @@ class PiePiece extends graphic.Group {
});
labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
- // @ts-ignore FIXME:TS
labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
var smooth = labelLineModel.get('smooth');
@@ -376,7 +367,6 @@ class PieView extends ChartView {
var piePiece = new PiePiece(data, idx);
// Default expansion animation
if (isFirstRender && animationType !== 'scale') {
- // @ts-ignore FIXME:TS modify zr?
piePiece.eachChild(function (child) {
child.stopAnimation(true);
});
@@ -392,7 +382,6 @@ class PieView extends ChartView {
var piePiece = oldData.getItemGraphicEl(oldIdx) as PiePiece;
if (!isFirstRender && animationTypeUpdate !== 'transition') {
- // @ts-ignore FIXME:TS modify zr?
piePiece.eachChild(function (child) {
child.stopAnimation(true);
});
diff --git a/src/model/mixin/itemStyle.ts b/src/model/mixin/itemStyle.ts
index 5703152..3c84c26 100644
--- a/src/model/mixin/itemStyle.ts
+++ b/src/model/mixin/itemStyle.ts
@@ -19,34 +19,38 @@
import makeStyleMapper from './makeStyleMapper';
import Model from '../Model';
+import { StyleOption } from 'zrender/src/graphic/Style';
-var getItemStyle = makeStyleMapper(
- [
- ['fill', 'color'],
- ['stroke', 'borderColor'],
- ['lineWidth', 'borderWidth'],
- ['opacity'],
- ['shadowBlur'],
- ['shadowOffsetX'],
- ['shadowOffsetY'],
- ['shadowColor'],
- ['textPosition'],
- ['textAlign']
- ]
-);
+const STYLE_LIST = [
+ ['fill', 'color'],
+ ['stroke', 'borderColor'],
+ ['lineWidth', 'borderWidth'],
+ ['opacity'],
+ ['shadowBlur'],
+ ['shadowOffsetX'],
+ ['shadowOffsetY'],
+ ['shadowColor'],
+ ['textPosition'],
+ ['textAlign']
+] as const;
+var getItemStyle = makeStyleMapper(STYLE_LIST);
interface ItemStyleMixin extends Pick<Model, 'get'> {}
+type ItemStyleOption = Pick<
+ StyleOption, typeof STYLE_LIST[number][0]
+>
+
class ItemStyleMixin {
- getItemStyle(excludes?: string[], includes?: string[]) {
+ getItemStyle(excludes?: string[], includes?: string[]): ItemStyleOption {
var style = getItemStyle(this, excludes, includes);
var lineDash = this.getBorderLineDash();
lineDash && ((style as any).lineDash = lineDash);
return style;
}
- getBorderLineDash() {
+ getBorderLineDash(): number[] {
var lineType = this.get('borderType');
return (lineType === 'solid' || lineType == null) ? null
: (lineType === 'dashed' ? [5, 5] : [1, 1]);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org