codeant-ai-for-open-source[bot] commented on code in PR #43770:
URL: https://github.com/apache/superset/pull/43770#discussion_r3906289002
##########
superset/mcp_service/chart/tool/get_chart_preview.py:
##########
@@ -700,6 +701,126 @@ def _bar_chart_spec(
},
}
+ def _bullet_chart_spec(
+ self, fields: List[str], field_types: Dict[str, str] | None = None
+ ) -> Dict[str, Any]:
+ """Create a horizontal Bullet spec from saved native form_data."""
+ from superset.mcp_service.chart.preview_utils import (
+ _bullet_numeric_tokens,
+ _form_column_label,
+ _form_metric_label,
+ )
+ from superset.utils import json as utils_json
+
+ field_types = field_types or {}
+ form_data = self._get_form_data() or {}
+
+ def result_field(label: str | None) -> str | None:
+ if label in fields:
+ return label
+ if label:
+ matches = [
+ field for field in fields if field.casefold() ==
label.casefold()
+ ]
+ if len(matches) == 1:
+ return matches[0]
+ return None
+
+ metric_field =
result_field(_form_metric_label(form_data.get("metric")))
+ if metric_field is None:
+ metric_field = next(
+ (
+ field
+ for field in reversed(fields)
+ if field_types.get(field) == "quantitative"
+ ),
+ fields[-1] if fields else "metric",
+ )
+ dimensions = [
+ field
+ for column in form_data.get("groupby") or []
+ if (field := result_field(_form_column_label(column)))
+ ]
+ if not dimensions:
+ dimensions = [field for field in fields if field != metric_field]
+
+ category_field = "__mcp_bullet_category"
+ calculate = (
+ " + ', ' + ".join(
+ f"toString(datum[{utils_json.dumps(field)}])" for field in
dimensions
+ )
+ if dimensions
+ else "'Measure'"
+ )
+ y_encoding = {
+ "field": category_field,
+ "type": "nominal",
+ "title": ", ".join(dimensions) if dimensions else None,
+ "sort": None,
+ }
+ layers: list[dict[str, Any]] = []
+ for index, threshold in enumerate(
+ sorted(_bullet_numeric_tokens(form_data.get("ranges")),
reverse=True)
+ ):
+ layers.append(
+ {
+ "mark": {
+ "type": "rect",
+ "opacity": max(0.08, 0.28 - index * 0.04),
+ },
+ "encoding": {
+ "x": {"datum": 0, "type": "quantitative"},
+ "x2": {"datum": threshold},
+ },
+ }
+ )
Review Comment:
**Suggestion:** Range rectangles have no category `y` encoding, so grouped
Bullet previews render each threshold as one chart-wide band instead of a
background behind every bullet row. [logic error]
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=644c73c7093f4c519955df442e608dab&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=644c73c7093f4c519955df442e608dab&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/chart/tool/get_chart_preview.py
**Line:** 762:776
**Comment:**
*Logic Error: Range rectangles have no category `y` encoding, so
grouped Bullet previews render each threshold as one chart-wide band instead of
a background behind every bullet row.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43770&comment_hash=7cd859131e86d2bc9e5997fb1037c11e9d85254a9b1199b0e8e128b01ca2be52&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43770&comment_hash=7cd859131e86d2bc9e5997fb1037c11e9d85254a9b1199b0e8e128b01ca2be52&reaction=dislike'>๐</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]