How to add custom visualization in Looker using javascript?
- Looker FAQs
- January 15, 2018
In Looker, there are two ways to add custom visualizations using Javascript:
- Adding a custom visualization for all projects
- Adding a custom visualization for a specific project
Adding a custom visualization for all projects:
- Expand the “Admin” panel and click on the “Visualizations” page under the Platform header.
- The Visualizations page will display all of the custom visualizations that are already added to your Looker instance.
- On the top left corner of the page, click on the Add Visualization button. This would take you to the New Visualization page. Fill in the following line items:
- ID field : This is the unique ID of the visualization, which will be defined in JavaScript.
- Label field : The name of the visualization will be displayed in the visualization menu in explore.
- Main field : The URL of the visualization’s main JavaScript file in the code repository.
- Subresource Integrity (SRI) hash : This Advanced Option lets you enter the SRI hash if the site hosting the custom visualization code uses a Subresource Integrity for verification purposes.
- Dependencies field : This is also an advanced option that lets you enter the URLs of any files that the visualization JavaScript may depend upon. You can enter multiple URLs separated by commas, or you can add multiple URLs one at a time by clicking the “Add” button.
- Once submitted, you should see the new visualization type in the visualization menu of an Explore, and you may use it like any other existing visualization type.
Adding a custom visualization for a specific project:
Alternatively, you can add a custom visualization to your LookML project by adding the following LookML to a project’s manifest file. Enter the same details as listed in point 3 of the above section (Adding a custom visualization for all projects):
visualization: {
id: "demo-visualization-dev"
label: "Demo Viz"
url: "https://abc-test.com/viz-destination/demo.js"
sri_hash: "xyz"
dependencies: ["https://xyz/jquery.min.js","","",""]
}
Up Next: