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

Function getSingleMarkerEndPoint

src/component/marker/MarkAreaView.ts:156–230  ·  view source on GitHub ↗
(
    data: SeriesData<MarkAreaModel>,
    idx: number,
    dims: typeof dimPermutations[number],
    seriesModel: SeriesModel,
    api: ExtensionAPI
)

Source from the content-addressed store, hash-verified

154
155// dims can be ['x0', 'y0'], ['x1', 'y1'], ['x0', 'y1'], ['x1', 'y0']
156function getSingleMarkerEndPoint(
157 data: SeriesData<MarkAreaModel>,
158 idx: number,
159 dims: typeof dimPermutations[number],
160 seriesModel: SeriesModel,
161 api: ExtensionAPI
162) {
163 const coordSys = seriesModel.coordinateSystem;
164 const itemModel = data.getItemModel<MarkAreaMergedItemOption>(idx);
165
166 let point;
167 const xPx = numberUtil.parsePercent(itemModel.get(dims[0]), api.getWidth());
168 const yPx = numberUtil.parsePercent(itemModel.get(dims[1]), api.getHeight());
169 if (!isNaN(xPx) && !isNaN(yPx)) {
170 point = [xPx, yPx];
171 }
172 else {
173 // Chart like bar may have there own marker positioning logic
174 if (seriesModel.getMarkerPosition) {
175 // Consider the case that user input the right-bottom point first
176 // Pick the larger x and y as 'x1' and 'y1'
177 const pointValue0 = data.getValues(['x0', 'y0'], idx);
178 const pointValue1 = data.getValues(['x1', 'y1'], idx);
179 const clampPointValue0 = coordSys.clampData(pointValue0);
180 const clampPointValue1 = coordSys.clampData(pointValue1);
181 const pointValue = [];
182 if (dims[0] === 'x0') {
183 pointValue[0] = (clampPointValue0[0] > clampPointValue1[0]) ? pointValue1[0] : pointValue0[0];
184 }
185 else {
186 pointValue[0] = (clampPointValue0[0] > clampPointValue1[0]) ? pointValue0[0] : pointValue1[0];
187 }
188 if (dims[1] === 'y0') {
189 pointValue[1] = (clampPointValue0[1] > clampPointValue1[1]) ? pointValue1[1] : pointValue0[1];
190 }
191 else {
192 pointValue[1] = (clampPointValue0[1] > clampPointValue1[1]) ? pointValue0[1] : pointValue1[1];
193 }
194 // Use the getMarkerPosition
195 point = seriesModel.getMarkerPosition(
196 pointValue, dims, true
197 );
198 }
199 else {
200 const x = data.get(dims[0], idx) as number;
201 const y = data.get(dims[1], idx) as number;
202 const pt = [x, y];
203 coordSys.clampData && coordSys.clampData(pt, pt);
204 point = coordSys.dataToPoint(pt, true);
205 }
206 if (isCoordinateSystemType<Cartesian2D>(coordSys, 'cartesian2d')) {
207 // TODO: TYPE ts@4.1 may still infer it as Axis instead of Axis2D. Not sure if it's a bug
208 const xAxis = coordSys.getAxis('x') as Axis2D;
209 const yAxis = coordSys.getAxis('y') as Axis2D;
210 const x = data.get(dims[0], idx) as number;
211 const y = data.get(dims[1], idx) as number;
212 if (isInfinity(x)) {
213 point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[dims[0] === 'x0' ? 0 : 1]);

Callers 2

updateTransformMethod · 0.85
renderSeriesMethod · 0.85

Calls 13

isCoordinateSystemTypeFunction · 0.90
getItemModelMethod · 0.80
clampDataMethod · 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…