andfanilo / streamlit-echarts

A Streamlit component to render ECharts.
https://share.streamlit.io/andfanilo/streamlit-echarts-demo/master/app.py
MIT License
548 stars 67 forks source link

echarts whit tabs #54

Open josepaulo1233 opened 1 year ago

josepaulo1233 commented 1 year ago

Hey,

I’m trying to make a line and bar chart using st_echarts and separating them with a st.tabs

However, when the second tab is selected, the chart is not displayed…

tabs_echarts_2

from streamlit_echarts import st_echarts
import streamlit as st

tab1, tab2 = st.tabs(['Line', 'Bar'])

with tab1:
    options = {
    "xAxis": {
        "type": "category",
        "data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    },
    "yAxis": {"type": "value"},
    "series": [
        {"data": [820, 932, 901, 934, 1290, 1330, 1320], "type": "line"}
    ],
    }
    st_echarts(options=options)

with tab2:
    options = {
        "xAxis": {
            "type": "category",
            "data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        "yAxis": {"type": "value"},
        "series": [
            {"data": [820, 932, 901, 934, 1290, 1330, 1320], "type": "bar"}
        ],
    }
    st_echarts(options=options)
doliveira-lts commented 1 year ago

Hi! Try adding this to your code:

st.write(
            '<style>iframe[title="streamlit_echarts.st_echarts"]{ height: 500px !important }</style>',
            unsafe_allow_html=True
 )
nicedouble commented 1 year ago

@doliveira-lts ,i has the same issue.But i use sac.tabs my custom component streamlit-antd-components instand of st.tabs.