Ejemplo n.º 1
0
Archivo: GChart.py Proyecto: fay/Nankin
 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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 def get_context_data(self, **kwargs):
     context = super(ServerDetailView, self).get_context_data(**kwargs)
     context['match'] = self.get_object().match_set.latest()
     context['players_scores'] = []
     e = Encoder("text")
     context['players_nums_data'] = e.encodedata( [d.data for d in self.get_object().nums_players.all()])
     context['players_nums_datetime'] = "one thow tree"
     for player in self.get_object().match_set.latest().players.all():
         player_name = player.name
         player_score = player.score_set.latest().data
         context['players_scores'].append((player_name, player_score))
     return context
Ejemplo n.º 6
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])
Ejemplo n.º 7
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])
Ejemplo n.º 8
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'])
Ejemplo n.º 9
0
 def getdata(self):
     return Encoder().decode(self.data['chd'])