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: update vutils/vscale version to support custom callback in tick… #1378

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
50 changes: 21 additions & 29 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/demos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
"@visactor/vrender-kits": "workspace:0.14.8",
"@visactor/vutils": "~0.18.13",
"@visactor/vutils": "~0.18.14",
"d3-scale-chromatic": "^3.0.0",
"lodash": "4.17.21",
"dat.gui": "^0.7.9",
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@arco-design/web-react": "2.46.1",
"@visactor/vchart": "1.3.0",
"@visactor/vutils": "~0.18.13",
"@visactor/vutils": "~0.18.14",
"@visactor/vgrammar": "~0.5.7",
"@visactor/vrender": "workspace:0.19.23",
"markdown-it": "^13.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-vrender-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@visactor/vrender": "workspace:0.19.23",
"@visactor/react-vrender": "workspace:0.19.23",
"@visactor/vutils": "~0.18.13",
"@visactor/vutils": "~0.18.14",
"react-reconciler": "^0.29.0",
"tslib": "^2.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-vrender/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@visactor/vrender": "workspace:0.19.23",
"@visactor/vutils": "~0.18.13",
"@visactor/vutils": "~0.18.14",
"react-reconciler": "^0.29.0",
"tslib": "^2.3.1"
},
Expand Down
30 changes: 30 additions & 0 deletions packages/vrender-components/__tests__/unit/axis/tick.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { LinearScale, wilkinsonExtended } from '@visactor/vscale';
import { ticks } from '../../../src';

test('Custom Line Ticks', () => {
const s = new LinearScale().domain([0, 100]).range([500, 1000]);
expect(
ticks(s, {
coordinateType: 'cartesian',
axisOrientType: 'bottom',
labelStyle: {},
tickCount: 5,
tickMode: (scale, count) => {
const d = scale.calculateVisibleDomain(scale.get('_range'));
return wilkinsonExtended(d[0], d[1], count);
}
}).map(tick => tick.value)
).toStrictEqual([0, 25, 50, 75, 100]);
});

test('Normal Line Ticks', () => {
const s = new LinearScale().domain([0, 100]).range([500, 1000]);
expect(
ticks(s, {
coordinateType: 'cartesian',
axisOrientType: 'bottom',
labelStyle: {},
tickCount: 5
}).map(tick => tick.value)
).toStrictEqual([0, 20, 40, 60, 80, 100]);
});
6 changes: 3 additions & 3 deletions packages/vrender-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
"dependencies": {
"@visactor/vrender-core": "workspace:0.19.23",
"@visactor/vrender-kits": "workspace:0.19.23",
"@visactor/vutils": "~0.18.13",
"@visactor/vscale": "~0.18.9"
"@visactor/vutils": "~0.18.14",
"@visactor/vscale": "~0.18.14"
},
"devDependencies": {
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
"@rushstack/eslint-patch": "~1.1.4",
"@visactor/vscale": "~0.18.9",
"@visactor/vscale": "~0.18.14",
"@types/jest": "^26.0.0",
"jest": "^26.0.0",
"jest-electron": "^0.1.12",
Expand Down
3 changes: 2 additions & 1 deletion packages/vrender-components/src/axis/tick-data/continuous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const continuousTicks = (scale: ContinuousScale, op: ITickDataOpt): ITick
scaleTicks = (scale as LinearScale).d3Ticks(count ?? DEFAULT_CONTINUOUS_TICK_COUNT, { noDecimals });
} else {
const count = isFunction(tickCount) ? tickCount({ axisLength: rangeSize, labelStyle }) : tickCount;
scaleTicks = (scale as LinearScale).ticks(count ?? DEFAULT_CONTINUOUS_TICK_COUNT, { noDecimals });
const customTicks = isFunction(op.tickMode) ? op.tickMode : undefined;
scaleTicks = (scale as LinearScale).ticks(count ?? DEFAULT_CONTINUOUS_TICK_COUNT, { noDecimals, customTicks });
}

if (op.sampling) {
Expand Down
3 changes: 2 additions & 1 deletion packages/vrender-components/src/axis/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
IGraphic
} from '@visactor/vrender-core';
import type { Dict } from '@visactor/vutils';
import type { ContinuousScale, CustomTicksFunc } from '@visactor/vscale';
import type { Point, TextContent } from '../core/type';
import type { SegmentAttributes } from '../segment';
import type { TagAttributes } from '../tag';
Expand Down Expand Up @@ -453,7 +454,7 @@ export interface ITickDataOpt {
tickCount?: number | ((option: ITickCallbackOption) => number);
forceTickCount?: number;
tickStep?: number;
tickMode?: 'average' | 'd3' | string;
tickMode?: 'average' | 'd3' | string | CustomTicksFunc<ContinuousScale>;
noDecimals?: boolean;

coordinateType: CoordinateType;
Expand Down
2 changes: 1 addition & 1 deletion packages/vrender-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"color-convert": "2.0.1",
"@visactor/vutils": "~0.18.13"
"@visactor/vutils": "~0.18.14"
},
"devDependencies": {
"@internal/bundler": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/vrender-kits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@visactor/vrender-core": "workspace:0.19.23",
"@visactor/vutils": "~0.18.13",
"@visactor/vutils": "~0.18.14",
"@resvg/resvg-js": "2.4.1",
"roughjs": "4.5.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vrender/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
"@rushstack/eslint-patch": "~1.1.4",
"@visactor/vutils": "~0.18.13",
"@visactor/vutils": "~0.18.14",
"canvas": "2.11.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
Expand Down
Loading