Skip to content

Commit

Permalink
Add JavaScript embed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Nov 12, 2024
1 parent 832dc2f commit 116fec5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions docs/source/features/embed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# JavaScript Embed
The [`vegafusion-wasm`](https://www.npmjs.com/package/vegafusion-wasm) NPM package provides a JavaScript API for embedding Vega charts backed by VegaFusion in web applications. These charts can be connected to a local VegaFusion runtime compiled to WebAssembly, or a remote VegaFusion server over gRPC-Web.

## Usage
See the [vegafusion-wasm README](https://github.com/vega/vegafusion/blob/v2/vegafusion-wasm/README.md) for usage instructions.

## Demo
See [editor demo](https://github.com/vega/vegafusion/tree/v2/examples/editor-demo) for a complete example.
1 change: 1 addition & 0 deletions docs/source/features/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ transform_extract
chart_state
inline_datasets
grpc
embed
vega-lite
```
8 changes: 6 additions & 2 deletions vegafusion-wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Wasm library for interfacing with VegaFusion.

For more information, see the VegaFusion repository at https://github.com/hex-inc/vegafusion

## Usage
## gRPC-WebUsage
Example usage with the VegaFusion server running locally on port 50051, with grpc-enabled:

```
Expand Down Expand Up @@ -31,11 +31,15 @@ let config = {
let chart_handle = await vegaFusionEmbed(
element,
spec, // Replace with your Vega spec
send_message_grpc,
config,
send_message_grpc,
);
```

## Embedded Runtime Usage

To use an embedded VegaFusion Runtime compiled with Web Assembly, simply omit the `send_message_grpc` argument from the `vegaFusionEmbed` call. In this configuration, the chart is fully self-contained and does not require a VegaFusion server.

## webpack config

To use this library in a webpack project, you need to add the following [experimental options](https://webpack.js.org/configuration/experiments/) to your webpack config:
Expand Down

0 comments on commit 116fec5

Please sign in to comment.