How to use the altair.vegalite.v3.schema.core function in altair

To help you get started, we’ve selected a few altair examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github altair-viz / altair / altair / vegalite / v3 / api.py View on Github external
raise ValueError("Only chart objects can be layered.")
    if  _get(spec, 'facet') is not Undefined:
        raise ValueError("Faceted charts cannot be layered.")
    if isinstance(spec, FacetChart) or _get(spec, 'facet') is not Undefined:
        raise ValueError("Faceted charts cannot be layered.")
    if isinstance(spec, RepeatChart) or _get(spec, 'repeat') is not Undefined:
        raise ValueError("Repeat charts cannot be layered.")
    if isinstance(spec, ConcatChart) or _get(spec, 'concat') is not Undefined:
        raise ValueError("Concatenated charts cannot be layered.")
    if isinstance(spec, HConcatChart) or _get(spec, 'hconcat') is not Undefined:
        raise ValueError("Concatenated charts cannot be layered.")
    if isinstance(spec, VConcatChart) or _get(spec, 'vconcat') is not Undefined:
        raise ValueError("Concatenated charts cannot be layered.")


@utils.use_signature(core.TopLevelRepeatSpec)
class RepeatChart(TopLevelMixin, core.TopLevelRepeatSpec):
    """A chart repeated across rows and columns with small changes"""
    def __init__(self, data=Undefined, spec=Undefined, repeat=Undefined, **kwargs):
        _check_if_valid_subspec(spec, 'RepeatChart')
        super(RepeatChart, self).__init__(data=data, spec=spec, repeat=repeat, **kwargs)

    def interactive(self, name=None, bind_x=True, bind_y=True):
        """Make chart axes scales interactive

        Parameters
        ----------
        name : string
            The selection name to use for the axes scales. This name should be
            unique among all selections within the chart.
        bind_x : boolean, default True
            If true, then bind the interactive scales to the x-axis
github altair-viz / altair / altair / vegalite / v3 / api.py View on Github external
@utils.use_signature(core.Binding)
def binding(input, **kwargs):
    """A generic binding"""
    return core.Binding(input=input, **kwargs)
github altair-viz / altair / altair / vegalite / v3 / api.py View on Github external
@utils.use_signature(core.BindCheckbox)
def binding_checkbox(**kwargs):
    """A checkbox binding"""
    return core.BindCheckbox(input='checkbox', **kwargs)
github altair-viz / altair / altair / vegalite / v3 / schema / mixins.py View on Github external
def configure_selection(self, *args, **kwargs):
        copy = self.copy(deep=['config'])
        if copy.config is Undefined:
            copy.config = core.Config()
        copy.config["selection"] = core.SelectionConfig(*args, **kwargs)
        return copy
github altair-viz / altair / altair / vegalite / v3 / schema / mixins.py View on Github external
    @use_signature(core.AreaConfig)
    def configure_area(self, *args, **kwargs):
        copy = self.copy(deep=['config'])
        if copy.config is Undefined:
            copy.config = core.Config()
        copy.config["area"] = core.AreaConfig(*args, **kwargs)
        return copy
github altair-viz / altair / altair / vegalite / v3 / schema / mixins.py View on Github external
    @use_signature(core.RectConfig)
    def configure_rect(self, *args, **kwargs):
        copy = self.copy(deep=['config'])
        if copy.config is Undefined:
            copy.config = core.Config()
        copy.config["rect"] = core.RectConfig(*args, **kwargs)
        return copy
github altair-viz / altair / altair / vegalite / v3 / api.py View on Github external
op: 'sum'
          })]
        })

        """
        if kwargs:
            if window is Undefined:
                window = []
            for as_, shorthand in kwargs.items():
                kwds = {'as': as_}
                kwds.update(utils.parse_shorthand(shorthand,
                                                  parse_aggregates=False,
                                                  parse_window_ops=True,
                                                  parse_timeunits=False,
                                                  parse_types=False))
                window.append(core.WindowFieldDef(**kwds))

        return self._add_transform(core.WindowTransform(window=window, frame=frame, groupby=groupby,
                                                        ignorePeers=ignorePeers, sort=sort))
github altair-viz / altair / altair / vegalite / v3 / api.py View on Github external
If the lengths of parallel arrays do not match,
            the longest array will be used with ``null`` values added for missing entries.
        as : List(string)
            The output field names for extracted array values.
            **Default value:** The field name of the corresponding array field

        Returns
        -------
        self : Chart object
            returns chart to allow for chaining

        See Also
        --------
        alt.FlattenTransform : underlying transform object
        """
        return self._add_transform(core.FlattenTransform(flatten=flatten, **{'as': as_}))
github altair-viz / altair / altair / vegalite / v3 / api.py View on Github external
@utils.use_signature(core.MultiSelection)
def selection_multi(**kwargs):
    """Create a selection with type='multi'"""
    return selection(type='multi', **kwargs)
github altair-viz / altair / altair / vegalite / v3 / api.py View on Github external
def _consolidate_data(data, context):
    """If data is specified inline, then move it to context['datasets']

    This function will modify context in-place, and return a new version of data
    """
    values = Undefined
    kwds = {}

    if isinstance(data, core.InlineData):
        if data.name is Undefined and data.values is not Undefined:
            values = data.values
            kwds = {'format': data.format}

    elif isinstance(data, dict):
        if 'name' not in data and 'values' in data:
            values = data['values']
            kwds = {k:v for k,v in data.items() if k != 'values'}

    if values is not Undefined:
        name = _dataset_name(values)
        data = core.NamedData(name=name, **kwds)
        context.setdefault('datasets', {})[name] = values

    return data