Skip to content

Commit

Permalink
Multiline example (#15)
Browse files Browse the repository at this point in the history
* Multi-line example

Thanks to Saman Kumara on StackOverflow for this example: https://stackoverflow.com/a/59207977/1437016

* Added multi-line image

* Updated readme for multi-line example
  • Loading branch information
Bigood authored Mar 6, 2020
1 parent c213882 commit 30b18af
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Click an example to see the code! 💪
[<img src="./screenshots/extras.png" width=33% />](./storybook/stories/extras.js)
[<img src="./screenshots/both-axes.png" width=33% />](./storybook/stories/both-axes.js)
[<img src="./screenshots/decorators.png" width=33% />](./storybook/stories/decorator.js)
[<img src="./screenshots/multi-line.png" width=33% />](./storybook/stories/line-chart/multi-line.js)

## StackedAreaChart

Expand Down
Binary file added screenshots/multi-line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions storybook/stories/line-chart/multi-line.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'
import { LineChart, Path, Grid } from 'react-native-svg-charts'

class LineChartExample extends React.PureComponent {

render() {

const data1 = [ 50, 10, 40, 95, -4, -24, 85, 91, 35, 53, -53, 24, 50, -20, -80 ]
const data2 = [ -87, 66, -69, 92, -40, -61, 16, 62, 20, -93, -54, 47, -89, -44, 18 ]

//Array of datasets, following this syntax:
const data = [
{
data: data1,
svg: { stroke: 'purple' },
},
{
data: data2,
svg: { stroke: 'green' },
},
]

return (
<LineChart
style={{ height: 200 }}
data={ data }
contentInset={{ top: 20, bottom: 20 }}
>
<Grid />
</LineChart>
)
}
}

export default LineChartExample

0 comments on commit 30b18af

Please sign in to comment.