Пример #1
0
 def processData(self):
     """ produce the different recordSet with the level of clicks defined in teh vals and set functions """
     recordSet = AresChartsService.toPie(self.vals,
                                         self.chartKeys,
                                         self.chartVals,
                                         extKeys=self.extKeys)
     self.aresObj.jsGlobal.add("data_%s = %s ;" %
                               (self.htmlId, json.dumps(recordSet)))
Пример #2
0
    def pivot(self, keys, vals, filters=None):
        """ """
        mapHeader = dict([(self.recKey(hdr), hdr['colName'])
                          for hdr in self.header[-1]])
        self.__data = [[
            AresHtmlTableItems.Td(self.aresObj,
                                  mapHeader[header],
                                  True,
                                  cssAttr={
                                      'background': '#225D32',
                                      'text-align': 'center',
                                      'color': 'white',
                                      'font-weight': 'bold'
                                  }) for header in keys + vals
        ]]
        rows = AresChartsService.toPivotTable(self.vals, keys, vals, filters)
        self.__rows_hidden = {}
        for i, val in enumerate(rows):
            if self.formatVals:
                for keyVal in vals:
                    val[keyVal] = AresHtmlText.UpDown(self.aresObj,
                                                      val[keyVal], val[keyVal])
            row, indexCol = [], i + 1
            #
            if not indexCol in self.__rows_attr['rows']:
                self.__rows_attr['rows'][indexCol] = {'name': val['_id']}
            else:
                self.__rows_attr['rows'][indexCol]['name'] = val['_id']
            self.__rows_attr['rows'][indexCol]['data-index'] = val['level']

            if 'class' in self.__rows_attr['rows'][indexCol]:
                self.__rows_attr['rows'][indexCol]['class'].extend(
                    val['cssCls'])
            else:
                self.__rows_attr['rows'][indexCol]['class'] = val['cssCls']

            if val.get('_parent', 0) == 0:
                if 'css' in self.__rows_attr['rows'][indexCol]:
                    self.__rows_attr['rows'][indexCol]['css'].update(
                        {'display': 'None'})
                else:
                    self.__rows_attr['rows'][indexCol]['css'] = {
                        'display': 'None'
                    }

            #
            if val.get('_hasChildren', 0) == 1:
                self.__rows_attr['rows'][indexCol]['class'].append('details')
                if 'css' in self.__rows_attr['rows'][indexCol]:
                    self.__rows_attr['rows'][indexCol]['css'].update(
                        self.cssPivotRows)
                else:
                    self.__rows_attr['rows'][indexCol][
                        'css'] = self.cssPivotRows
            for j, header in enumerate(self.header[-1]):
                cellVal = val.get(self.recKey(header), self.dflt)
                attrCss = dict(
                    self.tdCssAttr) if self.tdCssAttr is not None else {}
                if cellVal is not None:
                    if j == 0:
                        attrCss['padding-left'] = '%spx' % (val['level'] * 20)
                    row.append(
                        AresHtmlTableItems.Td(self.aresObj,
                                              cellVal,
                                              cssCls=self.tdCssCls,
                                              cssAttr=attrCss))
            self.__data.append(row)

        self.aresObj.jsOnLoadFnc.add('''
      $( ".details > td:first-child" ).click(function() {
        var trObj = $(this).closest('tr');
        var children_data_id = trObj.data('index') + 1;
        var trName = trObj.attr('name');
        var isVisible = $(this).hasClass('changed');
        $(this).toggleClass('changed');
        $('#%s > tbody  > tr').each(function() {
          var trId = $(this).data('index');
          var trHasParent = $(this).hasClass(trName);
          if (isVisible) {
            if ((trId >= children_data_id) && trHasParent ) {
              if ($(this).hasClass('details')){
                var firstTd = $(this).find('td:first-child');
                if  (firstTd.hasClass('changed')) {
                  $(this).find('td:first-child').removeClass('changed');}
              }
              $(this).hide() ;
            }
         } else {
            if ((trId == children_data_id) && trHasParent ) {
              $(this).toggle() ;
            }
          }
          //alert($(this).attr('name'));
        } );
      });
      ''' % self.htmlId)
Пример #3
0
 def processData(self):
     """ produce the different recordSet with the level of clicks defined in teh vals and set functions """
     recordSet = AresChartsService.toPlotBox(self.vals, self.chartKeys, self.chartVals, withMean=self.withMean, seriesNames=self.seriesNames)
     self.aresObj.jsGlobal.add("data_%s = %s" % (self.htmlId, json.dumps(recordSet)))