Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
How can we proramatically generate vega grammar JSON from vega-lite plot?

I am able to get vega json grammar on local installation of nodejs with vega-lite and vega-lite-api installed through npm as follows:

vl = require('vega-lite') 
vla = require('vega-lite-api') 
data = require('vega-datasets') 

const df2 = data['movies.json']()

const plot = vla.markBar().data(df2).encode(
    vla.x().fieldQ('IMDB_Rating').bin(true),
    vla.y().count()
  )

vega_lite_json = plot.toObject();
vega_json = vl.compile(plot.toObject()).spec;

However I am unable to make it work in Observablehq.

I am not able to do last line: vl.compile(...). This is what I have did:

vegalite = require("@observablehq/vega-lite@0.2")
vegalite.compile(plot.toObject()).spec;

It says: TypeError: vegalite.compile is not a function Here is link to my observablehq notebook cell executing vegalie.compile(...).

What I am doing wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

the vegalite compile option is located within the vl object, like this: vl.vegalite.compile(...)

Here's a notebook with the modified code: https://observablehq.com/@shan/untitled/6

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!