question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

reference data by url as signal in compiled vega

See original GitHub issue

As was concluded in this issue: https://github.com/vega/vega/issues/2597.

In a VL spec where the data is referenced by values such as:

"data": {
  "name": "SOURCE",
  "values": {
    "nested": [
      {"key": "alpha", "foo": [1, 2], "bar": ["A", "B"]},
      {"key": "beta", "foo": [3, 4, 5], "bar": ["C", "D"]}
    ]
  },
  "format": {"property": "nested"}
}

Is compiled into Vega as such (stripped):

{
  "data": [
    {
      "name": "SOURCE",
      "values": {
        "nested": [
          {"key": "alpha", "foo": [1, 2], "bar": ["A", "B"]},
          {"key": "beta", "foo": [3, 4, 5], "bar": ["C", "D"]}
        ]
      },
      "format": {"property": "nested"}
    },
    {
      "name": "data_0",
      "source": "SOURCE",
      "transform": [
        {"type": "flatten", "fields": ["foo", "bar"], "as": ["foo", "bar"]}
      ]
    }
  ]
}

In a VL spec where the same data is referenced by url such as:

"data": {
  "name": "SOURCE",
  "url": "https://tsws.hkvservices.nl/mangrove.ws/data.ashx?function=dataportal.db.getdata&parameters={database:%27vega%27,key:%27nested_data%27}&contentType=application/json",
  "format": {"property": "nested"}
}

The Vega is compiled as such (stripped):

{
  "data": [
    {
      "name": "SOURCE",
      "url": "https://tsws.hkvservices.nl/mangrove.ws/data.ashx?function=dataportal.db.getdata&parameters={database:%27vega%27,key:%27nested_data%27}&contentType=application/json",
      "format": {"property": "nested", "type": "json"},
      "transform": [
        {"type": "flatten", "fields": ["foo", "bar"], "as": ["foo", "bar"]}
      ]
    }
  ]
}

In the latter the transform is applied in the same data source. This misalignment leads to confusing behaviour when removing datasets from the chart, as was discussed in above mentioned issue.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
domoritzcommented, May 12, 2020

That super useful context! Let’s try to create signals for data URLs then. I bumped the priority up.

0reactions
mattijncommented, May 11, 2020

For companies that work with multiple people with different skills-set, such as:

Untitled Diagram-2

  • Data comes from person a
  • Vega(-Lite/Altair) specifications comes from person b
  • Person c combines all together within an app or web application.

Data is improved all the time and Vega(-Lite) specifications mature over time as well. Being able to reference data by URL dynamically is a real pain reliever.

For that reason the applications we develop are roughly 75% referenced by URL (through signal) and 25% referenced by values.

It’s not that we don’t reference by values, but adopting the URL-signal route comes naturally as it is:

  • very convenient for person c (an improved json-spec can be updated by merely a copy+paste in the front-end) and
  • person b can develop/improve/debug instantaneously in Vega-editor.

Especially with a growing Altair/Vega-Lite community it would be great that these people can directly integrate their visuals within bigger frameworks as is possible with Vega specifications.

Read more comments on GitHub >

github_iconTop Results From Across the Web

View API | Vega
View API Reference. View Construction; View Configuration; Dataflow and Rendering; Signals; Event Handling; Image Export; Data and Scales ...
Read more >
Easing into Vega from Vega-Lite / IAT355 - Observable
In most cases, one simply needs to reference a named data set defined in the top-level data property. If no from property is...
Read more >
Get clicked mark data using react-vega and vega-lite
Switch to vega by compiling my vega-lite spec into vega spec and then adding the signals block worked.
Read more >
Vega | Kibana Guide [master] - Elastic
Vega and Vega-Lite panels can display one or more data sources, including Elasticsearch, Elastic Map Service, URL, or static data, and support Kibana ......
Read more >
vegawidget: 'Htmlwidget' for 'Vega' and 'Vega-Lite'
URL https://vegawidget.github.io/vegawidget/ ... signal-handler and data-handler arguments: name, value. • event-handler arguments: event, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found