def set_domain(self, values): """Set domain of the colors based on min and max of a list of values.""" _flattenedList = sorted(flatten(values)) self.domain = tuple(_flattenedList[0] if d == 'min' else d for d in self.domain) self.domain = tuple(_flattenedList[-1] if d == 'max' else d for d in self.domain)
def calculate_colors(self, values): """Return a list (or list of lists) of colors based on input values.""" # set domain if it is not set _flattenedList = list(flatten(values)) if not self.is_domain_set: self.set_domain(_flattenedList) _flattenedColors = range(len(_flattenedList)) for count, value in enumerate(_flattenedList): _flattenedColors[count] = self.calculate_color(value) return unflatten(values, iter(_flattenedColors))
def calculate_colors(self, values): """Return a list (or list of lists) of colors based on input values.""" # set domain if it is not set _flattenedList = list(flatten(values)) if not self.is_domain_set: self.set_domain(_flattenedList) _flattenedColors = range(len(_flattenedList)) for count, value in enumerate(_flattenedList): _flattenedColors[count] = self.calculate_color(value) return unflatten(values, iter(_flattenedColors))
def set_domain(self, values): """Set domain of the colors based on min and max of a list of values.""" _flattenedList = sorted(flatten(values)) self.domain = tuple(_flattenedList[0] if d == 'min' else d for d in self.domain) self.domain = tuple(_flattenedList[-1] if d == 'max' else d for d in self.domain)