Vega-lite: Field name doesn't accept two or more dots

Created on 18 Sep 2019  路  6Comments  路  Source: vega/vega-lite

I am having trouble with field names that have two or more dots.

According to the field documentation (https://vega.github.io/vega/docs/types/#Field), _To specify field names that contain dots but are not nested lookups, escape the dot inline ("my\\.field") or enclose the field name in brackets ("[my.field]")._

I can do this only with one dot. The following example (a.b) works well in the Vega Editor:

{
  "data": {
    "values": [
      {
        "color": "default",
        "a.b": 28
      }
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {
      "field": "color",
      "type": "nominal"
    },
    "y": {
      "field": "[a.b]",
      "type": "quantitative"
    }
  }
}

However, I can't get something like a.b.c working, neither with

"y": {
      "field": "[a.b.c]",
      "type": "quantitative"
    }

nor with

"y": {
      "field": "a\\.b\\.c",
      "type": "quantitative"
    }

Is this how it is supposed to work, or is this a bug?

Hope I was clear, thanks!

Bug

Most helpful comment

Ahh, looks like we only replace the first ..

Screen Shot 2019-09-18 at 13 35 47

> 'a.b.c'.replace('.','\\.')
"a\\.b.c"

We need

> 'a.b.c'.replace(/\./g,'\\.')
"a\\.b\\.c"

All 6 comments

I have the same issue

I'll take a look. Can you make a small example and illustrate what doesn't work?

Thanks @domoritz!
Well, for example the following doesn't render a bar, like the first example.

{
  "data": {
    "values": [
      {
        "color": "default",
        "a.b.c": 28
      }
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {
      "field": "color",
      "type": "nominal"
    },
    "y": {
      "field": "a\\.b\\.c",
      "type": "quantitative"
    }
  }
}

I also tried the following, with no luck:
"field": "[a.b.c]",

Ahh, looks like we only replace the first ..

Screen Shot 2019-09-18 at 13 35 47

> 'a.b.c'.replace('.','\\.')
"a\\.b.c"

We need

> 'a.b.c'.replace(/\./g,'\\.')
"a\\.b\\.c"

Great, thanks!

Thank you for the bug report.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

learnwithratnesh picture learnwithratnesh  路  4Comments

paintdog picture paintdog  路  4Comments

kanitw picture kanitw  路  3Comments

iliatimofeev picture iliatimofeev  路  3Comments

kanitw picture kanitw  路  3Comments