react-native-chart-kit
Version:
Beautiful React Native charts for dashboards, reports, and data-rich mobile apps.
25 lines (24 loc) • 765 B
JavaScript
const DECIMAL_PLACES = 6;
export const formatPathNumber = (value) => {
const rounded = Number(value.toFixed(DECIMAL_PLACES));
if (Object.is(rounded, -0)) {
return "0";
}
return String(rounded);
};
export const pointCommand = (command, x, y) => {
return `${command} ${formatPathNumber(x)} ${formatPathNumber(y)}`;
};
export const cubicCommand = (c1x, c1y, c2x, c2y, x, y) => {
return [
"C",
formatPathNumber(c1x),
formatPathNumber(c1y),
formatPathNumber(c2x),
formatPathNumber(c2y),
formatPathNumber(x),
formatPathNumber(y)
].join(" ");
};
export const horizontalCommand = (x) => `H ${formatPathNumber(x)}`;
export const verticalCommand = (y) => `V ${formatPathNumber(y)}`;