def on_facts_loaded(self): self.clear() main = layout.VBox(padding=10, spacing=10) self.add_child(main) first_row = layout.HBox(spacing=10, expand=False) main.add_child(first_row) activity_weekdays = layout.HBox( [layout.VBox(spacing=15, expand=False), layout.VBox(spacing=15, expand=False), layout.VBox(spacing=15)], spacing=20, ) first_row.add_child(activity_weekdays) activity_weekdays[0].add_child(layout.Label("Category", expand=False, x_align=0)) activity_weekdays[1].add_child(layout.Label("Hour of the day", expand=False, x_align=0)) stats = Stats(self.facts, lambda fact: (fact.category, "")) by_hour = stats.by_hour() for activity in sorted(stats.groups.keys()): label = layout.Label("%s@%s" % (activity[1], activity[0]), color="#333", size=12, x_align=0, y_align=0.5) label.max_width = 150 activity_weekdays[0].add_child(label) activity_weekdays[1].add_child(SparkBars(by_hour[activity], 150)) activity_weekdays[0].add_child(layout.Label("Activity", expand=False, x_align=0)) activity_weekdays[1].add_child(layout.Label("Hour of the day", expand=False, x_align=0)) stats = Stats(self.facts, lambda fact: (fact.category, fact.activity)) by_hour = stats.by_hour() for activity in sorted(stats.groups.keys()): label = layout.Label("%s@%s" % (activity[1], activity[0]), color="#333", size=12, x_align=0, y_align=0.5) label.max_width = 150 activity_weekdays[0].add_child(label) activity_weekdays[1].add_child(SparkBars(by_hour[activity], 150))
def on_facts_loaded(self): self.clear() main = layout.VBox(padding=10, spacing=10) self.add_child(main) first_row = layout.HBox(spacing=10, expand=False) main.add_child(first_row) activity_weekdays = layout.HBox([ layout.VBox(spacing=15, expand=False), layout.VBox(spacing=15, expand=False), layout.VBox(spacing=15) ], spacing=20) first_row.add_child(activity_weekdays) activity_weekdays[0].add_child( layout.Label("Category", expand=False, x_align=0)) activity_weekdays[1].add_child( layout.Label("Hour of the day", expand=False, x_align=0)) stats = Stats(self.facts, lambda fact: (fact.category, "")) by_hour = stats.by_hour() for activity in sorted(stats.groups.keys()): label = layout.Label("%s@%s" % (activity[1], activity[0]), color="#333", size=12, x_align=0, y_align=0.5) label.max_width = 150 activity_weekdays[0].add_child(label) activity_weekdays[1].add_child(SparkBars(by_hour[activity], 150)) activity_weekdays[0].add_child( layout.Label("Activity", expand=False, x_align=0)) activity_weekdays[1].add_child( layout.Label("Hour of the day", expand=False, x_align=0)) stats = Stats(self.facts, lambda fact: (fact.category, fact.activity)) by_hour = stats.by_hour() for activity in sorted(stats.groups.keys()): label = layout.Label("%s@%s" % (activity[1], activity[0]), color="#333", size=12, x_align=0, y_align=0.5) label.max_width = 150 activity_weekdays[0].add_child(label) activity_weekdays[1].add_child(SparkBars(by_hour[activity], 150))