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

Deneb Vega-lite: Agregar etiqueta a la línea de referencia para la fecha de hoy

Tengo un gráfico de burbujas de la línea de tiempo (que se muestra con datos ficticios) con una línea de referencia para la fecha actual.
asodie_3-1692211533616.png

Quiero agregar una etiqueta para la línea de referencia que solo dice "fecha de hoy". Cuando intento agregar uno, agrega una etiqueta con la fecha de hoy a cada burbuja. Me gustaría una etiqueta para la línea de referencia en la parte superior donde sería legible.

Aquí está mi código:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"name": "dataset"},
  "width": 950,
  "height": 400,
  "transform": [
    {
      "calculate": "now()",
      "as": "today"
    }
  ],
  "encoding": {
    "x": {
      "field": "Date",
      "type": "temporal",
      "axis": {
        "grid": false,
        "format": "Q%q %Y"
      }
    },
    "y": {
      "field": "Prob",
      "type": "quantitative"
    }
  },
  "layer": [
    {
      "mark": {
        "type": "circle",
        "opacity": 0.8,
        "stroke": "black",
        "strokeWidth": 1
      },
      "encoding": {
        "size": {
          "field": "Amount",
          "type": "quantitative"
        },
        "color": {
          "field": "Group",
          "type": "nominal"
        }
      }
    },
    {
      "mark": {
        "type": "circle",
        "opacity": 0.8,
        "stroke": "black",
        "strokeWidth": 1
      },
      "encoding": {
        "size": {
          "field": "Amount",
          "type": "quantitative",
          "scale": {"rangeMax": 1000}
        },
        "color": {
          "field": "Group",
          "type": "nominal"
        }
      }
    },
    {
      "mark": {
        "type": "rule",
        "opacity": 0.6
      },
      "encoding": {
        "x": {
          "field": "today",
          "type": "temporal"
        },
        "size": {"value": 1},
        "color": {"value": "grey"}
      }
    }
  ]
}

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

Respondiendo a mi propia pregunta:

Creé otra capa dentro de las capas originales que contenía solo la línea de referencia y la marca de texto para la fecha de hoy. Este es mi código para la marca de texto:

{
          "mark": {
            "type": "text",
            "align": "left",
            "baseline": "bottom",
            "dx":-15
          },
          "encoding": {
            "text": {"value": "Today"},
            "x": {
              "field": "today",
              "type": "temporal"
            },
            "y": {"value": 0}
          }
        }

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.