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

How to remove legends ? #42

Closed
yormi opened this issue Mar 11, 2018 · 4 comments
Closed

How to remove legends ? #42

yormi opened this issue Mar 11, 2018 · 4 comments

Comments

@yormi
Copy link

yormi commented Mar 11, 2018

Hi there !

I was just wondering if there is a way to remove the legends ?

Btw, your library is lovely to use. Thanks ! :)

@jwoLondon
Copy link
Member

Yes. Simply add an MLegend type with an empty list to the encoding that would otherwise generate a legend. For example,

barChart : Spec
barChart =
    let
        data =
            dataFromColumns []
                << dataColumn "a" (Strings [ "A", "B", "C" ])
                << dataColumn "b" (Numbers [ 28, 55, 43 ])

        enc =
            encoding
                << position X [ PName "a", PmType Ordinal ]
                << position Y [ PName "b", PmType Quantitative ]
                << color [ MName "a", MmType Nominal, MLegend [] ]
    in
    toVegaLite [ data [], mark Bar [], enc [] ]

@yormi
Copy link
Author

yormi commented Mar 11, 2018

Lovely ! Thank you for the quick reply !

Is it in the doc ? Otherwise I'd suggest to add it. Personnally, I just found in vega-lite doc:

User can set the legend property of a mark property channel’s field definition to an object to customize legend properties or set legend to null to remove the legend.

and I was a bit confused on how to represent null in elm haha

@jwoLondon
Copy link
Member

You are right about it not being obvious in the docs, so I've added this to the next release documentation (under the color function).

In general, where Vega-Lite says null elm-vega uses [] for lists, "" for strings and Nothing for numeric values.

Thanks very much for raising this issue.

@yormi
Copy link
Author

yormi commented Mar 14, 2018

Great ! I looked at your commit and was wondering if the following:

In general, where Vega-Lite says null elm-vega uses [] for lists, "" for strings and Nothing for numeric values.

apply to more than the legend and the axis. If yes, I'd suggest to add it in a general section in the beginning.

Thanks again for the tremendous work !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants