コード例 #1
0
    def create(cls, section, table, title, width=6, height=300, column=None):
        """Class method to create a MapWidget.

        `column` is the data column to graph, defaults to the first non-key
                 column found assigned to the table.
        """
        w = Widget(section=section,
                   title=title,
                   width=width,
                   height=height,
                   module=__name__,
                   uiwidget=cls.__name__)
        w.compute_row_col()
        keycols = [
            col.name for col in table.get_columns() if col.iskey is True
        ]
        if len(keycols) == 0:
            raise ValueError("Table %s does not have any key columns defined" %
                             str(table))

        column = column or [
            col.name for col in table.get_columns() if col.iskey is False
        ][0]

        w.options = MapWidgetOptions(key=keycols[0], value=column)
        w.save()
        w.tables.add(table)
コード例 #2
0
 def create(cls, section, table, title, width=6, height=300,
            stacked=False, cols=None, altaxis=None):
     w = Widget(section=section, title=title, width=width, height=height,
                module=__name__, uiwidget=cls.__name__)
     w.compute_row_col()
     timecols = [col.name for col in table.get_columns()
                 if col.datatype == 'time']
     if len(timecols) == 0:
         raise ValueError("Table %s must have a datatype 'time' column for "
                          "a timeseries widget" % str(table))
     cols = cols or [col.name for col in table.get_columns()
                     if col.datatype != 'time']
     if altaxis:
         axes = {'0': {'position': 'left',
                       'columns': [col for col in cols if col not in altaxis]},
                 '1': {'position': 'right',
                       'columns': [col for col in cols if col in altaxis]}
                 }
     else:
         axes = {'0': {'position': 'left',
                       'columns': cols}}
     w.options = JsonDict(axes=axes,
                          columns=cols,
                          stacked=stacked)
     w.save()
     w.tables.add(table)
コード例 #3
0
 def create(cls, section, table, title, width=6, rows=1000, height=300):
     w = Widget(section=section,
                title=title,
                rows=rows,
                width=width,
                height=height,
                module=__name__,
                uiwidget=cls.__name__)
     w.compute_row_col()
     w.save()
     w.tables.add(table)
コード例 #4
0
 def create(cls,
            section,
            table,
            title,
            width=6,
            height=300,
            stacked=False,
            cols=None,
            altaxis=None):
     w = Widget(section=section,
                title=title,
                width=width,
                height=height,
                module=__name__,
                uiwidget=cls.__name__)
     w.compute_row_col()
     timecols = [
         col.name for col in table.get_columns() if col.datatype == 'time'
     ]
     if len(timecols) == 0:
         raise ValueError("Table %s must have a datatype 'time' column for "
                          "a timeseries widget" % str(table))
     cols = cols or [
         col.name for col in table.get_columns() if col.datatype != 'time'
     ]
     if altaxis:
         axes = {
             '0': {
                 'position': 'left',
                 'columns': [col for col in cols if col not in altaxis]
             },
             '1': {
                 'position': 'right',
                 'columns': [col for col in cols if col in altaxis]
             }
         }
     else:
         axes = {'0': {'position': 'left', 'columns': cols}}
     w.options = JsonDict(axes=axes, columns=cols, stacked=stacked)
     w.save()
     w.tables.add(table)
コード例 #5
0
    def create(cls, section, table, title, width=6, rows=10, height=300):
        w = Widget(section=section, title=title, rows=rows, width=width,
                   height=height, module=__name__, uiwidget=cls.__name__)
        w.compute_row_col()
        keycols = [col.name for col in table.get_columns() if col.iskey is True]
        if len(keycols) == 0:
            raise ValueError("Table %s does not have any key columns defined" %
                             str(table))

        if table.sortcol is None:
            raise ValueError("Table %s does not have a sort column defined" %
                             str(table))

        w.options = JsonDict(key=keycols[0],
                             value=table.sortcol.name)
        w.save()
        w.tables.add(table)
