Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use @antv/vendor to replace d3 package #6594

Merged
merged 7 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,7 @@
"@antv/g-plugin-dragndrop": "^2.0.22",
"@antv/scale": "^0.4.16",
"@antv/util": "^3.3.10",
"d3-array": "^3.2.4",
"d3-dsv": "^3.0.1",
"d3-force": "^3.0.0",
"d3-format": "^3.1.0",
"d3-geo": "^3.1.1",
"d3-hierarchy": "^3.1.2",
"d3-path": "^3.1.0",
"d3-scale-chromatic": "^3.1.0",
"d3-shape": "^3.2.0",
"@antv/vendor": "1.0.3-g2.0",
hustcc marked this conversation as resolved.
Show resolved Hide resolved
"flru": "^1.0.2",
"fmin": "0.0.2",
"pdfast": "^0.2.0"
Expand Down Expand Up @@ -183,4 +175,4 @@
"bugs": {
"url": "https://github.com/antvis/g2/issues"
}
}
}
2 changes: 1 addition & 1 deletion src/animation/scaleInY.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arc } from 'd3-shape';
import { arc } from '@antv/vendor/d3-shape';
import {
Path,
convertToPath,
Expand Down
2 changes: 1 addition & 1 deletion src/animation/waveIn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arc } from 'd3-shape';
import { arc } from '@antv/vendor/d3-shape';
import { CSS, PropertySyntax } from '@antv/g';
import { G2Element } from '../utils/selection';
import { AnimationComponent as AC } from '../runtime';
Expand Down
2 changes: 1 addition & 1 deletion src/component/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DisplayObject } from '@antv/g';
import { Axis as AxisComponent } from '@antv/component';
import { Linear as LinearScale } from '@antv/scale';
import { deepMix, omit, upperFirst } from '@antv/util';
import { extent } from 'd3-array';
import { extent } from '@antv/vendor/d3-array';
import { format } from 'd3-format';
import {
BBox,
Expand Down
2 changes: 1 addition & 1 deletion src/composition/d3Projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export {
geoStereographicRaw,
geoTransverseMercator,
geoTransverseMercatorRaw,
} from 'd3-geo';
} from '@antv/vendor/d3-geo';
2 changes: 1 addition & 1 deletion src/composition/facetRect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { deepMix } from '@antv/util';
import { extent, group, max } from 'd3-array';
import { extent, group, max } from '@antv/vendor/d3-array';
import {
CompositionComponent as CC,
G2MarkChildrenCallback,
Expand Down
2 changes: 1 addition & 1 deletion src/composition/geoView.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Linear } from '@antv/scale';
import { upperFirst } from '@antv/util';
import { geoPath, geoGraticule10 } from 'd3-geo';
import { geoPath, geoGraticule10 } from '@antv/vendor/d3-geo';
import { maybeTooltip } from '../utils/mark';
import { CompositionComponent as CC } from '../runtime';
import { GeoViewComposition } from '../spec';
Expand Down
2 changes: 1 addition & 1 deletion src/data/cluster.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cluster, hierarchy } from 'd3-hierarchy';
import { cluster, hierarchy } from '@antv/vendor/d3-hierarchy';
import { DataComponent as DC } from '../runtime';

export type ClusterOptions = Omit<Record<string, any>, 'type'>;
Expand Down
4 changes: 2 additions & 2 deletions src/data/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dsvFormat, autoType as d3AutoType } from 'd3-dsv';
import { dsvFormat, autoType as d3AutoType } from '@antv/vendor/d3-dsv';
import { FetchConnector } from '../spec';
import { DataComponent as DC } from '../runtime';
import { identity } from '../utils/helper';
Expand All @@ -16,7 +16,7 @@ export const Fetch: DC<FetchOptions> = (options) => {
const response = await fetch(value);

if (format === 'csv') {
// @see: https://github.com/d3/d3-dsv#dsv_parse
// @see: https://github.com/d3/@antv/vendor/d3-dsv#dsv_parse
const str = await response.text();
hustcc marked this conversation as resolved.
Show resolved Hide resolved
return dsvFormat(delimiter).parse(str, autoType ? d3AutoType : identity);
} else if (format === 'json') {
Expand Down
2 changes: 1 addition & 1 deletion src/data/join.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rollup } from 'd3-array';
import { rollup } from '@antv/vendor/d3-array';
import { DataComponent as DC } from '../runtime';
import { JoinTransform } from '../spec';

Expand Down
2 changes: 1 addition & 1 deletion src/data/kde.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pdf from 'pdfast';
import { group } from 'd3-array';
import { group } from '@antv/vendor/d3-array';
import { DataComponent as DC } from '../runtime';
import { KDEDataTransform } from '../spec';

Expand Down
2 changes: 1 addition & 1 deletion src/data/tree.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tree } from 'd3-hierarchy';
import { tree } from '@antv/vendor/d3-hierarchy';
import { DataComponent as DC } from '../runtime';
import { hierarchyFunction } from './cluster';

