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

Vega plots rendered in VS Code are not aware of the themes #11292

Closed
DonJayamanne opened this issue Sep 6, 2022 · 4 comments
Closed

Vega plots rendered in VS Code are not aware of the themes #11292

DonJayamanne opened this issue Sep 6, 2022 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded

Comments

@DonJayamanne
Copy link
Contributor

Whether we're using dark or light them, the plot is still a light styled plot.
In JLab it changes based on the theme.
Should we change this, what if user want the old light style plots even in dard vscode themes?

@DonJayamanne DonJayamanne added the bug Issue identified by VS Code Team member as probable bug label Sep 6, 2022
@DonJayamanne DonJayamanne self-assigned this Sep 6, 2022
@DonJayamanne
Copy link
Contributor Author

Fixed, this should now work.

Note: vega supports light and dark themes, hence if you use light or dark themes, the vega output will change accrodingly.

Testing instructions:

  • Install latest VS Code Insiders, Jupyter pre-release and Notebook renderers extension
  • Install the following python packages
    pip install altair, vega, vega-datasets
  • Run a cell in a notebook with light theme
import altair as alt
from vega_datasets import data

# Show an image where the interactive plot is not supported
alt.renderers.enable('mimetype')

source = data.cars()

alt.Chart(source).mark_boxplot().encode(
    x='Origin',
    y=alt.Y(alt.repeat('column'), type='quantitative'),
).repeat(column=['Horsepower', 'Weight_in_lbs'])
  • Change the theme and run the previous cell again
  • Run a cell in a notebook with light theme
from IPython.display import display

display({
    "application/vnd.vegalite.v3+json": {
        "$schema": "https://vega.github.io/schema/vega-lite/v3.json",
        "description": "A simple bar chart with embedded data.",
        "data": {
            "values": [
                {"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
                {"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
                {"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
            ]
        },
        "mark": "bar",
        "encoding": {
            "x": {"field": "a", "type": "ordinal"},
            "y": {"field": "b", "type": "quantitative"}
        }
    }
}, raw=True)
  • Change the theme and run the previous cell again

@DonJayamanne DonJayamanne added this to the September 2022 milestone Sep 26, 2022
@mjbvz mjbvz added the verified Verification succeeded label Sep 29, 2022
@joelostblom
Copy link

@DonJayamanne Is it possible to use a light theme for vegalite/altair when the dark theme is enabled in VS Code? This is a quite important use case since it allows you to see what the plot would look like for others outside the editor. It seems like setting it back to "default" does not work and it is still dark:

image

Also see vega/vega-themes#413

@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Oct 15, 2022

@joelostblom
please could you file a separate feature request.

@joelostblom
Copy link

@DonJayamanne Follow up here #11670

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants