Public
Edited
May 1, 2023
Insert cell
Insert cell
<div>
<svg width="600" height="300">
<g id="layer1"></g>
</svg>
<div id="tooltip"></div>

<style>
#tooltip {position: absolute; z-index: 100; padding: 2px 8px; background-color: rgba(220,220,220,0.7); border: 1px solid #aaa; border-radius: 5px; font-family: Arial, sans-serif; font-size: 12px;}
#tooltip .TTtitle {font-size: 15px; font-weight: bold;}
#tooltip .TTsubtitle {font-weight: bold;}
</style>
</div>
Insert cell
Insert cell
Insert cell
data = [
{name: "one", value: 1},
{name: "two", value: 2},
{name: "three", value: 3},
{name: "four", value: 4},
{name: "five", value: 5}
]
Insert cell
circles = viz.select("#layer1").selectAll(".mycircle")
.data(data)
.join("circle")
.classed("mycircle", true)
.attr("cx",d => d.value * 100)
.attr("cy", 150)
.attr("r", d => d.value * 10)
.style("fill","steelblue")
.on("mousemove", (e,d) => tooltip.show(e,d,ttOptions))
.on("mouseout", () => tooltip.hide())
Insert cell
Insert cell
Insert cell
import {dvTooltip} from "@emfielduva/dvlib_ui"
Insert cell
tooltip = new dvTooltip(d3.select(container).select("#tooltip"))
Insert cell
// options to define and control the tooltip
ttOptions = ({
title: {dataName: "name"},
subtitle: {dataName: "name"},
fields: [
{displayName: "My Name", dataName: "name", prefix: "", suffix: ""},
{displayName: "My Value", dataName: "value", prefix: "", suffix: " some_units"}
]
})
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more