Skip to content

Commit df8dd57

Browse files
CopilotAarebecca
andauthored
fix(chart-line): adaptive y-axis tick precision for small decimal ranges (#233)
* Initial plan * fix: adaptive y-axis tick precision for small decimal values in chart-line Agent-Logs-Url: https://github.com/antvis/Infographic/sessions/aca9d170-d41a-44d2-b381-fdf2a616d576 Co-authored-by: Aarebecca <25787943+Aarebecca@users.noreply.github.com> * fix: use -Math.floor instead of Math.ceil(-...) for tick decimal precision Agent-Logs-Url: https://github.com/antvis/Infographic/sessions/0c6b28a0-a891-483e-bbf0-14a568d5e00b Co-authored-by: Aarebecca <25787943+Aarebecca@users.noreply.github.com> * chore: bump version to 0.2.17 Agent-Logs-Url: https://github.com/antvis/Infographic/sessions/a166fa68-300b-40e6-a9b2-7936ce472830 Co-authored-by: Aarebecca <25787943+Aarebecca@users.noreply.github.com> * refactor: optimize tick calc --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Aarebecca <25787943+Aarebecca@users.noreply.github.com> Co-authored-by: Aaron <antvaaron@gmail.com>
1 parent 59a231f commit df8dd57

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/infographic",
3-
"version": "0.2.16",
3+
"version": "0.2.17",
44
"description": "An Infographic Generation and Rendering Framework, bring words to life!",
55
"keywords": [
66
"antv",

‎src/designs/structures/chart-line.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export const ChartLine: ComponentType<ChartLineProps> = (props) => {
121121
const tickElements: JSXElement[] = [];
122122

123123
const ticksY = scaleY.ticks(6);
124+
const formatTickY = scaleY.tickFormat(6);
125+
124126
ticksY.forEach((tick) => {
125127
const yPos = chartOriginY + scaleY(tick);
126128
gridElements.push(
@@ -145,7 +147,7 @@ export const ChartLine: ComponentType<ChartLineProps> = (props) => {
145147
fontSize={12}
146148
fill={axisColor}
147149
>
148-
{Number.isInteger(tick) ? tick.toString() : tick.toFixed(1)}
150+
{formatTickY(tick)}
149151
</Text>,
150152
);
151153
});

‎src/version.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VERSION = '0.2.16';
1+
export const VERSION = '0.2.17';

0 commit comments

Comments
 (0)