You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Vis Tools] Define standardized vis tools in Flask and allow customization (#6066)
## Issue
[b/489513837](https://buganizer.corp.google.com/issues/489513837)
## Description
Pre-standardized versions of the vis tools allowed for customization of
the examples. The default examples (for the main site) were provided in
Flask as JSON, and these could be overridden by duplicating them into a
particular custom_dc directory and editing them.
While this functionality still exists, it is not applied to the (very
different) examples given by the new standardizecd tools. These were
provided directly in the TS, and were not easily customizable.
This PR moves the definitions of examples out of TypeScript and into
Flask. We have a few different ways that we transfer information from
Flask to the frontend. In this case, we opted to use the same method as
we used for the old tools, in order to keep the process of customizing
these nearly identical to what it was before.
## Details
In `server/template/tools`, the same directory where the existing
default examples for older tools was provided, we now supply files for
each of the three tool types: `scatter_vis_tool_examples.json`,
`map_vis_tool_examples.json` and `timeline_vis_tool_examples.json`.
These three files populate the primary DC website and also serve as the
main examples.
The files are JSON, in the following format:
```
[
{
"id": "unique_id_1",
"titleMessageId": "optional id for i18n, does not need to be provided if a title is given. This will be translated by the frontend, and will not generally be used by custom DCs",
"title": "Title to be used in lieu of a translatable message ID. This will be used by custom DCs.
"url": "/tools/timeline#{...url to chart...}"
},
... subsequent examples
```
As described in the example above, you only need to give either a
titleMessageId (for i18n conversion) or a title, which will be used
directly.
Custom DCs will almost certainly only use the `title`.
### Process for customizing
The process for a custom DC to customize these examples is very similar
to what it was for the old tools. You take the example file from the
root `server/template/tools` directory, and copy it into
`server/custom_dc/{custom dc name}`.
You would then edit the file, giving the titles and URLs that you want
for the examples. The frontend will then pick those up. As noted above,
a custom DC is very unlikely to use a titleMessageId, because they won't
be using the i18n library.
## Testing
If you do not provide a custom example set, the site should look
identical to how it did before. In other words the following URL should
look the same on both master and locally:
https://datacommons.org/tools/map
http://localhost:8080/tools/map
However, if you either edit the default examples, or load a custom DC
and create an override for that custom DC as above, you will see those
examples, rather than the default ones.
A note that if you are running a custom DC, you will want to turn the
standardized vis tool flag on in order to see the changes.
## Screenshots
### Before
<img width="1294" height="669" alt="Screenshot 2026-03-06 at 8 35 19 AM"
src="https://github.com/user-attachments/assets/7e531088-0f24-4a79-acb9-4c1e56289071"
/>
### After
<img width="1681" height="679" alt="Screenshot 2026-03-06 at 8 37 05 AM"
src="https://github.com/user-attachments/assets/3f5771cb-9776-4cfa-a6cb-8c173a181a36"
/>
0 commit comments