We need a utility function to calculate percentages within the PowerBI JavaScript library. This utility will streamline scenarios where percentage calculations are needed, such as:
- 📊 Rendering percentage-based visualizations.
- ⏳ Displaying progress indicators.
- 📈 Calculating relative metrics for data processing.
- Add a function to calculate percentages based on a
partand atotal. - Ensure the function:
- Returns
0if thetotalis0. 🛑 - Handles edge cases gracefully. ✅
- Returns
- Place the function in the appropriate utilities or helper file. 📂
- 🖋️ A fully implemented
calculatePercentageutility function. - 🧪 Comprehensive unit tests validating its functionality written in Jest.
- 📝 Clear and concise documentation accompanying the function.
This utility will:
- 🧹 Improve code reusability and readability.
- 🚀 Reduce redundancy in calculating percentages across the codebase.
- 🛡️ Ensure consistent implementation of percentage logic.
Medium
- Ensure the function adheres to existing code style and patterns within the repository. 🎨
- Maintain clarity and simplicity to support future enhancements. 📈
