11import React , { Component } from "react" ;
2- import { BarChart , Bar , XAxis , YAxis , Tooltip } from "recharts" ;
2+ import {
3+ BarChart ,
4+ Bar ,
5+ XAxis ,
6+ YAxis ,
7+ Tooltip ,
8+ ResponsiveContainer ,
9+ } from "recharts" ;
10+ import { withStyles } from "@material-ui/styles" ;
11+ import styles from "../styles/BarchartStyles" ;
312
4- export default class Barchart extends Component {
13+ class Barchart extends Component {
514 render ( ) {
6- const { data, isLoading, dataKey, stroke } = this . props ;
15+ const { data, isLoading, dataKey, stroke, classes } = this . props ;
716 let result ;
817 try {
918 const updatedData = data . slice ( 1 ) . slice ( - 50 ) ;
@@ -26,21 +35,25 @@ export default class Barchart extends Component {
2635 } catch ( err ) { }
2736
2837 return (
29- < div className = "barcharts" >
30- { ! isLoading && (
31- < BarChart
32- width = { 350 }
33- height = { 150 }
34- data = { result }
35- margin = { { top : 5 , right : 30 , left : 20 , bottom : 5 } }
36- >
37- < XAxis dataKey = "date" />
38- < YAxis />
39- < Tooltip />
40- < Bar dataKey = { dataKey } fill = { stroke } />
41- </ BarChart >
42- ) }
38+ < div className = { classes . barcharts } >
39+ < ResponsiveContainer >
40+ { ! isLoading && (
41+ < BarChart
42+ width = { 350 }
43+ height = { 150 }
44+ data = { result }
45+ margin = { { top : 5 , right : 30 , left : 20 , bottom : 5 } }
46+ >
47+ < XAxis dataKey = "date" />
48+ < YAxis />
49+ < Tooltip />
50+ < Bar dataKey = { dataKey } fill = { stroke } />
51+ </ BarChart >
52+ ) }
53+ </ ResponsiveContainer >
4354 </ div >
4455 ) ;
4556 }
4657}
58+
59+ export default withStyles ( styles ) ( Barchart ) ;
0 commit comments