gicentre / elm-vegalite

Elm - Vega-Lite Integration for functional declarative visualization

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to handle 'text: [...]' setting?

DougBurke opened this issue · comments

I was going through the Vega-Lite examples for hvega, and came to https://vega.github.io/vega-lite/examples/concat_layer_voyager_result.html which has this construct (the ability for text to take an array of strings looks to have been added somewhere in v4):

          "mark": {
            "type": "text",
            "align": "right",
            "style": "arrow-label",
            "text": ["Polestar", "More Valuable"]
          },

My current approach in hvega is to add an equivalent to maText but for lists - e.g.

maTexts : List String -> MarkProperty

An alternative was to make maText accept a list rather than a scalar (I'm not sure which is better).

I know you have a version of this visualization in your gallery code, but it looks like it requires a lot more work to get a similar display than supporting lists for text.

I haven't checked to see if any of the other mark properties can now take lists. I guess I should.

Thanks for raising this. In order to avoid inflating the API, I have simply allowed maText to accept multi-line strings (or strings with '\n' within them). This is consistent with multi-line text handling elsewhere (mStr, title etc.).

I've updated the Likert example to reflect this.

For anyone wishing to allow input of string lists, it would be a simple case of creating a helper function List.intersperse "\n" >> String.concat