How to pass a st.chart to other files for some add_rows function?

I am developing a website which can running a live chart, when the simpy environment running, some logs generated, I capture them and update to the chart. But I have no idea how to pass the chart to my handling py files. Are there any solutions?
In the reading function run with main function.

env.process(UIsupport.reading(env))

UIsupport.py

from LEAF import inf_chart

def reading(env):
    while 1:
        yield env.timeout(0.5)
        read_logs_update_chart()

start_point=0
def read_logs_update_chart():
    fo = open("logfile.log", "rb") # 'rb for bites'
    global start_point 
    fo.seek(start_point, 1)
    for line in fo.readlines():
        logs = str(line.decode())
        if logs[0].isdigit():
            temp_list = logs.split(":")
            pattern = re.compile(r'[0-9]*\.?[0-9]\w')
            power_sum = pattern.findall(temp_list[2])
            power = float(power_sum[0]) + float(power_sum[1])
            element = []
            element.append(power)
            columns = temp_list[1] #columns name
            i = temp_list[0] # 
            draw_infrastructure(element,i,columns)
        else:
            print('logs not found')
            continue
    start_point=fo.tell() # move pointer to last bite
    fo.close()

def draw_infrastructure(element,i,columns):
    df = pd.DataFrame(element,index=[i],columns=[columns])
    inf_chart.add_rows(df)

LEAF.py this part is for showing the website

infrastructure, application = st.columns(2)
infrastructure.empty()
application.empty()
empty_dataframe = pd.DataFrame([''],columns=[''])

inf_chart = infrastructure.line_chart(empty_dataframe,width=500)
app_chart = application.line_chart(empty_dataframe,width=500)

add_rows doesn’t work and also import LEAF brings some bugs.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.