hptooltip = {
var width = 400,
height = 400;
var pokemon = d3.csvParse(`color,num,hex,highlighthex
gray,2473,#808080,#D3D3D3
cinnamon,392,#D2691E,#D2B48C
black,103,#000000,#2F4F4F
none,55,#00FF00,#00FF00`);
var xScale = d3.scaleBand()
.domain(d3.range(pokemon.length))
.rangeRound([0, width])
.padding(0.05);
var yScale = d3.scaleLinear()
.domain([0, d3.max((pokemon.map(d => d.num)).map(function(d) { return +d; }))])
.range([0, height]);
const svg = d3.select(DOM.svg(width, height));
svg.selectAll("rect")
.data(pokemon)
.enter().append("rect")
.attr("x", (d, i) => xScale(i))
.attr("y", d => height - yScale(d.num))
.attr("width", xScale.bandwidth())
.attr("height", d => yScale(d.num))
.attr("fill", d => d.hex)
.on("mouseover", function(d) {
var xpos = parseFloat(d3.select(this).attr("x")) + xScale.bandwidth() / 2;
var ypos = parseFloat(d3.select(this).attr("y"));
var tgrp = svg.append("g")
.attr("id", "tooltip")
.attr("transform", (d, i) => `translate(${xpos},${ypos})`);
tgrp.append("rect")
.attr("width", "140px")
.attr("height", "22px")
.attr("fill", "burlywood")
tgrp.append("text")
.attr("x", 5)
.attr("y", 14)
.attr("text-anchor", "left")
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("font-weight", "bold")
.attr("fill", "black")
.text('${d.num}');
d3.select(this)
.attr("fill", d => d.highlighthex);
})
.on("mouseout", function(d) {
d3.select("#tooltip").remove();
d3.select(this)
.transition().duration(250)
.attr("fill", d => d.hex);
});
return svg.node();
}