Massachussetts Top 10 Crime City filter works
This example displays the top 10 Massachusetts cities by crime rate, presented as a bar chart with a dropdown menu to filter by community type (all, city, rural, or suburb). The visualization uses React for state management and D3 v5’s `scaleBand` and `scaleLinear` for axes, with data from a 2016 crime dataset loaded via `d3.csv`. The dropdown is implemented with `react-dropdown`, and selecting an option updates the chart, though the filtering logic is incomplete. SVG rendering with tick marks and formatting via `d3.format` displays percentages on the y-axis.
AI-generated descriptionA program that shows the top 10 most crime city in massachusetts
I am able to add menu to exist column chart, also use react dropdown to optimize appearance. When select menu, the value can show correct. The only issue which has not been resolved is to pass the value of menu selection to filter the dataset, so the bar chart changed per user's selection
I have tried my best to adjust the chart. there are a few things I cannot figure out still.
- adjst the Y axis, so that 0.0% line line with bottom of column. column value appear correct though. wrap my head, not sure why
- tilt the text label so they don't overlap
- I was able to refactor useData.js, but not other module. There is a tick() is not a function error I don't have solution.