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.data.update(self.axes.render()) encoder = Encoder(self._encoding) if not 'chs' in self.data: self.data['chs'] = '300x150' else: size = self.data['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.data, 'No chart type defined, use type method' self.data['cht'] = self.check_type(self.data['cht']) if ('any' in dir(self._dataset) and self._dataset.any()) or self._dataset: self.data['chd'] = encoder.encode(self._dataset) elif not 'choe' in self.data: assert 'chd' in self.data, 'You must have a dataset, or use chd' if self._scale: assert self.data['chd'].startswith('t:'), 'You must use text encoding with chds' self.data['chds'] = ','.join(self._scale) if self._geo and self._ld: self.data['chtm'] = self._geo self.data['chld'] = self._ld if self.lines: self.data['chls'] = '|'.join(self.lines) if self.markers: self.data['chm'] = '|'.join(self.markers) if self.fills: self.data['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 render(self): """ Renders the chart context and axes into the dict data """ self.data.update(self.axes.render()) encoder = Encoder(self._encoding) if not 'chs' in self.data: self.data['chs'] = '300x150' else: size = self.data['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.data), 'No chart type defined, use type method' self.data['cht'] = self.check_type(self.data['cht']) if self._dataset: self.data['chd'] = encoder.encode(self._dataset) # except: raise IndexError, 'Data encoding went screwy' else: assert ('chd' in self.data), 'You must have a dataset, or use chd' if self.scales: assert (self.data['chd'].startswith('t:') ), 'You must use text encoding with chds' self.data['chds'] = ','.join(self.scales) if self.bar_heights: self.data['chbh'] = self.bar_heights if self._geo and self._cc: self.data['chtm'] = self._geo self.data['chld'] = self._cc if self.lines: self.data['chls'] = '|'.join(self.lines) if self.markers: self.data['chm'] = '|'.join(self.markers) if self.fills: self.data['chf'] = '|'.join(self.fills)
def _test_encoding(self, encoding, expected, data, scale): codec = Encoder(encoding, scale) self.assertEqual(codec.encode(data), expected) self.assertEqual(codec.decode(codec.encode(data)), [data])