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

Method transformTo

src/coord/geo/Region.ts:252–285  ·  view source on GitHub ↗

* Transform the raw coords to target bounding. * @param x * @param y * @param width * @param height

(x: number, y: number, width: number, height: number)

Source from the content-addressed store, hash-verified

250 * @param height
251 */
252 transformTo(x: number, y: number, width: number, height: number): void {
253 let rect = this.getBoundingRect();
254 const aspect = rect.width / rect.height;
255 if (!width) {
256 width = aspect * height;
257 }
258 else if (!height) {
259 height = width / aspect;
260 }
261 const target = new BoundingRect(x, y, width, height);
262 const transform = rect.calculateTransform(target);
263 const geometries = this.geometries;
264 for (let i = 0; i < geometries.length; i++) {
265 const geo = geometries[i];
266 if (geo.type === 'polygon') {
267 transformPoints(geo.exterior, transform);
268 each(geo.interiors, interior => {
269 transformPoints(interior, transform);
270 });
271 }
272 else {
273 each(geo.points, points => {
274 transformPoints(points, transform);
275 });
276 }
277 }
278 rect = this._rect;
279 rect.copy(target);
280 // Update center
281 this._center = [
282 rect.x + rect.width / 2,
283 rect.y + rect.height / 2
284 ];
285 }
286
287 cloneShallow(name: string): GeoJSONRegion {
288 name == null && (name = this.name);

Callers 1

_parseToRegionsMethod · 0.80

Calls 3

getBoundingRectMethod · 0.95
transformPointsFunction · 0.85
eachFunction · 0.50

Tested by

no test coverage detected