散景中列表项的复选框组更新问题

为有一个很长的帖子道歉。我正在开发一个可视化效果,表示不同位置的每周库存值。我能够通过单击图例从图形中隐藏某些位置,但y轴不会自行更新。这就是为什么我试图实现复选框组来过滤图形的项目。但是,我可以绘制图形,但是每当我在 CheckBox 组中取消选择某些项目时,图形都不会自行更新。您可以在下面找到输出的图像。任何帮助都将是有用的。

P.S:为了重现输出处理,必须首先运行数据代码,然后运行图形代码。

谢谢, E

输出:代码的输出

数据 : 链接

处理数据:

import pandas as pd

import numpy as np


dataset_inventory = pd.read_excel('weekly_inventory_data.xls')

df = dataset_inventory.copy()

df = df.fillna(0)

df = df.replace('-',0)


resource = "çÇğĞıİöÖşŞüÜ"

target = "cCgGiIoOsSuU"

translate = str.maketrans(resource,target)

df['Location']= df['Location'].str.translate(translate)

df.columns = [x.lower() if type(x)==str else x for x in df.columns]

df['location'] = [x.lower() for x in df['location']]


df1 = df.copy()

df2 =df.copy()

for column in df2:

    if type(column) == int: 

        df2[column] = [1 if x>0 else 0 for x in df2[column]]

    else:

        pass  


def table(df,info):

    pivot = df.groupby('location').sum().T

    pivot.columns.names = ['']

    pivot['total'] = pivot.sum(axis=1)

    pivot.reset_index(level=0, inplace=True)

    pivot.insert(loc=0, column='year', value=np.where(pivot['index'].apply(lambda x: x > 16), 2015, 2016))

    pivot.insert(loc=2, column='year_week', value=pivot['year'].astype(str) +'_'+ pivot['index'].astype(str))

    pivot.reset_index(inplace=True)

    pivot.rename(columns={'level_0' :'observation','index':'week'}, inplace=True)

    pivot['year_week'] = pd.Categorical(pivot.year_week, ordered=True)

    pivot['observation'] = [x+1 for x in pivot['observation']]

    pivot.rename(columns={'cayirova' :'cayirova_'+info, 'orhanli' :'orhanli_'+info,

                          'fason' :'fason_'+info, 'samandira' :'samandira_'+info,

                          'gebze' :'gebze_'+info, 'sultanbeyli' :'sultanbeyli_'+info,

                          'yenidogan' :'yenidogan_'+info, 'total' :'total_'+info

                         }, inplace=True)

    return pivot


input1='qty'

input2='wh'

df1 = table(df1,input1)

df2 = table(df2,input2)

翻过高山走不出你
浏览 82回答 1
1回答

慕虎7371278

您不需要复选框组。只需添加某个地方。fig.y_range.only_visible = True您不需要复选框组。只需添加某个地方。fig.y_range.only_visible = True
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python