# Write your visualizations faster with dscc-gen

[Video](https://www.youtube.com/watch?v=P4z4I0HsZdo)

The typical workflow for seeing changes in your community visualization is to
[upload](https://developers.google.com/data-studio/visualization/upload-viz.md.txt) your files to GCS, then refresh your Data Studio report. This works,
but means that you can spend a lot of time waiting to see changes. [dscc-gen](https://github.com/googledatastudio/dscc-gen)
enables a workflow to immediately see your visualization code changes, reducing
the time it takes to write a community visualization.

To get started, make sure [npm 5.2.0 or later](https://www.npmjs.com/get-npm) and [gsutil](https://cloud.google.com/storage/docs/gsutil) are installed. Then,
run:

```bash
npx @google/dscc-gen viz
```

> [!NOTE]
> **Note:** If you prefer to use yarn, pass `--yarn` as an argument.

## First Time Configuration

`dscc-gen` comes with a default local dataset that's probably not representative
of the data you want to visualize. To update this dataset to meet your needs:

1. [Update your config](https://developers.google.com/data-studio/visualization/config-reference.md.txt) at `src/index.json`.
2. Run `npm run update_message`. This deploys a visualization to your `dev` bucket that displays the [message](https://developers.google.com/data-studio/visualization/library-reference.md.txt) in a format that's easy to copy.
3. [Create a new report](https://datastudio.google.com) and connect to a dataset that's representative of the data you want to visualize.
4. [Add a community visualization](https://developers.google.com/data-studio/visualization/load-viz.md.txt) using your `dev` bucket as your component ID.
5. Copy the contents of the visualization to `scripts/data/localData.js`. This data will be used when you develop locally.

## Scripts

The following scripts are available for visualization projects created with
`dscc-gen`.

| Command | Action |
|---|---|
| `npm run start` | Start the local server and preview your visualization |
| `npm run update_message` | Update the message using the [objectFormat](https://developers.google.com/data-studio/visualization/library-reference.md.txt#objectformat_reference) |
| `npm run build:dev` | Build files from `./src` into `./build` with [caching](https://developers.google.com/data-studio/visualization/caching.md.txt) disabled. |
| `npm run push:dev` | Copy the files from `build` to your `dev` bucket. |
| `npm run build:prod` | Build files from `./src` into `./build` with [caching](https://developers.google.com/data-studio/visualization/caching.md.txt) enabled. |
| `npm run push:prod` | Copy the files from `build` to your `prod` bucket. |

> [!CAUTION]
> **Caution:** Before you build \& deploy your viz, make sure you change `const LOCAL=` in `src/index.js` to `false`.

The `update_message` command defaults to the [objectFormat](https://developers.google.com/data-studio/visualization/library-reference.md.txt#objectformat_reference). To use the
[tableFormat](https://developers.google.com/data-studio/visualization/library-reference.md.txt#tableformat_reference), edit the parameters in the `update_message` script in
`package.json` from `-f object` to `-f table`.

## Codelab

To learn how to use the tooling, review the dscc-gen [codelab](https://codelabs.developers.google.com/codelabs/community-visualization-dscc-gen/).

[![dscc-gen codelab](https://developers.google.com/static/data-studio/visualization/images/dscc-gen-codelab.png)](https://codelabs.developers.google.com/codelabs/community-visualization-dscc-gen/)