forked from vega/vega-lite
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add example of rendering images in tooltips (vega#8048)
* docs: add example of rendering images in tooltips * docs: add link to vega-tooltip plugin in the image tooltip section * chore: update TOC [CI] * chore: update examples [CI] * style: auto-formatting [CI] * Improve wording Co-authored-by: Dominik Moritz <domoritz@gmail.com> * Remove stroke outline * chore: update examples [CI] Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com> Co-authored-by: Dominik Moritz <domoritz@gmail.com>
- Loading branch information
Showing
6 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega/v5.json", | ||
"description": "A simple chart with an image tooltip.", | ||
"background": "white", | ||
"padding": 5, | ||
"width": 20, | ||
"style": "cell", | ||
"encode": {"update": {"stroke": {"value": null}}}, | ||
"data": [ | ||
{ | ||
"name": "source_0", | ||
"values": [ | ||
{"image": "data/ffox.png"}, | ||
{"image": "data/gimp.png"}, | ||
{"image": "data/7zip.png"} | ||
] | ||
} | ||
], | ||
"signals": [ | ||
{"name": "y_step", "value": 20}, | ||
{ | ||
"name": "height", | ||
"update": "bandspace(domain('y').length, 1, 0.5) * y_step" | ||
} | ||
], | ||
"marks": [ | ||
{ | ||
"name": "marks", | ||
"type": "text", | ||
"style": ["text"], | ||
"from": {"data": "source_0"}, | ||
"encode": { | ||
"update": { | ||
"fill": {"value": "black"}, | ||
"tooltip": { | ||
"signal": "{\"image\": isValid(datum[\"image\"]) ? datum[\"image\"] : \"\"+datum[\"image\"]}" | ||
}, | ||
"description": { | ||
"signal": "\"image: \" + (isValid(datum[\"image\"]) ? datum[\"image\"] : \"\"+datum[\"image\"])" | ||
}, | ||
"x": {"signal": "width", "mult": 0.5}, | ||
"y": {"scale": "y", "field": "image"}, | ||
"text": { | ||
"signal": "isValid(datum[\"image\"]) ? datum[\"image\"] : \"\"+datum[\"image\"]" | ||
}, | ||
"align": {"value": "center"}, | ||
"baseline": {"value": "middle"} | ||
} | ||
} | ||
} | ||
], | ||
"scales": [ | ||
{ | ||
"name": "y", | ||
"type": "point", | ||
"domain": {"data": "source_0", "field": "image", "sort": true}, | ||
"range": {"step": {"signal": "y_step"}}, | ||
"padding": 0.5 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json", | ||
"view": {"stroke": null}, | ||
"description": "A simple chart with an image tooltip.", | ||
"data": { | ||
"values": [ | ||
{"image": "data/ffox.png"}, | ||
{"image": "data/gimp.png"}, | ||
{"image": "data/7zip.png"} | ||
] | ||
}, | ||
"mark": "text", | ||
"encoding": { | ||
"text": {"field": "image"}, | ||
"y": {"field": "image", "axis": null}, | ||
"tooltip": [{"field": "image"}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters