Rename reserved keyword prop to data

This commit is contained in:
Alex Holliday committed 2024-09-14 11:29:14 +08:00
1 parent 88f5cbb254
commit 4b0ac5822a
1 file changed
+16 -3
@@ -87,6 +87,15 @@ const PieValueLabel = ({ value, startAngle, endAngle, color, highlighted }) => {
); );
}; };
// Validate props using PropTypes
PieValueLabel.propTypes = {
value: PropTypes.number.isRequired,
startAngle: PropTypes.number.isRequired,
endAngle: PropTypes.number.isRequired,
color: PropTypes.string.isRequired,
highlighted: PropTypes.bool.isRequired,
};
const PieChart = ({ audits }) => { const PieChart = ({ audits }) => {
const theme = useTheme(); const theme = useTheme();
@@ -148,7 +157,7 @@ const PieChart = ({ audits }) => {
*/ */
let performance = 0; let performance = 0;
const getPieData = (audits) => { const getPieData = (audits) => {
let props = []; let data = [];
let startAngle = 0; let startAngle = 0;
const padding = 3; // padding between arcs const padding = 3; // padding between arcs
const max = 360 - padding * (Object.keys(audits).length - 1); // _id is a child of audits const max = 360 - padding * (Object.keys(audits).length - 1); // _id is a child of audits
@@ -159,7 +168,7 @@ const PieChart = ({ audits }) => {
let endAngle = startAngle + (weights[key] * max) / 100; let endAngle = startAngle + (weights[key] * max) / 100;
let theme = getColors(audits[key].score * 100); let theme = getColors(audits[key].score * 100);
props.push({ data.push({
id: key, id: key,
data: [ data: [
{ {
@@ -195,7 +204,7 @@ const PieChart = ({ audits }) => {
} }
}); });
return props; return data;
}; };
const pieSize = { width: 230, height: 230 }; const pieSize = { width: 230, height: 230 };
@@ -296,4 +305,8 @@ const PieChart = ({ audits }) => {
); );
}; };
PieChart.propTypes = {
audits: PropTypes.object,
};
export default PieChart; export default PieChart;