cancel
Showing results for 
Search instead for 
Did you mean: 

using multiple datasources in a Vega visualisation element for Kx

simon_watson_sj
New Contributor III
Hi, 

I have set up some visualisations using Kx Dash and am looking to use an edge bundling vega dashboard based on this template:

https://vega.github.io/editor/#/examples/vega/edge-bundling

I note that there are multiple datasources required. 
My understanding is that the Kx implementation of Vega works by replacing the first datasource in the Vega config with a datasource specified in the 'Data Source' config of the Vega dash element.
Could you advise if you know of a way of passing multiple data sources to the vega visualisation?

I had thought an approach would be to pass the data in JSON format actually within the Vega config, leaving the 'Data Source' element on the Kx Dash side blank. However, I have got as far as passing a Vega Script from an Analytic function as a datasource in the dash. I do not know how to get this script from a datasource and into a Viewstate that I can then use to assign to the 'Vega Config' in the dash element. 

Is this a reasonable approach? If so, how might I get a Vega script generated on the fly from an Analytic function (query) to the 'Vega Config' in my dashboard element and how do I ensure it updates as I set filters and the like? (For instance, would I set an action to query the datasource?)

Thanks and regards,

Simon
1 REPLY 1

simon_watson_sj
New Contributor III

I worked this out myself eventually. The trick is to write an analytic that takes in data, converts it to JSON and then writes a new vega script around it. That is then passed back to the vega element in the dashboard via a viewstate from a query mapper. Any dashboard controls can be used to operate on the analytic writing the vega script. Sounds like it would be too clunky to work but it's seamless.