From b91b5bbeddd15317d42379f6296cd9b28eaeabc6 Mon Sep 17 00:00:00 2001 From: Anvesh Mora Date: Wed, 1 May 2024 12:47:19 +0530 Subject: [PATCH] Static charts using Flask Adding an example for rendering chart using Flask or FastAPI --- docs/source/examples/gui_examples.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/source/examples/gui_examples.md b/docs/source/examples/gui_examples.md index 06780680..d4003234 100644 --- a/docs/source/examples/gui_examples.md +++ b/docs/source/examples/gui_examples.md @@ -1,5 +1,18 @@ # Alternative GUI's +## Static Charts for Flask or FastAPI +```python +from lightweight_charts.widgets import StaticLWC +import jinja2 + +@app.route('/static-chart') +def static_chart(): + chart = StaticLWC() + df = pd.read_csv('ohlcv.csv') + chart.set(df) + chart.load() + return render_template(jinja2.Template(f'{chart._html}')) +``` ## PyQt5 / PySide6 @@ -95,4 +108,4 @@ df = pd.read_csv('ohlcv.csv') chart.set(df) chart.load() -``` \ No newline at end of file +```