-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.js
87 lines (82 loc) · 2.22 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React, { createClass } from 'react'
import { LineChart } from '../../src'
const categories = [
{
title: 'Accommodation',
points: [
{ label: 'Fri 17', value: 7.65 },
{ label: 'Sat 18', value: 25.50 },
{ label: 'Sun 19', value: 21.55 },
{ label: 'Mon 20', value: 21.55 },
{ label: 'Tue 21', value: 21.55 },
{ label: 'Wed 22', value: 21.55 },
{ label: 'Thu 23', value: 39.82 },
{ label: 'Fri 24', value: 39.82 },
{ label: 'Sat 25', value: 39.82 }
]
},
{
title: 'Food',
points: [
{ label: 'Fri 17', value: 5.46 },
{ label: 'Sat 18', value: 5.71 },
{ label: 'Sun 19', value: 9.79 },
{ label: 'Mon 20', value: 9.03 },
{ label: 'Tue 21', value: 13.52 },
{ label: 'Wed 22', value: 12.50 },
{ label: 'Thu 23', value: 15.56 },
{ label: 'Fri 24', value: 9.18 },
{ label: 'Sat 25', value: 9.44 }
]
},
{
title: 'Drink',
points: [
{ label: 'Fri 17', value: 2.35 },
{ label: 'Sat 18', value: 2.55 },
{ label: 'Sun 19', value: 10.20 },
{ label: 'Mon 20', value: 10.97 },
{ label: 'Tue 21', value: 3.83 },
{ label: 'Wed 22', value: 2.04 },
{ label: 'Thu 23', value: 4.52 },
{ label: 'Fri 24', value: 1.28 },
{ label: 'Sat 25', value: 10.91 }
]
}
]
const App = createClass({
onChange (e) {
this.setState({
category: categories[ e.target.value ]
})
},
getInitialState () {
return {
category: categories[ 0 ]
}
},
render () {
return (
<section className='content'>
<select onChange={this.onChange}>
{ categories.map((cat, i) => (
<option key={i} value={i}>{ cat.title }</option>
))}
</select>
<LineChart
description={`Amount of money spent on ${this.state.category.title}`}
formatValue={v => `£${v.toFixed(2)}`}
lines={[{ points: this.state.category.points }]}
pointSize={18}
labelSpacing={15}
preserveAspectRatio='xMinYMid meet'
title='Travel budget'
valueHeight={34}
valueOffset={37}
valueWidth={65}
/>
</section>
)
}
})
export default App