-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd8d2ed
commit 260f139
Showing
11 changed files
with
965 additions
and
1,159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: Ruff | ||
on: [push, pull_request] | ||
jobs: | ||
ruff: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: astral-sh/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,40 @@ | ||
from fasthtml.common import fast_app, serve, Div, H1, P, Script | ||
from fasthtml.common import fast_app, serve, Div, H1, P | ||
import pandas as pd | ||
import numpy as np | ||
import plotly.express as px | ||
|
||
from fh_plotly import plotly2fasthtml, plotly_headers | ||
|
||
|
||
app, rt = fast_app(hdrs=plotly_headers) | ||
|
||
|
||
def generate_line_chart(): | ||
df = pd.DataFrame({'y': [1, 2, 3, 2], 'x': [3, 1, 2, 4]}) | ||
fig = px.line(df, x='x', y='y') | ||
df = pd.DataFrame({"y": [1, 2, 3, 2], "x": [3, 1, 2, 4]}) | ||
fig = px.line(df, x="x", y="y") | ||
return plotly2fasthtml(fig) | ||
|
||
|
||
def generate_bar_chart(): | ||
df = pd.DataFrame({'y': [1, 2, 3], 'x': ['A', 'B', 'C']}) | ||
fig = px.bar(df, x='x', y='y') | ||
df = pd.DataFrame({"y": [1, 2, 3], "x": ["A", "B", "C"]}) | ||
fig = px.bar(df, x="x", y="y") | ||
return plotly2fasthtml(fig) | ||
|
||
|
||
def generate_scatter_chart(): | ||
df = pd.DataFrame({'y': [1, 2, 3, 2], 'x': [3, 1, 2, 4], 'size': [10, 20, 30, 40]}) | ||
fig = px.scatter(df, x='x', y='y', size='size') | ||
df = pd.DataFrame({"y": [1, 2, 3, 2], "x": [3, 1, 2, 4], "size": [10, 20, 30, 40]}) | ||
fig = px.scatter(df, x="x", y="y", size="size") | ||
return plotly2fasthtml(fig) | ||
|
||
|
||
def generate_3d_scatter_chart(): | ||
df = pd.DataFrame({ | ||
'x': [1, 2, 3, 4], | ||
'y': [10, 11, 12, 13], | ||
'z': [100, 110, 120, 130] | ||
}) | ||
fig = px.scatter_3d(df, x='x', y='y', z='z') | ||
df = pd.DataFrame({"x": [1, 2, 3, 4], "y": [10, 11, 12, 13], "z": [100, 110, 120, 130]}) | ||
fig = px.scatter_3d(df, x="x", y="y", z="z") | ||
return plotly2fasthtml(fig) | ||
|
||
@app.get('/') | ||
|
||
@app.get("/") | ||
def home(): | ||
return Div( | ||
H1("Plotly Charts Demo with FastHTML"), | ||
P("Plot 1: Line Chart"), | ||
Div(generate_line_chart()), | ||
P("Plot 2: Bar Chart"), | ||
Div(generate_bar_chart()), | ||
P("Plot 3: Scatter Chart"), | ||
Div(generate_scatter_chart()), | ||
P("Plot 4: 3D Scatter Chart"), | ||
Div(generate_3d_scatter_chart()) | ||
) | ||
return Div(H1("Plotly Charts Demo with FastHTML"), P("Plot 1: Line Chart"), Div(generate_line_chart()), P("Plot 2: Bar Chart"), Div(generate_bar_chart()), P("Plot 3: Scatter Chart"), Div(generate_scatter_chart()), P("Plot 4: 3D Scatter Chart"), Div(generate_3d_scatter_chart())) | ||
|
||
|
||
serve() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
from fh_plotly.p2fh import plotly2fasthtml, plotly_headers | ||
|
Oops, something went wrong.