Skip to content

Commit

Permalink
truncate path data to 2 decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
cwagner22 committed Dec 4, 2024
1 parent 1a8788b commit f8c55eb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/victory-area/src/area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const getAngleAccessor = (scale) => {
};
};

const formatPathData = (pathData: string) => {
// Truncate to 2 decimal places
return pathData.replace(/(\d+\.\d{2})\d*/g, "$1");
};

const getCartesianArea = (props: AreaProps) => {
const { horizontal, scale } = props;
const interpolationFunction = LineHelpers.getInterpolationFunction(props);
Expand Down Expand Up @@ -147,7 +152,7 @@ export const Area: React.FC<AreaProps> = (initialProps) => {
{
key: `${id}-area`,
style: Object.assign({}, style, { stroke: areaStroke }),
d: areaFunction(data),
d: formatPathData(areaFunction(data) ?? ""),
desc,
tabIndex,
},
Expand Down

0 comments on commit f8c55eb

Please sign in to comment.