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

Function updateSingleMarkerEndLayout

src/component/marker/MarkLineView.ts:199–261  ·  view source on GitHub ↗
(
    data: SeriesData<MarkLineModel>,
    idx: number,
    isFrom: boolean,
    seriesModel: SeriesModel,
    api: ExtensionAPI
)

Source from the content-addressed store, hash-verified

197}
198
199function updateSingleMarkerEndLayout(
200 data: SeriesData<MarkLineModel>,
201 idx: number,
202 isFrom: boolean,
203 seriesModel: SeriesModel,
204 api: ExtensionAPI
205) {
206 const coordSys = seriesModel.coordinateSystem;
207 const itemModel = data.getItemModel<MarkLine2DDataItemOption[number]>(idx);
208
209 let point;
210 const xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
211 const yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
212 if (!isNaN(xPx) && !isNaN(yPx)) {
213 point = [xPx, yPx];
214 }
215 else {
216 // Chart like bar may have there own marker positioning logic
217 if (seriesModel.getMarkerPosition) {
218 // Use the getMarkerPosition
219 point = seriesModel.getMarkerPosition(
220 data.getValues(data.dimensions, idx)
221 );
222 }
223 else {
224 const dims = coordSys.dimensions;
225 const x = data.get(dims[0], idx);
226 const y = data.get(dims[1], idx);
227 point = coordSys.dataToPoint([x, y]);
228 }
229 // Expand line to the edge of grid if value on one axis is Inifnity
230 // In case
231 // markLine: {
232 // data: [{
233 // yAxis: 2
234 // // or
235 // type: 'average'
236 // }]
237 // }
238 if (isCoordinateSystemType<Cartesian2D>(coordSys, 'cartesian2d')) {
239 // TODO: TYPE ts@4.1 may still infer it as Axis instead of Axis2D. Not sure if it's a bug
240 const xAxis = coordSys.getAxis('x') as Axis2D;
241 const yAxis = coordSys.getAxis('y') as Axis2D;
242 const dims = coordSys.dimensions;
243 if (isInfinity(data.get(dims[0], idx))) {
244 point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[isFrom ? 0 : 1]);
245 }
246 else if (isInfinity(data.get(dims[1], idx))) {
247 point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[isFrom ? 0 : 1]);
248 }
249 }
250
251 // Use x, y if has any
252 if (!isNaN(xPx)) {
253 point[0] = xPx;
254 }
255 if (!isNaN(yPx)) {
256 point[1] = yPx;

Callers 2

updateTransformMethod · 0.85

Calls 13

isCoordinateSystemTypeFunction · 0.90
getItemModelMethod · 0.80
setItemLayoutMethod · 0.80
isInfinityFunction · 0.70
getWidthMethod · 0.65
getHeightMethod · 0.65
getMarkerPositionMethod · 0.65
dataToPointMethod · 0.65
toGlobalCoordMethod · 0.65
getExtentMethod · 0.65
getMethod · 0.45
getValuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…