(finder: {
seriesIndex?: number
dataIndex?: number | number[]
dataIndexInside?: number | number[]
name?: string | string[]
isStacked?: boolean
}, ecModel: GlobalModel)
| 29 | * @return {point: [x, y], el: ...} point Will not be null. |
| 30 | */ |
| 31 | export default function findPointFromSeries(finder: { |
| 32 | seriesIndex?: number |
| 33 | dataIndex?: number | number[] |
| 34 | dataIndexInside?: number | number[] |
| 35 | name?: string | string[] |
| 36 | isStacked?: boolean |
| 37 | }, ecModel: GlobalModel): { |
| 38 | point: number[] |
| 39 | el?: Element |
| 40 | } { |
| 41 | let point: number[] = []; |
| 42 | const seriesIndex = finder.seriesIndex; |
| 43 | let seriesModel; |
| 44 | if (seriesIndex == null || !( |
| 45 | seriesModel = ecModel.getSeriesByIndex(seriesIndex) |
| 46 | )) { |
| 47 | return { |
| 48 | point: [] |
| 49 | }; |
| 50 | } |
| 51 | |
| 52 | const data = seriesModel.getData(); |
| 53 | const dataIndex = modelUtil.queryDataIndex(data, finder as Payload); |
| 54 | if (dataIndex == null || dataIndex < 0 || zrUtil.isArray(dataIndex)) { |
| 55 | return {point: []}; |
| 56 | } |
| 57 | |
| 58 | const el = data.getItemGraphicEl(dataIndex); |
| 59 | const coordSys = seriesModel.coordinateSystem; |
| 60 | |
| 61 | if (seriesModel.getTooltipPosition) { |
| 62 | point = seriesModel.getTooltipPosition(dataIndex) || []; |
| 63 | } |
| 64 | else if (coordSys && coordSys.dataToPoint) { |
| 65 | if (finder.isStacked) { |
| 66 | const baseAxis = coordSys.getBaseAxis(); |
| 67 | const valueAxis = coordSys.getOtherAxis(baseAxis as any); |
| 68 | const valueAxisDim = valueAxis.dim; |
| 69 | const baseAxisDim = baseAxis.dim; |
| 70 | const baseDataOffset = valueAxisDim === 'x' || valueAxisDim === 'radius' ? 1 : 0; |
| 71 | const baseDim = data.mapDimension(baseAxisDim); |
| 72 | const stackedData = []; |
| 73 | stackedData[baseDataOffset] = data.get(baseDim, dataIndex); |
| 74 | stackedData[1 - baseDataOffset] = data.get(data.getCalculationInfo('stackResultDimension'), dataIndex); |
| 75 | point = coordSys.dataToPoint(stackedData) || []; |
| 76 | } |
| 77 | else { |
| 78 | point = coordSys.dataToPoint( |
| 79 | data.getValues( |
| 80 | zrUtil.map(coordSys.dimensions, function (dim) { |
| 81 | return data.mapDimension(dim); |
| 82 | }), dataIndex |
| 83 | ) |
| 84 | ) || []; |
| 85 | } |
| 86 | } |
| 87 | else if (el) { |
| 88 | // Use graphic bounding rect |
no test coverage detected
searching dependent graphs…