Skip to content
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

data plot #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,35 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Home from './screens/home/index';
import Quiz from './screens/quiz/index';
import Login from './screens/login/index';
import PersonalAssistant from './screens/Personalassistant';
import DataViz from './screens/data_viz';
import Data from './components/Data/index';
// import PersonalAssistant from './screens/Personalassistant';

const Stack = createNativeStackNavigator();

export default function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
{/* <Stack.Screen
name="login"
component={Login}
options={{ title: 'Login', headerShown: false }}
/>
<Stack.Screen
/> */}
{/* <Stack.Screen
name="Calendar"
component={PersonalAssistant}
options={{ title: 'Calendar' }}
/>
<Stack.Screen
/> */}
{/* <Stack.Screen
name="quiz"
component={Quiz}
options={{ title: 'quiz', headerShown: false }}
/> */}
<Stack.Screen
name="data_viz"
component={DataViz}
options={{ title: 'Data Visualization', headerShown: false }}
/>
</Stack.Navigator>
<StatusBar style="auto" />
Expand Down
50 changes: 50 additions & 0 deletions app/components/Data/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react'
import { AreaChart, Grid, XAxis, YAxis } from 'react-native-svg-charts'
import { Defs, LinearGradient, Stop } from 'react-native-svg'
import { View } from 'react-native'

class GradientChart extends React.PureComponent {
render() {
const { data } = this.props;
const axesSvg = { fontSize: 5, fill: 'grey' };
const verticalContentInset = { top: 5, bottom: 5 };

const Gradient = ({ index }) => (
<Defs key={index}>
<LinearGradient id={'gradient'} x1={'0%'} y1={'0%'} x2={'0%'} y2={'100%'}>
<Stop offset={'0%'} stopColor={'rgb(134, 65, 244)'} stopOpacity={0.8}/>
<Stop offset={'100%'} stopColor={'rgb(134, 65, 244)'} stopOpacity={0.2}/>
</LinearGradient>
</Defs>
)

return (
<View style={{display:'flex', flexDirection:'row'}}>
<YAxis style={{height:200, width:'8%'}}
data={data}
contentInset={{ top: 10, bottom: 10 }}
svg={{
fill: 'grey',
fontSize: 10,
}}
numberOfTicks={5}
formatLabel={(value) => `${value}`}
/>
<AreaChart
style={{ height: 200 , width: 310}}
data={data}
contentInset={{ top: 20, bottom: 20 }}
svg={{ fill: 'url(#gradient)' }}

>

<Grid/>
<Gradient/>
</AreaChart>
</View>
)
}

}

export default GradientChart
129 changes: 129 additions & 0 deletions app/components/Data2/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import React from 'react'
import { LinearGradient, Stop, Defs } from 'react-native-svg'
import { BarChart, Grid , XAxis, YAxis} from 'react-native-svg-charts'
import { View } from 'react-native'

class GradientBar extends React.PureComponent {

render() {
const { data } = this.props;

const Gradient = () => (
<Defs key={'gradient'}>
<LinearGradient id={'gradient'} x1={'0%'} y={'0%'} x2={'0%'} y2={'100%'}>
<Stop offset={'0%'} stopColor={'rgb(134, 65, 244)'}/>
<Stop offset={'100%'} stopColor={'rgb(66, 194, 244)'}/>
</LinearGradient>
</Defs>
)

return (
<View>
<XAxis
// style={{height:200, width:'8%'}}
// data={["A", "B", "C", "D", "E", "F", "G"]}
data={data.values}
contentInset={{ top: 20, bottom: 20 }}
svg={{
fill: 'grey',
fontSize: 10,
}}
numberOfTicks={5}
formatLabel={(value) => `${value}`}
/>
<BarChart
style={ { height: 200 } }
data={ data }
contentInset={ { top: 20, bottom: 20 } }
svg={ {
strokeWidth: 2,
fill: 'url(#gradient)',
} }
>
<Grid/>
<Gradient/>
</BarChart>
</View>

)
}

}

export default GradientBar

// import React from 'react'
// import { View } from 'react-native'
// import { BarChart, Grid, YAxis } from 'react-native-svg-charts'
// import * as scale from 'd3-scale'

// class GradientBar extends React.PureComponent {

// render() {

// const data = [
// {
// value: 50,
// label: 'One',
// },
// {
// value: 10,
// label: 'Two',
// },
// {
// value: 40,
// label: 'Three',
// },
// {
// value: 95,
// label: 'Four',
// },
// {
// value: 85,
// label: 'Five',
// },
// ]


// return (
// <View style={{ flexDirection: 'row', height: 200, paddingVertical: 15 }}>
// <YAxis
// style={{height:200, width:'3%'}}
// // data={['A', 'B', 'C', 'D', 'E']}
// data={data}
// yAccessor={({ index }) => index}
// scale={scale.scaleBand}
// contentInset={{ top: 10, bottom: 10 }}
// // spacing={0.2}
// formatLabel={(_, index) => data[ index ].label}
// // formatLabel={(value) => `${value}`}
// />
// {/* <YAxis style={{height:200, width:'2%'}}
// data={data}
// contentInset={{ top: 10, bottom: 10 }}
// svg={{
// fill: 'grey',
// fontSize: 10,
// }}
// numberOfTicks={5}
// formatLabel={(_, index) => data[ index ].label}
// /> */}
// <BarChart
// style={{ flex: 1, marginLeft: 8 }}
// data={data}
// horizontal={true}
// yAccessor={({ item }) => item.value}
// svg={{ fill: 'rgba(134, 65, 244, 0.8)' }}
// contentInset={{ top: 10, bottom: 10 }}
// spacing={0.2}
// gridMin={0}
// >
// <Grid direction={Grid.Direction.VERTICAL}/>
// </BarChart>
// </View>
// )
// }

// }

// export default GradientBar
Loading