Vite for VizHub exports
If you are using VizHub with hot reloading, you can use this template to "eject" out of VizHub and develop locally.
The example viz that is exported here is Parallel Coordinates Brushing Prototype. This example was chosen because it leverages the following features of VizHub that need to be reproduced using Vite and NPM workspaces:
import { observeResize } from '@curran/responsive-axes';
)import data from './data.csv';
)div
with ResizeObserverTo adapt this template to work with your own viz:
vizhub-download
script to point to your vizvizhub-pull
script whenever you want to get the latest out of VizHubpackage.json
to match your vizzesmain
to point to your entry pointTo run locally:
git clone https://github.com/curran/vite-d3-template.git
cd vite-d3-template
npm install
npm run dev
If it worked correctly, you should see your running viz appear!
This setup uses NPM workspaces, so the import syntax in VizHub works "out of the box" with no need for modification. You get a standard Vite project, so you can use the Vite build system to generate static assets for hosting.
One of the design goals of VizHub is to enable users to author portable code. One of the aspects of VizHub that was initially not portable at all was the "import from viz" feature. This lets users import code and data across vizzes. Now that the VizHub export API includes all imported vizzes in the exported files, and adds the name
field to the package.json
of each exported viz, it is finally possible to eject code out of VizHub and into an industry standard project setup using Vite and NPM workspaces.
See also the video of this being created initially.