Embed ARC Relationship Graphs in LWC?
Question:
The ARC Relationship Graph provides a visually appealing representation of household relationships to their contacts in Salesforce. Is there a way to embed this graph directly into a Lightning Web Component (LWC) without recreating it from scratch? While it is a useful feature, there seems to be no obvious way to expose or reuse it programmatically within custom components. What are the possible approaches to achieve this?
Answer:
The ARC Relationship Graph is a proprietary visualization within Salesforce, and currently, it is not directly exposed as a reusable component or API for embedding into custom LWCs. However, there are potential workarounds depending on the level of customization required and the functionality desired.
Searching for premier Salesforce training in Pune? CRS Info Solutions offers expert-led courses with real-world projects for hands-on learning—join a free demo session today to elevate your skills!
1.Embedding Using an Iframe or Lightning Out:
If the ARC Relationship Graph is available on a standard page layout or Visualforce page, you can embed it into your LWC using an iframe.
For example:
<template>
<lightning-card title="Household Relationships">
<iframe src="/apex/ARCGraphPage" width="100%" height="600px"></iframe>
</lightning-card>
</template>Code explanation:
The provided code creates a Lightning Web Component (LWC) template that displays a lightning-card titled “Household Relationships.” Inside the card, it embeds an iframe, which loads a Visualforce page (/apex/ARCGraphPage) to render the ARC Relationship Graph. The iframe is set to occupy 100% of the card’s width and has a fixed height of 600 pixels. This approach allows integrating the graph into an LWC without rebuilding its functionality but may have limitations in styling and interactivity.
In this approach, you create a Visualforce page (e.g., ARCGraphPage) that contains the graph and load it within the LWC. However, this is not ideal for modern UIs and may limit interactivity.
2.Custom Data Fetching and Visualization:
If you want full control over the visualization, you can retrieve the relationship data through the Salesforce API or Apex. For example, use SOQL queries to fetch the necessary relationship records and then visualize them with a charting library like D3.js or Highcharts in your LWC.
Example Apex to fetch data:
@AuraEnabled(cacheable=true)
public static List<AccountContactRelation> getRelationshipData(Id householdId) {
return [SELECT AccountId, ContactId, Role FROM AccountContactRelation WHERE AccountId = :householdId];
}Code explanation:
This Apex method, annotated with @AuraEnabled(cacheable=true), is designed to be called from Lightning components to fetch data efficiently. It retrieves a list of AccountContactRelation records for a specified householdId, including the AccountId, ContactId, and Role fields. By making the method cacheable, it enables improved performance by allowing results to be stored locally for subsequent use without additional server calls.
Corresponding LWC JavaScript to call the Apex method:
import { LightningElement, wire } from 'lwc';
import getRelationshipData from '@salesforce/apex/RelationshipController.getRelationshipData';
export default class HouseholdGraph extends LightningElement {
relationships;
@wire(getRelationshipData, { householdId: '$householdId' })
wiredData({ error, data }) {
if (data) {
this.relationships = data;
this.renderGraph();
} else if (error) {
console.error(error);
}
}
renderGraph() {
// Use a charting library like D3.js to visualize relationships.
}
}Code explanation:
The JavaScript code defines a Lightning Web Component (LWC) class HouseholdGraph that fetches relationship data from an Apex method getRelationshipData. The @wire decorator retrieves data dynamically based on a householdId property and assigns it to the relationships variable, calling the renderGraph method to visualize the data using a charting library like D3.js. Error handling ensures issues during data fetching are logged to the console for debugging.
3.Salesforce AppExchange or Custom Solutions:
If building a custom solution is not feasible, you can explore AppExchange packages or third-party solutions designed to replicate the ARC Relationship Graph functionality. These often come with APIs or reusable components for embedding into LWCs.
While Salesforce does not provide an out-of-the-box way to embed the ARC Relationship Graph into LWCs, combining techniques like iframes, API integrations, or custom charting solutions can help achieve a similar result.
Summing Up:
Embedding the ARC Relationship Graph directly into a Lightning Web Component (LWC) is not natively supported in Salesforce, but there are feasible workarounds. You can embed the graph using an iframe that points to a Visualforce page hosting the graph, allowing quick integration with minimal effort. For greater customization, you can fetch the relationship data using Apex and visualize it with modern charting libraries like D3.js. While not as seamless as a built-in solution, these approaches enable you to leverage or replicate the functionality of the ARC Relationship Graph within an LWC.
Launch Your Salesforce Career with Expert Training in Pune
Looking to propel your career in Salesforce? CRS Info Solutions in Pune offers comprehensive Salesforce training designed to equip you with essential skills for success in the Salesforce ecosystem. Our courses cover key areas such as Salesforce Administration, Development, and AI, combining theoretical knowledge with hands-on project experience. Salesforce training in Pune Taught by seasoned professionals, our training ensures you’re ready to tackle real-world challenges. Whether you’re starting fresh or advancing your expertise, our program prepares you to be job-ready.
Our training focuses on practical learning, personalized mentorship, and valuable resources, including detailed notes, certification coaching, and interview support. We provide everything you need to succeed and stand out in the competitive Salesforce job market.
Take the first step toward your Salesforce career—sign up for a free demo session and start your journey today!

