Skip to content

Commit

Permalink
format all files (for real this time)
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperLekland committed Jul 6, 2019
1 parent 83d36cb commit 8a3af79
Show file tree
Hide file tree
Showing 60 changed files with 560 additions and 878 deletions.
12 changes: 3 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,20 @@ const App = () => {
textAlign: 'center',
}}
>
{
'Welcome to "react-native-svg-charts". \n' +
'To see showcases of all our charts\n'
}
{'Welcome to "react-native-svg-charts". \n' + 'To see showcases of all our charts\n'}
</Text>
<Text
style={{
fontSize: 14,
alignSelf: 'center',
}}
>
{
'• Stop your packager \n' +
{'• Stop your packager \n' +
'• run "yarn storybook" \n' +
'• Go to "localhost:7008" in your browser\n' +
'• reload your device \n' +
'• browse our charts'
}
'• browse our charts'}
</Text>

</View>
)
}
Expand Down
12 changes: 2 additions & 10 deletions src/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react'
import { StyleSheet, Text, View } from 'react-native'

class Card extends React.PureComponent {

state = {
hasError: false,
}
Expand All @@ -13,18 +12,11 @@ class Card extends React.PureComponent {
}

render() {
const { hasError } = this.state
const { hasError } = this.state
const { style, children } = this.props

return (
<View style={ [ styles.container, style ] }>
{
hasError ?
<Text>{'Something went wrong'}</Text> :
children

}
</View>
<View style={[styles.container, style]}>{hasError ? <Text>{'Something went wrong'}</Text> : children}</View>
)
}
}
Expand Down
11 changes: 1 addition & 10 deletions src/chart-decorators/horizontal-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@ import React from 'react'
import { Line } from 'react-native-svg'

class HorizontalLine extends React.Component {

render() {
const { y, value, ...other } = this.props
return (
<Line
x1={ '0%' }
x2={ '100%' }
y1={ y(value) }
y2={ y(value) }
{ ...other }
/>
)
return <Line x1={'0%'} x2={'100%'} y1={y(value)} y2={y(value)} {...other} />
}
}

Expand Down
12 changes: 2 additions & 10 deletions src/chart-decorators/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@ import { Circle } from 'react-native-svg'

const Point = ({ x, y, value, index, radius, color }) => {
if (isNaN(value)) {
return <Circle/>
return <Circle />
}

return (
<Circle
cx={ x(index) }
cy={ y(value) }
r={ radius }
stroke={ color }
fill={ 'white' }
/>
)
return <Circle cx={x(index)} cy={y(value)} r={radius} stroke={color} fill={'white'} />
}

Point.propTypes = {
Expand Down
46 changes: 7 additions & 39 deletions src/chart-decorators/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,13 @@ import { Circle, G, Line, Rect, Text } from 'react-native-svg'
const Tooltip = ({ x, y, value, index, height, text, stroke, pointStroke }) => {
return (
<G>
<Line
x1={ x(index) }
y1={ height }
x2={ x(index) }
y2={ 20 }
stroke={ stroke }
/>
<Circle
cx={ x(index) }
cy={ y(value) }
r={ 4 }
stroke={ pointStroke }
strokeWidth={ 2 }
fill={ 'white' }
/>
<G x={ x(index) < 40 ? 40 : x(index) } y={ 10 }>
<Rect
x={ -40 }
y={ 1 }
width={ 80 }
height={ 20 }
fill={ 'rgba(0, 0, 0, 0.2)' }
rx={ 2 }
ry={ 2 }
/>
<Rect
x={ -40 }
y={ 0 }
width={ 80 }
height={ 20 }
fill={ 'white' }
rx={ 2 }
ry={ 2 }
/>
<Text
fontSize="12"
textAnchor="middle"
>
{ text }
<Line x1={x(index)} y1={height} x2={x(index)} y2={20} stroke={stroke} />
<Circle cx={x(index)} cy={y(value)} r={4} stroke={pointStroke} strokeWidth={2} fill={'white'} />
<G x={x(index) < 40 ? 40 : x(index)} y={10}>
<Rect x={-40} y={1} width={80} height={20} fill={'rgba(0, 0, 0, 0.2)'} rx={2} ry={2} />
<Rect x={-40} y={0} width={80} height={20} fill={'white'} rx={2} ry={2} />
<Text fontSize='12' textAnchor='middle'>
{text}
</Text>
</G>
</G>
Expand Down
8 changes: 3 additions & 5 deletions src/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import { G } from 'react-native-svg'
const Extra = ({ children, ...props }) => {
return (
<G>
{
React.Children.map(children, child => {
return React.cloneElement(child, props)
})
}
{React.Children.map(children, (child) => {
return React.cloneElement(child, props)
})}
</G>
)
}
Expand Down
63 changes: 29 additions & 34 deletions src/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,46 @@ import { G, Line } from 'react-native-svg'
const Horizontal = ({ ticks = [], y, svg }) => {
return (
<G>
{
ticks.map(tick => (
<Line
key={ tick }
x1={ '0%' }
x2={ '100%' }
y1={ y(tick) }
y2={ y(tick) }
strokeWidth={ 1 }
stroke={ 'rgba(0,0,0,0.2)' }
{ ...svg }
/>
))
}
{ticks.map((tick) => (
<Line
key={tick}
x1={'0%'}
x2={'100%'}
y1={y(tick)}
y2={y(tick)}
strokeWidth={1}
stroke={'rgba(0,0,0,0.2)'}
{...svg}
/>
))}
</G>
)
}

const Vertical = ({ ticks = [], x, svg }) => {
return (
<G>
{
ticks.map((tick, index) => (
<Line
key={ index }
y1={ '0%' }
y2={ '100%' }
x1={ x(tick) }
x2={ x(tick) }
strokeWidth={ 1 }
stroke={ 'rgba(0,0,0,0.2)' }
{ ...svg }
/>
))

}
{ticks.map((tick, index) => (
<Line
key={index}
y1={'0%'}
y2={'100%'}
x1={x(tick)}
x2={x(tick)}
strokeWidth={1}
stroke={'rgba(0,0,0,0.2)'}
{...svg}
/>
))}
</G>
)
}

const Both = (props) => {
return (
<G>
<Horizontal { ...props }/>
<Vertical { ...props }/>
<Horizontal {...props} />
<Vertical {...props} />
</G>
)
}
Expand Down Expand Up @@ -78,11 +73,11 @@ const Direction = {

const Grid = ({ direction, ...props }) => {
if (direction === Direction.VERTICAL) {
return <Vertical { ...props } />
return <Vertical {...props} />
} else if (direction === Direction.HORIZONTAL) {
return <Horizontal { ...props } />
return <Horizontal {...props} />
} else if (direction === Direction.BOTH) {
return <Both { ...props } />
return <Both {...props} />
}

return null
Expand Down
Loading

0 comments on commit 8a3af79

Please sign in to comment.