npm.io
0.4.0 • Published 5 years ago

use-vega

Licence
MIT
Version
0.4.0
Deps
0
Size
67 kB
Vulns
0
Weekly
0
Stars
1

useVega

Version License: MIT Twitter: bbenzikry

Simple react hook for rendering Vega/Vega lite specifications

Demo

Prerequisites

use-vega requires vega and vega-lite

Install

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

Usage

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

Notes and FAQ

The implementation is less performant than the one in 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!

Keywords