Build an Accessible Market Share Donut Chart Infographic With Legend in HTML
A prompt that builds a single-file SVG donut chart of competitor market share, with a ranked legend, keyboard navigation, tap focus and an automatic Other bucket.
You getone complete HTML file in a single code block, then 3 short ideas to extend it.
The prompt
Act as a senior data-visualization developer who builds accessible, framework-free charts. Build 'Who Grinds the Beans?', a market share donut chart infographic for a fictional 2024 North American home coffee grinder market of 4.2 million units, with 11 invented brands such as Grindwell, Burrline, Northbean, Kettle & Mill and Alder Works. Draw the donut as inline SVG paths computed in JavaScript from a data array. Place a ranked legend beside it that shows a swatch, brand name, share bar and percentage for each brand.
Rules:
1. Automatically group every brand below a share threshold into one grey 'Other' slice placed last. Add a 2% / 4% / 6% segmented toggle that regroups and redraws the chart instantly.
2. Hovering, tapping, Tab focus or a legend click selects a slice. The selected slice pops outward, the others dim, and the donut center shows its share, name and estimated units.
3. Keyboard: use a roving tabindex on the slices. Arrow keys move between slices and Home or End jump to the first or last. Show visible focus rings and give each slice a descriptive aria-label. A polite live region states an insight: rank, points ahead or behind the neighbor, or the brands inside Other.
4. Layout: one card with the chart and legend side by side, stacking below 760px, and fitting widths from 360 to 1280px.
5. Palette: navy ink, white card, soft grey page, distinct slice colors plus neutral grey for Other, system fonts.
6. Turn off slice motion under prefers-reduced-motion. Use no external resources or storage.
Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.Example output
Tips and common edits
Why this works
- Computing SVG arc paths from one data array keeps slices, legend and labels in sync after every regroup.
- A roving tabindex with arrow keys gives screen reader and keyboard users the same focus model as mouse hover.
- The threshold toggle demonstrates the Other grouping live, so small shares never become unreadable slivers.
Paste into ChatGPT, Claude or Gemini. Save the returned code as market-share.html and open it in any browser, or view it in the chat's preview or canvas. To chart your own market, replace the brand names and shares in the data array.
Common edits
- Swap the data array for your own competitors and update the total units and the headline.
- Change the default threshold or the palette to match your brand colors, keeping grey for Other.
Prompt details
- By
- Prompts-GPT editors
- Published
Keep exploring
More like this
Build a 100-Person Icon Array Demographic Infographic in One HTML File
You get a single HTML file that shows a fictional town as 100 SVG person icons, with tabs for commute, age and housing and an interactive legend that highlights each group.
Build a Classroom Grade Distribution Infographic with Histogram and Quartiles
A single HTML file that turns an inline array of class scores into a histogram with mean and median markers, a box plot, stat cards and a plain-language summary.
Build a Gantt-Style Project Timeline Infographic with Milestones in Pure SVG
A single HTML file that draws a project Gantt chart in pure SVG, with progress bars, dependency arrows, milestone diamonds, a Today marker and hover tooltips.
Build a Product Feature Comparison Matrix with Checkmarks in One HTML File
A prompt that produces an accessible, filterable feature comparison table for four competing products, with sticky headers, symbol-plus-text cells and a show-only-differences toggle.
Build a Year-over-Year Growth Infographic with Animated Counters and Sparklines
A single HTML file KPI infographic where year-over-year numbers count up once on view, each metric carries an inline SVG sparkline, and reduced-motion users see static final values.
Build an Animated Top-10 Bar Chart Race Infographic in One HTML File
You get a single HTML file with an animated top-10 bar chart race. It has play, pause and a year scrubber, smooth rank swaps, and a static final-ranking view for users who prefer reduced motion.