Skip to content

Commit 83d4473

Browse files
committed
Updating README.md
1 parent 581ea6b commit 83d4473

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,51 @@ Event handlers for specific [`plotly.js` events](https://plot.ly/javascript/plot
140140
| `(unhover)` | `Function` | `plotly_unhover` |
141141

142142

143+
## Customizing the `plotly.js` bundle
144+
145+
By default, this library bundles `plotly.js` from the peer dependency together within the output. This results on huge outputs, for `plotly.js` itself is ~3MB when bundled. It also makes the build (with `ng serve --prod`) really slow, for it minifies everything together.
146+
147+
If you wish to optimize loading `plotly.js` in a different way, please check both [`PlotlyViaCDNModule`](#plotly-via-cdn-module) and [`PlotlyViaWindowModule`](#plotly-via-window-module) modules below.
148+
149+
150+
### Plotly Via CDN Module
151+
152+
If you want to load `plotly.js` [from a CDN](https://github.com/plotly/plotly.js#use-the-plotlyjs-cdn-hosted-by-fastly), use the `PlotlyViaCDNModule` and call `forRoot` method with the version you want to use:
153+
154+
```typescript
155+
import { NgModule } from '@angular/core';
156+
import { CommonModule } from '@angular/common';
157+
158+
import { PlotlyViaCDNModule } from 'angular-plotly.js';
159+
160+
@NgModule({
161+
imports: [
162+
CommonModule,
163+
PlotlyViaCDNModule.forRoot({version: '1.5.0'}) // can be `latest` or any version number (i.e.: '1.4.3')
164+
],
165+
...
166+
})
167+
export class AppModule { }
168+
```
169+
170+
### Plotly Via Window Module
171+
172+
If you want to use a [different precompiled bundle](https://github.com/plotly/plotly.js/blob/master/dist/README.md#partial-bundles) or if your 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).
173+
174+
```typescript
175+
import { NgModule } from '@angular/core';
176+
import { CommonModule } from '@angular/common';
177+
178+
import { PlotlyViaWindowModule } from 'angular-plotly.js';
179+
180+
@NgModule({
181+
imports: [CommonModule, PlotlyViaWindowModule],
182+
...
183+
})
184+
export class AppModule { }
185+
```
186+
187+
143188
## Development
144189

145190
To get started:
@@ -162,4 +207,4 @@ $ npm run test
162207

163208
## License
164209

165-
&copy; 2018 Plotly, Inc. MIT License.
210+
&copy; 2018 Plotly, Inc. MIT License.

0 commit comments

Comments
 (0)