def __init__(self, series_set, scale, style=None, vertical_scale=True, stacked=True, zero_base=True): """ Constructor; creates a new LineGraph. @param mseries: The data to plot, as a MultiSeries @type mseries: graphication.series.MultiSeries @param style: The Style to apply to this graph @type style: graphication.style.Style @param scale: The Scale to use for the graph. @type scale: graphication.scales.BaseScale @param smoothed: If the graph is smoothed (not straight lines) @type smoothed: bool """ self.series_set = series_set self.style = default_css.merge(style) self.scale = scale self.stacked = stacked self.zero_base = zero_base self.vertical_scale = vertical_scale # Initialise the vertical scale if stacked: y_min, y_max = self.stacked_value_range() else: y_min, y_max = self.series_set.value_range() if self.zero_base: y_min = 0 self.y_scale = VerticalWavegraphScale(y_min, y_max)
def __init__(self, series_set, scale, style=None, vertical_scale=None, zero_base=True, label_on=True, stacked=True, sharp_edges=True, top_only=False, border_only=False): """ Constructor; creates a new CurvyBarChart. """ self.series_set = series_set self.style = default_css.merge(style) self.scale = scale self.label_height = style['curvybarchart label'].get_float("height", 30) self.label_on = label_on self.zero_base = zero_base self.stacked = stacked self.sharp_edges = sharp_edges self.top_only = top_only self.border_only = border_only if vertical_scale is None: if stacked: y_min, y_max = self.stacked_value_range() else: y_min, y_max = self.series_set.value_range() if self.zero_base: y_min = 0 vertical_scale = VerticalWavegraphScale(y_min, y_max) self.y_scale = vertical_scale
def calc_rel_points(self): """Calculates the relative shapes of the sections""" # Get the style stuff y_offset = self.style['wavegraph'].get_align("vertical-align", 0.5) y_size = self.style['wavegraph'].get_align("height", 0.9) # Work out our extents y_total = max([total for (key, total) in self.series_set.totals()]) self.y_scale = VerticalWavegraphScale(0, y_total) # Calculate the points cols = [] self.xs = [] for x, stack in self.series_set.stacks(): self.xs.append(self.scale.get_point(x)) # Collect the points ys = [] total = 0 for ser, val in stack: y = self.y_scale.get_point(val) * y_size ys.append(total) total += y ys.append(total) shift = 1 - total # Shift them down to center them ys = [a + (shift * y_offset) for a in ys] cols.append(ys) self.rows = list(zip(*cols))
def calc_rel_points(self): """Calculates the relative shapes of the sections""" if isinstance(self.vertical_scale, BaseScale): self.y_scale = self.vertical_scale else: # Work out our extents y_min, y_max = self.series_set.value_range() if self.zero_base: y_min = 0 self.y_scale = VerticalWavegraphScale(y_min, y_max)