Expand Down
2 changes: 1 addition & 1 deletion src/data/utils/arc/arc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { group, sum } from 'd3-array';
import { group, sum } from '@antv/vendor/d3-array';
import { error } from '../../../utils/helper';
import { ArcData, ArcOptions } from './types';
import * as SortMethods from './sort';
Expand Down
2 changes: 1 addition & 1 deletion src/data/utils/d3-sankey/align.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { min } from 'd3-array';
import { min } from '@antv/vendor/d3-array';

function targetDepth(d) {
return d.target.depth;
Expand Down
2 changes: 1 addition & 1 deletion src/data/utils/d3-sankey/sankey.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sum, max, min } from 'd3-array';
import { sum, max, min } from '@antv/vendor/d3-array';
import { justify } from './align';
import { constant } from './constant';

Expand Down
2 changes: 1 addition & 1 deletion src/data/wordCloud.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { min, max } from 'd3-array';
import { min, max } from '@antv/vendor/d3-array';
import { DataComponent as DC } from '../runtime';
import { flow } from './utils/flow';
import { tagCloud } from './utils/d3-cloud';
Expand Down
2 changes: 1 addition & 1 deletion src/interaction/chartIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
bisectCenter,
bisector,
group,
} from 'd3-array';
} from '@antv/vendor/d3-array';
import { G2Element } from 'utils/selection';
import { subObject } from '../utils/helper';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/interaction/elementHighlight.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DisplayObject } from '@antv/g';
import { deepMix } from '@antv/util';
import { group } from 'd3-array';
import { group } from '@antv/vendor/d3-array';
import { subObject } from '../utils/helper';
import {
createDatumof,
Expand Down
2 changes: 1 addition & 1 deletion src/interaction/elementSelect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DisplayObject } from '@antv/g';
import { group } from 'd3-array';
import { group } from '@antv/vendor/d3-array';
import { deepMix } from '@antv/util';
import { subObject } from '../utils/helper';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/interaction/legendHighlight.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { group } from 'd3-array';
import { group } from '@antv/vendor/d3-array';
import { subObject } from '../utils/helper';
import {
mergeState,
Expand Down
2 changes: 1 addition & 1 deletion src/interaction/tooltip.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Circle, DisplayObject, IElement, Line } from '@antv/g';
import { sort, group, mean, bisector, minIndex } from 'd3-array';
import { sort, group, mean, bisector, minIndex } from '@antv/vendor/d3-array';
import { deepMix, lowerFirst, throttle } from '@antv/util';
import { Tooltip as TooltipComponent } from '@antv/component';
import { Constant, Band } from '@antv/scale';
Expand Down
5 changes: 2 additions & 3 deletions src/interaction/treemapDrillDown.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Text, Group } from '@antv/g';
import { get, deepMix, pick, keys, find, size, last } from '@antv/util';
import type { Node } from 'd3-hierarchy';
import type { DisplayObject } from '@antv/g';
import { subObject } from '../utils/helper';
import { PLOT_CLASS_NAME } from '../runtime';
import { select } from '../utils/selection';
import { treeDataTransform } from '../utils/treeDataTransform';
import { Node, treeDataTransform } from '../utils/treeDataTransform';
import { legendClearSetState } from './legendFilter';
import { getElements } from './utils';

Expand All @@ -14,7 +13,7 @@ function selectPlotArea(root: DisplayObject): DisplayObject {
}

export type DrillDownOptions = {
originData?: Node[];
originData?: Node<any>[];
layout?: any;
[key: string]: any;
};
Expand Down
4 changes: 2 additions & 2 deletions src/interaction/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DisplayObject, Path, AABB } from '@antv/g';
import { path as d3Path } from 'd3-path';
import { sort } from 'd3-array';
import { path as d3Path } from '@antv/vendor/d3-path';
import { sort } from '@antv/vendor/d3-array';
import { Vector2 } from '@antv/coord';
import { filter } from '@antv/util';
import type { PathArray } from '@antv/util';
Expand Down
2 changes: 1 addition & 1 deletion src/label-transform/contrastReverse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DisplayObject } from '@antv/g';
import { maxIndex } from 'd3-array';
import { maxIndex } from '@antv/vendor/d3-array';
import { ContrastReverseLabelTransform } from '../spec';
import { LabelTransformComponent as LLC } from '../runtime';
import { parseToRGB } from '../utils/color';
Expand Down
2 changes: 1 addition & 1 deletion src/label-transform/overlapDodgeY.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DisplayObject } from '@antv/g';
import { ascending } from 'd3-array';
import { ascending } from '@antv/vendor/d3-array';
import { OverlapDodgeYLabelTransform } from '../spec';
import { LabelTransformComponent as LLC } from '../runtime';

