Skip to content

Commit 8bd3ced

Browse files
fzfstyd
authored andcommitted
Adding docs for importmaps
1 parent 0d41130 commit 8bd3ced

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

docs/web-support/rails.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,45 @@ window.ApexCharts = require("apexcharts") // expose to window
1919
import ApexCharts from 'apexcharts'
2020
window.ApexCharts = ApexCharts
2121
```
22+
23+
Or, if you use `importmaps', you can:
24+
25+
Download to local vendor directory (optional but recommended)
26+
27+
```bash
28+
$ wget -O vendor/javascript/apexcharts.esm.js https://ga.jspm.io/npm:apexcharts@latest/dist/apexcharts.esm.js`
29+
```
30+
31+
Pin "apexcharts" in `config/importmap.rb` to local esm file (if you do No. 1):
32+
33+
```ruby
34+
pin "apexcharts", to: "apexcharts.esm.js"`
35+
```
36+
37+
or, to CDN URL
38+
39+
```ruby
40+
pin "apexcharts", to: "https://ga.jspm.io/npm:apexcharts@latest/dist/apexcharts.esm.js"`
41+
```
42+
43+
Import and assign to window in `app/javascript/application.js`
44+
45+
```js
46+
import ApexCharts from "apexcharts"
47+
window.ApexCharts = ApexCharts
48+
```
49+
50+
Use it with options `module: true`
51+
For example:
52+
53+
```
54+
<% series = [{
55+
name: "Desktops",
56+
data: [10, 41, 35, 51, 49, 62, 69, 91, 148]
57+
}]
58+
options = {
59+
module: true
60+
}
61+
%>
62+
<%= line_chart(series, options) %>
63+
```

0 commit comments

Comments
 (0)