Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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"}
}
}
]
}
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}
}
}