Skip to content

Commit

Permalink
Victory-Charts
Browse files Browse the repository at this point in the history
* first commit

* name change wip

* ios run successful

* add husky

* wip

* clipboard & pressable

* rn-config

* rn-action-view

* rn-contacts to start

* wip

* rn-contacts done

* wip

* razorpay done

* permissions screen

* location wip

* wip

* ios-permissions wip

* rm rn-permissions

* geolocation svc done

* update README

* minor changes

* minor changes

* intial setup android

* fixes after merge

* razorpay now works

* getcontacts wip

* contacts android done

* location & contacts done

* remove unused libs

* remove netinfo

* run prettier

* ios app start changes

* add basic rn-chart-wrapper

* wip

* separate chart modules for android & ios

* add more datapoints to radar chart

* update readme

* add basic victory charts

* wip

* list view

* polar chart basic done

* polar chart wip

* wip

Co-authored-by: nish <[email protected]>
  • Loading branch information
nishkohli96 and nishStoryDigital authored Sep 27, 2021
1 parent 630798e commit 9a79c55
Show file tree
Hide file tree
Showing 15 changed files with 1,047 additions and 59 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"extensions": [".js", ".ios.js", ".android.js"],
"alias": {
"_App": "./app",
"_Constants": "./app/constants",
"_Fonts": "./app/assets/fonts",
"_Images": "./app/assets/images",
"_I18N": "./app/assets/i18n",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
## Main Libraries Used

- [@react-native-community/clipboard](https://www.npmjs.com/package/@react-native-community/clipboard)
- [react-native-charts-wrapper](https://www.npmjs.com/package/react-native-charts-wrapper) ( Only Android, iOS was breaking on my M1 Mac )
- [react-native-config](https://www.npmjs.com/package/react-native-config)
- [react-native-contacts](https://www.npmjs.com/package/react-native-contacts)
- [react-native-geolocation-service](https://www.npmjs.com/package/react-native-geolocation-service)
- [react-native-razorpay](https://www.npmjs.com/package/react-native-razorpay)
- [victory-native](https://www.npmjs.com/package/victory-native)

# Other Libaries not used here

Expand Down
32 changes: 32 additions & 0 deletions app/constants/ListRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export const PermissionsList = [
{
navigateRoute: 'ContactsList',
iconName: 'person-outline',
label: 'Contacts',
},
{
navigateRoute: 'Location',
iconName: 'location-outline',
label: 'Location',
},
];

export const ChartsList = [
{
navigateRoute: 'VictoryBarChart',
label: 'Victory BarChart',
},
{
navigateRoute: 'VictoryPolarChart',
label: 'Victory PolarChart',
},
/* No iOS code for these 2 pages, so they're at the bottom of the list */
{
navigateRoute: 'LineChartScreen',
label: 'Line Chart',
},
{
navigateRoute: 'RadarChartScreen',
label: 'Radar Chart',
},
];
13 changes: 13 additions & 0 deletions app/navigation/DrawerLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ const DrawerLayout = () => {
navigation.navigate('Razorpay');
}}
/>
<DrawerItem
icon={() => (
<IoniconsI
name="bar-chart"
color={themeObj.colors.heading}
size={CommonStyles.icons.drawerIcon}
/>
)}
label={() => <ThemedHeading>Charts</ThemedHeading>}
onPress={() => {
navigation.navigate('Charts');
}}
/>
</DrawerContentScrollView>
<DrawerItem
label={() => (
Expand Down
29 changes: 29 additions & 0 deletions app/navigation/DrawerNav.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import React from 'react';
import { Platform } from 'react-native';
import { createDrawerNavigator } from '@react-navigation/drawer';

import DrawerLayout from './DrawerLayout';
import Home from '_Screens/home/Home';
import Settings from '_Screens/settings/Settings';
import Razorpay from '_Screens/razorpay/Razorpay';

import Permissions from '_Screens/permissions';
import ContactsList from '_Screens/permissions/contacts/ContactsList';
import Location from '_Screens/permissions/location/Location';

import Charts from '_Screens/charts';
import LineChartScreen from '_Screens/charts/LineChartScreen';
import RadarChartScreen from '_Screens/charts/RadarChartScreen';
import VictoryBarChart from '_Screens/charts/VictoryBarChart';
import VictoryPolarChart from '_Screens/charts/VictoryPolarChart';

const Drawer = createDrawerNavigator();

const NavDrawer = () => {
Expand All @@ -22,7 +30,28 @@ const NavDrawer = () => {
<Drawer.Screen name="Settings" component={Settings} />
<Drawer.Screen name="Razorpay" component={Razorpay} />

<<<<<<< HEAD
{/* Chart Screens */}
<Drawer.Screen name="Charts" component={Charts} />
<Drawer.Screen name="VictoryBarChart" component={VictoryBarChart} />
<Drawer.Screen name="VictoryPolarChart" component={VictoryPolarChart} />
{Platform.OS === 'android' && (
<>
<Drawer.Screen
name="LineChartScreen"
component={LineChartScreen}
/>
<Drawer.Screen
name="RadarChartScreen"
component={RadarChartScreen}
/>
</>
)}

{/* Permission Screens */}
=======
{/* Permission Related Screens */}
>>>>>>> origin/main
<Drawer.Screen name="Permissions" component={Permissions} />
<Drawer.Screen name="ContactsList" component={ContactsList} />
<Drawer.Screen name="Location" component={Location} />
Expand Down
37 changes: 37 additions & 0 deletions app/screens/charts/LineChartScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import { StyleSheet } from 'react-native';
import { LineChart } from 'react-native-charts-wrapper';
import { ThemedContainer, ThemedBody, ThemedCard } from '_Shared/Comps.themed';
import Header from '_Shared/Header';

const LineChartScreen = () => {
return (
<ThemedContainer>
<Header title="Line Chart" />
<ThemedBody>
<ThemedCard>
<LineChart
style={styles.chart}
data={{
dataSets: [
{
label: 'demo',
values: [{ y: 1 }, { y: 2 }, { y: 1 }],
},
],
}}
/>
</ThemedCard>
</ThemedBody>
</ThemedContainer>
);
};

const styles = StyleSheet.create({
chart: {
width: 300,
height: 600,
},
});

export default LineChartScreen;
111 changes: 111 additions & 0 deletions app/screens/charts/RadarChartScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React from 'react';
import { StyleSheet, View, processColor } from 'react-native';
import { RadarChart } from 'react-native-charts-wrapper';

import {
ThemedContainer,
ThemedBody,
ThemedCard,
ThemedText,
} from '_Shared/Comps.themed';
import Header from '_Shared/Header';

const RadarChartScreen = () => {
const legend = {
enabled: true,
textSize: 14,
form: 'CIRCLE',
wordWrapEnabled: true,
};

const xAxis = {
valueFormatter: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
zeroLine: {
enabled: true,
lineWidth: 1.5,
},
};

const data = {
dataSets: [
{
values: [
{ value: 90 },
{ value: 110 },
{ value: 125 },
{ value: 115 },
{ value: 110 },
{ value: 130 },
{ value: 107 },
{ value: 126 },
{ value: 104 },
{ value: 109 },
],
label: 'Some stat',
config: {
color: processColor('#FF8C9D'),
drawFilled: true,
fillColor: processColor('#FF8C9D'),
fillAlpha: 100,
lineWidth: 2,
},
},
],
};

const [selectedEntry, setSelectedEntry] = React.useState('');

const handleSelect = event => {
let entry = event.nativeEvent;
if (entry === null) {
setSelectedEntry('');
} else {
setSelectedEntry(JSON.stringify(entry));
}
console.log(event.nativeEvent);
};

return (
<ThemedContainer>
<Header title="Radar Chart" />
<ThemedBody>
<ThemedCard>
<View style={styles.textView}>
<ThemedText> selected entry</ThemedText>
<ThemedText> {selectedEntry}</ThemedText>
</View>

<View>
<RadarChart
style={styles.chart}
data={data}
xAxis={xAxis}
yAxis={{ drawLabels: true }}
chartDescription={{ text: '' }}
legend={legend}
drawWeb={true}
webLineWidth={5}
webLineWidthInner={2}
webAlpha={255}
webColor={processColor('#007aba')}
webColorInner={processColor('silver')}
skipWebLineCount={1}
onSelect={e => handleSelect(e)}
onChange={event => console.log(event.nativeEvent)}
/>
</View>
</ThemedCard>
</ThemedBody>
</ThemedContainer>
);
};

const styles = StyleSheet.create({
chart: {
width: 300,
height: 500,
},
textView: { height: 80 },
});

export default RadarChartScreen;
49 changes: 49 additions & 0 deletions app/screens/charts/VictoryBarChart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import {
VictoryBar,
VictoryChart,
VictoryTheme,
VictoryLabel,
} from 'victory-native';
import { ThemedContainer, ThemedBody, ThemedCard } from '_Shared/Comps.themed';
import Header from '_Shared/Header';

const data = [
/* Label is optional */
{ quarter: 1, earnings: 13000, label: 'Q1' },
{ quarter: 2, earnings: 16500, label: 'Q2' },
{ quarter: 3, earnings: 14250, label: 'Q3' },
{ quarter: 4, earnings: 19000, label: 'Q4' },
];

const VictoryBarChart = () => {
return (
<ThemedContainer>
<Header title="Victory Bar Chart" />
<ThemedBody>
<ThemedCard>
<VictoryChart width={350} theme={VictoryTheme.material}>
<VictoryBar
style={{ data: { fill: '#c43a31' } }}
data={data}
x="quarter"
y="earnings"
labelComponent={
<VictoryLabel
dy={-20}
backgroundStyle={{
fill: 'gold',
opacity: 0.6,
}}
backgroundPadding={{ bottom: 5, top: 5 }}
/>
}
/>
</VictoryChart>
</ThemedCard>
</ThemedBody>
</ThemedContainer>
);
};

export default VictoryBarChart;
Loading

0 comments on commit 9a79c55

Please sign in to comment.