mirror of
https://github.com/MinaSaad1/pbi-cli
synced 2026-04-21 13:37:19 +00:00
feat: add advancedSlicerVisual (tile/image slicer) visual type (v3.6.0)
Registers advancedSlicerVisual with aliases advanced_slicer, adv_slicer, and tile_slicer. Includes template with Values queryState, data roles, role aliases, default size (280x280), renderer color/icon, and tests.
This commit is contained in:
parent
ba44ff814c
commit
316fafa675
5 changed files with 57 additions and 0 deletions
|
|
@ -75,6 +75,7 @@ SUPPORTED_VISUAL_TYPES: frozenset[str] = frozenset({
|
|||
"shape",
|
||||
"textbox",
|
||||
"pageNavigator",
|
||||
"advancedSlicerVisual",
|
||||
})
|
||||
|
||||
# Mapping from user-friendly names to PBIR visualType identifiers
|
||||
|
|
@ -132,6 +133,9 @@ VISUAL_TYPE_ALIASES: dict[str, str] = {
|
|||
"page_navigator": "pageNavigator",
|
||||
"page_nav": "pageNavigator",
|
||||
"navigator": "pageNavigator",
|
||||
"advanced_slicer": "advancedSlicerVisual",
|
||||
"adv_slicer": "advancedSlicerVisual",
|
||||
"tile_slicer": "advancedSlicerVisual",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ VISUAL_DATA_ROLES: dict[str, list[str]] = {
|
|||
"shape": [],
|
||||
"textbox": [],
|
||||
"pageNavigator": [],
|
||||
"advancedSlicerVisual": ["Values"],
|
||||
}
|
||||
|
||||
# Roles that should default to Measure references (not Column)
|
||||
|
|
@ -138,6 +139,7 @@ ROLE_ALIASES: dict[str, dict[str, str]] = {
|
|||
"shape": {},
|
||||
"textbox": {},
|
||||
"pageNavigator": {},
|
||||
"advancedSlicerVisual": {"value": "Values", "field": "Values"},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -224,6 +226,7 @@ DEFAULT_SIZES: dict[str, tuple[float, float]] = {
|
|||
"shape": (300, 200),
|
||||
"textbox": (300, 100),
|
||||
"pageNavigator": (120, 400),
|
||||
"advancedSlicerVisual": (280, 280),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ _VISUAL_COLORS: dict[str, str] = {
|
|||
"shape": "#7F7F7F",
|
||||
"textbox": "#404040",
|
||||
"pageNavigator": "#00B0F0",
|
||||
"advancedSlicerVisual": "#FFC000",
|
||||
}
|
||||
|
||||
_VISUAL_ICONS: dict[str, str] = {
|
||||
|
|
@ -122,6 +123,7 @@ _VISUAL_ICONS: dict[str, str] = {
|
|||
"shape": "▲",
|
||||
"textbox": "◻",
|
||||
"pageNavigator": "►",
|
||||
"advancedSlicerVisual": "☰",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
24
src/pbi_cli/templates/visuals/advancedSlicerVisual.json
Normal file
24
src/pbi_cli/templates/visuals/advancedSlicerVisual.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definition/visualContainer/2.7.0/schema.json",
|
||||
"name": "__VISUAL_NAME__",
|
||||
"position": {
|
||||
"x": __X__,
|
||||
"y": __Y__,
|
||||
"z": __Z__,
|
||||
"height": __HEIGHT__,
|
||||
"width": __WIDTH__,
|
||||
"tabOrder": __TAB_ORDER__
|
||||
},
|
||||
"visual": {
|
||||
"visualType": "advancedSlicerVisual",
|
||||
"query": {
|
||||
"queryState": {
|
||||
"Values": {
|
||||
"projections": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"objects": {},
|
||||
"drillFilterOtherVisuals": true
|
||||
}
|
||||
}
|
||||
|
|
@ -905,3 +905,27 @@ def test_textbox_no_how_created(report_with_page: Path) -> None:
|
|||
)
|
||||
data = json.loads(vfile.read_text())
|
||||
assert "howCreated" not in data
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# v3.6.0 -- advancedSlicerVisual
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("alias", [
|
||||
"advancedSlicerVisual", "advanced_slicer", "adv_slicer", "tile_slicer",
|
||||
])
|
||||
def test_advanced_slicer_aliases(report_with_page: Path, alias: str) -> None:
|
||||
r = visual_add(report_with_page, "test_page", alias, x=0, y=0)
|
||||
assert r["visual_type"] == "advancedSlicerVisual"
|
||||
|
||||
|
||||
def test_advanced_slicer_has_values_querystate(report_with_page: Path) -> None:
|
||||
r = visual_add(report_with_page, "test_page", "advancedSlicerVisual", x=0, y=0)
|
||||
vfile = (
|
||||
report_with_page / "pages" / "test_page" / "visuals" / r["name"] / "visual.json"
|
||||
)
|
||||
data = json.loads(vfile.read_text())
|
||||
assert "query" in data["visual"]
|
||||
assert "Values" in data["visual"]["query"]["queryState"]
|
||||
assert isinstance(data["visual"]["query"]["queryState"]["Values"]["projections"], list)
|
||||
|
|
|
|||
Loading…
Reference in a new issue