MCPcopy
hub / github.com/apache/echarts / findPointFromSeries

Function findPointFromSeries

src/component/axisPointer/findPointFromSeries.ts:31–98  ·  view source on GitHub ↗
(finder: {
    seriesIndex?: number
    dataIndex?: number | number[]
    dataIndexInside?: number | number[]
    name?: string | string[]
    isStacked?: boolean
}, ecModel: GlobalModel)

Source from the content-addressed store, hash-verified

29 * @return {point: [x, y], el: ...} point Will not be null.
30 */
31export 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

Callers 2

manuallyShowTipMethod · 0.85
axisTriggerFunction · 0.85

Calls 14

getSeriesByIndexMethod · 0.80
getItemGraphicElMethod · 0.80
mapDimensionMethod · 0.80
getCalculationInfoMethod · 0.80
getDataMethod · 0.65
getTooltipPositionMethod · 0.65
getBaseAxisMethod · 0.65
dataToPointMethod · 0.65
getOtherAxisMethod · 0.45
getMethod · 0.45
getValuesMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…