def plot(self, keys, data): self.data = data bars = dict([(bar.key, bar.normalized) for bar in self.bars]) max_val = float(max(data or [0])) new_bars, new_labels = [], [] for key, value in zip(keys, data): if max_val: normalized = value / max_val else: normalized = 0 bar = Bar(key, locale.format(self.value_format, value), normalized, self.label_color) bar.interactive = self.graph_interactive if key in bars: bar.normalized = bars[key] self.tweener.add_tween(bar, normalized=normalized) new_bars.append(bar) label = graphics.Label(stuff.escape_pango(key), size = 8, alignment = pango.Alignment.RIGHT) new_labels.append(label) self.plot_area.remove_child(*self.bars) self.remove_child(*self.labels) self.bars, self.labels = new_bars, new_labels self.add_child(*self.labels) self.plot_area.add_child(*self.bars) self.show() self.redraw()
def parent_painter(column, cell, model, iter): cell_text = model.get_value(iter, 1) if model.iter_parent(iter) is None: if model.get_path(iter) == (0,): text = '<span weight="heavy">%s</span>' % cell_text else: text = '<span weight="heavy" rise="-20000">%s</span>' % cell_text cell.set_property('markup', text) else: activity_name = stuff.escape_pango(cell_text) description = stuff.escape_pango(model.get_value(iter, 4)) category = stuff.escape_pango(model.get_value(iter, 5)) markup = stuff.format_activity(activity_name, category, description, pad_description = True) cell.set_property('markup', markup)
def plot(self, keys, data): self.data = data bars = dict([(bar.key, bar.normalized) for bar in self.bars]) max_val = float(max(data or [0])) totals = sum(data) new_bars, new_labels = [], [] for key, value in zip(keys, data): if max_val: normalized = value / max_val else: normalized = 0 if totals: divided = 100*value/totals else: divided = 0 bar = Bar(key, locale.format(self.value_format, value) + "h (%d%%)" % divided, normalized, self.label_color) bar.interactive = self.graph_interactive if key in bars: bar.normalized = bars[key] self.tweener.add_tween(bar, normalized=normalized) new_bars.append(bar) label = graphics.Label(stuff.escape_pango(key), size = 8, alignment = pango.ALIGN_RIGHT) new_labels.append(label) self.plot_area.remove_child(*self.bars) self.remove_child(*self.labels) self.bars, self.labels = new_bars, new_labels self.add_child(*self.labels) self.plot_area.add_child(*self.bars) self.show() self.redraw()