Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot with webR console #256

Closed
thomasdenecker opened this issue Aug 21, 2023 · 1 comment
Closed

Plot with webR console #256

thomasdenecker opened this issue Aug 21, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@thomasdenecker
Copy link

Hello,

First of all, a huge thank you for your fantastic work! R has never been more accessible to users! Congratulations !

Bug

I've detected a bug when I try to make a plot using the console. This bug can be reproduced using the demo on the following page:
https://docs.r-wasm.org/webr/latest/examples.html

By typing plot and observing the javascript console log, we can read

console.ts:174 Unhandled output type for webR Console: canvas.
run_fn @ console.ts:174

Suggestions

Way 1 : change console.ts

To correct this bug, I've changed this locally:

async #run() {
  for (;;) {
    const output = await this.webR.read();
    switch (output.type) {
      case 'stdout':
        this.#stdout(output.data as string);
        break;
      case 'stderr':
        this.#stderr(output.data as string);
        break;
      case 'prompt':
        this.#prompt(output.data as string);
        break;
      case 'canvas':
        this.#canvasImage(output.data.image as ImageBitmap);
        break;
      case 'closed':
        return;
      default:
        console.warn(`Unhandled output type for webR Console: ${output.type}.`);
    }
  }
}

Change type of output from console

Currently, when a plot is generated by the console, its output.type is canvas and not canvasImage. The second solution is to change this output type.

I hope this will be useful to you.

Many thanks again for your work!
See you soon!

@georgestagg
Copy link
Member

Thank you for reporting this! Indeed, this does look like a typo.

I'll get this fixed, hopefully for a 0.2.1 patch release, and try to add a unit test to catch future similar regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants