Fork of Fork of Stacked bar chart of Yelp data: top cities
✓ Published0🌍 Public
Yyuting89830@gmail.com
Last edited Oct 23, 2023
Created on Oct 22, 2023
This stacked bar chart visualizes the distribution of ten food types (e.g., American, Italian, Mexican) across ten cities, excluding Boston, using Yelp data from a CSV file. Each horizontal bar is segmented by food category, with segment lengths proportional to the count of restaurants per cuisine, enabling quick comparison of culinary profiles between cities. The chart is built with D3.js, using `d3.scaleBand` for the city axis, `d3.scaleLinear` for the count axis, and `d3.scaleOrdinal` with a custom color palette for food types. The `d3.stack()` function transforms the data into stacked segments, and interactive tooltips display exact counts on mouseover via `d3.select` and a `toolTip` div. A legend and title annotate the visualization.
AI-generated descriptionMIT Licensed