From b40ece1b9862a9cfb3e9c64fc5e253751c41f4c2 Mon Sep 17 00:00:00 2001 From: dengfuping Date: Fri, 12 Apr 2024 21:27:25 +0800 Subject: [PATCH] fix(charts): Remove unreasonable xAxis.tickCount calculate logic for Line, Area, Column and DualAxes --- .dumirc.ts | 8 ++++---- packages/charts/src/Area/demo/basic.tsx | 3 +++ packages/charts/src/Area/demo/stack.tsx | 3 +++ packages/charts/src/Area/demo/tooltip-scrollable.tsx | 3 +++ packages/charts/src/Area/index.tsx | 2 -- packages/charts/src/Column/index.tsx | 2 -- packages/charts/src/DualAxes/index.tsx | 2 -- packages/charts/src/Line/demo/basic.tsx | 3 +++ packages/charts/src/Line/index.tsx | 2 -- 9 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index 39d988a3d..030f258d0 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -263,14 +263,14 @@ export default defineConfig({ title: 'Histogram 直方图', link: '/charts/histogram', }, - { - title: 'Pie 饼图&环图', - link: '/charts/pie', - }, { title: 'DualAxes 双轴图', link: '/charts/dual-axes', }, + { + title: 'Pie 饼图&环图', + link: '/charts/pie', + }, { title: 'Gauge 仪表盘', link: '/charts/gauge', diff --git a/packages/charts/src/Area/demo/basic.tsx b/packages/charts/src/Area/demo/basic.tsx index 4a4db0b8f..f22355825 100644 --- a/packages/charts/src/Area/demo/basic.tsx +++ b/packages/charts/src/Area/demo/basic.tsx @@ -18,6 +18,9 @@ export default () => { data, xField: 'timePeriod', yField: 'value', + xAxis: { + tickCount: 7, + }, }; return ; }; diff --git a/packages/charts/src/Area/demo/stack.tsx b/packages/charts/src/Area/demo/stack.tsx index 4fded539c..3195789f7 100644 --- a/packages/charts/src/Area/demo/stack.tsx +++ b/packages/charts/src/Area/demo/stack.tsx @@ -19,6 +19,9 @@ export default () => { xField: 'date', yField: 'value', seriesField: 'country', + xAxis: { + tickCount: 7, + }, }; return ; }; diff --git a/packages/charts/src/Area/demo/tooltip-scrollable.tsx b/packages/charts/src/Area/demo/tooltip-scrollable.tsx index 950137830..046575597 100644 --- a/packages/charts/src/Area/demo/tooltip-scrollable.tsx +++ b/packages/charts/src/Area/demo/tooltip-scrollable.tsx @@ -22,6 +22,9 @@ export default () => { xField: 'date', yField: 'value', seriesField: 'country', + xAxis: { + tickCount: 7, + }, tooltip: { scrollable: true, }, diff --git a/packages/charts/src/Area/index.tsx b/packages/charts/src/Area/index.tsx index 7f4e13456..b5cd4eda8 100644 --- a/packages/charts/src/Area/index.tsx +++ b/packages/charts/src/Area/index.tsx @@ -47,8 +47,6 @@ const Area = forwardRef( // type 为 time 时需要关闭自动美化,否则 X 轴两侧会留白 // issue: https://github.com/antvis/G2Plot/issues/1951 nice: xAxis?.type === 'time' ? false : undefined, - // 点数 >= 14 时,x 方向展示 7 个刻度线和网格 - tickCount: data?.length >= 14 ? 7 : undefined, ...xAxis, // x 方向增加虚线网格 grid: diff --git a/packages/charts/src/Column/index.tsx b/packages/charts/src/Column/index.tsx index c39e3cccb..1becfd9b5 100644 --- a/packages/charts/src/Column/index.tsx +++ b/packages/charts/src/Column/index.tsx @@ -81,8 +81,6 @@ const Column = forwardRef( // type 为 time 时需要关闭自动美化,否则 X 轴两侧会留白 // issue: https://github.com/antvis/G2Plot/issues/1951 nice: xAxis?.type === 'time' ? false : undefined, - // 点数 >= 14 时,x 方向展示 7 个刻度线和网格 - tickCount: data?.length >= 14 ? 7 : undefined, ...xAxis, // x 方向增加虚线网格 grid: diff --git a/packages/charts/src/DualAxes/index.tsx b/packages/charts/src/DualAxes/index.tsx index 08b9511c6..e65a3d202 100644 --- a/packages/charts/src/DualAxes/index.tsx +++ b/packages/charts/src/DualAxes/index.tsx @@ -55,8 +55,6 @@ const DualAxes = forwardRef( // type 为 time 时需要关闭自动美化,否则 X 轴两侧会留白 // issue: https://github.com/antvis/G2Plot/issues/1951 nice: xAxis?.type === 'time' ? false : undefined, - // 点数 >= 14,x 方向展示 7 个刻度线和网格 - tickCount: data?.length >= 14 ? 7 : undefined, ...xAxis, // x 方向增加虚线网格 grid: diff --git a/packages/charts/src/Line/demo/basic.tsx b/packages/charts/src/Line/demo/basic.tsx index 3e783f91e..e6360f9b5 100644 --- a/packages/charts/src/Line/demo/basic.tsx +++ b/packages/charts/src/Line/demo/basic.tsx @@ -18,6 +18,9 @@ export default () => { data, xField: 'Date', yField: 'scales', + xAxis: { + type: 'timeCat', + }, }; return ; }; diff --git a/packages/charts/src/Line/index.tsx b/packages/charts/src/Line/index.tsx index 2cc1104a7..7e86a6b79 100644 --- a/packages/charts/src/Line/index.tsx +++ b/packages/charts/src/Line/index.tsx @@ -41,8 +41,6 @@ const Line = forwardRef( // type 为 time 时需要关闭自动美化,否则 X 轴两侧会留白 // issue: https://github.com/antvis/G2Plot/issues/1951 nice: xAxis?.type === 'time' ? false : undefined, - // 非阶梯折线图,并且点数 >= 14,x 方向展示 7 个刻度线和网格 - tickCount: !stepType && data?.length >= 14 ? 7 : undefined, ...xAxis, // x 方向增加虚线网格 grid: