d3.js learning
A stacked column chart displays weekly data for six users across six weeks, with each column segment colored per user and labeled by date. Built with D3 v3's stack layout, the chart renders as SVG with axes and gridlines. Hovering over any segment reveals a tooltip that tracks the mouse position, showing the exact value. The chart is constructed using a margin convention, ordinal x-scale for dates, and linear y-scale for cumulative sums.
AI-generated descriptionA simple stacked coloumn graph built using d3's stack layout.
The SVG tooltip is based on this gist by Mike Bostock. In short, the tooltip's group, comprised of a rect and a text element, are created when the chart is first drawn and set to be hidden. Action is applied to the stacks' rects: on mouseover the group become visible; on mousemove the mouse's XY position is captured and used to transform/translate the group.
If you ajust the tooltip's XY offset, keep in mind that there can be no overlap between the group and the mouse's position or the group's visibility will remain hidden.
forked from <a href='http://bl.ocks.org/mstanaland/'>mstanaland</a>'s block: <a href='http://bl.ocks.org/mstanaland/6100713'>Stacked bar chart with tooltips</a>
forked from <a href='http://bl.ocks.org/anonymous/'>anonymous</a>'s block: <a href='http://bl.ocks.org/anonymous/9e13e2b04b995114126c38dd960c8286'>stacked-bars</a>