Skip to content
Discussion options

You must be logged in to vote

This example uses HTML data attributes to pass the labels and values to the chart with the htmx:afterSwap event. The hx-preserve attribute keeps the canvas from being replaced by the HTML response.

app.py

Here is the Python code that returns the results template along with data values that are eventually used by the chart.

from quart import Quart, render_template, request

app = Quart(__name__)

@app.get("/")
async def root():
    return await render_template("index.html")

@app.post("/results")
async def results():
    form = await request.form
    nums = form["numbers"]

    y = [float(n) for n in nums.split(",")]
    x = list(range(1, len(y) + 1))
    data = {"x": x, "y": y}

    return 

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
5 replies
@wigging
Comment options

@yawaramin
Comment options

@wigging
Comment options

@wigging
Comment options

@yawaramin
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@wigging
Comment options

@yawaramin
Comment options

Answer selected by wigging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants