This is an automated email from the ASF dual-hosted git repository. 100pah pushed a commit to branch release-dev in repository https://gitbox.apache.org/repos/asf/echarts.git
commit a1718d9097d488407a71e2dd30322abb70e737a2 Author: 100pah <[email protected]> AuthorDate: Mon May 11 23:54:58 2026 +0800 fix(lint): Fix according to lint. --- src/chart/funnel/funnelLayout.ts | 62 ++++++++++++++++++++------------- src/chart/sankey/sankeyLayout.ts | 8 ++--- src/chart/tree/TreeView.ts | 2 +- src/component/toolbox/featureManager.ts | 5 ++- src/coord/calendar/prepareCustom.ts | 1 - src/coord/cartesian/Grid.ts | 2 -- src/coord/parallel/Parallel.ts | 2 -- src/coord/polar/polarCreator.ts | 2 -- src/coord/single/Single.ts | 2 -- 9 files changed, 46 insertions(+), 40 deletions(-) diff --git a/src/chart/funnel/funnelLayout.ts b/src/chart/funnel/funnelLayout.ts index 30daefa44..bc4668040 100644 --- a/src/chart/funnel/funnelLayout.ts +++ b/src/chart/funnel/funnelLayout.ts @@ -23,7 +23,7 @@ import FunnelSeriesModel, { FunnelSeriesOption, FunnelDataItemOption, SERIES_TYP import ExtensionAPI from '../../core/ExtensionAPI'; import SeriesData from '../../data/SeriesData'; import GlobalModel from '../../model/Global'; -import { isFunction } from 'zrender/src/core/util'; +import { indexOf, isFunction, isString } from 'zrender/src/core/util'; import { createSimpleOverallStageHandler } from '../../util/model'; @@ -53,8 +53,8 @@ function getSortedIndices(data: SeriesData, sort: FunnelSeriesOption['sort']) { } function labelLayout(data: SeriesData) { - const seriesModel = data.hostModel; - const orient = seriesModel.get('orient'); + const seriesModel = data.hostModel as FunnelSeriesModel; + const isHorizontal = isOrientHorizontal(seriesModel); data.each(function (idx) { const itemModel = data.getItemModel<FunnelDataItemOption>(idx); const labelModel = itemModel.getModel('label'); @@ -100,14 +100,22 @@ function labelLayout(data: SeriesData) { let x2; let y2; const labelLineLen = labelLineModel.get('length'); - if (__DEV__) { - if (orient === 'vertical' && ['top', 'bottom'].indexOf(labelPosition as string) > -1) { + if (isString(labelPosition)) { + if (!isHorizontal && indexOf(['top', 'bottom'], labelPosition) > -1) { labelPosition = 'left'; - console.warn('Position error: Funnel chart on vertical orient dose not support top and bottom.'); + if (__DEV__) { + console.warn( + 'Position error: Funnel chart on vertical orient dose not support top and bottom.' + ); + } } - if (orient === 'horizontal' && ['left', 'right'].indexOf(labelPosition as string) > -1) { + if (isHorizontal && indexOf(['left', 'right'], labelPosition as string) > -1) { labelPosition = 'bottom'; - console.warn('Position error: Funnel chart on horizontal orient dose not support left and right.'); + if (__DEV__) { + console.warn( + 'Position error: Funnel chart on horizontal orient dose not support left and right.' + ); + } } } if (labelPosition === 'left') { @@ -144,9 +152,9 @@ function labelLayout(data: SeriesData) { } else if (labelPosition === 'rightTop') { // RightTop side - x1 = orient === 'horizontal' ? points[3][0] : points[1][0]; - y1 = orient === 'horizontal' ? points[3][1] : points[1][1]; - if (orient === 'horizontal') { + x1 = isHorizontal ? points[3][0] : points[1][0]; + y1 = isHorizontal ? points[3][1] : points[1][1]; + if (isHorizontal) { y2 = y1 - labelLineLen; textY = y2 - 5; textAlign = 'center'; @@ -161,7 +169,7 @@ function labelLayout(data: SeriesData) { // RightBottom side x1 = points[2][0]; y1 = points[2][1]; - if (orient === 'horizontal') { + if (isHorizontal) { y2 = y1 + labelLineLen; textY = y2 + 5; textAlign = 'center'; @@ -175,8 +183,8 @@ function labelLayout(data: SeriesData) { else if (labelPosition === 'leftTop') { // LeftTop side x1 = points[0][0]; - y1 = orient === 'horizontal' ? points[0][1] : points[1][1]; - if (orient === 'horizontal') { + y1 = isHorizontal ? points[0][1] : points[1][1]; + if (isHorizontal) { y2 = y1 - labelLineLen; textY = y2 - 5; textAlign = 'center'; @@ -189,9 +197,9 @@ function labelLayout(data: SeriesData) { } else if (labelPosition === 'leftBottom') { // LeftBottom side - x1 = orient === 'horizontal' ? points[1][0] : points[3][0]; - y1 = orient === 'horizontal' ? points[1][1] : points[2][1]; - if (orient === 'horizontal') { + x1 = isHorizontal ? points[1][0] : points[3][0]; + y1 = isHorizontal ? points[1][1] : points[2][1]; + if (isHorizontal) { y2 = y1 + labelLineLen; textY = y2 + 5; textAlign = 'center'; @@ -206,7 +214,7 @@ function labelLayout(data: SeriesData) { // Right side or Bottom side x1 = (points[1][0] + points[2][0]) / 2; y1 = (points[1][1] + points[2][1]) / 2; - if (orient === 'horizontal') { + if (isHorizontal) { y2 = y1 + labelLineLen; textY = y2 + 5; textAlign = 'center'; @@ -217,7 +225,7 @@ function labelLayout(data: SeriesData) { textAlign = 'left'; } } - if (orient === 'horizontal') { + if (isHorizontal) { x2 = x1; textX = x2; } @@ -250,14 +258,14 @@ function funnelLayout(ecModel: GlobalModel, api: ExtensionAPI) { const layoutRef = layout.createBoxLayoutReference(seriesModel, api); const viewRect = layout.getLayoutRect(seriesModel.getBoxLayoutParams(), layoutRef.refContainer); - const orient = seriesModel.get('orient'); + const isHorizontal = isOrientHorizontal(seriesModel); const viewWidth = viewRect.width; const viewHeight = viewRect.height; let indices = getSortedIndices(data, sort); let x = viewRect.x; let y = viewRect.y; - const sizeExtent = orient === 'horizontal' ? [ + const sizeExtent = isHorizontal ? [ parsePercent(seriesModel.get('minSize'), viewHeight), parsePercent(seriesModel.get('maxSize'), viewHeight) ] : [ @@ -276,12 +284,12 @@ function funnelLayout(ecModel: GlobalModel, api: ExtensionAPI) { const funnelAlign = seriesModel.get('funnelAlign'); let gap = seriesModel.get('gap'); - const viewSize = orient === 'horizontal' ? viewWidth : viewHeight; + const viewSize = isHorizontal ? viewWidth : viewHeight; let itemSize = (viewSize - gap * (data.count() - 1)) / data.count(); const getLinePoints = function (idx: number, offset: number) { // End point index is data.count() and we assign it 0 - if (orient === 'horizontal') { + if (isHorizontal) { const val = data.get(valueDim, idx) as number || 0; const itemHeight = linearMap(val, [min, max], sizeExtent, true); let y0; @@ -326,7 +334,7 @@ function funnelLayout(ecModel: GlobalModel, api: ExtensionAPI) { // From bottom to top itemSize = -itemSize; gap = -gap; - if (orient === 'horizontal') { + if (isHorizontal) { x += viewWidth; } else { @@ -340,7 +348,7 @@ function funnelLayout(ecModel: GlobalModel, api: ExtensionAPI) { const nextIdx = indices[i + 1]; const itemModel = data.getItemModel<FunnelDataItemOption>(idx); - if (orient === 'horizontal') { + if (isHorizontal) { let width = itemModel.get(['itemStyle', 'width']); if (width == null) { width = itemSize; @@ -387,3 +395,7 @@ function funnelLayout(ecModel: GlobalModel, api: ExtensionAPI) { labelLayout(data); }); } + +function isOrientHorizontal(seriesModel: FunnelSeriesModel): boolean { + return seriesModel.get('orient') === 'horizontal'; +} diff --git a/src/chart/sankey/sankeyLayout.ts b/src/chart/sankey/sankeyLayout.ts index 546632009..26bb48104 100644 --- a/src/chart/sankey/sankeyLayout.ts +++ b/src/chart/sankey/sankeyLayout.ts @@ -149,11 +149,11 @@ function computeNodeBreadths( for (let edgeIdx = 0; edgeIdx < node.outEdges.length; edgeIdx++) { const edge = node.outEdges[edgeIdx]; - const indexEdge = edges.indexOf(edge); + const indexEdge = zrUtil.indexOf(edges, edge); remainEdges[indexEdge] = 0; const targetNode = edge.node2; - const nodeIndex = nodes.indexOf(targetNode); - if (--indegreeArr[nodeIndex] === 0 && nextTargetNode.indexOf(targetNode) < 0) { + const nodeIndex = zrUtil.indexOf(nodes, targetNode); + if (--indegreeArr[nodeIndex] === 0 && zrUtil.indexOf(nextTargetNode, targetNode) < 0) { nextTargetNode.push(targetNode); } } @@ -201,7 +201,7 @@ function adjustNodeWithNodeAlign( node.setLayout({skNodeHeight: nodeHeight}, true); for (let j = 0; j < node.inEdges.length; j++) { const edge = node.inEdges[j]; - if (nextSourceNode.indexOf(edge.node1) < 0) { + if (zrUtil.indexOf(nextSourceNode, edge.node1) < 0) { nextSourceNode.push(edge.node1); } } diff --git a/src/chart/tree/TreeView.ts b/src/chart/tree/TreeView.ts index 2c38612f0..c819e1971 100644 --- a/src/chart/tree/TreeView.ts +++ b/src/chart/tree/TreeView.ts @@ -675,7 +675,7 @@ function removeNode( }); // remove edge as parent node - node.children.forEach(childNode => { + zrUtil.each(node.children, function (childNode) { removeNodeEdge(childNode, data, group, seriesModel, removeAnimationOpt); }); // remove edge as child node diff --git a/src/component/toolbox/featureManager.ts b/src/component/toolbox/featureManager.ts index a1f554355..65b0917bc 100644 --- a/src/component/toolbox/featureManager.ts +++ b/src/component/toolbox/featureManager.ts @@ -67,7 +67,10 @@ export interface ToolboxFeatureModel<Opts extends ToolboxFeatureOption = Toolbox setIconStatus(iconName: string, status: DisplayState): void } -interface ToolboxFeature<Opts extends ToolboxFeatureOption = ToolboxFeatureOption> { +interface ToolboxFeature< + // eslint-disable-next-line @typescript-eslint/no-unused-vars + Opts extends ToolboxFeatureOption = ToolboxFeatureOption +> { getIcons?(): Dictionary<string> onclick(ecModel: GlobalModel, api: ExtensionAPI, type: string, event: ZRElementEvent): void diff --git a/src/coord/calendar/prepareCustom.ts b/src/coord/calendar/prepareCustom.ts index b17903dc4..c7cfbfced 100644 --- a/src/coord/calendar/prepareCustom.ts +++ b/src/coord/calendar/prepareCustom.ts @@ -18,7 +18,6 @@ */ import type Calendar from './Calendar'; -import { OptionDataValueDate } from '../../util/types'; export default function calendarPrepareCustom(coordSys: Calendar) { const rect = coordSys.getRect(); diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index fc67db888..911c9ae5a 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -34,8 +34,6 @@ import { determineAxisType, isOnAxisZeroDiscouraged, SCALE_VALUE_POSITION_KIND_OUTSIDE, - SCALE_VALUE_POSITION_KIND_EDGE, - SCALE_VALUE_POSITION_KIND_INSIDE, getTickValueOutermost, isAxisOnBand, } from '../../coord/axisHelper'; diff --git a/src/coord/parallel/Parallel.ts b/src/coord/parallel/Parallel.ts index 32adb0301..6c9056773 100644 --- a/src/coord/parallel/Parallel.ts +++ b/src/coord/parallel/Parallel.ts @@ -38,8 +38,6 @@ import { Dictionary, DimensionName, ScaleDataValue } from '../../util/types'; import { CoordinateSystem, CoordinateSystemMaster } from '../CoordinateSystem'; import ParallelAxisModel, { ParallelActiveState } from './AxisModel'; import SeriesData from '../../data/SeriesData'; -import { AxisBaseModel } from '../AxisBaseModel'; -import { CategoryAxisBaseOption } from '../axisCommonTypes'; import { scaleCalcNice } from '../axisNiceTicks'; import { AXIS_EXTENT_INFO_BUILD_FROM_COORD_SYS_UPDATE, scaleRawExtentInfoCreate diff --git a/src/coord/polar/polarCreator.ts b/src/coord/polar/polarCreator.ts index 45bfe4335..6bca2506e 100644 --- a/src/coord/polar/polarCreator.ts +++ b/src/coord/polar/polarCreator.ts @@ -37,8 +37,6 @@ import { PolarAxisModel, AngleAxisModel, RadiusAxisModel } from './AxisModel'; import SeriesModel from '../../model/Series'; import { SeriesOption } from '../../util/types'; import { SINGLE_REFERRING } from '../../util/model'; -import { AxisBaseModel } from '../AxisBaseModel'; -import { CategoryAxisBaseOption } from '../axisCommonTypes'; import { createBoxLayoutReference } from '../../util/layout'; import { scaleCalcNice } from '../axisNiceTicks'; import { diff --git a/src/coord/single/Single.ts b/src/coord/single/Single.ts index 6b95de52c..1bda87f46 100644 --- a/src/coord/single/Single.ts +++ b/src/coord/single/Single.ts @@ -31,8 +31,6 @@ import BoundingRect from 'zrender/src/core/BoundingRect'; import SingleAxisModel, { COORD_SYS_TYPE_SINGLE } from './AxisModel'; import { ParsedModelFinder, ParsedModelFinderKnown } from '../../util/model'; import { ScaleDataValue } from '../../util/types'; -import { AxisBaseModel } from '../AxisBaseModel'; -import { CategoryAxisBaseOption } from '../axisCommonTypes'; import { scaleCalcNice } from '../axisNiceTicks'; import { AXIS_EXTENT_INFO_BUILD_FROM_COORD_SYS_UPDATE, scaleRawExtentInfoCreate --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
