Skip to content

Instantly share code, notes, and snippets.

@ozcanzaferayan
Last active May 2, 2020 22:51
Show Gist options
  • Select an option

  • Save ozcanzaferayan/4b44b330d866ec29a94aeb497089c780 to your computer and use it in GitHub Desktop.

Select an option

Save ozcanzaferayan/4b44b330d866ec29a94aeb497089c780 to your computer and use it in GitHub Desktop.
Weird piechart with React Native SVG
/* eslint-disable react-native/no-inline-styles */
import React from 'react';
import {SafeAreaView, StyleSheet, StatusBar} from 'react-native';
import Svg, {Circle} from 'react-native-svg';
const App = () => {
const viewBoxWidth = 42;
const viewBoxHeight = viewBoxWidth;
const viewBox = `0 0 ${viewBoxWidth} ${viewBoxHeight}`;
const centerX = viewBoxWidth / 2;
const centerY = viewBoxHeight / 2;
const colorPrimary = '#dd0000';
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView style={styles.safeAreaView}>
<Svg viewBox={viewBox} style={{transform: [{rotateZ: '-90deg'}]}}>
<Circle
cx={centerX}
cy={centerY}
r={10}
stroke={colorPrimary}
strokeWidth={viewBoxWidth}
strokeDasharray={3}
strokeDashoffset={10}
/>
</Svg>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
safeAreaView: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
padding: 24,
},
});
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment