Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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])
Пример #4
0
 def getdata(self):
     """
     Returns the decoded dataset from chd param
     """
     #XXX: Why again? not even sure decode works well
     return Encoder(self._encoding).decode(self['chd'])
Пример #5
0
 def getdata(self):
     return Encoder().decode(self.data['chd'])