Deneb - Is it possible to put a label inside every circle in a scatter plot?

Hi Community,

Is there a way to put a label inside circle of a bubble chart , I have this following chart. I need to put label inside this. I am uploading my script too , inside circle I want to show to value of “Label” inside circle. I am using following code `{
“$schema”: “https://vega.github.io/schema/vega-lite/v5.json”,
“data”: {
“values”: [
{
“A”: 16506,
“B”: “”,
“C”: “Estimate Line Type 1”,
“D”: 30347707.14,
“E”: null,
“Label”: “”,
“F”: null
}

]

},
“width”: 600,
“height”: 400,
“layer”: [
{
“transform”: [
{
“filter”: {
“field”: “C”,
“oneOf”: [“Amount (inflation adjusted NEW)”]
}
}
],
“mark”: {
“type”: “circle”,
“opacity”: 0.8,
“stroke”: “black”,
“strokeWidth”: 1
},
“encoding”: {
“x”: {
“field”: “A”,
“type”: “quantitative”,
“axis”: {“grid”: false}
},
“y”: {
“field”: “F”,
“type”: “quantitative”,
“axis”: {“title”: “F”}
},
“size”: {
“field”: “E”,
“type”: “quantitative”,
“title”: “E”,
“legend”: {“clipHeight”: 30},
“scale”: {“rangeMax”: 5000}
},
“color”: {“field”: “B”, “type”: “nominal”}
}
},
{
“transform”: [
{
“filter”: {
“field”: “C”,
“oneOf”: [“Estimate Line Type 1”, “Estimate Line Type 2”]
}
}
],
“mark”: {“type”: “line”},
“encoding”: {
“x”: {“field”: “A”, “type”: “quantitative”},
“y”: {“field”: “D”, “type”: “quantitative”},
“color”: {“field”: “C”, “type”: “nominal”}
}
}
],
“config”: {}
}`

Hi @manishchhipa98.

Sure, just put a layer block around the circle mark and add a second mark (text) and encode to the desired field.

(I was not able to decipher your Vega-Lite code; it wouldn’t work in a new PBIX file … in the future, please instead upload a PBIX file along with a marked-up screenshot of the Deneb visual in question showing exactly what you’re trying to do; if you’re including JSON code, please format it.)
_eDNA Forum - Format DAX or PQ

Greg

Hi @Greg I tried doing the one you suggested but it just prints one value in the center. Also there is some issue with my Power BI, so I am using Vega-Editor for all these examples. I am uploading the json itself here.
visualization.vl (3).json (46.6 KB)

(PS: Thank you for the feedback on post formatting will take care of it going forward.

Regrds,
Manish

Hi @manishchhipa98. If you want the text mark to be at the same location as each circle mark, then you need to use the same position encoding; moving the Y and Y encoding outside the layer block (i.e., into a “shared” encoding block) should give you something more of what you’re looking for.
Greg

1 Like

Hi @Greg Thank you for response I tried that now its stacked in same line rather than on circle, what I did is just pulled out the y encoding outside the layer block. Now it looks like this :

Hi @Greg Thank you for hint , I got the logic I pulled out both x and y now I am able to see text inside circle. Thank you so much .

Regards,
Manish