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

196
Views
Getting "SyntaxError: Unexpected token" in Observable

I was trying vega-lite-api on observablehq here.

This is my code:

Putting these two in different cells work:

obj = vl.markPoint()
  .data(df)
  .encode(vl.y().fieldN('city'));

In next cell:

obj.render()

If I put both in the same cell, it gives SyntaxError: Unexpected token:

obj2 = vl.markPoint()
  .data(df)
  .encode(vl.y().fieldN('city'));

obj2.render();
^

Why is this so?

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

0

If you want to put the code into the same cell, you can either chain the call to render like so:

vl.markPoint()
  .data(df)
  .encode(vl.y().fieldN('city'))
  .render()

Or you can use a block cell with curly braces like so:

{
  const obj = vl.markPoint()
    .data(df)
    .encode(vl.y().fieldN('city'));

  return obj.render();
}

For more on Observable JavaScript:

https://observablehq.com/@observablehq/observables-not-javascript

about 4 years ago · Juan Pablo Isaza Report

0

for obj you have a definition before you use it...

obj = N {
  Symbol(data): Object {mark: h, data: Object, encoding: h}
  <prototype>: N {}
}

I guess you forgot about it for obj2?

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!