question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tfjs-vis - error in vega rendering scatterplot - basic example from the docs

See original GitHub issue

TensorFlow.js version

@tensorflow/tfjs”: “^2.0.0”, “@tensorflow/tfjs-vis”: “^1.4.0”,

Browser version

Safari Version 13.0.3 (15608.3.10.1.4) Chrome Version 83.0.4103.97 (Offizieller Build) (64-Bit)

Describe the problem

I want to run sample code for scatterplot from documentation in a React/Storybook setup. An exception is thrown:

“Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating ‘code.length’)”

this is the line in vega: https://github.com/vega/vega/blob/62565bbe084a422c4a0cbc6e19c6f7c45a3e5137/packages/vega-runtime/src/expression.js#L25 operator: (ctx, expr) => expression(ctx, ['_'], expr.code),

that means the variable “code” is missing in the variable ‘expr’ which results in “undefined is not an object”. This is the content of ‘expr’, extracted from debugger:

{"offset":18,"direction":"horizontal","left":{"direction":"vertical"},"right":{"direction":"vertical"}}"

so here vega expects a field ‘code’ which is missing.

Maybe a bug in communication between ‘tfjs-vis’ and ‘vega’, or some kind of compatibility problem?

Code to reproduce the bug / link to feature request


import React from 'react';
import * as tf from '@tensorflow/tfjs';
import * as tfvis from '@tensorflow/tfjs-vis';

export function Sample() {
    const renderIt = () => {
        const doRender = async () => {
        const series1 = Array(100).fill(0)
            .map(y => Math.random() * 100 - (Math.random() * 50))
            .map((y, x) => ({ x, y, }));

         const series2 = Array(100).fill(0)
            .map(y => Math.random() * 100 - (Math.random() * 150))
            .map((y, x) => ({ x, y, }));

        const series = ['First', 'Second'];
        const data = { values: [series1, series2], series }

        const surface = { name: 'Scatterplot', tab: 'Charts' };
            const renderResult = await tfvis.render.scatterplot(surface, data);
          };
          doRender();
    }

    return <button onClick={() => renderIt()}>test render scatterplot</button>;
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tafsiricommented, Jun 10, 2020

Ok, I was able to reproduce this too, I think an older lockfile was preventing me from getting the same error, so I cleared those out. I release a pre-release with the fix, if you could give that a try and confirm it works in your setup that would be great (the issue is related to some vega dependencies). Here is that version. https://www.npmjs.com/package/@tensorflow/tfjs-vis/v/1.4.2-pre.1 its published under a ‘next’ tag on npm, so you probably have to manually set “1.4.2-pre.1” as your version for tfjs-vis in your package.json. Let me know if that works and I’ll do a regular release shortly after

0reactions
tafsiricommented, Jun 10, 2020

Thanks for confirming, https://www.npmjs.com/package/@tensorflow/tfjs-vis/v/1.4.2 has been published

Read more comments on GitHub >

github_iconTop Results From Across the Web

TensorFlow.js Vis API
tfjs-vis provides some UI helpers to make it easier to render visualizations in an unobtrusive way. Visor & Surfaces /. tfvis.visor () function...
Read more >
7 Visualizing Data and Models - Deep Learning with JavaScript
This chapter covers: How to use tfjs-vis to perform custom visualization of data; Why it is important to visualize the model-training process and...
Read more >
Scatter Plot Example - Vega & Vega-Lite
Scatter plots are ideal for visualizing the relationship between two quantitative variables. This example plots horsepower vs. mileage for a data set of...
Read more >
TensorFlow Visor - W3Schools
To use tfjs-vis, add the following script tag to your HTML file(s): ... Example with a Visor ... tfvis.render.scatterplot({name: "my Plots"}, data);.
Read more >
Deep Learning with JavaScript - FreePdf-books.com
Getting started: Simple linear regression in TensorFlow.js 37 ... Flow.js, including the examples, the documentation, and the related tooling. They.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found