Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Mostrar gráficos de dos líneas con Deneb Visual Vega Lite

Quería probar el bi visual de Deneb Power, quiero mostrar dos medidas "Recuento de hojas tomadas en 2022" y "Recuento de hojas tomadas en 2023" usando Vega Lite. El problema es que no sabía cómo mostrar dos gráficos de líneas en mi eje Y.

Así es como se ve actualmente (solo intenté mostrar 1 medida a la vez)

userpowerbiii12_0-1687003922778.png

Seguí este tutorial de Youtube

¿Hay alguna manera de mostrar ambos gráficos al mismo tiempo?

Este es mi código:

{

"data": {"name": "dataset"}, "layer": [
{
"marca": {
"tipo": "área",
"line": {"color": "#7b516f"},
"color": {
"x1": 1,
"y1": 1,
"degradado": "lineal",
"paradas": [
{
"offset": 0,
"color": "blanco"
},
{
"compensación": 0,8,
"color": "#7b516f"
}
]
}
}
},
{
"marca": {
"tipo": "bar",
"ancho": 2,
"clip": verdadero,
"color": {
"x1": 1,
"y1": 1,
"degradado": "lineal",
"paradas": [
{
"offset": 0,
"color": "blanco"
},
{
"compensación": 0,8,
"color": "#7b516f"
}
]
}
},
"codificación": {
"opacidad": {
"condición": {
"prueba": {
"campo": "__selected__",
"igual": "desactivado"
},
"valor": 0.1
},
"valor": 1
},
"y": {
"campo": "__1____highlight",
"tipo": "cuantitativo",
"eje": nulo
}
}
},
{
"marca": {
"tipo": "texto",
"yOffset": -10,
"tamaño": 10,
"Opacidad": 0.2
},
"codificación": {
"text": {"field": "__1__"}
}
},
{
"marca": {
"tipo": "texto",
"yOffset": -10,
"tamaño": 10
},
"codificación": {
"text": {"field": "__1__"},
"opacidad": {
"condición": {
"prueba": {
"campo": "__selected__",
"igual": "desactivado"
},
"valor": 0.1
},
"valor": 1
},
"y": {
"campo": "__1____highlight",
"tipo": "cuantitativo",
"eje": nulo
}
}
} ], "codificación": {
"x": {
"field": "MES",
"tipo": "ordinal",
"axis": {"labelPadding": 0},
"title": null
},
"y": {
"field": "Cuenta de hojas 2023",
"tipo": "cuantitativo",
"eje": nulo
} } }

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Funciona bien, pero las barras en el video no se me muestran

Syndicate_Admin
Administrator
Administrator

@userpowerbiii12 ,

Pruebe el código siguiente:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"name": "dataset"},
  "layer": [
    {
      "mark": {
        "type": "area",
        "line": {"color": "#7b516f"},
        "color": {
          "x1": 1,
          "y1": 1,
          "gradient": "linear",
          "stops": [
            {"offset": 0, "color": "white"},
            {"offset": 0.8, "color": "#7b516f"}
          ]
        }
      }
    },
    {
      "mark": {
        "type": "bar",
        "width": 2,
        "clip": true,
        "color": {
          "x1": 1,
          "y1": 1,
          "gradient": "linear",
          "stops": [
            {"offset": 0, "color": "white"},
            {"offset": 0.8, "color": "#7b516f"}
          ]
        }
      },
      "encoding": {
        "opacity": {
          "condition": {"test": {"field": "__selected__", "equal": "off"}, "value": 0.1},
          "value": 1
        },
        "y": {"field": "__1____highlight", "type": "quantitative", "axis": null}
      }
    },
    {
      "mark": {"type": "text", "yOffset": -10, "size": 10, "opacity": 0.2},
      "encoding": {"text": {"field": "__1__"}}
    },
    {
      "mark": {"type": "text", "yOffset": -10, "size": 10},
      "encoding": {
        "text": {"field": "__1__"},
        "opacity": {
          "condition": {"test": {"field": "__selected__", "equal": "off"}, "value": 0.1},
          "value": 1
        },
        "y": {"field": "__1____highlight", "type": "quantitative", "axis": null}
      }
    },
    {
      "mark": {"type": "area", "color": "blue", "opacity": 0.05},
      "encoding": {
        "x": {"field": "MONTH", "type": "ordinal", "axis": {"labelPadding": 0}, "title": null},
        "y": {"field": "Leaves Count 2022", "type": "quantitative", "axis": null}
      }
    }
  ],
  "encoding": {
    "x": {"field": "MONTH", "type": "ordinal", "axis": {"labelPadding": 0}, "title": null},
    "y": {"field": "Leaves Count 2023", "type": "quantitative", "axis": null}
  }
}

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.