Description
When I'm scrolling horizontally, it just gets the graph out of the mobile device, is there any way where we can restrict the scrolling through 1st and last point? Attaching the code and recording of the issue
`import React from "react";
import { LinearGradient, useFont, vec } from "@shopify/react-native-skia";
import { View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import {
Area,
CartesianChart,
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-03-27.at.14.43.23.mp4
Line,
useChartTransformState,
} from "victory-native";
const spaceMono = require("../../assets/fonts/SpaceMono-Regular.ttf");
const DATA = Array.from({ length: 31 }, (_, i) => ({
day: i + 1,
highTmp: 40 + 30 * Math.random(),
lowTmp: 30 + 20 * Math.random(),
}));
const yKeys = ["highTmp", "lowTmp"];
const colors = ["#E77828", "#549D4C"];
const lightColors = ["#E7782820", "#549D4C20"];
const CHART_HEIGHT = 300;
export default function HomeScreen() {
const font = useFont(spaceMono, 12);
const { state: chartTransform } = useChartTransformState({
scaleX: 2.0, // Initial zoom level for x-axis
scaleY: 1.0, // Keep y-axis at normal scale
});
return (
<SafeAreaView style={{ flex: 1, backgroundColor: "black" }}>
<View style={{ height: CHART_HEIGHT }}>
<CartesianChart
data={DATA}
xKey="day"
yKeys={yKeys as any}
transformState={chartTransform}
transformConfig={{
pan: {
dimensions: ["x"],
activateAfterLongPress: 0,
},
}}
domainPadding={{ top: 100, bottom: 100 }}
axisOptions={{
font,
labelColor: "white",
tickCount: { x: 10, y: 5 },
}}
>
{({ points, chartBounds }) => (
<>
{yKeys.map((key, index) => (
<React.Fragment key={key}>
<Line
points={points[key as keyof typeof points]}
color={colors[index]}
strokeWidth={1}
curveType="monotoneX"
/>
<Area
curveType="monotoneX"
points={points[key as keyof typeof points]}
y0={chartBounds.bottom}
>
<LinearGradient
start={vec(0, 0)}
end={vec(0, chartBounds.bottom)}
colors={[colors[index], lightColors[index]]}
/>
</React.Fragment>
))}
</>
)}
);
}
`