Skip to content

Conversation

@Ishankoradia
Copy link
Contributor

@Ishankoradia Ishankoradia commented Oct 27, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced pie chart label customization with configurable label threshold and explicit label format options for improved control over label display behavior.

@Ishankoradia Ishankoradia changed the title Threshold percentage on labels for pie charts #135 Threshold percentage on labels for pie charts Oct 27, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Walkthrough

Modified generate_pie_config function to introduce a label_threshold variable (default value 5) sourced from customizations and propagated into pie label configuration as labelThreshold. Also added labelFormat to pie label configuration to extend frontend-visible label customization options.

Changes

Cohort / File(s) Summary
Pie chart label configuration enhancement
ddpui/core/charts/echarts_config_generator.py
Added label_threshold variable (default 5) from customizations to pie label config as labelThreshold. Added labelFormat to pie label configuration to support extended label customization.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that label_threshold correctly extracts from customizations with proper default handling
  • Confirm labelFormat addition aligns with existing label configuration patterns and frontend expectations
  • Check that no unintended side effects occur to existing pie chart rendering logic

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Threshold percentage on labels for pie charts" directly corresponds to the main change in the pull request, which introduces a new label_threshold variable in the generate_pie_config function that controls the threshold for displaying labels on pie charts. The title is specific, clear, and concise—avoiding vague language, emojis, or noise. A teammate scanning the project history would immediately understand that this PR adds threshold customization functionality for pie chart labels, which accurately reflects the primary intent of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enhancement/label-threshold

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
ddpui/core/charts/echarts_config_generator.py (1)

211-211: Consider adding validation for the label threshold value.

The label_threshold is retrieved from customizations without validation. If a non-numeric, negative, or out-of-range value (e.g., > 100 for percentage) is provided, it could cause unexpected behavior in the frontend.

Consider adding validation:

-        label_threshold = customizations.get("labelThreshold", 5)  # Default 5% threshold
+        label_threshold = customizations.get("labelThreshold", 5)  # Default 5% threshold
+        # Validate threshold is numeric and within reasonable range
+        if not isinstance(label_threshold, (int, float)) or label_threshold < 0 or label_threshold > 100:
+            label_threshold = 5
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d623795 and 9bfec33.

📒 Files selected for processing (1)
  • ddpui/core/charts/echarts_config_generator.py (2 hunks)

Comment on lines +280 to +282
# Pass threshold as a custom property for frontend processing
"labelThreshold": label_threshold,
"labelFormat": label_format,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Clarify the purpose of passing both labelFormat and formatter.

The code passes both labelFormat (the raw format string like "percentage") and formatter (the mapped ECharts format like "{d}%"). Since the comment indicates these are "custom properties for frontend processing," it would be helpful to clarify:

  1. Are labelThreshold and labelFormat intended as non-standard properties for custom frontend logic?
  2. Why is labelFormat needed when formatter already provides the formatted output?

If these are indeed custom properties, the frontend will need to handle them explicitly. Otherwise, ECharts will ignore them.


🏁 Script executed:

#!/bin/bash
# Search for frontend code that processes these custom properties
rg -n --type=js --type=ts -C3 'labelThreshold|labelFormat' -g '!**/node_modules/**' -g '!**/dist/**'

Length of output: 148



---

🏁 Script executed:

```shell
#!/bin/bash
# View the context around the lines in question
cat ddpui/core/charts/echarts_config_generator.py | sed -n '270,290p'

Length of output: 938


🏁 Script executed:

#!/bin/bash
# Search more broadly without type filters for frontend references
rg -n 'labelThreshold|labelFormat' -g '!**/node_modules/**' -C2

Length of output: 1830


🏁 Script executed:

#!/bin/bash
# Look for where this config is used or sent to frontend
rg -n 'echarts_config_generator|to_json|serialize' -g '!**/node_modules/**' | head -20

Length of output: 1857



---

🏁 Script executed:

```shell
#!/bin/bash
# Find the function containing these lines (look around line 280)
sed -n '150,290p' ddpui/core/charts/echarts_config_generator.py | head -150

Length of output: 6135


🏁 Script executed:

#!/bin/bash
# Find all function definitions in this file
rg -n 'def ' ddpui/core/charts/echarts_config_generator.py

Length of output: 609


🏁 Script executed:

#!/bin/bash
# Search for where echarts_config_generator functions are imported/called
rg -n 'from.*echarts_config_generator|import.*echarts_config_generator' -g '!**/node_modules/**'

Length of output: 104


🏁 Script executed:

#!/bin/bash
# Look for API views or serializers that might return this config
rg -n 'echarts_config|chart.*config' -g '!**/node_modules/**' -C1 | grep -E '\.(py|js|ts):' | head -20

Length of output: 2071



---

🏁 Script executed:

```shell
#!/bin/bash
# Check the charts_api.py file to see how config is used
cat ddpui/api/charts_api.py | head -100

Length of output: 3454


🏁 Script executed:

#!/bin/bash
# Search for all usages of generate_pie_config
rg -n 'generate_pie_config' -g '!**/node_modules/**' -C3

Length of output: 1170


🏁 Script executed:

#!/bin/bash
# Look for any API endpoints that return echarts_config or pie configuration
rg -n '@.*route|def.*view|def.*api' ddpui/api/charts_api.py -A5 | head -50

Length of output: 2245


🏁 Script executed:

#!/bin/bash
# Check if labelThreshold or labelFormat are referenced anywhere else beyond definition/assignment
rg -n 'labelThreshold|labelFormat' -g '!**/node_modules/**' --type=py

Length of output: 472


Remove or clarify the purpose of labelThreshold and labelFormat custom properties.

Verification confirms no frontend code processes these custom properties. They are only defined in the backend (lines 281-282) and never referenced elsewhere in the codebase. When placed inside ECharts' label object, these non-standard properties will be ignored by ECharts.

Either:

  1. Remove labelThreshold and labelFormat if they're unused
  2. Move them outside the label object if intended for custom frontend processing, and implement corresponding frontend logic
  3. Document why they're passed if they serve a specific purpose
🤖 Prompt for AI Agents
In ddpui/core/charts/echarts_config_generator.py around lines 280 to 282, the
custom properties "labelThreshold" and "labelFormat" are being inserted inside
the ECharts "label" object but are not consumed by frontend code and will be
ignored by ECharts; either remove these two properties from the generated config
if they are unused, or move them out of the "label" object into a top-level or
custom namespace in the config (and add corresponding frontend handling), or add
an inline code comment/docstring explaining their intended purpose and
where/when frontend logic will read them so their presence is justified.

@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 51.79%. Comparing base (d623795) to head (9bfec33).

Files with missing lines Patch % Lines
ddpui/core/charts/echarts_config_generator.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1187      +/-   ##
==========================================
- Coverage   51.80%   51.79%   -0.01%     
==========================================
  Files          97       97              
  Lines       11627    11628       +1     
==========================================
  Hits         6023     6023              
- Misses       5604     5605       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants