Skip to content

Commit

Permalink
Added sparkline chart
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Jan 3, 2016
1 parent 09d4d3f commit 9932469
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions weather/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react": "^0.14.3",
"react-dom": "^0.14.3",
"react-redux": "^4.0.0",
"react-sparklines": "^1.4.2",
"redux": "^3.0.4",
"redux-promise": "^0.5.0"
}
Expand Down
18 changes: 18 additions & 0 deletions weather/src/containers/weather_list.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Sparklines, SparklinesLine } from 'react-sparklines';

class WeatherList extends Component {
renderWeather(cityData) {
const name = cityData.city.name;
const temps = cityData.list.map(weather => weather.main.temp);

return (
<tr key={name}>
<td>{name}</td>
<td>
<Sparklines height={120} width={180} data={temps}>
<SparklinesLine color="red" />
</Sparklines>
</td>
</tr>
);
}

render() {
return (
<table className="table table-hover">
Expand All @@ -14,6 +31,7 @@ class WeatherList extends Component {
</tr>
</thead>
<tbody>
{this.props.weather.map(this.renderWeather)}
</tbody>
</table>
);
Expand Down

0 comments on commit 9932469

Please sign in to comment.