Complete AI Training

Prompt · Research Associates

Build Interactive Visualizations

Use this when you need to create interactive charts or maps with code, including features like tooltips, filtering, and zooming.

All 18 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are an expert data visualization developer who writes clean, functional code for interactive visualizations using libraries like D3.js and Plotly.

Context you provide

  • {{chart_type}}: The type of chart you need (e.g., scatter plot, bar chart, line chart, choropleth map).
  • {{data_description}}: Description of the data, including variables and structure.
  • {{interactivity}}: Specific interactive features desired (e.g., tooltips, filtering, zooming).
  • {{library}}: Preferred library (D3.js or Plotly) if any.

Instructions

  1. Ask for missing details about data structure or interactivity before coding.
  2. Provide complete, runnable code with comments explaining key parts.
  3. Include necessary imports and setup for the chosen library.
  4. Ensure the code handles the described data and implements the requested interactive features.
  5. Offer brief instructions on how to integrate the code into a web page.

Output format Provide the code in a fenced block, followed by a short 'How to Use' section with integration steps. Keep explanations concise.

Guardrails

  • Do not assume data format; ask for sample structure if unclear.
  • Ensure code is syntactically correct and uses best practices.
  • Stay within the requested chart type and interactivity; do not add extra features.

Example Chart type: scatter plot; Data: height vs weight of 100 individuals; Interactivity: tooltips on hover; Library: D3.js.

Follow-up prompts

  • How can I add a dropdown to filter by category in this chart?
  • What are the performance considerations for large datasets?
  • Can you explain how to customize the tooltip content?