All Toolsโ€บInteractive Chart Injector
๐Ÿ”ง Interactive AI Data VisualizationMarch 13, 2026โœ… Tests passing

Interactive Chart Injector

This Python library allows AI developers to integrate dynamically generated interactive charts from AI tools like Claude into Jupyter notebooks. It parses AI-generated chart data and converts it into interactive visualizations using Plotly, making it easy to debug, share, and explore AI-driven insights.

What It Does

  • Seamless Integration: Easily integrate AI-generated chart data into Jupyter notebooks.
  • Interactive Visualizations: Supports interactive Plotly charts for deeper exploration.
  • Simple API: Parse and render AI chart data with a single function call.

Installation

pip install plotly==5.15.0 pandas==2.1.1 ipython==8.16.1

Usage

Example

import interactive_chart_injector

# Example chart data
data = {
    "type": "scatter",
    "data": [
        {"x": [1, 2, 3], "y": [4, 5, 6], "mode": "lines", "name": "Test Line"}
    ],
    "layout": {"title": "Test Scatter Chart"}
}

interactive_chart_injector.render_chart(data)

CLI Usage

You can also use this tool from the command line:

python interactive_chart_injector.py path_to_chart_data.json

Source Code

import json
import plotly.graph_objects as go
import pandas as pd
from IPython.display import display

def render_chart(chart_data):
    """
    Render an interactive chart in a Jupyter notebook based on AI-generated chart data.

    Args:
        chart_data (dict or str): A dictionary or JSON string containing chart data.

    Raises:
        ValueError: If the input data is invalid or cannot be parsed.
    """
    if isinstance(chart_data, str):
        try:
            chart_data = json.loads(chart_data)
        except json.JSONDecodeError as e:
            raise ValueError("Invalid JSON string provided.") from e

    if not isinstance(chart_data, dict):
        raise ValueError("Input data must be a dictionary or a valid JSON string.")

    # Validate required keys
    required_keys = {"type", "data", "layout"}
    if not required_keys.issubset(chart_data.keys()):
        raise ValueError(f"Input data must contain the keys: {required_keys}")

    # Extract chart type, data, and layout
    chart_type = chart_data["type"].lower()
    data = chart_data["data"]
    layout = chart_data.get("layout", {})

    if not isinstance(data, list) or not all(isinstance(trace, dict) for trace in data):
        raise ValueError("'data' must be a list of dictionaries.")

    if chart_type == "scatter":
        fig = go.Figure()
        for trace in data:
            fig.add_trace(go.Scatter(**trace))
    elif chart_type == "bar":
        fig = go.Figure()
        for trace in data:
            fig.add_trace(go.Bar(**trace))
    else:
        raise ValueError(f"Unsupported chart type: {chart_type}")

    fig.update_layout(**layout)
    display(fig)

if __name__ == "__main__":
    import argparse

    parser = argparse.ArgumentParser(description="Interactive Chart Injector")
    parser.add_argument("chart_data", type=str, help="Path to a JSON file containing chart data.")

    args = parser.parse_args()

    try:
        with open(args.chart_data, "r") as f:
            chart_data = json.load(f)
        render_chart(chart_data)
    except Exception as e:
        print(f"Error: {e}")

Community

Downloads

ยทยทยท

Rate this tool

No ratings yet โ€” be the first!

Details

Tool Name
interactive_chart_injector
Category
Interactive AI Data Visualization
Generated
March 13, 2026
Tests
Passing โœ…

Quick Install

Clone just this tool:

git clone --depth 1 --filter=blob:none --sparse \
  https://github.com/ptulin/autoaiforge.git
cd autoaiforge
git sparse-checkout set generated_tools/2026-03-13/interactive_chart_injector
cd generated_tools/2026-03-13/interactive_chart_injector
pip install -r requirements.txt 2>/dev/null || true
python interactive_chart_injector.py
Interactive Chart Injector โ€” AI Tools by AutoAIForge