-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(charts): Move charts into dedicated component
- Loading branch information
Showing
9 changed files
with
118 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import Card from 'react-bootstrap/esm/Card'; | ||
import { CardGroupStyle, StyledCard } from '../../../templates/sharedStyles.styles'; | ||
import Graph1 from '../../../assets/temp/lc1.png'; | ||
import Graph2 from '../../../assets/temp/lc2.png'; | ||
import Graph3 from '../../../assets/temp/dc.png'; | ||
import DonutChart from '../d3charts/d3donutChart'; | ||
// import SparklineChart from '../../d3charts/d3areaChart'; | ||
|
||
import WorkingFutures from './WorkingFutures'; | ||
|
||
const ReverseCardGroupStyle = styled(CardGroupStyle)` | ||
grid-template-columns: 35% 60%; | ||
`; | ||
const GraphImg = styled.img` | ||
width: 100%; | ||
`; | ||
const Charts: React.FC<{ soc: string; name: string }> = ({ soc, name }) => { | ||
return ( | ||
<div className="mb-5"> | ||
<h2 className="mb-4"> | ||
Statistical Data About <strong>{name}</strong> | ||
</h2> | ||
<ReverseCardGroupStyle className="mb-5 mt-5"> | ||
<div style={{ width: `100%` }}> | ||
<StyledCard className="mb-3"> | ||
<Card.Body> | ||
<Card.Title className="mb-4"> | ||
<strong>Average Salary</strong> | ||
</Card.Title> | ||
<GraphImg src={Graph1} /> | ||
{/* {lmiData.loading ? ( | ||
`loading` | ||
) : ( | ||
<SparklineChart estimatePay={lmiData.lmiData.estimatePay} /> | ||
)} */} | ||
</Card.Body> | ||
</StyledCard> | ||
<StyledCard> | ||
<Card.Body> | ||
<Card.Title className="mb-4"> | ||
<strong>Employment Rate</strong> | ||
</Card.Title> | ||
<GraphImg src={Graph2} /> | ||
</Card.Body> | ||
</StyledCard> | ||
</div> | ||
<StyledCard> | ||
<Card.Body> | ||
<Card.Title className="mb-4"> | ||
<strong>Courses taken to become {name}</strong> | ||
</Card.Title> | ||
<GraphImg src={Graph3} /> | ||
</Card.Body> | ||
</StyledCard> | ||
</ReverseCardGroupStyle> | ||
<p> | ||
<StyledCard> | ||
<Card.Body> | ||
<Card.Title className="mb-4"> | ||
<strong> | ||
Another card that has infomration about current number of vacancies, replacemenet | ||
demand with a number over ceratin time of years. top skills in demand to become | ||
{` `} | ||
{name}. | ||
</strong> | ||
<WorkingFutures soc={soc} /> | ||
</Card.Title> | ||
</Card.Body> | ||
</StyledCard> | ||
</p> | ||
<p> | ||
<StyledCard> | ||
<Card.Body> | ||
<Card.Title className="mb-4"> | ||
<strong>predicted Employment</strong> | ||
<DonutChart /> | ||
</Card.Title> | ||
</Card.Body> | ||
</StyledCard> | ||
</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Charts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React, { useState } from 'react'; | ||
import useSOC from './useSOC'; | ||
|
||
const WorkingFutures: React.FC<{ soc: string }> = ({ soc }) => { | ||
const [, setWfData] = useState(``); | ||
const [, setError] = useState(``); | ||
|
||
useSOC({ soc, endpoint: `/wf/predict`, setWfData, setError }); | ||
return <p>{soc}</p>; | ||
}; | ||
|
||
export default WorkingFutures; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useEffect } from 'react'; | ||
import axios from 'axios'; | ||
|
||
const apiBaseUrl = `http://api.lmiforall.org.uk/api/v1`; | ||
|
||
export default function useSOC({ endpoint, soc, setWfData }) { | ||
useEffect(() => { | ||
axios.get(`${apiBaseUrl + endpoint}?soc=${soc}`).then((res) => { | ||
setWfData(res); | ||
}); | ||
}, [soc, setWfData]); | ||
} |
4 changes: 2 additions & 2 deletions
4
src/components/d3charts/d3areaChart.tsx → ...nents/careerPath/d3charts/d3areaChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters