AI LLM Data Visualizer
An interactive AI-powered data visualization app built with Next.js 14, TypeScript, Tailwind CSS, D3.js, and the OpenAI API (gpt-4o
). The app allows users to input raw text or prompts, transforms them into structured JSON using GPT, and visualizes the output in real time as bar, line, or pie charts.
✨ Features
- 📊 Dynamic D3.js visualizations (Bar, Line, Pie)
- 🤖 LLM-powered JSON generation using
gpt-4o-2024-05-13
- 🌓 Theme toggle via
next-themes
- 🌐
/embed
route for iframe integration and live chart sharing
- 🧠 Prompt-to-chart experience powered by AI
- 💾 Export structured JSON to
.json
file
- 🚫 Robust error handling for bad input or failed requests
- 🔄 Zustand state management for chat-related features (if needed later)
🛠️ Tech Stack
- Next.js 14 — App Router, API Routes
- TypeScript 5.3+
- Tailwind CSS 3.4+
- D3.js 7.8+ — For all chart rendering
- OpenAI SDK — GPT-4o JSON generation
- Zustand — Lightweight state store
- shadcn/ui — For styled components (
button
, input
, textarea
)
- clsx + tailwind-merge — For clean utility class merging
🚀 Getting Started
1. Clone the repository
git clone https://github.com/your-username/llm-data-visualizer.git
cd llm-data-visualizer
2. Install dependencies
yarn install
3. Set up environment variables
Create a .env.local
file in the root:
OPENAI_API_KEY=your-openai-api-key-here
4. Run the development server
yarn dev
Open http://localhost:3000 in your browser.
📦 Embed Support
Use the /embed
route with a URL like:
<iframe
src="https://yourdomain.com/embed?prompt=Show sales for A, B, C&type=bar"
width="600"
height="350"
frameborder="0"
></iframe>
🧪 Example Prompts
Here are 20 prompts you can use with the LLM Data Visualizer:
- Visualize sales numbers for Product A, B, C, and D.
- Show time spent on work, exercise, sleep, and entertainment per day.
- Breakdown website traffic sources: direct, referral, search, and social.
- Compare monthly revenue from January to June.
- Show popularity of programming languages in 2024.
- Compare coffee vs tea consumption by day of the week.
- Visualize a weekly breakdown of fitness activities: running, lifting, yoga, and rest.
- Show user engagement by platform: mobile, desktop, tablet.
- Breakdown daily calorie intake: carbs, protein, fat.
- Show distribution of time across meetings, emails, and deep work.
- Compare average temperatures for spring, summer, fall, and winter.
- Visualize time spent per task in a morning routine.
- Show customer satisfaction ratings from five departments.
- Compare income streams: salary, freelance, dividends, and rental income.
- Visualize how students rate math, science, English, and art.
- Show device usage: iOS, Android, Windows, macOS, and Linux.
- Visualize time spent learning different subjects each week.
- Compare sales performance of four team members.
- Breakdown vacation days taken across each quarter.
- Compare hours spent on personal, family, and professional development.
✅ Todo
📝 License
MIT — free to use, adapt, and deploy.