mljar / mercury

Convert Jupyter Notebooks to Web Apps
https://RunMercury.com
GNU Affero General Public License v3.0
3.87k stars 243 forks source link

Table show incorrect #452

Open zenz opened 1 month ago

zenz commented 1 month ago

If drawing multiple tables in a for loop. the arrangement for first two tables will be conflict.

import mercury as mr  # for widgets
import pandas as pd

app = mr.App(title="Test", description="Table test")

category = ["model1", "model2", "model3", "model4"]

employee = ["employeeA", "employeeB", "employeeC"]
for emp in employee:
    temp_df = pd.DataFrame(
        columns=["类别", "对比年总销售额", "对比年同期销售额", "今年同期销售额", "同期增长额", "同期增长比例%"]
    )
    for x in category:
        temp_df.loc[len(temp_df)] = [
            x,
            1,
            1,
            1,
            1,
            1,
        ]
    mr.Table(data=temp_df, width="800px", text_align="center")

Please see pictures below

截屏2024-05-29 16 16 56