(
data: SeriesData<MarkLineModel>,
idx: number,
isFrom: boolean,
seriesModel: SeriesModel,
api: ExtensionAPI
)
| 197 | } |
| 198 | |
| 199 | function 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; |
no test coverage detected
searching dependent graphs…