Data Studio community visualizations allow you to write custom JavaScript visualizations for Google Data Studio.
This template provides
- An opinionated workflow for developing community visualizations
- A local development workflow with immediate feedback
- Scripts to manage building and deploying your visualization
To develop your visualization, you should be editing the files in the [./src] directory.
| File | Template location | Documentation |
|---|---|---|
| Manifest | src/manifest.json |
manifest reference |
| Config | src/index.json |
config reference |
| JavaScript | src/index.js |
write viz code |
| CSS | src/index.css |
[write css code] |
To create a new community visualization based on this template, run the command
npx @google/dscc-gen vizAfter running this command (and answering some prompts), you will have a minimal
working visualization and have set GCS buckets for a dev and prod version. Edit
src/index.js to see changes.
- Update the dimensions and metrics your visualization requires in
src/index.json - Run the command
npm run update_messageto build and deploy your visualization to your "dev" bucket. - Create a new report and connect to the dataset you want to use for your sample message.
- Use your "dev bucket" to add this visualization to your report. It will
display div with the
datareturned by the ds-component helper library. - Copy the
datain the visualization and replace the empty object insrc/localData.js. This is the "local data" that you will develop with.
To develop locally:
- Change
const LOCALtotrueinsrc/index.js. - Run
npm run startto start a local server. A browser tab should open with the visualization you just deployed in Data Studio. - Make changes in
src/index.jsandsrc/index.css, save the changes, and see them reflected in the browser tab.
You should have two deployments of your visualization: a "dev" version, where caching is disabled and where you normally develop, and a "prod" version, where caching is enabled and you only push "finished" visualizations.
To deploy:
- Change
const LOCALtofalseinsrc/index.js - Run the appropriate build and push command (see below)
- Load your viz in Data Studio
To update the message:
npm run update_messageNote: The message update script uses the object format by default. To update
the message with the table format, change the -f parameter update_message
script in package.json from object to table.
Build the "dev" (devMode is true) visualization
npm run build:devDeploy the "dev" (devMode is true) visualization
npm run push:devBuild the "prod" (devMode is false) visualization
npm run build:prodDeploy the "prod" (devMode is false) visualization
npm run push:prodThe build and deploy scripts can be found in the ./scripts/bin directory.