m-ric HF staff commited on
Commit
b749eb1
Β·
verified Β·
1 Parent(s): 33d2d61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -38,21 +38,23 @@ class DownloadsTracker:
38
  return None
39
 
40
  def plot(self, use_log_scale):
41
- fig = px.line(title="Package Downloads")
42
  fig = make_subplots(rows=2, cols=1, subplot_titles=("Cumulative Downloads", "Weekly Downloads"))
43
-
44
- for pkg in self.current_packages:
 
45
  if pkg in self.all_packages:
46
  df = self.all_packages[pkg]
47
-
48
 
49
  fig.add_trace(
50
- go.Scatter(x=df["date"], y=df["cumulative_downloads"], name=f"{pkg} (cumulative)"),
 
51
  row=1, col=1
52
  )
53
 
54
  fig.add_trace(
55
- go.Scatter(x=df["date"], y=df["weekly_downloads"], name=f"{pkg} (weekly)"),
 
56
  row=2, col=1
57
  )
58
 
@@ -63,7 +65,7 @@ class DownloadsTracker:
63
  fig.update_yaxes(type="linear", row=1, col=1)
64
  fig.update_yaxes(type="linear", row=2, col=1)
65
 
66
- fig.update_layout(height=800) # Make the figure taller to accommodate both plots
67
  return fig
68
 
69
  def render(self, package_list, use_log_scale):
 
38
  return None
39
 
40
  def plot(self, use_log_scale):
 
41
  fig = make_subplots(rows=2, cols=1, subplot_titles=("Cumulative Downloads", "Weekly Downloads"))
42
+
43
+ colors = px.colors.qualitative.Set1 # Built-in color sequence
44
+ for i, pkg in enumerate(self.current_packages):
45
  if pkg in self.all_packages:
46
  df = self.all_packages[pkg]
47
+ color = colors[i % len(colors)]
48
 
49
  fig.add_trace(
50
+ go.Scatter(x=df["date"], y=df["cumulative_downloads"],
51
+ name=pkg, line=dict(color=color)),
52
  row=1, col=1
53
  )
54
 
55
  fig.add_trace(
56
+ go.Scatter(x=df["date"], y=df["weekly_downloads"],
57
+ name=pkg, line=dict(color=color), showlegend=False),
58
  row=2, col=1
59
  )
60
 
 
65
  fig.update_yaxes(type="linear", row=1, col=1)
66
  fig.update_yaxes(type="linear", row=2, col=1)
67
 
68
+ fig.update_layout(height=800)
69
  return fig
70
 
71
  def render(self, package_list, use_log_scale):