From cffe0a55adf8d4e32d3d3830f5c3993d460cf655 Mon Sep 17 00:00:00 2001 From: "anhaohui.ahh" Date: Mon, 14 Oct 2024 15:56:17 +0800 Subject: [PATCH] fix: dual-axes thumbnails out of sync --- .github/workflows/build.yml | 4 +++- __tests__/unit/utils/pattern/line-spec.ts | 2 +- src/index.ts | 2 +- src/plots/dual-axes/util/render-sider.ts | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 694bf578a8..3069cd2a7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: 14 + - name: yarn install run: | yarn install @@ -38,9 +39,10 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js 14 - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: 14 + architecture: 'x64' - name: yarn install run: | yarn install diff --git a/__tests__/unit/utils/pattern/line-spec.ts b/__tests__/unit/utils/pattern/line-spec.ts index 50f56f0e4b..b8c3027457 100644 --- a/__tests__/unit/utils/pattern/line-spec.ts +++ b/__tests__/unit/utils/pattern/line-spec.ts @@ -29,7 +29,7 @@ describe('utils: line pattern', () => { drawLine(ctx, cfg as LinePatternCfg, d); // 传入的是呈现的位置 expect(getPixelColor(canvas, 0, 0).hex).toEqual('#ff0000'); - expect(getPixelColor(canvas, 0, height - 1).hex).toEqual('#ff0000'); + expect(getPixelColor(canvas, 0, height - 1).hex).toEqual('#000000'); }); it('lineUnitPattern with strokeOpacity', () => { diff --git a/src/index.ts b/src/index.ts index 30efbf6ecc..96b860f90f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export const version = '2.4.30'; +export const version = '2.4.31'; // G2 自定义能力透出 import * as G2 from '@antv/g2'; diff --git a/src/plots/dual-axes/util/render-sider.ts b/src/plots/dual-axes/util/render-sider.ts index d8f89b1a65..be75e84e56 100644 --- a/src/plots/dual-axes/util/render-sider.ts +++ b/src/plots/dual-axes/util/render-sider.ts @@ -21,8 +21,8 @@ export const doSliderFilter = (view: View, sliderValue: [number, number]) => { const values = valuesOfKey(data, xScale.field); const xValues = isHorizontal ? values : values.reverse(); const xTickCount = size(xValues); - const minIndex = Math.floor(min * (xTickCount - 1)); - const maxIndex = Math.floor(max * (xTickCount - 1)); + const minIndex = Math.round(min * (xTickCount - 1)); + const maxIndex = Math.round(max * (xTickCount - 1)); // 增加 x 轴的过滤器 view.filter(xScale.field, (value: any) => {