You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `plotly.js` is bundled within the angular code. To avoid this, please read [how to customize the plotlyjs bundle](#customizing-the-plotlyjs-bundle) below.
87
+
86
88
## API Reference
87
89
88
90
### Basic Props
@@ -172,7 +174,29 @@ export class AppModule { }
172
174
173
175
### Plotly Via Window Module
174
176
175
-
If you want to use a [different precompiled bundle](https://github.com/plotly/plotly.js/blob/master/dist/README.md#partial-bundles) or if you wish to [assemble you own customized bundle](https://github.com/plotly/plotly.js#modules), you can use `PlotlyViaWindowModule` to force the use of `window.Plotly` object. You can add the script via tag `<script>` direct on your code, or add it as a [global script on angular.json](https://github.com/angular/angular-cli/wiki/stories-global-scripts#global-scripts).
177
+
`plotly.js` can be added as a [global script on angular.json](https://github.com/angular/angular-cli/wiki/stories-global-scripts#global-scripts) to avoid it beingb bundled into the final project's code. To make this happen, you must first add `plotly.js` path into `angular.json` file as shown below:
178
+
179
+
```json
180
+
// angular.json
181
+
{
182
+
"projects": {
183
+
"project-name": {
184
+
"architect": {
185
+
"build": {
186
+
"options": {
187
+
"scripts": [
188
+
"node_modules/plotly.js/dist/plotly.min.js"// add this
189
+
]
190
+
}
191
+
}
192
+
}
193
+
}
194
+
}
195
+
}
196
+
```
197
+
198
+
This will include `plotly.js` into the `vendor.js` file generated by angular CLI build process, and `plotly.js` library will be loaded before angular and your project's code. The `window.Plotly` will be available. Thus, you must use `PlotlyViaWindowModule` module to force `angular-plotly.js` to use `window.Plotly` object:
199
+
176
200
177
201
```typescript
178
202
import { NgModule } from'@angular/core';
@@ -187,6 +211,7 @@ import { PlotlyViaWindowModule } from 'angular-plotly.js';
187
211
exportclassAppModule { }
188
212
```
189
213
214
+
If you want to use a [different precompiled bundle](https://github.com/plotly/plotly.js/blob/master/dist/README.md#partial-bundles) or if you wish to [assemble you own customized bundle](https://github.com/plotly/plotly.js#modules), you can use `PlotlyViaWindowModule` to force the use of `window.Plotly` object as shown above.
0 commit comments