altair icon indicating copy to clipboard operation
altair copied to clipboard

Consistently show or hide warning message from Vega-Lite

Open joelostblom opened this issue 2 years ago • 2 comments

I noticed Vega-Lite warnings are hidden when using the default html renderer but visible when renderer with vl-convert. I think we should make it consistent so that they are either always hidden or always visible. I am not sure if the VL warnings are mostly helpful or mostly a nuisance at the Altair level. E.g. the warning in the example below suggest that we shouldn't use a quantitative variable for faceting which on the one hand sounds like sound advice, but also works without any issues and seems reasonable if it is intentional although maybe changing to nominal is better for some reason and more future proof? Probably a good idea to show the warnings?

import altair as alt
import pandas as pd


source = pd.DataFrame(
    [
        {"a": "a1", "b": "b2", "c": "z", "p": "0.55"},
        {"a": "a1", "b": "b3", "c": "y", "p": "0.58"},
    ]
)

chart = alt.Chart(source, width=60, height=alt.Step(8)).mark_bar().encode(
    alt.Y("c:N").axis(None),
    alt.X("a:N").title("Factor A"),
    alt.Row("p:Q").header(format=".0%"),
)

image

joelostblom avatar Aug 04 '23 06:08 joelostblom

In the vl-convert case, I believe these warnings are written to standard error by Vega-Lite inside the deno runtime. I'm actually not sure off hand how to intercept them, but it's probably doable.

jonmmease avatar Aug 04 '23 10:08 jonmmease

As I'm using vegafusion more, I'm noticing that some of these warnings are quite informative. For example, I didn't know that vega-lite automatically switched a line mark with an x2 encoding to a rule mark:

image

And still, I haven't run into an instance where the warning helped me do something I couldn't do earlier, it's just more information of what is happening under the hood (here, automatically switching the mark).

joelostblom avatar Aug 31 '23 17:08 joelostblom