コード例 #6
0
    def create(cls, section, table, title, width=6, height=300, column=None):
        """Class method to create a MapWidget.

        `column` is the data column to graph, defaults to the first non-key
                 column found assigned to the table.
        """
        w = Widget(section=section, title=title, width=width, height=height,
                   module=__name__, uiwidget=cls.__name__)
        w.compute_row_col()
        keycols = [col.name for col in table.get_columns() if col.iskey is True]
        if len(keycols) == 0:
            raise ValueError("Table %s does not have any key columns defined" % str(table))

        column = column or [col.name for col in table.get_columns() if col.iskey is False][0]

        w.options = MapWidgetOptions(key=keycols[0], value=column)
        w.save()
        w.tables.add(table)
コード例 #7
0
    def create(cls,
               section,
               table,
               title,
               width=6,
               rows=10,
               height=300,
               keycols=None,
               valuecols=None,
               chart_type='line'):
        w = Widget(section=section,
                   title=title,
                   rows=rows,
                   width=width,
                   height=height,
                   module=__name__,
                   uiwidget=cls.__name__)
        w.compute_row_col()
        if keycols is None:
            keycols = [
                col.name for col in table.get_columns() if col.iskey is True
            ]
        if len(keycols) == 0:
            raise ValueError("Table %s does not have any key columns defined" %
                             str(table))

        if valuecols is None:
            valuecols = [
                col.name for col in table.get_columns() if col.iskey is False
            ]
        w.options = JsonDict(
            dict={
                'keycols': keycols,
                'columns': valuecols,
                'axes': None,
                'chart_type': chart_type
            })
        w.save()
        w.tables.add(table)
コード例 #8
0
    def create(cls, section, table, title, width=6, rows=10, height=300):
        w = Widget(section=section,
                   title=title,
                   rows=rows,
                   width=width,
                   height=height,
                   module=__name__,
                   uiwidget=cls.__name__)
        w.compute_row_col()
        keycols = [
            col.name for col in table.get_columns() if col.iskey is True
        ]
        if len(keycols) == 0:
            raise ValueError("Table %s does not have any key columns defined" %
                             str(table))

        if table.sortcol is None:
            raise ValueError("Table %s does not have a sort column defined" %
                             str(table))

        w.options = JsonDict(key=keycols[0], value=table.sortcol.name)
        w.save()
        w.tables.add(table)
コード例 #9
0
    def create(cls, section, table, title, width=6, rows=10, height=300,
               keycols=None, valuecols=None):
        w = Widget(section=section, title=title, rows=rows, width=width,
                   height=height, module=__name__, uiwidget=cls.__name__)
        w.compute_row_col()
        if keycols is None:
            keycols = [col.name for col in table.get_columns()
                       if col.iskey is True]
        if len(keycols) == 0:
            raise ValueError("Table %s does not have any key columns defined" %
                             str(table))

        if valuecols is None:
            valuecols = [col.name for col in table.get_columns()
                         if col.iskey is False]
        w.options = JsonDict(dict={'keycols': keycols,
                                   'columns': valuecols,
                                   'axes': None})
        w.save()
        w.tables.add(table)
