Skip to content
/ httpgd-js Public

JavaScript R httpgd GraphicsDevice API and connection handler

Notifications You must be signed in to change notification settings

nx10/httpgd-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

R httpgd GraphicsDevice API and connection handler

API and connection handler to connect with R httpgd servers.

Features

  • Simplify httpgd server access from JavaScript
  • Full TypeScript type definitions
  • Automatic WebSocket connection with polling fallback and reconnection

Usage

Base usage

Minimal example how to listen for server side changes:

import { Httpgd } from 'httpgd';

const httpgd = new Httpgd('127.0.0.1:1234', 'mytoken', true);
httpgd.onPlotsChanged((newState) => console.log(newState));
httpgd.connect();

// httpgd.removePlot(...)
// httpgd.getPlotURL(...)

Advanced usage example: The client included in the httpgd R package.

Direct API access

In applications where there is no need to continuously listen for server side changes, httpgd APIs can also be called directly using the api module.

Example:

import { url_plot } from 'httpgd/lib/api';

const url = url_plot({ host: '127.0.0.1:1234' }, { id: 'myPlotId' });
document.getElementsByTagName('img')[0].src = url;

License

MIT

About

JavaScript R httpgd GraphicsDevice API and connection handler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published