Closed pmackay closed 3 years ago
Hey @pmackay, if I understand correctly, there's not a way to load an existing Vega spec into a Vega.lite
or Vega.start
object. Can you share more about the use case?
The use case is that Airtable has add-on apps, including one to render charts using Vega based on the data in a Base. These are configured with a Vega JSON config that typically has all the config settings except the data source. I would like to recreate those charts in a Rails app!
Sounds like perhaps the best way is to define a separate JSON endpoint that can serve the data from the Rails app and set that as the URL in the config thats passed to the call to Vega.display
?
Yeah, you can add a data
key to the spec hash directly (spec[:data] = {url: "..."}
for a URL) and pass it to Vega.render
for Rails (or Vega.display
for iRuby) without the need to create a Vega.lite
or Vega.start
object.
Great, I have this working, thanks for help!
The docs describe how to make API calls to set the data and then build up the chart configuration. Separately a whole chart can be configured using a Vega spec, which includes a data location.
Is there a way to configure a chart using a Vega spec, but make an API call to independently set the data?
Thanks!