def render(self): """ Renders the chart context and axes into the dict data """ self.update(self.axes.render()) encoder = Encoder(self._encoding, None, self._series) if not "chs" in self: self["chs"] = "300x150" else: size = self["chs"].split("x") assert len(size) == 2, "Invalid size, must be in the format WxH" self.check_size(*map(int, size)) assert "cht" in self, "No chart type defined, use type method" self["cht"] = self.check_type(self["cht"]) if ("any" in dir(self._dataset) and self._dataset.any()) or self._dataset: self["chd"] = encoder.encode(self._dataset) elif not "choe" in self: assert "chd" in self, "You must have a dataset, or use chd" if self._scale: assert self["chd"].startswith("t"), "You must use text encoding with chds" self["chds"] = ",".join(self._scale) if self._geo and self._ld: self["chtm"] = self._geo self["chld"] = self._ld if self.lines: self["chls"] = "|".join(self.lines) if self.markers: self["chm"] = "|".join(self.markers) if self.fills: self["chf"] = "|".join(self.fills)
def render(self): """ Renders the chart context and axes into the dict data """ self.update(self.axes.render()) encoder = Encoder(self._encoding, None, self._series) if not 'chs' in self: self['chs'] = '300x150' else: size = self['chs'].split('x') assert len(size) == 2, 'Invalid size, must be in the format WxH' self.check_size(*map(int, size)) assert 'cht' in self, 'No chart type defined, use type method' self['cht'] = self.check_type(self['cht']) if ('any' in dir(self._dataset) and self._dataset.any()) or self._dataset: self['chd'] = encoder.encode(self._dataset) elif not 'choe' in self: assert 'chd' in self, 'You must have a dataset, or use chd' if self._scale: assert self['chd'].startswith('t'),\ 'You must use text encoding with chds' self['chds'] = ','.join(self._scale) if self._geo and self._ld: self['chtm'] = self._geo self['chld'] = self._ld if self.lines: self['chls'] = '|'.join(self.lines) if self.markers: self['chm'] = '|'.join(self.markers) if self.fills: self['chf'] = '|'.join(self.fills)
def _test_encoding(encoding, expected, data, scale): codec = Encoder(encoding, scale) assert codec.encode(data) == expected assert codec.decode(codec.encode(data)) == [data]