예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
    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)
예제 #10
0
    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)
예제 #11
0
    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)