#!/usr/bin/env python3 """ Plotly Express Test Interface - Try Different Examples """ import gradio as gr def create_pyodide_interface(): """Simple interface to test different Express examples""" pyodide_html = '''
🔄 Loading Pyodide...
''' return pyodide_html # Example templates examples = { "Minimal Test": '''# Absolute minimal test import plotly.express as px print("Testing minimal Express...") fig = px.scatter(x=[1, 2], y=[1, 2], title="Minimal") fig.show() print("Minimal test complete!")''', "Direct Arrays": '''# Test without DataFrame import plotly.express as px print("Testing direct arrays...") fig = px.scatter(x=[1, 2, 3, 4], y=[1, 4, 9, 16], title="Direct Arrays") fig.show() print("Direct arrays test complete!")''', "Simple DataFrame": '''# Simple DataFrame test import plotly.express as px import pandas as pd print("Creating DataFrame...") df = pd.DataFrame({ 'x': [1, 2, 3, 4, 5], 'y': [2, 4, 6, 8, 10] }) print("DataFrame:") print(df) print("Creating plot...") fig = px.scatter(df, x='x', y='y', title='DataFrame Test') fig.show() print("DataFrame test complete!")''', "Line Chart": '''# Line chart test import plotly.express as px import pandas as pd df = pd.DataFrame({ 'x': [1, 2, 3, 4, 5], 'y': [1, 4, 2, 8, 5] }) fig = px.line(df, x='x', y='y', title='Line Chart') fig.show() print("Line chart complete!")''', "Bar Chart": '''# Bar chart test import plotly.express as px import pandas as pd df = pd.DataFrame({ 'category': ['A', 'B', 'C', 'D'], 'values': [20, 35, 30, 25] }) fig = px.bar(df, x='category', y='values', title='Bar Chart') fig.show() print("Bar chart complete!")''', "Data Types": '''# Test different data types import plotly.express as px import pandas as pd import numpy as np print("Creating mixed data types...") df = pd.DataFrame({ 'int_col': [1, 2, 3, 4], 'float_col': [1.1, 2.2, 3.3, 4.4], 'numpy_col': np.array([1, 2, 3, 4]) }) print("DataFrame info:") print(df.dtypes) fig = px.scatter(df, x='int_col', y='float_col', title='Data Types') fig.show() print("Data typ