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.
The prompt
Act as a senior data-visualization developer who builds polished, accessible infographics in plain HTML, CSS and JavaScript.
Build "Marlow Library Loans Race", a ranked top-10 bar chart race. It shows physical loans, in thousands, at 14 branches of a fictional city library from 2015 to 2024. Hardcode realistic sample data with clear plot twists:
- The central branch starts first and fades.
- A new branch climbs from last to fourth.
- A 2021 closure dips nearly every total.
Add a one-line annotation for each year.
Rules:
- Interpolate values between years and slide bars smoothly to their new rank every frame.
- Bars that fall out of the top 10 fade out below the chart.
- Scale bars to the current leader and show a large faded year watermark.
- Controls: a Play/Pause/Replay button and a year scrubber range input that pauses playback. Space toggles play, the left and right arrows step one year, and Home and End jump to the ends.
- Add a Race / Final ranking toggle. The final view lists the 2024 top 10 with each value and the places gained or lost since 2015.
- With prefers-reduced-motion, open on the final ranking. In Race view, advance one year at a time with no sliding.
- Color bars by four districts and include a legend. Use a warm off-white background, dark ink text and 44px touch targets. The layout must work from 360 to 1280px wide.
- Use no external libraries, fonts or storage. Add a polite live region that announces the top three when paused.
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
- Interpolating values and easing each bar toward its rank target every frame gives smooth reorders without any chart library.
- Hardcoded data with named plot twists and yearly notes makes the race tell a story instead of shuffling random bars.
- A separate static final-ranking view plus stepped playback means reduced-motion users get the full story with no sliding.
Paste the prompt into ChatGPT, Claude or Gemini. Save the returned code as an .html file and open it in any browser, or view it in the chat's preview or canvas panel.
Common edits
- Swap the dataset for your own top-10 topic, such as city populations or product sales, and adjust the year range and notes.
- Change SPEED to make the race faster or slower, or recolor the four district swatches to match your brand.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
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 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.
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 12-Week Fitness Progress Tracker Infographic in a Single HTML File
Generates a one-page fitness report with bodyweight and lift line charts, personal-record badges, a streak calendar and an instant kg/lb toggle, all from built-in sample data.
Build a Before-and-After Statistics Infographic With Color-Coded Change Arrows
A single HTML infographic comparing two years across nine metrics, showing old and new values, absolute and percent change, and arrows colored by whether up is good.
Build a Budget Allocation Treemap Infographic in a Single HTML File
You get one HTML file that draws a squarified treemap of a city budget, hides labels on small blocks, and shows a details panel when you tap or click any block.