How to use the altair.vegalite.v2.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 / v2 / 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 / v2 / schema / mixins.py View on Github external
    @use_signature(core.BarConfig)
    def configure_bar(self, *args, **kwargs):
        copy = self.copy(deep=False)
        if copy.config is Undefined:
            copy.config = core.Config()
        else:
            copy.config = copy.config.copy(deep=False)
        copy.config["bar"] = core.BarConfig(*args, **kwargs)
        return copy
github altair-viz / altair / altair / vegalite / v2 / schema / mixins.py View on Github external
def configure_header(self, *args, **kwargs):
        copy = self.copy(deep=False)
        if copy.config is Undefined:
            copy.config = core.Config()
        else:
            copy.config = copy.config.copy(deep=False)
        copy.config["header"] = core.HeaderConfig(*args, **kwargs)
        return copy
github altair-viz / altair / altair / vegalite / v2 / api.py View on Github external
column using `alt.repeat('row')` and `alt.repeat('column')`.

        Parameters
        ----------
        row : list
            a list of data column names to be mapped to the row facet
        column : list
            a list of data column names to be mapped to the column facet

        Returns
        -------
        chart : RepeatChart
            a repeated chart.

        """
        repeat = core.Repeat(row=row, column=column)
        return RepeatChart(spec=self, repeat=repeat, **kwargs)
github altair-viz / altair / altair / vegalite / v2 / api.py View on Github external
@utils.use_signature(core.VgBinding)
def binding(input, **kwargs):
    """A generic binding"""
    return core.VgBinding(input=input, **kwargs)
github altair-viz / altair / altair / vegalite / v2 / api.py View on Github external
# (layer, hconcat, vconcat, facet, repeat)
TOPLEVEL_ONLY_KEYS = {'background', 'config', 'autosize', 'padding', '$schema'}


def _get_channels_mapping():
    mapping = {}
    for attr in dir(channels):
        cls = getattr(channels, attr)
        if isinstance(cls, type) and issubclass(cls, core.SchemaBase):
            mapping[cls] = attr.replace('Value', '').lower()
    return mapping


# -------------------------------------------------------------------------
# Tools for working with selections
class SelectionMapping(core.VegaLiteSchema):
    """A mapping of selection names to selection definitions.

    This is designed to match the schema of the "selection" property of
    top-level objects.
    """
    _schema = {
        'type': 'object',
        'additionalPropeties': {'$ref': '#/definitions/SelectionDef'}
    }
    _rootschema = core.Root._schema

    def __add__(self, other):
        if isinstance(other, SelectionMapping):
            copy = self.copy()
            copy._kwds.update(other._kwds)
            return copy
github altair-viz / altair / altair / vegalite / v2 / api.py View on Github external
})

        """
        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 / v2 / api.py View on Github external
return data

    # convert dataframes to dict
    if isinstance(data, pd.DataFrame):
        data = pipe(data, data_transformers.get())

    # convert string input to a URLData
    if isinstance(data, str):
        data = core.UrlData(data)

    # consolidate inline data to top-level datasets
    if data_transformers.consolidate_datasets:
        data = _consolidate_data(data, context)

    # if data is still not a recognized type, then return
    if not isinstance(data, (dict, core.Data)):
        warnings.warn("data of type {} not recognized".format(type(data)))

    return data
github altair-viz / altair / altair / vegalite / v2 / api.py View on Github external
@utils.use_signature(core.IntervalSelection)
def selection_interval(**kwargs):
    """Create a selection with type='interval'"""
    return selection(type='interval', **kwargs)
github altair-viz / altair / altair / vegalite / v2 / schema / channels.py View on Github external
----------

    condition : anyOf(:class:`ConditionalMarkPropFieldDef`, :class:`ConditionalValueDef`,
    List(:class:`ConditionalValueDef`))
        A field definition or one or more value definition(s) with a selection predicate.
    value : anyOf(float, string, boolean)
        A constant value in visual domain.
    """
    _class_is_valid_at_instantiation = False
    _encoding_name = "opacity"

    def __init__(self, value, condition=Undefined, **kwds):
        super(OpacityValue, self).__init__(value=value, condition=condition, **kwds)


class Order(FieldChannelMixin, core.OrderFieldDef):
    """Order schema wrapper

    Mapping(required=[shorthand])

    Attributes
    ----------

    shorthand : string
        shorthand for field, aggregate, and type
    aggregate : :class:`Aggregate`
        Aggregation function for the field
        (e.g., ``mean``, ``sum``, ``median``, ``min``, ``max``, ``count`` ).

        **Default value:** ``undefined`` (None)
    bin : anyOf(boolean, :class:`BinParams`)
        A flag for binning a ``quantitative`` field, or `an object defining binning