Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notes for advanced usage #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,49 @@ export default {
<vue-plotly :data="data" :layout="layout" :options="options"/>
```

### Webpack
### Advanced Usage

Plotly is quite heavy, so you probably don't need the whole package.

Plotly has different bundles available. You have to configure it yourself in your webpack config.

To use only the plotly-basic.js dist package you can configure the webpack resolve alias in your vue.config.js:

```js
module.exports = {
configureWebpack: {
resolve: {
alias: {
'plotly.js$': 'plotly.js/dist/plotly-basic.js'
}
},
```

And if you want to add additional locales you can do so in a own plotly configuration file which reexports VuePlotly:

```
import VuePlotly from '@statnett/vue-plotly'
import Plotly from 'plotly.js/dist/plotly-basic.js'
import de from 'plotly.js/lib/locales/de'

Plotly.register(de)

export default VuePlotly
```

This file can be imported from your application using a normal import or using a new webpackChunk to load async:

```
@Component({
name: "TheChart",
components: {
Plot: () => import(/* webpackChunkName: "plotly" */ "../plotly")
}
})
export default class TheChart extends Vue {
```

### Custom bundle with Webpack

To use vue-plotly with webpack you should see [this example repo](https://github.com/plotly/plotly-webpack) for how to make that work.

Expand Down