コード例 #10
0
ファイル: maps.py プロジェクト: HackLinux/flyscript-portal
    def create(cls, section, table, title, width=6, height=300,
               lat_col=None, long_col=None, val_col=None, label_col=None,
               min_bounds=None):
        """Class method to create a MapWidget.

        `lat_col` and `long_col` are optional pairs of columns indicating
                the latitude and longitude values of data to plot.  If these
                are omitted, the first column with the attribute 'iskey' will
                be used as the means for determining where to plot.

        `val_column` is the data column to graph, defaults to the first non-key
                column found assigned to the table.

        `name_column` is an optional column to use for marker labels when
                when defining lat/long columns.

        `min_bounds` is an optional tuple of (lat, lng) points representing
                the minimum extents that the map should include.  Useful to
                avoid the close zoomed-in effect when two close-in points
                would be plotted.  For example, to have continental US always
                shown, the argument could be:
                    ((33.184833, -116.999540),
                     (45.561302, -67.956573))

        Each column argument may be a Column object or the string name.

        """
        w = Widget(section=section, title=title, width=width, height=height,
                   module=__name__, uiwidget=cls.__name__)
        w.compute_row_col()

        if lat_col is None and long_col is None:
            keycol = [col.name for col in table.get_columns()
                      if col.iskey is True]
            if len(keycol) == 0:
                raise ValueError("Table %s does not have any key columns "
                                 "defined" % str(table))
            elif len(keycol) > 1:
                logger.debug('Widget %s: Choosing first key column from '
                             'available list %s ' % (repr(w), keycol))
            keycol = keycol[0]
        elif lat_col and long_col:
            keycol = None
            lat_col = getattr(lat_col, 'name', lat_col)
            long_col = getattr(long_col, 'name', long_col)
            label_col = getattr(label_col, 'label', label_col)
        else:
            raise ValueError('Both lat_col and long_col need to be defined '
                             'as a pair or omitted as a pair.')

        if val_col:
            val_col = getattr(val_col, 'name', val_col)
        else:
            val_col = [col.name for col in table.get_columns() if
                       col.iskey is False][0]

        w.options = MapWidgetOptions(key=keycol, latitude=lat_col,
                                     longitude=long_col, value=val_col,
                                     label=label_col, min_bounds=min_bounds)
        w.save()
        w.tables.add(table)
コード例 #11
0
ファイル: maps.py プロジェクト: rrx/flyscript-portal
    def create(cls,
               section,
               table,
               title,
               width=6,
               height=300,
               lat_col=None,
               long_col=None,
               val_col=None,
               label_col=None,
               min_bounds=None):
        """Class method to create a MapWidget.

        `lat_col` and `long_col` are optional pairs of columns indicating
                the latitude and longitude values of data to plot.  If these
                are omitted, the first column with the attribute 'iskey' will
                be used as the means for determining where to plot.

        `val_column` is the data column to graph, defaults to the first non-key
                column found assigned to the table.

        `name_column` is an optional column to use for marker labels when
                when defining lat/long columns.

        `min_bounds` is an optional tuple of (lat, lng) points representing
                the minimum extents that the map should include.  Useful to
                avoid the close zoomed-in effect when two close-in points
                would be plotted.  For example, to have continental US always
                shown, the argument could be:
                    ((33.184833, -116.999540),
                     (45.561302, -67.956573))

        Each column argument may be a Column object or the string name.

        """
        w = Widget(section=section,
                   title=title,
                   width=width,
                   height=height,
                   module=__name__,
                   uiwidget=cls.__name__)
        w.compute_row_col()

        if lat_col is None and long_col is None:
            keycol = [
                col.name for col in table.get_columns() if col.iskey is True
            ]
            if len(keycol) == 0:
                raise ValueError("Table %s does not have any key columns "
                                 "defined" % str(table))
            elif len(keycol) > 1:
                logger.debug('Widget %s: Choosing first key column from '
                             'available list %s ' % (repr(w), keycol))
            keycol = keycol[0]
        elif lat_col and long_col:
            keycol = None
            lat_col = getattr(lat_col, 'name', lat_col)
            long_col = getattr(long_col, 'name', long_col)
            label_col = getattr(label_col, 'label', label_col)
        else:
            raise ValueError('Both lat_col and long_col need to be defined '
                             'as a pair or omitted as a pair.')

        if val_col:
            val_col = getattr(val_col, 'name', val_col)
        else:
            val_col = [
                col.name for col in table.get_columns() if col.iskey is False
            ][0]

        w.options = MapWidgetOptions(key=keycol,
                                     latitude=lat_col,
                                     longitude=long_col,
                                     value=val_col,
                                     label=label_col,
                                     min_bounds=min_bounds)
        w.save()
        w.tables.add(table)
コード例 #12
0
 def create(cls, section, table, title, width=6, rows=1000, height=300):
     w = Widget(section=section, title=title, rows=rows, width=width,
                height=height, module=__name__, uiwidget=cls.__name__)
     w.compute_row_col()
     w.save()
     w.tables.add(table)