in src/component/marker/MarkAreaView.ts [155:229]
function getSingleMarkerEndPoint(
data: SeriesData<MarkAreaModel>,
idx: number,
dims: typeof dimPermutations[number],
seriesModel: SeriesModel,
api: ExtensionAPI
) {
const coordSys = seriesModel.coordinateSystem;
const itemModel = data.getItemModel<MarkAreaMergedItemOption>(idx);
let point;
const xPx = numberUtil.parsePercent(itemModel.get(dims[0]), api.getWidth());
const yPx = numberUtil.parsePercent(itemModel.get(dims[1]), api.getHeight());
if (!isNaN(xPx) && !isNaN(yPx)) {
point = [xPx, yPx];
}
else {
// Chart like bar may have there own marker positioning logic
if (seriesModel.getMarkerPosition) {
// Consider the case that user input the right-bottom point first
// Pick the larger x and y as 'x1' and 'y1'
const pointValue0 = data.getValues(['x0', 'y0'], idx);
const pointValue1 = data.getValues(['x1', 'y1'], idx);
const clampPointValue0 = coordSys.clampData(pointValue0);
const clampPointValue1 = coordSys.clampData(pointValue1);
const pointValue = [];
if (dims[0] === 'x0') {
pointValue[0] = (clampPointValue0[0] > clampPointValue1[0]) ? pointValue1[0] : pointValue0[0];
}
else {
pointValue[0] = (clampPointValue0[0] > clampPointValue1[0]) ? pointValue0[0] : pointValue1[0];
}
if (dims[1] === 'y0') {
pointValue[1] = (clampPointValue0[1] > clampPointValue1[1]) ? pointValue1[1] : pointValue0[1];
}
else {
pointValue[1] = (clampPointValue0[1] > clampPointValue1[1]) ? pointValue0[1] : pointValue1[1];
}
// Use the getMarkerPosition
point = seriesModel.getMarkerPosition(
pointValue, dims, true
);
}
else {
const x = data.get(dims[0], idx) as number;
const y = data.get(dims[1], idx) as number;
const pt = [x, y];
coordSys.clampData && coordSys.clampData(pt, pt);
point = coordSys.dataToPoint(pt, true);
}
if (isCoordinateSystemType<Cartesian2D>(coordSys, 'cartesian2d')) {
// TODO: TYPE ts@4.1 may still infer it as Axis instead of Axis2D. Not sure if it's a bug
const xAxis = coordSys.getAxis('x') as Axis2D;
const yAxis = coordSys.getAxis('y') as Axis2D;
const x = data.get(dims[0], idx) as number;
const y = data.get(dims[1], idx) as number;
if (isInfinity(x)) {
point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[dims[0] === 'x0' ? 0 : 1]);
}
else if (isInfinity(y)) {
point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[dims[1] === 'y0' ? 0 : 1]);
}
}
// Use x, y if has any
if (!isNaN(xPx)) {
point[0] = xPx;
}
if (!isNaN(yPx)) {
point[1] = yPx;
}
}
return point;
}