1- import React from 'react' ;
1+ import React , { useState , useEffect } from 'react' ;
2+
23import BarChart from './charts/BarChart/BarChart' ;
34import AreaChart from './charts/AreaChart/AreaChart' ;
45import LineChart from './charts/LineChart/LineChart' ;
56import ScatterPlot from './charts/ScatterPlot/ScatterPlot' ;
67import PieChart from './charts/PieChart/PieChart' ;
8+ import { Container } from './styles/componentStyles' ;
79
810import portfolio from '../data/portfolio.json' ;
911import penguins from '../data/penguins.json' ;
1012import fruit from '../data/fruit.json' ;
13+ import unemployment from '../data/unemployment.json'
1114import skinny_fruit from '../data/skinny_fruit.json' ;
1215
13- import { Container } from './styles/componentStyles' ;
1416
1517function App ( ) {
18+ const [ pie , setPie ] = useState ( fruit . sort ( ( a , b ) => a . value - b . value ) . slice ( 2 ) )
19+ const [ bar , setBar ] = useState ( skinny_fruit . reverse ( ) . slice ( 2 ) )
20+ const [ area , setArea ] = useState ( portfolio . slice ( 30 , 60 ) )
21+ const [ line , setLine ] = useState ( unemployment . slice ( 0 , 60 ) )
22+ const [ scatter , setScatter ] = useState ( penguins . slice ( 30 , 60 ) )
23+
24+ useEffect ( ( ) => {
25+ setTimeout ( ( ) => { setPie ( fruit . sort ( ( a , b ) => a . value - b . value ) ) } , 1000 ) ;
26+ setTimeout ( ( ) => { setBar ( skinny_fruit . reverse ( ) ) } , 2000 ) ;
27+ setTimeout ( ( ) => { setArea ( portfolio . slice ( 0 , 60 ) ) } , 4000 ) ;
28+ setTimeout ( ( ) => { setLine ( unemployment ) } , 6000 ) ;
29+ setTimeout ( ( ) => { setScatter ( penguins ) } , 8000 ) ;
30+ } , [ ] )
1631 return (
1732 < Container className = "app" >
1833 < PieChart
1934 theme = "dark"
20- data = { fruit . sort ( ( a , b ) => a . value - b . value ) }
35+ data = { pie }
2136 label = "label"
2237 value = "value"
2338 outerRadius = { 400 }
@@ -27,7 +42,7 @@ function App() {
2742 theme = "light"
2843 height = "100%"
2944 width = "100%"
30- data = { skinny_fruit . reverse ( ) }
45+ data = { bar }
3146 xKey = "date"
3247 yKey = "value"
3348 groupBy = "fruit"
@@ -43,7 +58,7 @@ function App() {
4358 theme = "dark"
4459 height = "100%"
4560 width = "100%"
46- data = { portfolio . slice ( 30 , 60 ) }
61+ data = { area }
4762 xKey = "date"
4863 yKey = "value"
4964 xAxis = "bottom"
@@ -56,10 +71,11 @@ function App() {
5671 theme = "light"
5772 height = { '100%' }
5873 width = { '100%' }
59- data = { portfolio }
74+ data = { line }
6075 xKey = "date"
6176 xDataType = "date"
62- yKey = "value"
77+ groupBy = 'division'
78+ yKey = "unemployment"
6379 xAxis = "bottom"
6480 yAxis = "left"
6581 yGrid = { true }
@@ -72,7 +88,8 @@ function App() {
7288 theme = "light"
7389 height = "100%"
7490 width = "100%"
75- data = { penguins }
91+ data = { scatter }
92+ groupBy = { 'species' }
7693 xKey = "flipper_length_mm"
7794 xDataType = "number"
7895 xGrid = { true }
@@ -82,6 +99,8 @@ function App() {
8299 yGrid = { true }
83100 yAxis = "right"
84101 yAxisLabel = "Body Mass"
102+ legend = { 'right' }
103+
85104 />
86105 </ Container >
87106 ) ;
0 commit comments