Skip to content

[Question]Applying Flet PlotlyChart and ElevatedButton onclickEvent #1531

Answered by heximing
minseob2996 asked this question in Q&A
Discussion options

You must be logged in to vote

The below code is just to show an idea. I could not make Plotly work on my machine, so I cannot confirm. But I replaced Plotly with matplotlib, and the code works, so the idea should work.

The idea is to put the chart in a Container. When buttons are clicked, create/modify the chart in the Container, and call update().

import flet as ft
import plotly.graph_objects as go
from flet.plotly_chart import PlotlyChart


def main(page: ft.Page):
    page.title = "Elevated button with 'click' event"

    def DrawPieGraph(e):
        print("Pie Chart button clicked")

        labels = ["Oxygen", "Hydrogen", "Carbon_Dioxide", "Nitrogen"]
        values = [4500, 2500, 1053, 500]

        fig = go.Figure

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by minseob2996
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
2 participants