Skip to main content
100%

Fork of STACKBAR Group Colours

✓ Published0🌍 Public
SsunilthkGmail
Last edited Jan 23, 2023
Created on Jan 23, 2023

This example presents a horizontal stacked bar chart where each bar represents an animal, and the bar segments correspond to values across four categories (A, B, C, D). The bars are colored by animal group, such as Domestic, Pest, or Marine, using a D3 scale that maps each group to a distinct set of fill colors per segment. Built with D3 v5, the visualization defines linear and band scales for the axes, stacks the data with `d3.stack()`, and renders SVG rectangles. Data loads from a CSV file using `d3.csv` and `d3.autoType`, with axes and a legend drawn via `d3.axisTop` and `d3.axisLeft`.

AI-generated description

Simplified Stack bar for colouring bars by different groups http://bl.ocks.org/JimMaltby/844ca313589e488b249b86ead0d621a9

MIT Licensed

Similar vizzes