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

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

One HTML file. Save it and open it in any browser.Open full screen

Example: Who Grinds the Beans?, a market share donut for a fictional coffee grinder market.

Hover or tap any slice, or Tab into the chart. The slice pops out and the center shows its share and estimated units. Use the arrow keys to step through brands and Home or End to jump. Click legend rows to select brands. Switch the 2% / 4% / 6% toggle and watch small brands fold into or out of the grey Other slice. Selecting Other lists the brands grouped inside it.

Written by AI from this prompt. Your results will vary.

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

Did this prompt work?

Keep exploring

More in Infographics