Yuri Astrakhan
Yuri Astrakhan

Reputation: 10035

Concatenating multiple data sources in Vega

In Vega, I have multiple data sources, and sometimes I want to merge them together one after another. For example, given sources A, B, and C, with two columns - date and value, I might want to create a combined data source with columns date, value, source, where the last column's values will be A, B, or C. Lookup transformation does not seem to be working for this because dates are not necessarily matching. Thanks!

Upvotes: 4

Views: 4127

Answers (2)

Iain Dillingham
Iain Dillingham

Reputation: 625

I don't think it's possible to merge multiple datasets within Vega [version 2 only, it is possible in v3 -- added by @yurik], unfortunately. Adding a new field (column) to an existing dataset is straightforward: use the formula transform. I'm stuck for an answer to the merge question, though.

Did you ask the merge question out of interest or out of necessity? If the latter, then you could merge the datasets outside Vega -- using d3, for example -- and then pass the new dataset at runtime.

Upvotes: 2

Yuri Astrakhan
Yuri Astrakhan

Reputation: 10035

As of Vega 3, it is possible to concatenate multiple data sources using source field in the data section:

 "source": ["source1", "source2", ...]`

The feature was added in v3.0.0-rc7.

Upvotes: 4

Related Questions