#!/usr/bin/env python3
"""
Minimal Working Plotly - Simple and Clean
"""
import gradio as gr
def create_interface():
html = '''
'''
return html
with gr.Blocks() as demo:
gr.Markdown("# 📊 Simple Plotly")
interface = gr.HTML(create_interface())
with gr.Row():
code = gr.Textbox(
value="""# Test 1: Graph Objects
import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(x=[1,2,3,4], y=[1,4,9,16], mode='markers+lines'))
fig.show()
# Test 2: Express
import plotly.express as px
import pandas as pd
df = pd.DataFrame({'x': [1,2,3,4], 'y': [1,4,9,16]})
fig = px.scatter(df, x='x', y='y')
fig.show()""",
lines=10,
label="Code"
)
result = gr.Textbox(label="Result", lines=2, interactive=False)
btn = gr.Button("▶️ Run")
btn.click(
fn=None,
inputs=[code],
outputs=[result],
js="(code) => window.run ? window.run(code) : 'Loading...'"
)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860)