0

I am trying to install plotly js in angular 12 app by following this article. But I'm getting compilations error in typescript,

Please help me to solve this error.

AppMoudle.ts

After clearing the above compilation issue by following this article, I'm getting below build error

Build error

2
  • Did you install both, angular-plotly.js and plotly.js? The command says npm install angular-plotly.js plotly.js. Commented Aug 5, 2021 at 12:26
  • @FelixLemke Yes, "angular-plotly.js": "^4.0.0", "plotly.js": "^2.3.1", Commented Aug 5, 2021 at 12:39

1 Answer 1

1

Try this:

npm install angular-plotly.js plotly.js-dist-min --save
npm install @types/plotly.js-dist-min --save-dev

In the AppModule, do the follow:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
    
import { PlotlyViaCDNModule } from 'angular-plotly.js';
    
PlotlyViaCDNModule.setPlotlyVersion('latest');
    
@NgModule({
    imports: [
        CommonModule,
        PlotlyViaCDNModule,
    ],
    ...
})
export class AppModule { }

Use the latest version of Plotly.js, but you can use a minor version as well.

You can take a look my project in Angular 12 with Plotly:

https://github.com/cristofima/AngularPlotly

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.