Skip to content

Commit 71753d1

Browse files
authored
Merge pull request #40 from plotly/improve-docs
Improving PlotlyViaWindowModule docs
2 parents 8bc6e1e + 019ba67 commit 71753d1

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

README.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ For a full description of Plotly chart types and attributes see the following re
8383
* [Plotly JavaScript API documentation](https://plot.ly/javascript/)
8484
* [Full plotly.js attribute listing](https://plot.ly/javascript/reference/)
8585

86+
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+
8688
## API Reference
8789

8890
### Basic Props
@@ -172,7 +174,33 @@ export class AppModule { }
172174

173175
### Plotly Via Window Module
174176

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+
```javascript
180+
// angular.json
181+
{
182+
...
183+
"projects": {
184+
"project-name": { // This is your project's name
185+
...
186+
"architect": {
187+
"build": {
188+
...
189+
"options": {
190+
"scripts": [
191+
"node_modules/plotly.js/dist/plotly.min.js" // add this
192+
]
193+
}
194+
}
195+
}
196+
...
197+
}
198+
}
199+
}
200+
```
201+
202+
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:
203+
176204

177205
```typescript
178206
import { NgModule } from '@angular/core';
@@ -187,6 +215,7 @@ import { PlotlyViaWindowModule } from 'angular-plotly.js';
187215
export class AppModule { }
188216
```
189217

218+
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.
190219

191220
## Development
192221

@@ -210,4 +239,4 @@ $ npm run test
210239

211240
## License
212241

213-
&copy; 2018 Plotly, Inc. MIT License.
242+
&copy; 2019 Plotly, Inc. MIT License.

0 commit comments

Comments
 (0)