Skip to content

Commit

Permalink
feat: 将maxBy,minBy替换为max,min 且升级版本
Browse files Browse the repository at this point in the history
  • Loading branch information
visiky committed Feb 10, 2021
1 parent ffcbcb0 commit 746500f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/g-base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-base",
"version": "0.5.5",
"version": "0.5.6",
"description": "A common util collection for antv projects",
"main": "lib/index.js",
"module": "esm/index.js",
Expand Down
18 changes: 9 additions & 9 deletions packages/g-base/src/abstract/container.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { maxBy, minBy } from '@antv/util';
import { max, min } from '@antv/util';
import { IContainer, IShape, IGroup, IElement, ICanvas } from '../interfaces';
import { BBox, ElementFilterFn } from '../types';
import Timeline from '../animate/timeline';
Expand Down Expand Up @@ -90,10 +90,10 @@ abstract class Container extends Element implements IContainer {
xArr.push(box.minX, box.maxX);
yArr.push(box.minY, box.maxY);
});
minX = minBy(xArr, (d) => d);
maxX = maxBy(xArr, (d) => d);
minY = minBy(yArr, (d) => d);
maxY = maxBy(yArr, (d) => d);
minX = min(xArr);
maxX = max(xArr);
minY = min(yArr);
maxY = max(yArr);
} else {
minX = 0;
maxX = 0;
Expand Down Expand Up @@ -132,10 +132,10 @@ abstract class Container extends Element implements IContainer {
xArr.push(box.minX, box.maxX);
yArr.push(box.minY, box.maxY);
});
minX = minBy(xArr, (d) => d);
maxX = maxBy(xArr, (d) => d);
minY = minBy(yArr, (d) => d);
maxY = maxBy(yArr, (d) => d);
minX = min(xArr);
maxX = max(xArr);
minY = min(yArr);
maxY = max(yArr);
} else {
minX = 0;
maxX = 0;
Expand Down
10 changes: 5 additions & 5 deletions packages/g-base/src/bbox/path.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Quad as QuadUtil, Cubic as CubicUtil, Arc as EllipseArcUtil } from '@antv/g-math';
import { path2Segments } from '@antv/path-util';
import { isNumberEqual, maxBy, minBy } from '@antv/util';
import { isNumberEqual, max, min } from '@antv/util';
import { SimpleBBox } from '../types';
import { IShape } from '../interfaces';
import { mergeArrowBBox } from './util';
Expand Down Expand Up @@ -50,10 +50,10 @@ function getPathBox(segments, lineWidth) {
// ref: https://github.com/antvis/g/issues/210
xArr = xArr.filter((item) => !Number.isNaN(item));
yArr = yArr.filter((item) => !Number.isNaN(item));
let minX = minBy(xArr, (d) => d);
let minY = minBy(yArr, (d) => d);
let maxX = maxBy(xArr, (d) => d);
let maxY = maxBy(yArr, (d) => d);
let minX = min(xArr);
let minY = min(yArr);
let maxX = max(xArr);
let maxY = max(yArr);
if (segmentsWithAngle.length === 0) {
return {
x: minX,
Expand Down
2 changes: 1 addition & 1 deletion packages/g-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvas",
"version": "0.5.6",
"version": "0.5.7",
"description": "A canvas library which providing 2d",
"main": "lib/index.js",
"module": "esm/index.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/g-canvas/src/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Region } from './types';
import ShapeBase from './shape/base';
import * as Shape from './shape';
import { applyAttrsToContext, drawChildren, refreshElement } from './util/draw';
import { each, maxBy, minBy } from '@antv/util';
import { each, max, min } from '@antv/util';
import { intersectRect } from './util/util';

class Group extends AbstractGroup {
Expand Down Expand Up @@ -57,10 +57,10 @@ class Group extends AbstractGroup {
});
let bbox = null;
if (xArr.length) {
const minX = minBy(xArr, (d) => d);
const maxX = maxBy(xArr, (d) => d);
const minY = minBy(yArr, (d) => d);
const maxY = maxBy(yArr, (d) => d);
const minX = min(xArr);
const maxX = max(xArr);
const minY = min(yArr);
const maxY = max(yArr);
bbox = {
minX,
minY,
Expand Down
10 changes: 5 additions & 5 deletions packages/g-canvas/src/util/draw.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { each, isArray, maxBy, minBy } from '@antv/util';
import { each, isArray, max, min } from '@antv/util';
import { IElement } from '../interfaces';
import { Region } from '../types';
import { parseStyle } from './parse';
Expand Down Expand Up @@ -305,10 +305,10 @@ export function getMergedRegion(elements): Region {
}
});
return {
minX: minBy(minXArr, (d) => d),
minY: minBy(minYArr, (d) => d),
maxX: maxBy(maxXArr, (d) => d),
maxY: maxBy(maxYArr, (d) => d),
minX: min(minXArr),
minY: min(minYArr),
maxX: max(maxXArr),
maxY: max(maxYArr),
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/g-math/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-math",
"version": "0.1.7",
"version": "0.1.8",
"description": "geometry math",
"main": "lib/index.js",
"module": "esm/index.js",
Expand Down
18 changes: 9 additions & 9 deletions packages/g-math/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { maxBy, minBy } from '@antv/util';
import { max, min } from '@antv/util';
import { BBox } from './types';

/**
Expand All @@ -20,10 +20,10 @@ export function isNumberEqual(v1: number, v2: number) {
}

export function getBBoxByArray(xArr: number[], yArr: number[]): BBox {
const minX = minBy(xArr, (d) => d);
const minY = minBy(yArr, (d) => d);
const maxX = maxBy(xArr, (d) => d);
const maxY = maxBy(yArr, (d) => d);
const minX = min(xArr);
const minY = min(yArr);
const maxX = max(xArr);
const maxY = max(yArr);
return {
x: minX,
y: minY,
Expand All @@ -34,10 +34,10 @@ export function getBBoxByArray(xArr: number[], yArr: number[]): BBox {

export function getBBoxRange(x1: number, y1: number, x2: number, y2: number) {
return {
minX: minBy([x1, x2], (d) => d),
maxX: maxBy([x1, x2], (d) => d),
minY: minBy([y1, y2], (d) => d),
maxY: maxBy([y1, y2], (d) => d),
minX: min([x1, x2]),
maxX: max([x1, x2]),
minY: min([y1, y2]),
maxY: max([y1, y2]),
};
}

Expand Down

0 comments on commit 746500f

Please sign in to comment.