From 7914ca6e52c1f48a7b64527c3bfff2277705730d Mon Sep 17 00:00:00 2001 From: Daniel Friyia Date: Wed, 10 Jul 2024 13:11:54 -0400 Subject: [PATCH] feat(linechart): add line chart --- example/storybook-nativewind/package.json | 6 +- .../LineChart/LineChart.stories.tsx | 17 + .../src/components/LineChart/LineChart.tsx | 63 ++++ .../nativewind/line-chart/index.tsx | 122 ++++++++ .../nativewind/line-chart/index.web.tsx | 20 ++ example/storybook-v7/package.json | 6 +- example/storybook-v7/yarn.lock | 123 +++++++- yarn.lock | 290 +++++++++++++++++- 8 files changed, 626 insertions(+), 21 deletions(-) create mode 100644 example/storybook-nativewind/src/components/LineChart/LineChart.stories.tsx create mode 100644 example/storybook-nativewind/src/components/LineChart/LineChart.tsx create mode 100644 example/storybook-nativewind/src/core-components/nativewind/line-chart/index.tsx create mode 100644 example/storybook-nativewind/src/core-components/nativewind/line-chart/index.web.tsx diff --git a/example/storybook-nativewind/package.json b/example/storybook-nativewind/package.json index 901e2836d..949dd76d6 100644 --- a/example/storybook-nativewind/package.json +++ b/example/storybook-nativewind/package.json @@ -51,6 +51,7 @@ "@react-native-community/slider": "4.2.4", "@react-stately/collections": "^3.6.0", "@react-stately/tree": "^3.5.0", + "@shopify/react-native-skia": "^1.3.8", "expo": "^47.0.0", "expo-linear-gradient": "^12.3.0", "expo-status-bar": "~1.4.2", @@ -64,7 +65,7 @@ "react-dom": "^18.2.0", "react-native": "0.72.4", "react-native-gesture-handler": "~2.14.0", - "react-native-reanimated": "~3.6.2", + "react-native-reanimated": "^3.14.0", "react-native-safe-area-context": "^4.4.1", "react-native-svg": "13.4.0", "react-native-vector-icons": "^10.0.0", @@ -74,7 +75,8 @@ "tailwind-variants": "^0.1.20", "tailwindcss": "^3.4.1", "ts-jest": "^29.1.0", - "uuidv4": "^6.2.13" + "uuidv4": "^6.2.13", + "victory-native": "^41.0.1" }, "devDependencies": { "@babel/core": "^7.19.3", diff --git a/example/storybook-nativewind/src/components/LineChart/LineChart.stories.tsx b/example/storybook-nativewind/src/components/LineChart/LineChart.stories.tsx new file mode 100644 index 000000000..949948147 --- /dev/null +++ b/example/storybook-nativewind/src/components/LineChart/LineChart.stories.tsx @@ -0,0 +1,17 @@ +import type { ComponentMeta } from '@storybook/react-native'; +import LineChart from './LineChart'; + +const AccordionMeta: ComponentMeta = { + title: 'stories/Line Chart', + component: LineChart, + // metaInfo is required for figma generation + // @ts-ignore + metaInfo: { + componentDescription: `The Line Chart component displays data compatable with a two-dimensional cartesian plane`, + }, + argTypes: {}, +}; + +export default AccordionMeta; + +export { LineChart }; diff --git a/example/storybook-nativewind/src/components/LineChart/LineChart.tsx b/example/storybook-nativewind/src/components/LineChart/LineChart.tsx new file mode 100644 index 000000000..f1c99a797 --- /dev/null +++ b/example/storybook-nativewind/src/components/LineChart/LineChart.tsx @@ -0,0 +1,63 @@ +import React, { useState } from 'react'; + +import { LineChart } from '@/components/ui/line-chart'; + +import { Button, View, StyleSheet, useColorScheme } from 'react-native'; + +const DATA = Array.from({ length: 31 }, (_, i) => ({ + x: i, + y: 40 + 30 * Math.random(), +})); +const DATA2 = Array.from({ length: 31 }, (_, i) => ({ + x: i, + y: 40 + 30 * Math.random(), +})); + +const LineChartBasic = () => { + const [data, setData] = useState(DATA); + const colorMode = useColorScheme(); + + const labelColor = colorMode === 'dark' ? 'white' : 'black'; + const lineColor = colorMode === 'dark' ? 'lightgrey' : 'black'; + + return ( + + +