Sample code for the Data visualization component
reference australia Updated Sep 10, 2026 1 min read we-data-viz-sample-code.md
Use this sample code to run an action when the Data visualization component triggers an event.
Sample code
Update the sample code for your use case before embedding the component on your webpage.
JavaScript
{
'NOW_VIS_WRAPPER#PROPERTY_OVERRIDE' : (e) => {
// Dispatched when the visualization overrides its property. For example when the user selects a different group by from the alternative group by selection
var {properties} = e.detail.payload;
console.log(properties);
},
'NOW_VIS_WRAPPER#SELECTED' : (e) => {
// Dispatched when the user selects/de-selects element on data visualizations, typically to filter other content on the page
var {title, type, isSelected, params, data} = e.detail.payload;
console.log(title, type, isSelected, params, data);
},
'NOW_VIS_WRAPPER#CLICKED' : (e) => {
// Dispatched when the visualization is clicked
var {title, type, params, data} = e.detail.payload;
console.log(title, type, params, data);
}}Related topics
Configure the Data visualization component instance
Embed the Data visualization component instance on the third-party website
68 lines · 2.6 KB
---
title: Sample code for the Data visualization component
description: Use this sample code to run an action when the Data visualization component triggers an event.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/customer-service-management/customer-self-service-and-omnichannel-engagement/we-data-viz-sample-code.html
release: australia
product: Customer Self-service and Omnichannel Engagement
classification: customer-self-service-and-omnichannel-engagement
topic_type: reference
last_updated: "2026-09-10"
reading_time_minutes: 1
breadcrumb: [Data visualization component, Configure web components, Configure Web Embeddables, Set up self-service, Configure, Customer Service Management]
---
# Sample code for the Data visualization component
Use this sample code to run an action when the Data visualization component triggers an event.
## Sample code
Update the sample code for your use case before embedding the component on your webpage.
```
{
'NOW_VIS_WRAPPER#PROPERTY_OVERRIDE' : (e) => {
// Dispatched when the visualization overrides its property. For example when the user selects a different group by from the alternative group by selection
var {properties} = e.detail.payload;
console.log(properties);
},
'NOW_VIS_WRAPPER#SELECTED' : (e) => {
// Dispatched when the user selects/de-selects element on data visualizations, typically to filter other content on the page
var {title, type, isSelected, params, data} = e.detail.payload;
console.log(title, type, isSelected, params, data);
},
'NOW_VIS_WRAPPER#CLICKED' : (e) => {
// Dispatched when the visualization is clicked
var {title, type, params, data} = e.detail.payload;
console.log(title, type, params, data);
}}
```
**Related topics**
[Configure the Data visualization component instance](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/customer-service-management/customer-self-service-and-omnichannel-engagement/config-data-viz-comp.md)
[Embed the Data visualization component instance on the third-party website](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/customer-service-management/customer-self-service-and-omnichannel-engagement/embed-data-viz-comp.md)
[Component properties for the Data visualization](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/customer-service-management/we-data-viz-comp-prop.md)
[Event handler in the Data visualization component](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/customer-service-management/we-data-viz-event-handler.md)
| title | Sample code for the Data visualization component |
| description | Use this sample code to run an action when the Data visualization component triggers an event. |
| locale | en-US |
| canonical_url | https://www.servicenow.com/docs/r/australia/customer-service-management/customer-self-service-and-omnichannel-engagement/we-data-viz-sample-code.html |
| release | australia |
| product | Customer Self-service and Omnichannel Engagement |
| classification | customer-self-service-and-omnichannel-engagement |
| topic_type | reference |
| last_updated | 2026-09-10 |
| reading_time_minutes | 1 |
| breadcrumb | Data visualization componentConfigure web componentsConfigure Web EmbeddablesSet up self-serviceConfigureCustomer Service Management |