Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda