From 6ed7e7707922eb6a2c47c5a457e8fea6bec2d680 Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Mon, 5 Aug 2024 14:43:10 -0400 Subject: [PATCH] Added docs --- Client/src/Pages/PageSpeed/Details/index.jsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Client/src/Pages/PageSpeed/Details/index.jsx b/Client/src/Pages/PageSpeed/Details/index.jsx index f5f376010..44f622a1b 100644 --- a/Client/src/Pages/PageSpeed/Details/index.jsx +++ b/Client/src/Pages/PageSpeed/Details/index.jsx @@ -78,6 +78,18 @@ const PieCenterLabel = ({ value, color }) => { ); }; +/** + * A component that renders a label on a pie chart slice. + * The label is positioned relative to the center of the pie chart and is optionally highlighted. + * + * @param {Object} props + * @param {number} props.value - The value to display inside the pie slice. + * @param {number} props.startAngle - The starting angle of the pie slice in degrees. + * @param {number} props.endAngle - The ending angle of the pie slice in degrees. + * @param {string} props.color - The color of the label text when highlighted. + * @param {boolean} props.highlighted - Determines if the label should be highlighted or not. + * @returns {JSX.Element} + */ const PieValueLabel = ({ value, startAngle, endAngle, color, highlighted }) => { const { width, height } = useDrawingArea(); @@ -233,6 +245,14 @@ const PageSpeedDetails = () => { return theme.pie.default; }; + /** + * Calculates and formats the data needed for rendering a pie chart based on audit scores and weights. + * This function generates properties for each pie slice, including angles, radii, and colors. + * It also calculates performance based on the weighted values. + * + * @returns {Array} An array of objects, each representing the properties for a slice of the pie chart. + * @returns {number} performance - A variable updated with the rounded sum of weighted values. + */ let performance = 0; const getPieData = (audits) => { let props = [];