Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bbenzikry/use-vega

Simple react hook for using vega(lite) specs
https://github.com/bbenzikry/use-vega

charts react react-hooks vega vega-lite visualization

Last synced: 18 days ago
JSON representation

Simple react hook for using vega(lite) specs

Awesome Lists containing this project

README

        


useVega ⚛



Version

License: MIT


Twitter: bbenzikry

> Simple react hook for rendering Vega/Vega lite specifications

### ✨ [Demo](https://bbenzikry.github.io/use-vega)

## Prerequisites

use-vega requires [vega](https://www.npmjs.com/package/vega) and [vega-lite](https://www.npmjs.com/package/vega-lite)

## Install

```sh
yarn add --production use-vega
# OR
npm install use-vega
```

## Usage

```tsx
import {useVega} from 'use-vega'
const spec = /* some vega / vega lite spec here*/;
const SomeChart = () => {
const { ref, noData, isLoading, error } = useVega(spec)
return (
<>


{noData && <>{'no data'}>}
{isLoading && <>{'loading'}>}
{error && <>{'error'}>}
>
)
}
```

## Notes and FAQ

The implementation is less performant than the one in [react-vega](https://github.com/vega/react-vega) as we recreate the view on change instead of doing a more in-depth comparison / update changesets.
This will change in a future version dependent on traction.
Feel free to PR if this bothers you 😁

## Show your support

Give a ⭐️ if this project helped you!