Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow providing DataFrame as part of vega(-lite) spec #6979

Merged
merged 2 commits into from
Jul 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions panel/tests/pane/test_vega.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
altair_available = pytest.mark.skipif(alt is None, reason="requires altair")

import numpy as np
import pandas as pd

import panel as pn

Expand Down Expand Up @@ -38,6 +39,18 @@
'$schema': 'https://vega.github.io/schema/vega-lite/v3.2.1.json'
}

vega_df_example = {
'config': {
'mark': {'tooltip': None},
'view': {'height': 300, 'width': 400}
},
'data': {'values': pd.DataFrame({'x': ['A', 'B', 'C', 'D', 'E'], 'y': [5, 3, 6, 7, 2]})},
'mark': 'bar',
'encoding': {'x': {'type': 'ordinal', 'field': 'x'},
'y': {'type': 'quantitative', 'field': 'y'}},
'$schema': 'https://vega.github.io/schema/vega-lite/v3.2.1.json'
}

vega4_selection_example = {
'config': {'view': {'continuousWidth': 300, 'continuousHeight': 300}},
'data': {'url': 'https://raw.githubusercontent.com/vega/vega/master/docs/data/penguins.json'},
Expand Down Expand Up @@ -194,8 +207,9 @@ def test_get_vega_pane_type_from_dict():
assert PaneBase.get_pane_type(vega_example) is Vega


def test_vega_pane(document, comm):
pane = pn.panel(vega_example)
@pytest.mark.parametrize('example', [vega_example, vega_df_example])
def test_vega_pane(document, comm, example):
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
pane = pn.panel(example)

# Create pane
model = pane.get_root(document, comm=comm)
Expand Down
Loading