Tuesday, August 5, 2025
HomeBusiness IntelligenceFrontend Integration Sequence: Angular | GoodData

Frontend Integration Sequence: Angular | GoodData


Integrating GoodData into Angular is simpler than it appears, even with out native assist. Let’s dive in and go over the 4 step course of:

  • Putting in Dependencies
  • Establishing Atmosphere Variables
  • Establishing the Code Base
  • Managing CORS

Be aware: For these interested by a deeper dive into these integrations, I like to recommend testing Patrik Braborec’s fast overview.

On the finish of this tutorial, it is possible for you to to combine GoodData Visualizations into your Angular software. For the needs of this demo, let’s assume that you’ve got a fruit retailer like this:

Fruit Store placeholder for the purposes of demo.
Fruit Retailer placeholder for the needs of demo.

That is a part of an ongoing collection about completely different front-end frameworks and their integration into GoodData. Final one was about Vue.js.

Step 1: Set up Dependencies

First issues first, you would wish so as to add a couple of issues to your dependencies.

npm set up --save react@^18.2.0 react-dom@^18.2.0 @gooddata/sdk-ui-all @gooddata/sdk-backend-tiger

Particulars concerning the GoodData.UI SDK isn’t within the scope of this text, however if you need to be taught extra about it, right here is the GoodData.UI structure overview.

And only for completeness listed below are TypeScript dependencies:

npm set up --save-dev @varieties/react@^18.2.0 @varieties/react-dom@^18.2.0

Now that’s out of the way in which, let us take a look at the code!

Step 2: Set setting variables

Be sure you have your setting.ts and setting.improvement.ts recordsdata with right values. After you clone the repository, you will notice a .setting.template.ts file within the /shoppers/angular/src/environments folder. It is advisable take away “template” from the filename so as to arrange every part accurately.

For .env, you will have to outline 4 variables:

export const setting = {
  apiKey: 'API_KEY',
  insightID: 'INSIGHT_ID',
  workspaceID: 'WORKSPACE_ID',
  hostname: 'HOSTNAME',
};

If you happen to open a GoodData dashboard, you will discover the HOSTNAME and WORKSPACE_ID within the URL:

https://<HOSTNAME>/dashboards/#/workspace/<WORKSPACE_ID>/dashboard/<DASHBOARD_ID>

For INSIGHT_ID you’ll have to navigate to the Analyze tab after which navigate to one of many visualizations. There you’ll discover INSIGHT_ID like this:

https://<HOSTNAME>/dashboards/#/workspace/<WORKSPACE_ID>/<INSIGHT_ID>/edit

Test Create an API token documentation for extra details about our API tokens.

In case you want to use this in your manufacturing, we extremely suggest to make use of OAuth, as you may probably leak your API_TOKEN.

Step 3: Arrange the Code

To shortly embed GoodData Visualizations, you would wish to create a backend within the type of tigerFactory() in your chart part:

const backend = tigerFactory()
    .onHostname(import.meta.env.VITE_HOSTNAME)
    .withAuthentication(
        new TigerTokenAuthProvider(import.meta.env.VITE_GD_API_TOKEN)
    )

Then simply merely fetch the props for the InsightView and feed it with within the  render() technique:

// protected getRootDomNode() { ...}
// non-public isMounted(): boolean { ... }

protected getProps(): IInsightViewProps {
  return {
    workspace: setting.workspaceID,
    perception: setting.insightID,
    backend,
   };
}

protected render() {
  if (this.isMounted()) {
    ReactDOM.render(
      React.createElement(InsightView, this.getProps()),
      this.getRootDomNode()
    );
  }
}

Now you possibly can merely create <gooddata-chart> and it might render the Visualization!

Here’s a quite simple template:

<h1>Angular with GoodData</h1>
<gooddata-chart></gooddata-chart>

Now you possibly can simply add styling and you might be set! Only for simplicity, let’s simply go together with a minimal one:

#gooddata-chart {
 width: 100%;
 peak: 400px;
}

.insight-view-container, .insight-view-visualization {
  width: 100%;
  peak: 400px;
}

Here’s a GitHub repo you possibly can simply begin with!

Step 4: Handle CORS

And that’s all for code! Fairly easy, is not it? 😉

Now the one factor that will be lacking is to deal with CORS. That is fairly easy in GoodData:

  1. Navigate to your GoodData Occasion,
  2. Go to the settings
  3. Add allowed origins to the CORS.
CORS setting in the GoodData web UI
CORS setting within the GoodData net UI

Be aware: For detailed details about CORS, confer with the official documentation.

For my native improvement, this was http://localhost:4200:

CORS example setting in the GoodData web UI
CORS instance setting within the GoodData net UI

CORS settings. Be aware, that there’s additionally the http://localhost:5173 from the Vue.js article.

Now simply merely run ng serve and it is best to see one thing like this:

Fruit Store placeholder with the embedded GoodData visualization
Fruit Retailer placeholder with the embedded GoodData visualization

In case the colours of the visualization don’t suit you, you possibly can at all times change them

Wish to Study extra?

If you wish to attempt GoodData, take a look at our free trial – it really works properly with the GitHub repo! If you want to debate embedding, AI, dashboard plugins or no matter you’ve got in your thoughts, attain out to us on our group Slack.

RELATED ARTICLES

Most Popular

Recent Comments