Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ddpui/core/charts/echarts_config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def generate_pie_config(data: Dict[str, Any], customizations: Dict[str, Any] = N
legend_display = customizations.get("legendDisplay", "paginated")
show_legend = customizations.get("showLegend", True)
show_tooltip = customizations.get("showTooltip", True)
label_threshold = customizations.get("labelThreshold", 5) # Default 5% threshold

# Determine label formatter
formatter_map = {
Expand Down Expand Up @@ -276,6 +277,9 @@ def generate_pie_config(data: Dict[str, Any], customizations: Dict[str, Any] = N
"show": show_data_labels,
"position": position_map.get(data_label_position, "outside"),
"formatter": formatter_map.get(label_format, "{d}%"),
# Pass threshold as a custom property for frontend processing
"labelThreshold": label_threshold,
"labelFormat": label_format,
Comment on lines +280 to +282
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.

},
"labelLine": {"show": show_data_labels and data_label_position == "outside"},
"data": data.get("pieData", []),
Expand Down
Loading