Skip to content

Commit

Permalink
rename BCRouter to FigureRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverlambson committed Aug 25, 2024
1 parent 02155ad commit 45fcd64
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions bored-charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ from pathlib import Path

import plotly.express as px
import plotly.graph_objects as go
from boredcharts import BCRouter, boredcharts
from boredcharts import FigureRouter, boredcharts

figures = BCRouter()
figures = FigureRouter()


@figures.chart("population")
Expand Down
6 changes: 3 additions & 3 deletions bored-charts/boredcharts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
__version__ = "0.7.0"
__version__ = "0.8.0"

from boredcharts.router import BCRouter
from boredcharts.router import FigureRouter
from boredcharts.webapp import boredcharts

__all__ = [
"BCRouter",
"FigureRouter",
"boredcharts",
]
6 changes: 3 additions & 3 deletions bored-charts/boredcharts/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ def __get_pydantic_core_schema__(
)


class BCRouter(APIRouter):
class FigureRouter(APIRouter):
"""A FastAPI router that turns charts into endpoints.
Usage:
```py
from boredcharts import BCRouter
from boredcharts import FigureRouter
import plotly.graph_objects as go
router = BCRouter()
router = FigureRouter()
@router.chart("my_chart")
async def my_chart() -> go.Figure:
Expand Down
4 changes: 2 additions & 2 deletions bored-charts/boredcharts/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from plotly.offline import get_plotlyjs

from boredcharts.jinja import figure, md_to_html, row
from boredcharts.router import BCRouter
from boredcharts.router import FigureRouter

module_root = Path(__file__).parent.absolute()


def boredcharts(
pages: Path,
figures: BCRouter | list[BCRouter],
figures: FigureRouter | list[FigureRouter],
*,
name: str = "bored-charts",
) -> FastAPI:
Expand Down
4 changes: 2 additions & 2 deletions examples/full/analysis/elasticity.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import matplotlib.figure as mplfig
import matplotlib.pyplot as plt
import numpy as np
from boredcharts import BCRouter
from boredcharts import FigureRouter

figures = BCRouter()
figures = FigureRouter()


@figures.chart("elasticity_vs_profit")
Expand Down
4 changes: 2 additions & 2 deletions examples/full/analysis/medals.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import altair as alt
import plotly.express as px
from boredcharts import BCRouter
from boredcharts import FigureRouter

figures = BCRouter()
figures = FigureRouter()


@figures.chart("medals")
Expand Down
4 changes: 2 additions & 2 deletions examples/full/analysis/population.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import plotly.express as px
from boredcharts import BCRouter
from boredcharts import FigureRouter
from plotly.graph_objects import Figure

figures = BCRouter(prefix="/population")
figures = FigureRouter(prefix="/population")


@figures.chart("population")
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import plotly.express as px
import plotly.graph_objects as go
from boredcharts import BCRouter, boredcharts
from boredcharts import FigureRouter, boredcharts

figures = BCRouter()
figures = FigureRouter()


@figures.chart("population")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

from boredcharts.router import BCRouter
from boredcharts.router import FigureRouter
from boredcharts.webapp import boredcharts
from fastapi.testclient import TestClient

Expand All @@ -9,7 +9,7 @@ def test_healthz() -> None:
client = TestClient(
boredcharts(
pages=Path(__file__).parent / "pages",
figures=BCRouter(),
figures=FigureRouter(),
)
)
response = client.get("/healthz")
Expand Down

0 comments on commit 45fcd64

Please sign in to comment.