def create(cls, section, table, title, width=6, rows=10, height=300, keycol=None, stack_widget=False): """Create a widget displaying data in a pie chart. :param int width: Width of the widget in columns (1-12, default 6) :param int rows: Number of rows to display as pie slices (default 10) :param int height: Height of the widget in pixels (default 300) :param str keycol: Optional column to use as key column. By default, the widget will pick the first Key column it finds, but there are cases where non-Key columns could be used instead or perhaps a secondary Key is desired. :param bool stack_widget: stack this widget below the previous one. The labels are taken from the Table key column (the first key, if the table has multiple key columns defined). The pie widget values are taken from the sort column. """ keycols = cls.calculate_keycol(table, keycols=[keycol]) if table.sortcols is None: raise ValueError("Table %s does not have a sort column defined" % str(table)) options = {'key': keycols[0], 'value': table.sortcols[0]} Widget.create(section=section, table=table, title=title, width=width, rows=rows, height=height, module=__name__, uiwidget=cls.__name__, options=options, stack_widget=stack_widget)
def create(cls, section, table, title, width=6, rows=10, height=300, stack_widget=False): """Create a widget displaying data in a pie chart. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param int rows: Number of rows to display as pie slices (default 10) :param bool stack_widget: stack this widget below the previous one. The labels are taken from the Table key column (the first key, if the table has multiple key columns defined). The pie widget values are taken from the sort column. """ keycols = cls.calculate_keycol(table, keycols=None) if table.sortcols is None: raise ValueError("Table %s does not have a sort column defined" % str(table)) options = {'key': keycols[0], 'value': table.sortcols[0]} Widget.create(section=section, table=table, title=title, width=width, rows=rows, height=height, module=__name__, uiwidget=cls.__name__, options=options, stack_widget=stack_widget)
def create(cls, section, table, title, width=6, height=300, rows=1000, cols=None, info=True, paging=False, row_chooser=False, searching=False, stack_widget=False): """Create a widget displaying data in a pivot table. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300). :param int rows: Number of rows to display (default 1000) :param list cols: List of columns by name to include. If None, the default, include all data columns. Data Table Options: :param bool info: Optionally display "Showing X of Y entries" :param bool paging: Optionally display page number chooser. If disabled, scrolling will instead be enabled and `row_chooser` will be set to False. :param bool row_chooser: Optionally choose how many rows to display. Will be disabled if paging option is disabled. :param bool searching: Optionally display search box at top. :param bool stack_widget: stack this widget below the previous one. """ options = {'columns': cols, 'info': info, 'paging': paging, 'row_chooser': row_chooser, 'searching': searching} Widget.create(section=section, table=table, title=title, rows=rows, width=width, height=height, module=__name__, uiwidget=cls.__name__, options=options, stack_widget=stack_widget)
def create(cls, section, table, title, width=6, height=300, cols=None, rows=1000, stack_widget=False): """Create a widget displaying data in a pivot table. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300). For this interactive widget, the best option is `0` - this will make the widget size dynamic as new pivots are chosen. Any other height will result in scrolling withing the widget pane. :param int rows: Number of rows to display (default 1000) :param list cols: List of columns by name to include. If None, the default, include all data columns. :param bool stack_widget: stack this widget below the previous one. """ options = {'columns': cols} Widget.create(section=section, table=table, title=title, rows=rows, width=width, height=height, module=__name__, uiwidget=cls.__name__, options=options, stack_widget=stack_widget)
def create(cls, section, table, title, width=6, rows=10, height=300, keycols=None, valuecols=None, charttype='line', **kwargs): """Create a widget displaying data as a chart. This class is typically not used directly, but via LineWidget or BarWidget subclasses :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param int rows: Number of rows to display (default 10) :param list keycols: List of key column names to use for x-axis labels :param list valuecols: Optional list of data columns to graph :param str charttype: Type of chart, defaults to 'line'. This may be any C3 'type' """ keycols = cls.calculate_keycol(table, keycols=None) if table.sortcols is None: raise ValueError("Table %s does not have a sort column defined" % str(table)) if valuecols is None: valuecols = [col.name for col in table.get_columns() if col.iskey is False] options = {'keycols': keycols, 'columns': valuecols, 'charttype': charttype} Widget.create(section=section, table=table, title=title, width=width, rows=rows, height=height, module=__name__, uiwidget=cls.__name__, options=options, **kwargs)
def create(cls, section, table, title, width=6, height=300, keycols=None, valuecols=None, altaxis=None, bar=False, stacked=False, stack_widget=False): """Create a widget displaying data as a chart. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param list keycols: List of key column names to use for x-axis labels :param list valuecols: List of data columns to graph :param list altaxis: List of columns to graph using the alternate Y-axis :param bool bar: If True, show time series in a bar chart. Can be combined with ``stacked`` to show as stacked bar chart rather than stacked area chart :param str stacked: True for stacked line chart, defaults to False :param bool stack_widget: stack this widget below the previous one """ keycols = cls.calculate_keycol(table, keycols) options = {'keycols': keycols, 'columns': valuecols, 'altaxis': altaxis, 'bar': bar, 'stacked': stacked} Widget.create(section=section, table=table, title=title, width=width, rows=-1, height=height, module=__name__, uiwidget=cls.__name__, options=options, stack_widget=stack_widget)
def create(cls, section, table, title, width=6, rows=10, height=300, keycols=None, valuecols=None, charttype='line', **kwargs): """Create a widget displaying data as a chart. This class is typically not used directly, but via LineWidget or BarWidget subclasses :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param int rows: Number of rows to display (default 10) :param list keycols: List of key column names to use for x-axis labels :param list valuecols: Optional list of data columns to graph :param str charttype: Type of chart, defaults to 'line'. This may be any C3 'type' """ keycols = cls.calculate_keycol(table, keycols=None) if table.sortcols is None: raise ValueError("Table %s does not have a sort column defined" % str(table)) if valuecols is None: valuecols = [ col.name for col in table.get_columns() if col.iskey is False ] options = { 'keycols': keycols, 'columns': valuecols, 'charttype': charttype } Widget.create(section=section, table=table, title=title, width=width, rows=rows, height=height, module=__name__, uiwidget=cls.__name__, options=options, **kwargs)
def create(cls, section, table, title, width=6, height=300, keycols=None, valuecols=None, altaxis=None, bar=False, stacked=False, stack_widget=False): """Create a widget displaying data as a chart. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param list keycols: List of key column names to use for x-axis labels :param list valuecols: List of data columns to graph :param list altaxis: List of columns to graph using the alternate Y-axis :param bool bar: If True, show time series in a bar chart. Can be combined with ``stacked`` to show as stacked bar chart rather than stacked area chart :param str stacked: True for stacked line chart, defaults to False :param bool stack_widget: stack this widget below the previous one """ keycols = cls.calculate_keycol(table, keycols) options = { 'keycols': keycols, 'columns': valuecols, 'altaxis': altaxis, 'bar': bar, 'stacked': stacked } Widget.create(section=section, table=table, title=title, width=width, rows=-1, height=height, module=__name__, uiwidget=cls.__name__, options=options, stack_widget=stack_widget)
def create(cls, section, table, title, width=6, rows=1000, height=300): """Create a widget displaying data in a two dimensional table. This is similar to ``yui3.TableWidget`` except the key and data values are minimally formatted to show raw data values. Usually only used for testing and debug. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param int rows: Number of rows to display (default 10) """ 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)
def create(cls, section, table, title, width=6, rows=10, height=300): """Create a widget displaying data in a pie chart. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param int rows: Number of rows to display (default 10) The labels are taken from the Table key column (the first key, if the table has multiple key columns defined). The pie widget values are taken from the sort column. """ 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.sortcols is None: raise ValueError("Table %s does not have a sort column defined" % str(table)) w.options = JsonDict(key=keycols[0], value=table.sortcols[0]) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, cols=None, rows=1000, height=300): """Create a widget displaying data in a two dimensional table. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param int rows: Number of rows to display (default 1000) :param list cols: List of columns by name to include. If None, the default, include all data columns. """ w = Widget(section=section, title=title, rows=rows, width=width, height=height, module=__name__, uiwidget=cls.__name__) w.compute_row_col() w.options = JsonDict(columns=cols) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, height=300, keycols=None, valuecols=None, charttype='candlestick', stack_widget=False): """Create a widget displaying stock prices as a candle stick chart. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param list keycols: List of key column names to use for x-axis labels :param list valuecols: List of data columns to graph :param str charttype: Type of chart, defaults to 'candlestick'. :param bool stack_widget: stack this widget below the previous one. The Y axis of this widget can't dynamically scale to different ranges. """ w = Widget(section=section, title=title, width=width, height=height, module=__name__, uiwidget=cls.__name__, stack_widget=stack_widget) 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, 'charttype': charttype}) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, rows=10, height=300, keycols=None, valuecols=None, charttype='line', dynamic=False, stack_widget=False): """Create a widget displaying data as a chart. This class is typically not used directly, but via LineWidget or BarWidget subclasses :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param int rows: Number of rows to display (default 10) :param list keycols: List of key column names to use for x-axis labels :param list valuecols: List of data columns to graph :param str charttype: Type of chart, defaults to 'line'. This may be any YUI3 'type' :param bool dynamic: columns will be added later from criteria if True :param bool stack_widget: stack this widget below the previous one. """ w = Widget(section=section, title=title, rows=rows, width=width, height=height, module=__name__, uiwidget=cls.__name__, stack_widget=stack_widget) 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, 'charttype': charttype, 'dynamic': dynamic }) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, height=300, stacked=False, cols=None, altaxis=None, bar=False, stack_widget=False): """Create a widget displaying time-series data in a line or bar chart :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param bool stacked: If True, show multiple series as stacked :param list cols: List of columns by name to graph. If None, the default, graph all data columns. :param list altaxis: List of columns to graph using the alternate Y-axis :param bool bar: If True, show time series in a bar chart. :param bool stack_widget: stack this widget below the previous one. As an example, the following will graph four columns of data:: section.add_widget(yui3.TimeSeriesWidget, 'Bytes and Packets', stacked=True, width=12, height=450, cols=['bytes', 'rtxbytes', 'packets', 'rtxpackets'], altaxis=['packets', rtxpackets']) The columns 'bytes' and 'rtxbytes' will be graphed against the left Y-axis, 'packets' and 'rtxpackets' on the right (alternate) Y-axis. """ w = Widget(section=section, title=title, width=width, height=height, module=__name__, uiwidget=cls.__name__, stack_widget=stack_widget) w.compute_row_col() timecols = [ col.name for col in table.get_columns() if col.istime() or col.isdate() ] if len(timecols) == 0: raise ValueError("Table %s must have a datatype 'time' column for " "a timeseries widget" % str(table)) w.options = JsonDict(columns=cols, altaxis=altaxis, stacked=stacked, bar=bar) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, height=300, keycols=None, valuecols=None, charttype='candlestick'): """Create a widget displaying stock prices as a candle stick chart. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param list keycols: List of key column names to use for x-axis labels :param list valuecols: List of data columns to graph :param str charttype: Type of chart, defaults to 'candlestick'. The Y axis of this widget can't dynamically scale to different ranges. """ w = Widget(section=section, title=title, 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, 'charttype': charttype}) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, rows=10, height=300): """Create a widget displaying data in a pie chart. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param int rows: Number of rows to display (default 10) The labels are taken from the Table key column (the first key, if the table has multiple key columns defined). The pie widget values are taken from the sort column. """ 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.sortcols is None: raise ValueError("Table %s does not have a sort column defined" % str(table)) w.options = JsonDict(key=keycols[0], value=table.sortcols[0]) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, height=300, stacked=False, cols=None, altaxis=None, bar=False, stack_widget=False): """Create a widget displaying time-series data in a line or bar chart :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param bool stacked: If True, show multiple series as stacked :param list cols: List of columns by name to graph. If None, the default, graph all data columns. :param list altaxis: List of columns to graph using the alternate Y-axis :param bool bar: If True, show time series in a bar chart. :param bool stack_widget: stack this widget below the previous one. As an example, the following will graph four columns of data:: section.add_widget(yui3.TimeSeriesWidget, 'Bytes and Packets', stacked=True, width=12, height=450, cols=['bytes', 'rtxbytes', 'packets', 'rtxpackets'], altaxis=['packets', rtxpackets']) The columns 'bytes' and 'rtxbytes' will be graphed against the left Y-axis, 'packets' and 'rtxpackets' on the right (alternate) Y-axis. """ w = Widget(section=section, title=title, width=width, height=height, module=__name__, uiwidget=cls.__name__, stack_widget=stack_widget) w.compute_row_col() timecols = [col.name for col in table.get_columns() if col.istime() or col.isdate()] if len(timecols) == 0: raise ValueError("Table %s must have a datatype 'time' column for " "a timeseries widget" % str(table)) w.options = JsonDict(columns=cols, altaxis=altaxis, stacked=stacked, bar=bar) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, rows=10, height=300, keycols=None, valuecols=None, charttype='line', dynamic=False, stack_widget=False): """Create a widget displaying data as a chart. This class is typically not used directly, but via LineWidget or BarWidget subclasses :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param int rows: Number of rows to display (default 10) :param list keycols: List of key column names to use for x-axis labels :param list valuecols: List of data columns to graph :param str charttype: Type of chart, defaults to 'line'. This may be any YUI3 'type' :param bool dynamic: columns will be added later from criteria if True :param bool stack_widget: stack this widget below the previous one. """ w = Widget(section=section, title=title, rows=rows, width=width, height=height, module=__name__, uiwidget=cls.__name__, stack_widget=stack_widget) 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, 'charttype': charttype, 'dynamic': dynamic}) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, height=300, lat_col=None, long_col=None, val_col=None, label_col=None, url_col=None, min_bounds=None): """Create a widget displaying data overlayed on a map. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param float lat_col, 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. :param str/col val_col: the data column to graph, defaults to the first non-key column found assigned to the table. :param str/col label_col: column to use for marker labels when when defining lat/long columns. :param str url_col: column to use for URL to redirect to when marker gets cliecked. :param tuple min_bounds: 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, url=url_col, min_bounds=min_bounds) w.save() w.tables.add(table)
def create(cls, section, table, title, width=6, height=300, lat_col=None, long_col=None, val_col=None, label_col=None, url_col=None, min_bounds=None): """Create a widget displaying data overlayed on a map. :param int width: Width of the widget in columns (1-12, default 6) :param int height: Height of the widget in pixels (default 300) :param float lat_col, 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. :param str/col val_col: the data column to graph, defaults to the first non-key column found assigned to the table. :param str/col label_col: column to use for marker labels when when defining lat/long columns. :param str url_col: column to use for URL to redirect to when marker gets cliecked. :param tuple min_bounds: 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, url=url_col, min_bounds=min_bounds) w.save() w.tables.add(table)