Skip to content

Allow VegaLite to accept either dict or JSON string? #33

@jakevdp

Description

@jakevdp

This came up in our chat – I think it's a good idea.

Could look something like this:

class Vegalite(object):
    def __init__(self, spec):
        try:
            spec = json.loads(spec)
        except TypeError:
            pass
        if 'data' not in spec:
            raise KeyError('No data provided with spec')
        self.spec = utils.update(spec, DEFAULTS, overwrite=False)

Advantage is more flexible API & ability to out-source dataframe formatting stuff to Pandas; the disadvantage is that in some situations we'd add an extra string->dict->string cycle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions