-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Time Series Line Chart #384
Comments
I think this may already be possible but it requires you to structure your data slightly differently. Take a look at the example bar chart in the example repo. With a combination of Let me know if that doesn't cover your use case. |
I am also interested in time series charts. Currently I see the following issue:
|
@denniske I think if you have your const DATA = [
{ x: new Date(2023, 11, 1).getTime(), y0: 10, y1: 5 },
{ x: new Date(2024, 5, 1).getTime(), y0: 15, y1: 5 },
{ x: new Date(2024, 5, 2).getTime(), y0: 20, y1: 10 },
{ x: new Date(2024, 5, 3).getTime(), y0: 20, y1: 15 },
{ x: new Date(2024, 12, 1).getTime(), y0: 30, y1: 25 },
];
export default function TestingScreen() {
const font = useFont(inter, 12);
return (
<SafeAreaView style={styles.safeView}>
<View style={{ flex: 1, maxHeight: 400, padding: 32 }}>
<CartesianChart
data={DATA}
xKey="x"
yKeys={["y0", "y1"]}
xAxis={{
font,
formatXLabel: (label) => {
const date = new Date(label);
const formattedDate = date.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
});
return formattedDate;
},
}}
yAxis={[
{
font,
},
]}
>
{({ points }) => (
<>
<Line points={points.y0} color="red" strokeWidth={1} />
<Line points={points.y1} color="yellow" strokeWidth={1} />
<Scatter
points={points.y0}
shape="circle"
radius={1.5}
style="fill"
color="red"
/>
<Scatter
points={points.y1}
shape="circle"
radius={1.5}
style="fill"
color="yellow"
/>
</>
)}
</CartesianChart>
</View>
</SafeAreaView>
);
} |
thank you @keithluchtel, that looks like a good workaround. I have just finished modifying the source code to use dates for the x axis with d3 scaleTime(): |
@denniske if you want to put up a PR for time scale support, I'd gladly take a look! |
@keithluchtel I will do that if I find time. Should the user need to configure the scale using something like |
That could be an option, or we could assume if all |
Description
I am using Victory Charts in my react native expo project and was wondering if it would be possible to create a Time-Series chart but I don't see this is a current feature.
Proposal
Add support for time series chart which takes in two arguments. X = Date | Y = Value
Thanks!
The text was updated successfully, but these errors were encountered: