Skip to content

Commit

Permalink
Personnalisation du graphique des activités quotidiennes mais il y a …
Browse files Browse the repository at this point in the history
…un pb d'affichage du tooltip
  • Loading branch information
charlenry committed Mar 3, 2023
1 parent 6897908 commit 9f2568b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
23 changes: 20 additions & 3 deletions src/components/Activity/Activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,31 @@ const Activity = ({ activityModel }) => {
<CartesianGrid horizontal="true" vertical="" />
<XAxis dataKey="day" />
<YAxis />
<Tooltip />
<Bar dataKey="kilogram" fill="#282D30" barSize={7} />
<Bar dataKey="calories" fill="#E60000" barSize={7} />
<Tooltip content={<CustomTooltip />} />
<Bar dataKey="kilogram" fill="#282D30" barSize={7} radius={[20, 20, 0, 0]} />
<Bar dataKey="calories" fill="#E60000" barSize={7} radius={[20, 20, 0, 0]}/>
<Legend />
</BarChart>
</div>
</div>
);
};


const CustomTooltip = ({ active, payload, label }) => {
if (active && payload && payload.length) {
// console.log('Valeur de active: ', active);
// console.log('Valeur de payload: ', payload);
// console.log('Valeur de label: ', label);
return (
<div className="custom-tooltip">
<p className="label">{`${payload[0].value}kg`}</p>
<p className="label">{`${payload[1].value}kcal`}</p>
</div>
);
}

return null;
};

export default Activity;
24 changes: 24 additions & 0 deletions src/components/Activity/Activity.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,28 @@
font-weight: 500;
color: $black;
}
}


.custom-tooltip {
display: flex;
flex-direction: column;
position: absolute;
top: -7rem;
left: 2.1rem;
border: 1px solid #E60000;
z-index: 10;

p.label {
background-color: #E60000;
color: white;
font-size: 0.7rem;
line-height: 2.4rem;
font-weight: 500;
width: 5rem;
height: 4rem;
display: flex;
justify-content: center;
align-items: center;
}
}
2 changes: 1 addition & 1 deletion src/components/Performance/Performance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./Performance.scss";
import './Performance.scss';
import React from "react";
import {
ResponsiveContainer,
Expand Down
1 change: 1 addition & 0 deletions src/components/TodayScore/TodayScore.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const TodayScore = ({ infosModel }) => {
cy={'50%'}
innerRadius={80}
outerRadius={90}
cornerRadius="50%"
fill="#ff0000"
/>
</PieChart>
Expand Down
3 changes: 3 additions & 0 deletions src/style/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
box-sizing: border-box;
margin: 0;
padding: 0;
border: 0.1px dashed #868686;
}
@font-face {
font-family: 'Roboto';
Expand Down Expand Up @@ -173,3 +174,5 @@ body {
max-height: 12.4rem;
overflow: hidden;
}


0 comments on commit 9f2568b

Please sign in to comment.