Expand Down
2 changes: 1 addition & 1 deletion src/mark/area.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { group } from 'd3-array';
import { group } from '@antv/vendor/d3-array';
import { MarkComponent as MC } from '../runtime';
import { AreaMark } from '../spec';
import { AreaShape, AreaHV, AreaHVH, AreaSmooth, AreaVH } from '../shape';
Expand Down
7 changes: 6 additions & 1 deletion src/mark/boxplot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { min as d3Min, max as d3Max, quantile, group } from 'd3-array';
import {
min as d3Min,
max as d3Max,
quantile,
group,
} from '@antv/vendor/d3-array';
import { CompositeMarkComponent as CC } from '../runtime';
import { BoxPlotMark } from '../spec';
import { subObject } from '../utils/helper';
Expand Down
2 changes: 1 addition & 1 deletion src/mark/forceGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
forceX,
forceY,
forceCenter,
} from 'd3-force';
} from '@antv/vendor/d3-force';
import { deepMix } from '@antv/util';
import { subObject } from '../utils/helper';
import { CompositeMarkComponent as CC } from '../runtime';
Expand Down
2 changes: 1 addition & 1 deletion src/mark/line.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Vector } from '@antv/coord';
import { group } from 'd3-array';
import { group } from '@antv/vendor/d3-array';
import { isParallel } from '../utils/coordinate';
import { Mark, MarkComponent as MC, SingleMark, Vector2 } from '../runtime';
import { LineMark } from '../spec';
Expand Down
6 changes: 5 additions & 1 deletion src/mark/pack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { deepMix, isArray } from '@antv/util';
import { stratify, hierarchy, pack as packLayout } from 'd3-hierarchy';
import {
stratify,
hierarchy,
pack as packLayout,
} from '@antv/vendor/d3-hierarchy';
import { CompositionComponent as CC } from '../runtime';
import { subObject } from '../utils/helper';
import { PackMark } from '../spec';
Expand Down
2 changes: 1 addition & 1 deletion src/mark/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Band } from '@antv/scale';
import { Primitive } from 'd3-array';
import { Primitive } from '@antv/vendor/d3-array';
import { Vector2 } from '@antv/coord';
import { Scale } from '../runtime/types/component';
import { Channel } from '../runtime';
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { Coordinate } from '@antv/coord';
import { deepMix, isEqual } from '@antv/util';
import { groups, max, sum } from 'd3-array';
import { groups, max, sum } from '@antv/vendor/d3-array';
import { format } from 'd3-format';
import { DisplayObject, Text } from '@antv/g';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/layout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Coordinate } from '@antv/coord';
import { ascending, group, max, min, sum } from 'd3-array';
import { ascending, group, max, min, sum } from '@antv/vendor/d3-array';
import { deepMix } from '@antv/util';
import { isParallel, isPolar, isRadar, radiusOf } from '../utils/coordinate';
import { capitalizeFirst, defined } from '../utils/helper';
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/mark.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rollups } from 'd3-array';
import { rollups } from '@antv/vendor/d3-array';
import { defined } from '../utils/helper';
import { useLibrary } from './library';
import { G2MarkState } from './types/common';
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/plot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Vector2 } from '@antv/coord';
import { DisplayObject, IAnimation as GAnimation, Rect } from '@antv/g';
import { deepMix, upperFirst, isArray } from '@antv/util';
import { group, groups } from 'd3-array';
import { group, groups } from '@antv/vendor/d3-array';
import { format } from 'd3-format';
import { mapObject } from '../utils/array';
import { ChartEvent } from '../utils/event';
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/scale.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Linear, createInterpolateValue } from '@antv/scale';
import { extent, max, rollups } from 'd3-array';
import * as d3ScaleChromatic from 'd3-scale-chromatic';
import { extent, max, rollups } from '@antv/vendor/d3-array';
import * as d3ScaleChromatic from '@antv/vendor/d3-scale-chromatic';
import { deepMix, omit, upperFirst } from '@antv/util';
import { firstOf, lastOf, unique } from '../utils/array';
import { defined, identity, isStrictObject } from '../utils/helper';
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/transform.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Primitive } from 'd3-array';
import { Primitive } from '@antv/vendor/d3-array';
import { deepMix, isNumber } from '@antv/util';
import { format } from 'd3-format';
import { indexOf, mapObject } from '../utils/array';
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/types/mark.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Coordinate, Vector2 } from '@antv/coord';
import { Primitive } from 'd3-array';
import { Primitive } from '@antv/vendor/d3-array';
import { Channel } from './common';
import { Scale } from './component';
import { TransformSpec } from './transform';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/area/area.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { curveLinearClosed, curveLinear } from 'd3-shape';
import { curveLinearClosed, curveLinear } from '@antv/vendor/d3-shape';
import { isPolar } from '../../utils/coordinate';
import { ShapeComponent as SC } from '../../runtime';
import { Curve } from './curve';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/area/curve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { area, areaRadial, CurveFactory } from 'd3-shape';
import { area, areaRadial, CurveFactory } from '@antv/vendor/d3-shape';
import { select } from '../../utils/selection';
import { isPolar, isTranspose } from '../../utils/coordinate';
import { Vector2, ShapeComponent as SC } from '../../runtime';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/area/hv.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { curveStepAfter } from 'd3-shape';
import { curveStepAfter } from '@antv/vendor/d3-shape';
import { ShapeComponent as SC } from '../../runtime';
import { Curve } from './curve';

Expand Down
2 changes: 1 addition & 1 deletion src/shape/area/hvh.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { curveStep } from 'd3-shape';
import { curveStep } from '@antv/vendor/d3-shape';
import { ShapeComponent as SC } from '../../runtime';
import { Curve } from './curve';

Expand Down
2 changes: 1 addition & 1 deletion src/shape/area/smooth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
curveCatmullRomClosed,
curveMonotoneX,
curveMonotoneY,
} from 'd3-shape';
} from '@antv/vendor/d3-shape';
import { isPolar, isTranspose } from '../../utils/coordinate';
import { ShapeComponent as SC } from '../../runtime';
import { Curve } from './curve';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/area/vh.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { curveStepBefore } from 'd3-shape';
import { curveStepBefore } from '@antv/vendor/d3-shape';
import { ShapeComponent as SC } from '../../runtime';
import { Curve } from './curve';

Expand Down
2 changes: 1 addition & 1 deletion src/shape/box/box.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { path as d3path } from 'd3-path';
import { path as d3path } from '@antv/vendor/d3-path';
import { Coordinate } from '@antv/coord';
import { applyStyle } from '../utils';
import { select } from '../../utils/selection';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/box/violin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { path as d3path } from 'd3-path';
import { path as d3path } from '@antv/vendor/d3-path';
import { Coordinate } from '@antv/coord';
import { applyStyle } from '../utils';
import { select } from '../../utils/selection';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/connector/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Coordinate } from '@antv/coord';
import type { PathArray } from '@antv/util';
import { PathStyleProps, Path } from '@antv/g';
import { Marker } from '@antv/component';
import { line as d3line } from 'd3-shape';
import { line as d3line } from '@antv/vendor/d3-shape';
import { ShapeComponent as SC, Vector2, WithPrefix } from '../../runtime';
import { isTranspose } from '../../utils/coordinate';
import { subObject } from '../../utils/helper';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/density/density.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { path as d3path } from 'd3-path';
import { path as d3path } from '@antv/vendor/d3-path';
import { applyStyle } from '../utils';
import { select } from '../../utils/selection';
import { ShapeComponent as SC } from '../../runtime';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/heatmap/heatmap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { max as d3max, min as d3min } from 'd3-array';
import { max as d3max, min as d3min } from '@antv/vendor/d3-array';
import { applyStyle } from '../utils';
import { select } from '../../utils/selection';
import { ShapeComponent as SC } from '../../runtime';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/interval/color.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arc } from 'd3-shape';
import { arc } from '@antv/vendor/d3-shape';
import { Vector2, ShapeComponent as SC } from '../../runtime';
import { isPolar, isHelix, isTranspose } from '../../utils/coordinate';
import { select } from '../../utils/selection';
Expand Down
2 changes: 1 addition & 1 deletion src/shape/interval/funnel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { line, curveLinearClosed } from 'd3-shape';
import { line, curveLinearClosed } from '@antv/vendor/d3-shape';
import { Coordinate } from '@antv/coord';
import { isTranspose } from '../../utils/coordinate';
import { ShapeComponent as SC, Vector2 } from '../../runtime';
Expand Down
Loading
Loading