diff options
| author | Pinapelz <yukais@pinapelz.com> | 2024-10-28 15:36:57 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2024-10-28 15:36:57 -0700 |
| commit | 26913c93b7ecb03a7ae4ba2e4dad7dbd07b48033 (patch) | |
| tree | 1b9b4a7e503ca22701bd71413fcaee5e8bba3eab | |
| parent | 60d655d7e6759093ad8848cec5005cd9e8d1bd60 (diff) | |
fix: individual toggling of traces
| -rw-r--r-- | graph.py | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -28,18 +28,21 @@ def plot_subscriber_count_over_time(server, table_name, gtitle="Subscriber Count for group_name in group_names: channels_in_group = sorted(df[df['group_name'] == group_name]['name'].unique()) - group_title_added = False + group_title_added = False # Flag to add group title only once for channel in channels_in_group: group = df[(df['group_name'] == group_name) & (df['name'] == channel)] if len(exclude_channels) != 0 and group['channel_id'].iloc[0] in exclude_channels: continue + color = member_color_map.get(channel, '#' + ''.join(random.choices('0123456789ABCDEF', k=6))) + if not group_title_added: legendgrouptitle_text = group_name group_title_added = True else: legendgrouptitle_text = None + fig.add_trace(go.Scattergl( x=group["timestamp"], y=group["subscriber_count"], @@ -48,7 +51,8 @@ def plot_subscriber_count_over_time(server, table_name, gtitle="Subscriber Count showlegend=True, line=dict(color=color), legendgroup=group_name, - legendgrouptitle_text=legendgrouptitle_text + legendgrouptitle_text=legendgrouptitle_text, + legendrank=group_names.index(group_name), )) fig.update_layout( @@ -61,7 +65,11 @@ def plot_subscriber_count_over_time(server, table_name, gtitle="Subscriber Count }, xaxis_title="Date", yaxis_title="Subscribers", - legend=dict(font=dict(size=16), title=dict(text="Channels")), + legend=dict( + font=dict(size=16), + title=dict(text="Channels"), + groupclick='toggleitem' + ), height=950, ) |
