diff --git a/src/chart/helper/Symbol.ts b/src/chart/helper/Symbol.ts index 4522504142..15fc84c6cf 100644 --- a/src/chart/helper/Symbol.ts +++ b/src/chart/helper/Symbol.ts @@ -24,7 +24,7 @@ import { enterEmphasis, leaveEmphasis, enableHoverEmphasis } from '../../util/st import {parsePercent} from '../../util/number'; import {getDefaultLabel} from './labelHelper'; import List from '../../data/List'; -import { ColorString, BlurScope, AnimationOption } from '../../util/types'; +import { ColorString, BlurScope, AnimationOption, ZRColor } from '../../util/types'; import SeriesModel from '../../model/Series'; import { PathProps } from 'zrender/src/graphic/Path'; import { SymbolDrawSeriesScope, SymbolDrawItemModelOption } from './SymbolDraw'; @@ -38,7 +38,7 @@ interface SymbolOpts { disableAnimation?: boolean useNameLabel?: boolean - symbolInnerColor?: string + symbolInnerColor?: ZRColor } class Symbol extends graphic.Group { diff --git a/src/chart/tree/TreeView.ts b/src/chart/tree/TreeView.ts index dbee5b1275..bcc8be8ee7 100644 --- a/src/chart/tree/TreeView.ts +++ b/src/chart/tree/TreeView.ts @@ -30,7 +30,7 @@ import {onIrrelevantElement} from '../../component/helper/cursorHelper'; import {parsePercent} from '../../util/number'; import ChartView from '../../view/Chart'; import TreeSeriesModel, { TreeSeriesOption, TreeSeriesNodeItemOption } from './TreeSeries'; -import Path, { PathProps } from 'zrender/src/graphic/Path'; +import Path, { PathProps, PathStyleProps } from 'zrender/src/graphic/Path'; import GlobalModel from '../../model/Global'; import ExtensionAPI from '../../core/ExtensionAPI'; import { TreeNode } from '../../data/Tree'; @@ -376,7 +376,7 @@ function updateNode( const isInit = !symbolEl; const node = data.tree.getNodeByDataIndex(dataIndex); const itemModel = node.getModel(); - const visualColor = node.getVisual('style').fill; + const visualColor = (node.getVisual('style') as PathStyleProps).fill; const symbolInnerColor = node.isExpand === false && node.children.length !== 0 ? visualColor : '#fff'; diff --git a/src/chart/treemap/TreemapView.ts b/src/chart/treemap/TreemapView.ts index 63075e0869..1947317496 100644 --- a/src/chart/treemap/TreemapView.ts +++ b/src/chart/treemap/TreemapView.ts @@ -862,7 +862,7 @@ function renderNode( } else { bg.invisible = false; - const style = thisNode.getVisual('style'); + const style = thisNode.getVisual('style') as PathStyleProps; const visualBorderColor = style.stroke; const normalStyle = getItemStyleNormal(itemStyleNormalModel); normalStyle.fill = visualBorderColor; @@ -877,7 +877,8 @@ function renderNode( const upperLabelWidth = thisWidth - 2 * borderWidth; prepareText( - bg, visualBorderColor, upperLabelWidth, upperHeight, style.opacity, + // PENDING: convert ZRColor to ColorString for text. + bg, visualBorderColor as ColorString, style.opacity, {x: borderWidth, y: 0, width: upperLabelWidth, height: upperHeight} ); } @@ -923,7 +924,7 @@ function renderNode( } else { content.invisible = false; - const nodeStyle = thisNode.getVisual('style'); + const nodeStyle = thisNode.getVisual('style') as PathStyleProps; const visualColor = nodeStyle.fill; const normalStyle = getItemStyleNormal(itemStyleNormalModel); normalStyle.fill = visualColor; @@ -932,7 +933,8 @@ function renderNode( const blurStyle = getStateItemStyle(itemStyleBlurModel); const selectStyle = getStateItemStyle(itemStyleSelectModel); - prepareText(content, visualColor, contentWidth, nodeStyle.opacity, contentHeight); + // PENDING: convert ZRColor to ColorString for text. + prepareText(content, visualColor as ColorString, nodeStyle.opacity, null); content.setStyle(normalStyle); content.ensureState('emphasis').style = emphasisStyle; @@ -954,9 +956,8 @@ function renderNode( rectEl: graphic.Rect, visualColor: ColorString, visualOpacity: number, - width: number, - height: number, - upperLabelRect?: RectLike + // Can be null/undefined + upperLabelRect: RectLike ) { const normalLabelModel = nodeModel.getModel( upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL diff --git a/src/data/Tree.ts b/src/data/Tree.ts index 291b5a2294..684fcb83e7 100644 --- a/src/data/Tree.ts +++ b/src/data/Tree.ts @@ -259,8 +259,9 @@ export class TreeNode { /** * Get item visual + * FIXME: make return type better */ - getVisual(key: string): any { + getVisual(key: string): unknown { return this.hostTree.data.getItemVisual(this.dataIndex, key as any); } diff --git a/src/util/symbol.ts b/src/util/symbol.ts index dee0263ee0..5e1c00ffb3 100644 --- a/src/util/symbol.ts +++ b/src/util/symbol.ts @@ -28,7 +28,7 @@ import { ZRColor } from './types'; export type ECSymbol = graphic.Path & { __isEmptyBrush?: boolean - setColor: (color: ZRColor, innerColor?: string) => void + setColor: (color: ZRColor, innerColor?: ZRColor) => void getColor: () => ZRColor }; type SymbolCtor = { new(): ECSymbol }; @@ -306,7 +306,7 @@ const SymbolClz = graphic.Path.extend({ }); // Provide setColor helper method to avoid determine if set the fill or stroke outside -function symbolPathSetColor(this: ECSymbol, color: ZRColor, innerColor?: string) { +function symbolPathSetColor(this: ECSymbol, color: ZRColor, innerColor?: ZRColor) { if (this.type !== 'image') { const symbolStyle = this.style; if (this.__isEmptyBrush) {