📶
Barras agrupadas (varias medidas con repeat)
Gráfico de barras agrupadas (varias medidas con ‘repeat’) que muestra los ingresos brutos mundiales y de EE. UU. por género cinematográfico principal. Basado en un ejemplo oficial de Vega-Lite y adaptado para Deneb en Power BI; ten en cuenta que la interactividad de cross-filter es limitada cuando se usa ‘repeat’.
Vega-Lite grouped-bar intermedio
✓ Tooltip
✓ Context menu
Vista previa en vivo
Render con datos de muestra · Vega/Vega-Lite
Cargando vista previa…
Vista previa renderizada con el runtime de Deneb · MIT © Daniel Marsh-Patrick
🧩 Campos que espera
-
__0__Major Genre texto -
__1__US Gross número medida -
__2__Worldwide Gross número medida
Arrastra tus campos a Values en este orden.
🎯 Técnica
- Motor
- Vega-Lite 5.16.3
- Marks
- bar, text
- Power BI
- pbiColor, pbiFormat
Cómo usarlo en Power BI
- Agrega el visual Deneb a tu reporte e ingresa a su editor.
- Arrastra tus campos a Values en este orden: Major Genre , US Gross , Worldwide Gross .
- Pega el spec (botón «Copiar spec» arriba) en el editor JSON de Deneb.
- Mapea tus columnas y ajusta a tu gusto. La interactividad nativa ya viene configurada.
Ver el spec Vega-Lite completo
spec.vega-lite.json
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"usermeta": {
"deneb": {
"build": "1.6.2.1",
"metaVersion": 1,
"provider": "vegaLite",
"providerVersion": "5.16.3"
},
"interactivity": {
"tooltip": true,
"contextMenu": true,
"selection": false,
"highlight": false,
"dataPointLimit": 50
},
"information": {
"name": "Grouped Bar Chart (Multiple Measure with Repeat)",
"description": "Based on an official Vega-Lite example and adapted for use in Deneb within Power BI, it should be noted that cross-filtering interactivity is limited when using 'repeat'. Author: Cristobal Salcedo Beltran. Contact: contacto@csalcedodatabi.com.",
"author": "Cristobal Salcedo Beltran",
"uuid": "3daea56b-488c-467b-9627-5cf0d503e056",
"generated": "2024-07-04T05:32:15.995Z"
},
"dataset": [
{
"key": "__0__",
"name": "Major Genre",
"description": "Primary classification of the data, representing different genres or segments.",
"type": "text",
"kind": "column"
},
{
"key": "__1__",
"name": "US Gross",
"description": "Quantitative measurement",
"type": "numeric",
"kind": "measure"
},
{
"key": "__2__",
"name": "Worldwide Gross",
"description": "Quantitative measurement",
"type": "numeric",
"kind": "measure"
}
]
},
"config": {
"axisX": {
"title": "",
"labelAngle": -45,
"labelFontSize": 18,
"labelExpr": "[split(datum.value,' ')[0],split(datum.value,' ')[1]]",
"labelColor": "black"
},
"axisY": {
"labelAngle": 0,
"gridDash": [
4,
8
],
"gridColor": "black",
"gridOpacity": 0.4,
"gridWidth": 1.5,
"tickCount": 6,
"labelFontSize": 16,
"labelExpr": "pbiFormat(datum['value'], '$#,0,,,.# bn')"
},
"legend": {
"orient": "top",
"labelFontSize": 18
}
},
"description": "This Grouped Bar Chart (Multiple Measure with Repeat) visualizes the Worldwide and US Gross Earnings by Major Film Genre. Based on an official Vega-Lite example and adapted for use in Deneb within Power BI, it should be noted that cross-filtering interactivity is limited when using 'repeat'. Author: Cristobal Salcedo Beltran. Contact: contacto@csalcedodatabi.com.",
"data": {
"name": "dataset"
},
"title": {
"text": "Worldwide and US Gross Earnings by Major Film Genre (in billions USD)",
"fontSize": 25
},
"transform": [
{
"filter": "datum['__0__']!== null"
}
],
"repeat": {
"layer": [
"__2__",
"__1__"
]
},
"spec": {
"mark": {
"type": "bar"
},
"encoding": {
"x": {
"field": "__0__",
"type": "nominal"
},
"y": {
"aggregate": "sum",
"field": {
"repeat": "layer"
},
"type": "quantitative",
"title": ""
},
"color": {
"datum": {
"repeat": "layer"
},
"type": "nominal",
"scale": {
"range": [
{
"expr": "pbiColor(0)"
},
{
"expr": "pbiColor(1)"
}
]
}
},
"xOffset": {
"datum": {
"repeat": "layer"
}
}
}
}
}